fix: tighten SQLite runtime truth in session refactor#79971
fix: tighten SQLite runtime truth in session refactor#79971100yenadmin wants to merge 409 commits intoopenclaw:exp-vfsfrom
Conversation
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. source-reproducible for the reviewed gaps: the base branch deleted orphan legacy transcripts, allowed stale legacy transcript truth in doctor checks, and could include off-branch compaction markers by scan order. I did not execute the runtime paths in this read-only review. Real behavior proof Next step before merge Security Review detailsBest possible solution: Keep the SQLite-truth fixes with the base runtime-state refactor, then have a maintainer/security reviewer validate the stacked branch and land it only with the broader database-first migration plan. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible for the reviewed gaps: the base branch deleted orphan legacy transcripts, allowed stale legacy transcript truth in doctor checks, and could include off-branch compaction markers by scan order. I did not execute the runtime paths in this read-only review. Is this the best way to solve the issue? Yes for the focused slice: archiving orphan transcripts is the safer fix for the prior data-loss finding, and the other changes keep SQLite as the canonical runtime truth without reintroducing JSONL compatibility paths. Final merge remains a maintainer/security decision because the PR is stacked and protected. Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c3d98153202d. Re-review progress:
|
|
Architecture fit for this slice: flowchart TD
A["#78595 database-first runtime"] --> B["#79971 runtime-truth fixes"]
B --> C["setup freshness uses SQLite truth"]
B --> D["doctor integrity uses SQLite truth"]
B --> E["export emits canonical session header"]
B --> F["checkpoint cleanup uses source-session ownership"]
B --> G["recent readers stay on active branch"]
Why this slice exists:
Why it was chosen as a separate PR:
Stack placement:
Lossless Claw connection:
|
|
Follow-up on the live review finding:
What changed:
Runtime proof is now in the PR body and shows:
This keeps the SQLite-truth direction from |
66da4a2 to
7e59d6c
Compare
Summary
This follow-up tightens runtime-truth behavior on top of
#78595without reopening the companion-seam work.It fixes five concrete correctness gaps in the SQLite session refactor path:
.jsonlfiles satisfy health checkstype: "session"headerWhy this is better
These changes help OpenClaw itself, not just LCM:
Scope
Included:
setup.migration-importSQLite freshness checksdoctor-state-integritySQLite-truth transcript checksNot included:
#79904#79903#79905Review Follow-up
The doctor cleanup path is now explicitly non-destructive.
Fix:
*.deleted.<timestamp>backups instead of deleting themarchiverather thandeleteWhy this was necessary:
Primary follow-up files:
src/commands/doctor-state-integrity.tssrc/commands/doctor-state-integrity.test.tsReal Behavior Proof
Runtime proof from a direct module invocation on the PR branch:
{ "transcriptStillPresent": false, "archived": [ "orphan-proof.jsonl.deleted.2026-05-09T21-15-17.596Z" ], "notes": [ "- Found 1 orphan transcript file in ~/state/agents/main/sessions.\n These legacy .jsonl files are no longer referenced by SQLite session rows, so they are not part of any active session history.\n Doctor can archive them safely by renaming each file to *.deleted.<timestamp>.\n Examples: orphan-proof.jsonl", "- Archived 1 orphan transcript file in ~/state/agents/main/sessions as .deleted timestamped backups." ] }That proof shows:
Validation
cd /Volumes/LEXAR/repos/openclaw-pr78595-review OPENCLAW_TEST_PROJECTS_SERIAL=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 \ node scripts/run-vitest.mjs \ src/wizard/setup.migration-import.test.ts \ src/commands/doctor-state-integrity.test.ts \ src/auto-reply/reply/commands-export-session.test.ts \ src/gateway/session-compaction-checkpoints.test.ts \ src/gateway/session-transcript-readers.test.ts \ src/agents/main-session-restart-recovery.test.ts \ src/auto-reply/status.test.tsObserved locally:
12files passed,172tests passedStack placement
This PR is intentionally the correctness lane on top of the database-first runtime refactor.
Related stack:
Why this is separate:
Context
This PR is intentionally scoped as a correctness follow-up on top of openclaw/openclaw#78595.