refactor: extract testable resolve-core + cover album routing; check.sh checks .cjs (closes task/resolver-orchestration-testable)

Source: task/resolver-orchestration-testable (plan/steward-linker-quality) — new album orchestration in resolver.js had zero node:test coverage.

- Extract the pure album/artist orchestration into service/resolve-core.js
  (resolveAll/resolveOne/pickDirect/cacheKey) taking injected search/classify
  fns; resolver.js becomes a thin server wiring the real Spotify search +
  ollama classify. No behavior change.
- Add service/resolver.test.js: self-titled artist+album tie-break, LLM-album
  -> Google fallback, kind-aware cache separation, plus gate/drop/error paths.
- scripts/check.sh: node --check now also matches *.cjs (extract.test.cjs).
- AGENTS.md Testing: note resolve-core coverage + the extract.test.cjs extractor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
paul
2026-06-23 00:29:59 +00:00
co-authored by Claude Opus 4.8
parent 2b4babf955
commit 8496e55baf
5 changed files with 265 additions and 79 deletions
+7 -3
View File
@@ -39,9 +39,13 @@ user's PAT). Do **not** use `towl-orchestrate` / worktree+PR here.
## Testing (zero-dep)
`node --test` over `service/*.test.js` exercises `lib.js` (norm + the exact-name match
+ link builders). Keep pure logic in `lib.js` (not `resolver.js`, which has the
server side effect) so it stays testable without opening a port. **Add/extend a test
with every logic change.** The extension's in-browser behavior is **not** headlessly
+ link builders), `llm.js` (the classifier prompt/parse), and `resolve-core.js` (the
album/artist orchestration — kindHint tie-break, kind-aware cache key, allowFallback
gating — driven with injected fake search/classify fns, no network). Keep pure logic in
`lib.js`/`resolve-core.js` (not `resolver.js`, which has the server side effect) so it stays
testable without opening a port. `extension/extract.test.cjs` covers the pure extractor
(artist/cue/album candidates) and must be extended with each detection change. **Add/extend a
test with every logic change.** The extension's in-browser behavior is **not** headlessly
testable in this environment — validate `content.js` with `node --check` and a
documented manual check on a real reddit thread (`about:debugging` → load temporary
add-on).