opencode session store migration to session_v2 breaks opencode-session ingest #6

Closed
opened 2026-11-01 21:19:15 +00:00 by david · 0 comments
Owner

Summary

opencode v2.0.24 migrated its session store on 2026-11-01 21:01:20 UTC. Session data now lives in session_v2 + session_message; the tables knox reads (session, message, part) are no longer written to. The ingest does not error — it silently reports 0 new forever.

Evidence

knox[1178]: [knox] opencode.db: 0 new, 446 unchanged

logged every ~90s while a live session existed.

table rows last write
session / message / part 446 / 58030 / 234891 2026-11-01 21:00:09 (frozen)
session_v2 / session_message 447 / 58301 live
  • Sessions created since migration: 1 in session_v2, 0 in session. Sessions updated since: 1 in v2, 0 in session. No dual-write.
  • ~/.local/share/knox/index.db has 965 opencode-session entries, newest 2026-11-01 = the last pre-migration session.

Schema change

old: part.data   = {"type":"text","text":...}
     message.data = {"role":"user"|"assistant"}

new: session_message.type = user | assistant | system | synthetic | compaction
     user/system/synthetic -> data.text
     assistant             -> data.content[] of {type: text|reasoning|tool}

Impact

  • loadOCSessions, loadOCTranscripts, loadOCPartCounts all read the frozen tables.
  • New and resumed sessions are never indexed; no error is raised, so the breakage is invisible.

Fix

  • Point the adapter at session_v2 / session_message, reconstructing text from data.text (user/system/synthetic) and data.content[].text (assistant), ordered by time_created, seq.
  • Filter <system-reminder> text: reminders are now stored as synthetic messages and would consume the 4000-byte summary budget.
  • Bump IngesterVersion to opencode-db/v2.
  • watch.go skips any entry whose CreatedAt matches, so a fixed adapter would not refresh old entries or resumed sessions. Replace that shortcut with an extent/content comparison.

Acceptance criteria

  • go test ./internal/ingest/ covers both message shapes against a temp SQLite DB.
  • Watcher log reports opencode.db: N new with N >= 1 after restart.
  • A phrase from a post-migration session is findable via knox search.
## Summary opencode v2.0.24 migrated its session store on 2026-11-01 21:01:20 UTC. Session data now lives in `session_v2` + `session_message`; the tables knox reads (`session`, `message`, `part`) are no longer written to. The ingest does not error — it silently reports `0 new` forever. ## Evidence ``` knox[1178]: [knox] opencode.db: 0 new, 446 unchanged ``` logged every ~90s while a live session existed. | table | rows | last write | |---|---|---| | `session` / `message` / `part` | 446 / 58030 / 234891 | 2026-11-01 21:00:09 (frozen) | | `session_v2` / `session_message` | 447 / 58301 | live | - Sessions created since migration: **1 in `session_v2`, 0 in `session`**. Sessions updated since: 1 in v2, 0 in `session`. No dual-write. - `~/.local/share/knox/index.db` has 965 `opencode-session` entries, newest 2026-11-01 = the last pre-migration session. ## Schema change ``` old: part.data = {"type":"text","text":...} message.data = {"role":"user"|"assistant"} new: session_message.type = user | assistant | system | synthetic | compaction user/system/synthetic -> data.text assistant -> data.content[] of {type: text|reasoning|tool} ``` ## Impact - `loadOCSessions`, `loadOCTranscripts`, `loadOCPartCounts` all read the frozen tables. - New and resumed sessions are never indexed; no error is raised, so the breakage is invisible. ## Fix - Point the adapter at `session_v2` / `session_message`, reconstructing text from `data.text` (user/system/synthetic) and `data.content[].text` (assistant), ordered by `time_created, seq`. - Filter `<system-reminder>` text: reminders are now stored as `synthetic` messages and would consume the 4000-byte summary budget. - Bump `IngesterVersion` to `opencode-db/v2`. - `watch.go` skips any entry whose `CreatedAt` matches, so a fixed adapter would not refresh old entries or resumed sessions. Replace that shortcut with an extent/content comparison. ## Acceptance criteria - [ ] `go test ./internal/ingest/` covers both message shapes against a temp SQLite DB. - [ ] Watcher log reports `opencode.db: N new` with N >= 1 after restart. - [ ] A phrase from a post-migration session is findable via `knox search`.
david closed this issue 2026-11-02 01:16:52 +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#6