Short description
getProjectState() in 0.44.4/0.45.0 selects an updated_at column that only exists in fresh installs (CREATE TABLE IF NOT EXISTS). No ALTER TABLE/ensureColumn migration ships for pre-existing context.db files, so every transform throws SQLiteError: no such column: updated_at and turns get hard-refused with MC-S06 DegradedPassRefusalError. Fix: add ensureColumn(db, "project_state", "updated_at", "INTEGER NOT NULL DEFAULT 0") to the migration path. Workaround: run that ALTER TABLE manually (verified working).
What happened?
On any context.db created before the updated_at column was added to
project_state, every transform that reads project state fails with:
SQLiteError: no such column: updated_at
at prepare (bun:sqlite)
at getProjectState (…/dist/index-16ny736w.js)
at getGlobalUserProfileVersion / readCurrentM0SnapshotMarkersUncached / materializeM0 / injectM0M1 …
The degraded pass then refuses the turn outright:
v2 refusal: interrupting the turn before the provider request arm=blocking-transform-error
cause="DegradedPassRefusalError: This request was not sent: Magic Context could not finish preparing it … (MC-S06)"
Observed on 0.44.4 and 0.45.0 (latest at time of report). In our logs
the error fired 2,000+ times across two days, with 3 hard MC-S06 blocks in one
day — opencode looked completely dead to the user.
Root cause
getProjectState() unconditionally selects the new column:
SELECT project_path, project_memory_epoch, project_user_profile_version, updated_at
FROM project_state WHERE project_path = ?
Fresh installs are fine because the base schema
(CREATE TABLE IF NOT EXISTS project_state (…)) includes
updated_at INTEGER NOT NULL DEFAULT 0. But there is no migration that adds
the column to existing databases — no ALTER TABLE project_state … and no
ensureColumn(db, "project_state", "updated_at", …) anywhere in the dist bundle
(the ensureColumn helper exists and is used ~300 times for other tables, just
never for this one). Old DBs keep the 3-column table:
0|project_path|TEXT|0||1
1|project_memory_epoch|INTEGER|0|0|0
2|project_user_profile_version|INTEGER|0|0|0
The schema migrations table confirms the DB is fully migrated (v94, latest) —
the migration simply doesn't exist.
Suggested fix
Add the same one-liner used for every other late-added column, e.g. in the
migration/startup path:
ensureColumn(db, "project_state", "updated_at", "INTEGER NOT NULL DEFAULT 0");
Workaround (for anyone hitting this now)
sqlite3 /root/.local/share/cortexkit/magic-context/context.db \
"ALTER TABLE project_state ADD COLUMN updated_at INTEGER NOT NULL DEFAULT 0;"
(back up context.db first — verified to fully resolve the failures, including
the MC-S06 refusals, with no restart required)
Environment
@cortexkit/opencode-magic-context@0.45.0 (also reproduced on 0.44.4)
- opencode v2.0.24, Linux, bun:sqlite backend
- DB at
~/.local/share/cortexkit/magic-context/context.db (~217 MB, migrations through v94)
Diagnostics
Plugin version
0.55.0
OpenCode version
2.0.24
Platform
No response
Client
Unknown
Log output (optional)
Short description
getProjectState() in 0.44.4/0.45.0 selects an updated_at column that only exists in fresh installs (CREATE TABLE IF NOT EXISTS). No ALTER TABLE/ensureColumn migration ships for pre-existing context.db files, so every transform throws SQLiteError: no such column: updated_at and turns get hard-refused with MC-S06 DegradedPassRefusalError. Fix: add ensureColumn(db, "project_state", "updated_at", "INTEGER NOT NULL DEFAULT 0") to the migration path. Workaround: run that ALTER TABLE manually (verified working).
What happened?
On any
context.dbcreated before theupdated_atcolumn was added toproject_state, every transform that reads project state fails with:The degraded pass then refuses the turn outright:
Observed on 0.44.4 and 0.45.0 (latest at time of report). In our logs
the error fired 2,000+ times across two days, with 3 hard MC-S06 blocks in one
day — opencode looked completely dead to the user.
Root cause
getProjectState()unconditionally selects the new column:Fresh installs are fine because the base schema
(
CREATE TABLE IF NOT EXISTS project_state (…)) includesupdated_at INTEGER NOT NULL DEFAULT 0. But there is no migration that addsthe column to existing databases — no
ALTER TABLE project_state …and noensureColumn(db, "project_state", "updated_at", …)anywhere in the dist bundle(the
ensureColumnhelper exists and is used ~300 times for other tables, justnever for this one). Old DBs keep the 3-column table:
The schema migrations table confirms the DB is fully migrated (v94, latest) —
the migration simply doesn't exist.
Suggested fix
Add the same one-liner used for every other late-added column, e.g. in the
migration/startup path:
Workaround (for anyone hitting this now)
sqlite3 /root/.local/share/cortexkit/magic-context/context.db \ "ALTER TABLE project_state ADD COLUMN updated_at INTEGER NOT NULL DEFAULT 0;"(back up
context.dbfirst — verified to fully resolve the failures, includingthe MC-S06 refusals, with no restart required)
Environment
@cortexkit/opencode-magic-context@0.45.0(also reproduced on 0.44.4)~/.local/share/cortexkit/magic-context/context.db(~217 MB, migrations through v94)Diagnostics
Plugin version
0.55.0
OpenCode version
2.0.24
Platform
No response
Client
Unknown
Log output (optional)