refactor(runtime): delete legacy SQLite state adoption - #837
Conversation
🦋 Changeset detectedLatest commit: 05c5f1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2e34d54156
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
commit: |
Summary
Delete the two pre-1.0 compatibility paths
createSqliteStateDrivergained in #201. The owner has approved breaking changes for old on-disk stores, so neither path gets a fallback reader or a migration shim.<sanitized id>-<first 12 hex of utf8(id)>.sqliteor renames it and its-wal/-shmsidecars to<sanitized id>-<sha256(id)[0:16]>.sqlite. An old file stays on disk untouched and a fresh store opens beside it.agent_state_journal.result_stateis nowNOT NULLin theCREATE TABLE. ThePRAGMA table_info+ALTER TABLE ... ADD COLUMNupgrade, therow.result_state ?? row.stateread fallback, the replay-to-revision fallback in#committedState, and the "legacy journal row ... has no recoverable committed result"migration-failurebranch are gone.CREATE TABLE IF NOT EXISTS,initializecompares each table'sPRAGMA table_infocolumn list with the current schema and fails closed withAgentStateError('corrupt', ...). Without it an old journal opened cleanly and the firstdispatchsurfaced a raw SQLite "no column named result_state" asunavailable. The check names no old format.Kept as-is: kernel formats 1/2, the
'compact'row stored as'reset', the pending-migration loop that migratesresult_statebetween schema versions, and the notice ledger migrations undersrc/notices/**(another PR).Removal matrix
legacySanitizedFileNamesrc/state/sqlite.ts-wal/-shmsidecars)open()now returnsresolve(join(root, sanitizedFileName(id)))existsSync/renameSyncimports, two ENOENT/race branchesPRAGMA table_info+ALTER TABLE agent_state_journal ADD COLUMN result_stateCREATE TABLEdeclaresresult_state TEXT NOT NULL; a generic column-list check fails closedrow.result_state ?? row.statefallbackJournalRow.result_state: string;#committedByKeyreads it directly#committedState, itsdbparameterrow.result_stateunconditionallymigration-failurebranch and head-row recovery branchadopts the legacy root database and live WAL sidecarslegacyFileName,currentFileName,holdUncheckpointedLegacyEventfails closed when a non-head legacy event...,migrates a legacy journal-head result...,preserves legacy reset input...keeps the original commit input while migrating each committed result(current writer, v1 → v2 open)createLegacyMigrationDatabase,clearLegacyEventResults,createLegacyHeadOnlyDatabase,valueCounterDefinitionAdded test:
fails closed with a typed corrupt error when a table does not match the current schema(dropsresult_statefrom a current store and asserts thecorrupterror namestable agent_state_journal).Consequence for old stores
Measured on the built
distwith a hand-seeded pre-#201 database:root:open()createsprobe-counter-271e964079f6c266.sqliteand reads{ revision: 0, state: initial };probe-counter-70726f62652f.sqlitekeeps its mtime and is never opened.result_state(any path):open()rejects withAgentStateErrorcodecorrupt, messageState 'probe/counter' table agent_state_journal at '<file>' does not match the current schema (has revision, kind, name, payload, state, to_version, idempotency_key, committed_at; expected revision, kind, name, payload, state, result_state, to_version, idempotency_key, committed_at).Delete or recreate such stores before upgrading. No docs page under
docs/,packages/rsc-runtime/README.md, orwebsite/docs/{en,zh}described either legacy behavior (grepped for the filename scheme,result_state, and adoption prose), so the changeset is the only prose change.Verification
Run in this worktree on top of
origin/main(64492dd):pnpm build: pass.pnpm typecheck: pass.pnpm lint: pass (1518 files, 88 rules).pnpm test:unit: 4486 passed, 0 failed, 6 skipped.packages/rsc-runtime/tests/state-sqlite.test.tsalone: 55 passed.pnpm test:integration:run packages/rsc-runtime/tests/notices-sqlite-cross-process.test.ts packages/rsc-runtime/tests/state-packaging.test.ts packages/rsc-runtime/tests/state-sqlite-cross-process.test.ts: 10 passed, 0 failed.pnpm test:packed packages/agent-bundle/tests/packed-readonly-state-root.test.ts: 1 passed.pnpm docs:site:buildnot run: no public export or website page changed.Follow-up
Codex threads addressed in #850. The P2 nullable-column case now fails at open: the schema check compares each column's NOT NULL flag. The P1 docs gap is closed in
reference/runtime-environment.mdx(en, zh), which says pre-current stores are not read or migrated and how to recover.