fix: read tool calls and prose from the v2 session store (#30) #32

Merged
david merged 1 commits from fix/v2-snippet-claims into main 2026-11-05 04:31:54 +00:00
Owner

Closes #30.

Studies both readers that were left on the v1 part table after the 2.0.24 migration:

  • SnippetExtractor.ExtractAll (internal/ingest/snippets.go)
  • claims.LoadSession (internal/claims/opencode.go)

Both now read session_message.data $.content[] first and fall back to part only for messages/sessions v2 does not describe, so a migrated session is never read twice.

Shape differences handled

v1 v2
tool name $.tool $.name
write/edit path filePath path (both accepted)
tool output $.state.output $.state.content[]
shell tool bash bash and shell
patch parts yes none — PatchHash stays empty

PatchHash is stored as metadata only; supersession already derives from the last full write, so nothing depends on it.

Why it matters

part stops at 2026-11-01 20:58 while sessions continue. 1,475 completed write/edit/bash/shell calls exist in v2 that v1 never saw — all currently invisible to snippet curation and to the claim lint.

Tests

  • TestSnippetExtractorReadsSessionV2 — a v2 write becomes a candidate with the right language/project/model.
  • TestSnippetExtractorShellV2 — shell, state.content, path, heredoc → technique.
  • TestSnippetExtractorDoesNotDoubleCountV1AndV2 — a session in both shapes is mined once; a v1-only session still falls back.
  • TestLoadSessionV2 — prose from $.content, evidence from $.state.content, and a completed tool backing the figure → Sourced. Running tools contribute nothing.
  • TestLoadSessionFallsBackToLegacyParts — pre-v2 messages still read from part.

go build ./... && go vet ./... && go test ./... pass.

Closes #30. Studies both readers that were left on the v1 `part` table after the 2.0.24 migration: - `SnippetExtractor.ExtractAll` (`internal/ingest/snippets.go`) - `claims.LoadSession` (`internal/claims/opencode.go`) Both now read `session_message.data` `$.content[]` first and fall back to `part` only for messages/sessions v2 does not describe, so a migrated session is never read twice. ### Shape differences handled | | v1 | v2 | |---|---|---| | tool name | `$.tool` | `$.name` | | write/edit path | `filePath` | `path` (both accepted) | | tool output | `$.state.output` | `$.state.content[]` | | shell tool | `bash` | `bash` and `shell` | | `patch` parts | yes | none — `PatchHash` stays empty | `PatchHash` is stored as metadata only; supersession already derives from the last full `write`, so nothing depends on it. ### Why it matters `part` stops at 2026-11-01 20:58 while sessions continue. **1,475** completed `write`/`edit`/`bash`/`shell` calls exist in v2 that v1 never saw — all currently invisible to snippet curation and to the claim lint. ### Tests - `TestSnippetExtractorReadsSessionV2` — a v2 `write` becomes a candidate with the right language/project/model. - `TestSnippetExtractorShellV2` — `shell`, `state.content`, `path`, heredoc → `technique`. - `TestSnippetExtractorDoesNotDoubleCountV1AndV2` — a session in both shapes is mined once; a v1-only session still falls back. - `TestLoadSessionV2` — prose from `$.content`, evidence from `$.state.content`, and a completed tool backing the figure → `Sourced`. Running tools contribute nothing. - `TestLoadSessionFallsBackToLegacyParts` — pre-v2 messages still read from `part`. `go build ./... && go vet ./... && go test ./...` pass.
david added 1 commit 2026-11-05 04:31:28 +00:00
fix: read tool calls and prose from the v2 session store (#30)
build / test (push) Has been cancelled
build / image (push) Has been cancelled
c559f4ab03
Snippet extraction and claim lint were still on the frozen v1 part table.
opencode 2.0.24 moved tool calls into session_message.data $.content and
stopped writing part at 2026-11-01, so every later session produced no
snippet candidates and no lint evidence: 1,475 completed write/edit/shell
calls are in v2 that v1 never saw.

Both readers now prefer v2 and fall back to v1 only where v2 has nothing,
so a migrated session is never counted twice.

Shape differences handled: the tool name moved from $.tool to $.name,
write/edit input carries 'path' as well as 'filePath', completed output
is $.state.content[] rather than a flat $.state.output, and the shell
tool is emitted as both 'bash' and 'shell'. v2 has no patch parts, so
PatchHash stays empty for v2 candidates; supersession already derives
from the last full write, so nothing depends on it.
david merged commit 45f966d44f into main 2026-11-05 04:31:54 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#32