18 Commits

Author SHA1 Message Date
Rodin df9c856d96 patterns(testing): add async test filtering pattern (#21)
When testing telemetry, pub/sub, or any broadcast mechanism with
async: true, events from concurrent tests can leak into mailbox.

Fix: Pin-match on unique identifier to filter.

Two-part pattern:
1. Filter at source — only forward events matching test's identifier
2. Pin in assertion — ^variable rejects mismatches that slip through

Applies to telemetry handlers, PubSub, GenStage/Broadway consumers,
any shared message bus.

Triggered by PR #710 flaky test fix in gargoyle.
2026-05-09 18:27:05 -07:00
Rodin b833d05410 patterns: add telemetry emission patterns (dedicated submodule, naming, measurements vs metadata) 2026-05-07 19:28:48 -07:00
Rodin 40f024b477 fix: update drifted source citations to match current upstream
Verified all 17 file:line citations against elixir-lang/elixir HEAD.
Fixed 10 citations where line numbers had shifted due to upstream changes:

- patterns/genserver.md: agent.ex:246 → 279 (start_link spec)
- patterns/process-design.md: task.ex:282 → 327 (child_spec)
- smells/anti-patterns.md: registry_test.exs:28 → 29, gen_server_test.exs:166 → 164,
  test_helper.exs:98 → 99
- smells/common-mistakes.md: registry_test.exs:28 → 29, callbacks.ex:423 → 433,
  task_test.exs:297,305,315,330 → 300,308,316,327,
  supervisor_test.exs:278 → 289, callbacks.ex:277 → 520
2026-05-06 16:33:21 -07:00
aweiker d3adeaac25 fix: standardize cross-reference link text for Pattern 10 subsection 2026-05-02 10:13:56 -07:00
aweiker edef02ed0f docs: add rule for when @impl functions earn their own @doc
Pattern 10 (Callback Documentation Convention) now owns the full rule
for callback documentation — both the behaviour side (@callback docs)
and the implementation side (when to override @doc false on @impl
functions). Patterns 2 and 5 cross-reference Pattern 10 instead of
making their own partial statements.

The test: "Would this statement be true of any implementation?" If yes,
it belongs on the @callback. If no, the implementation earns its own
@doc.
2026-05-02 10:03:56 -07:00
aweiker 10218813d3 docs: backfill TOC + decision trees, fix review findings
- Add ## Contents and ## Decision Tree to all 10 existing pattern files
- Fix embed_as/1 semantics inversion in types.md (:self → :dump)
- Fix fabricated __meta__.changes reference in changesets.md
- Fix default primary key type (:integer → :id) in schemas.md
- Combine @impl subsections into single "Minimal Callback Annotation"
2026-05-01 22:13:35 -07:00
aweiker b33accf37c docs: extend @impl pattern with multi-clause and @spec guidance 2026-05-01 21:29:47 -07:00
aweiker 49a006dd18 docs: add table of contents to all Ecto pattern files 2026-05-01 20:55:15 -07:00
aweiker d28b9c8844 fix: use Repo.transaction instead of non-existent Repo.transact 2026-05-01 20:41:06 -07:00
aweiker 7b38ac9b2a feat: add Ecto patterns extracted from elixir-ecto/ecto source
Adds 5 new pattern files covering the core Ecto APIs, each with real
source citations at commit fd2ec52b, before/after examples, anti-patterns,
and decision trees.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 19:22:39 -07:00
Rodin 5f62dd0bf1 feat: add source hyperlinks + remove thin from-source.md
Every source reference now links to elixir-lang/elixir at commit f4e1b34.
122 hyperlinks across 11 topic files. Added PATTERN_COMPLETE sentinels.
Removed from-source.md (326 lines, shallow) — covered by existing files.
2026-04-30 14:43:56 -07:00
Rodin 9ff22d2eed fix: add 'When to use' to every pattern (was missing) 2026-04-30 13:29:27 -07:00
Rodin e6fbfced96 docs: add patterns extracted from elixir-lang/elixir source
Using codebase-analysis skill (patterns mode) on the language source.
Real examples from the repo, not invented. Each pattern has:
- Rule, Example, Why, When NOT to use, Source file.

Topics: module org, protocol design, error handling, testing,
documentation, naming, process design, smells.
2026-04-30 13:26:23 -07:00
Aaron Weiker 8f606d40d7 docs: add when/when-not to error-handling 2026-04-30 05:40:11 -07:00
Aaron Weiker cb94a157a1 docs: add when/when-not to data-transforms 2026-04-30 05:38:33 -07:00
Aaron Weiker f23623250e docs: add when/when-not to process-design 2026-04-30 05:31:32 -07:00
Aaron Weiker 1a934eb2e3 docs: add when/when-not to typespecs + documentation + behaviours 2026-04-30 05:23:28 -07:00
Aaron Weiker 4ea9a884aa docs: idiomatic Elixir and Phoenix patterns with source citations
Extracted patterns, conventions, and code smells directly from the
Elixir and Phoenix source code with file path and line number citations.

Covers: GenServer, error handling, data transforms, process design,
testing, documentation, typespecs, macros, behaviours, module organization,
Phoenix-specific patterns, framework deviations, and anti-patterns.
2026-04-29 22:50:12 -07:00