Fix OpenCode session cache source paths
Summary
Fixes OpenCode session-cache keying by discovering one source per real opencode*.db file instead of one synthetic <dbPath>:<sessionId> source per root session.
The parser now opens the database source, iterates unarchived root sessions inside it, and keeps the recursive child-session parsing added in #343.
Root cause
OpenCode discovery used paths like:
/path/to/opencode.db:root-session-id
The shared session cache fingerprints source paths with stat(). That synthetic path is not a real file, so OpenCode cache entries could be treated as changed or stale on every run.
What changed
- OpenCode discovery now emits
path: dbPathfor eachopencode*.db. - The parser iterates unarchived root sessions from the DB source.
- Root parsing still walks unarchived child/grandchild session subtrees.
- Legacy compound
<dbPath>:<sessionId>source paths are still accepted. - Old synthetic cache keys are pruned on the next parse because discovery now reports only the real DB path.
- Docs and changelog describe the new cache behavior.
Validation
- [x] Differential synthetic repro against
origin/mainvs this branch. - [x]
npx vitest run tests/providers/opencode-cache.test.ts tests/providers/opencode.test.ts tests/provider-registry.test.ts- 54/54 tests passed. - [x]
npx tsc --noEmit --pretty false- passed. - [x]
npx vitest run- 876/876 tests passed. - [x]
npm run build- passed. - [x]
git diff --check origin/main...HEAD- passed. - [x] Argus-style strict review - PASS.
- [x] Claude Opus 4.7 effort max review - PASS.
- [x] Gemini 3.1 Pro Preview review - PASS.
Cache proof
Synthetic OpenCode DB fixture:
root-a
└─ child-a
root-b
Same fixture parsed on origin/main and this branch.
origin/main cache keys:
/tmp/.../opencode.db:root-a
/tmp/.../opencode.db:root-b
This branch cache keys:
/tmp/.../opencode.db
Behavior stayed equivalent:
calls: 3
root sessions: 2
projects:
tmp-project-a: 2 calls, 1 session
tmp-project-b: 1 call, 1 session
child dedup key preserved:
opencode:child-a:msg-child-a-assistant
warm unchanged run rewrote cache: false
legacy <dbPath>:<sessionId> keys pruned: true
Scope and privacy notes
Validation uses synthetic SQLite fixtures only. No real local OpenCode history, prompts, paths, session IDs, usage values, or private project data are included.