fix: snippet extraction and claim lint still read the frozen v1 part table #30

Closed
opened 2026-11-05 04:27:59 +00:00 by david · 0 comments
Owner

OpenCode 2.0.24 moved conversations to session_v2/session_message. Session ingestion was ported (internal/ingest/opencode_db.go), but two readers were left on the v1 part/message tables, which stopped being written at the migration:

  1. SnippetExtractor.ExtractAll (internal/ingest/snippets.go) queries part p JOIN message m.
  2. claims.LoadSession (internal/claims/opencode.go) joins session_message to part on p.message_id = m.id.

Symptom

Nothing produced after the migration becomes a snippet candidate, and knox claims lint sees an empty conversation. On this machine part.time_created stops at 2026-11-01 while sessions continue past 2026-11-05, so every session since the move yields zero candidates.

Fix

Read tool calls from session_message.data $.content[] and fall back to part only where the v2 content is absent.

v2 shape differences that matter:

  • tool name is $.name (v1 used $.tool), status at $.state.status
  • write/edit input carries path as well as filePath
  • completed tool output is $.state.content[] {type,text}, not $.state.output
  • shell is used as a tool name alongside bash
  • there is no patch part type in v2, so PatchHash is empty for v2-sourced candidates (it is stored as metadata only; supersession is computed from the last full write)

Expected

Snippet candidates and claim lint pick up sessions written after the migration, with no duplicates for sessions that exist in both shapes.

OpenCode 2.0.24 moved conversations to `session_v2`/`session_message`. Session ingestion was ported (`internal/ingest/opencode_db.go`), but two readers were left on the v1 `part`/`message` tables, which stopped being written at the migration: 1. `SnippetExtractor.ExtractAll` (`internal/ingest/snippets.go`) queries `part p JOIN message m`. 2. `claims.LoadSession` (`internal/claims/opencode.go`) joins `session_message` to `part` on `p.message_id = m.id`. ## Symptom Nothing produced after the migration becomes a snippet candidate, and `knox claims lint` sees an empty conversation. On this machine `part.time_created` stops at 2026-11-01 while sessions continue past 2026-11-05, so every session since the move yields zero candidates. ## Fix Read tool calls from `session_message.data` `$.content[]` and fall back to `part` only where the v2 content is absent. v2 shape differences that matter: - tool name is `$.name` (v1 used `$.tool`), status at `$.state.status` - `write`/`edit` input carries `path` as well as `filePath` - completed tool output is `$.state.content[]` `{type,text}`, not `$.state.output` - `shell` is used as a tool name alongside `bash` - there is no `patch` part type in v2, so `PatchHash` is empty for v2-sourced candidates (it is stored as metadata only; supersession is computed from the last full `write`) ## Expected Snippet candidates and claim lint pick up sessions written after the migration, with no duplicates for sessions that exist in both shapes.
david closed this issue 2026-11-05 04:31:55 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: david/knox#30