refactor: add SQLite session store foundation#89178
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed June 24, 2026, 7:25 PM ET / 23:25 UTC. Summary PR surface: Source +2349, Tests +1694, Generated +220. Total +4263 across 7 files. Reproducibility: no. current-main runtime reproduction applies because this is an unmerged internal storage refactor. Source inspection of the PR head gives a high-confidence reproduction of the review blockers in the new SQLite helper/schema paths. Review metrics: 2 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land only after no-create SQLite reads, export-before-delete structure, an Do we have a high-confidence way to reproduce the issue? No current-main runtime reproduction applies because this is an unmerged internal storage refactor. Source inspection of the PR head gives a high-confidence reproduction of the review blockers in the new SQLite helper/schema paths. Is this the best way to solve the issue? No, this is not yet the best mergeable shape. The typed SQLite foundation direction matches the tracker, but the branch still needs no-create reads, export-before-delete structure, a local blob-bridge contract, and proof before it is a maintainable storage base. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3ab8d6aa609a. Label changesLabel justifications:
Evidence reviewedPR surface: Source +2349, Tests +1694, Generated +220. Total +4263 across 7 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
f18f99c to
b39023f
Compare
6d15882 to
1ccad0c
Compare
a13e0eb to
890d5e3
Compare
890d5e3 to
b496b4b
Compare
|
Requesting changes to lock in the 3.2 scope agreed on the #88838 tracker. The foundation direction is confirmed good — typed relational schema ( 1. Absorb the caller-side plumbing from #91491 (closed; its semantics move here)
2. Add a no-create/read-only open path 3. Guard export-before-delete against the CASCADE 4. Confirm and document the 5. Minor
Context for reviewers: per maintainer decisions on #88838, the seam is permanent internal API, the flip is one-way (no reverse migration), and doctor preview must never create DBs — items 2 and 3 derive directly from those decisions plus the #91322 postmortem. |
1ccad0c to
07e48cf
Compare
1e31abd to
094f9b5
Compare
543fb5c to
ffd2ae9
Compare
What
Path 3 / PR 3.2 for #88838 adds the unused, additive SQLite session/transcript store foundation behind the 3.1a/3.1b accessor seam. It introduces the per-agent SQLite schema, generated Kysely types, SQLite-backed session/transcript helper module, SQLite checkpoint branch/restore support for validation branches, and shared conformance coverage while preserving the current file-backed runtime behavior.
Why
The SQLite storage flip should not land in the same PR as caller rewrites or legacy migration work. This foundation lets disposable validation branches exercise the future SQLite backend against the existing accessor seam while production runtime remains file-backed until later Path 3 slices complete caller adoption, doctor migration, and the atomic storage flip.
Changes
sessions.jsonpath paritypreserveActivityparity for SQLite patchessrc/state/openclaw-agent-schema.sqlsrc/state/openclaw-agent-db.tssrc/config/sessions/session-accessor.sqlite.tssrc/config/sessions/session-accessor.conformance.test.tsSchema Audit
The refreshed schema has durable homes for the data currently needed by this foundation slice:
sessionsstores normalized session identity/status/routing fields,session_routesmaps persisted keys to session ids,session_entries.entry_jsonpreserves the fullSessionEntryobject,transcript_eventsstores ordered transcript rows,transcript_event_identitiesstores event ids/parent links/message idempotency keys, andconversationsplussession_conversationscover future conversation linkage.The current 3.1b accessor seam is broader than this helper module. Newer storage-sized operations such as transcript-turn persistence, manual trim, reset/delete lifecycle, restart recovery, reply-session initialization, and plugin-host cleanup can be represented with the existing tables, mostly through
session_entries.entry_jsonplus transcript rows, but they still need SQLite adapter methods before the production storage flip. That is adapter coverage work, not a schema gap found in this refresh.Out Of Scope
Production storage flip/runtime wiring, doctor migration/import, runtime dual-read/fallback, and complete SQLite implementations for every post-3.1b accessor operation remain out of scope for this additive foundation PR.
Evidence
upstream/main3ab8d6aa609ab7f1a6bee14500694bd7ca243489node scripts/generate-kysely-types.mjs --verifynode scripts/check-kysely-guardrails.mjsnode scripts/check-session-accessor-boundary.mjsnode scripts/run-vitest.mjs src/config/sessions/session-accessor.conformance.test.ts src/state/openclaw-agent-db.test.tsnode scripts/run-oxlint.mjs src/config/sessions/session-accessor.sqlite.ts src/config/sessions/session-accessor.conformance.test.ts src/state/openclaw-agent-db.ts src/state/openclaw-agent-db.test.ts./node_modules/.bin/oxfmt --check --threads=1 src/config/sessions/session-accessor.sqlite.ts src/config/sessions/session-accessor.conformance.test.ts src/state/openclaw-agent-db.ts src/state/openclaw-agent-db.test.ts src/state/openclaw-agent-schema.sql src/state/openclaw-agent-schema.generated.ts src/state/openclaw-agent-db.generated.d.tsnode scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfonode scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.test.src.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/test-src.tsbuildinfo.agents/skills/autoreview/scripts/autoreview --mode branch --base upstream/main --engine codex --no-web-search --thinking codex=lowreturned clean