Skip to content

ADRs + agent-rules sync - #68

Merged
LukeMainwaring merged 2 commits into
mainfrom
docs/adrs-and-rules-sync
Jul 16, 2026
Merged

ADRs + agent-rules sync#68
LukeMainwaring merged 2 commits into
mainfrom
docs/adrs-and-rules-sync

Conversation

@LukeMainwaring

Copy link
Copy Markdown
Owner

Stage 3 of 3 in the refactor series (follows #66 and #67). Docs and agent-rules only — no app code changes.

Part A — docs/adr/

Four rationales that already lived in code comments are now numbered records, and each source cites its ADR back (per .claude/rules/conventions.md: "the docstring that implements it cites the ADR").

ADR Summary
0001-hnsw-over-ivfflat IVFFlat would be trained on an empty table at migration time and need a REINDEX after every seed pass; HNSW builds on empty and has better recall at our ~2k–10k rows.
0002-itunes-previews-over-spotify-preview-url Spotify deprecated preview_url for standard-mode apps (0/10 hits here), so iTunes Search supplies audio bytes while Spotify stays the identity source; Spotify's duration_ms anchors the match.
0003-two-layer-tool-error-convention Tools propagate to hooks.py for a structured recovery payload rather than each wrapping try/except; retrieve_tracks_from_brain_state's inline DeapFileMissingError catch is the one sanctioned exception, because the hook payload drops the actionable message.
0004-subject-median-label-binarization DEAP Likert labels split at each subject's own median rather than the literature's >= 5, which skews ~25/75 and bakes rater bias into LOSO folds; --label-split fixed_5 reproduces the paper setting.

Citations added to: the pgvector migration, models/track_audio_embedding.py, services/audio_catalog.py, agents/hooks.py, agents/tools/retrieval_tools.py, ml/dataset.py.

Migrations were touched in comments only — no migration code changed.

Part B — rules + AGENTS.md sync

  • .claude/rules/conventions.mddocs/adr/ exists now; the "doesn't exist yet / until then" paragraph is replaced with the four records and how to add the next one.
  • .claude/rules/frontend/vercel-ai-sdk.md — replaces the stale "panels switch on part.type, add a branch" bullet with the registry reality from Frontend tool-panel registry + feature slices #67 (slice map + one entry, hideRawOutput when the panel replaces raw JSON).
  • .claude/rules/frontend/code-conventions.md — new "Feature slices" section: slice boundaries, no slice-to-slice imports, registry as the only aggregator, relative intra-slice vs @/ cross-directory.
  • AGENTS.md — moved components now point at features/{sessions,retrieval}/, plus lines for the registry, the three-tier test layout, and docs/adr/. 116 lines, under the ~200 ceiling.
  • Both frontend rules files now also match against frontend/features/**, which their paths: frontmatter predated.
  • Backend code-conventions.md testing section was already rewritten in Adopt three-tier test layout with real-Postgres integration tier #66 — verified against the tree, unchanged.

Verification

  • pre-commit run --all-files — passed (ruff, ruff-format, mypy)
  • pytest (unit tier) — 175 passed
  • No frontend source changed, so no lint run.

🤖 Generated with Claude Code

LukeMainwaring and others added 2 commits July 16, 2026 18:08
Four decisions that look wrong without context were only explained in
comments next to the code that implements them. Promote each into a
numbered ADR and cite it from the implementing docstring, per
.claude/rules/conventions.md.

- 0001 HNSW over IVFFlat for the track-embedding index
- 0002 iTunes Search previews instead of Spotify preview_url
- 0003 Two-layer error handling for agent tools
- 0004 Binarize DEAP labels at each subject's own median

The pgvector migration is touched in comments only; no migration code
changes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The rules described the codebase as it was before the ADR directory and
the frontend feature-slice registry landed, so they pointed agents at
patterns that no longer exist.

- conventions.md: docs/adr/ exists now; drop the "doesn't exist yet" note
- vercel-ai-sdk.md: tool panels come from the registry, not a branch in
  the message renderer
- frontend/code-conventions.md: document the feature-slice boundaries
- AGENTS.md: point moved components at features/, note the registry in
  the data flow, and add pointers to docs/adr/ and the test tiers

Both frontend rules files now match against frontend/features/**.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@LukeMainwaring
LukeMainwaring merged commit d2f898e into main Jul 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant