Repository navigation
fix(cli): read session history from the canonical store, not a retired file - #132185
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 1:04 AM ET / 05:04 UTC. ClawSweeper reviewWhat this changesThe branch replaces retired JSONL session-history reads with canonical SQLite history across CLI preparation, hooks, retries, embedded dispatch, and cron execution, with focused regressions and documentation. Merge readinessThe prior embedded-dispatch blocker is fixed at the current head, and the canonical SQLite reader is consistently propagated through the inspected CLI paths. This member-authored, maintainer-labeled PR remains necessary because current main does not contain the repair; exact-head CI should finish before merge. Priority: P1 Review scores
Verification
How this fits togetherCLI-backed agent turns load persisted conversation context for hooks, fresh-session reseeding, and context-engine maintenance. The resolved session target identifies the canonical SQLite transcript that each entry point must carry through to those consumers. flowchart LR
A[Agent or cron turn] --> B[Resolved session target]
B --> C[CLI preparation]
C --> D[Canonical SQLite transcript]
D --> E[History and compaction context]
B --> F[Embedded CLI dispatch]
F --> C
E --> G[CLI agent response]
Before merge
Agent review detailsSecurityNone. PR surfaceSource -301, Tests -455, Docs 0, Other 0. Total -756 across 26 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Use the canonical SQLite transcript as the sole CLI-history source, preserve the admitted target through every production entry point, and merge after exact-head validation completes. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the pinned base’s file-based reader returns empty history for absent JSONL, while the new SQLite-backed fixtures exercise the same consumers with canonical stored history. This read-only review did not independently execute the reproduction. Is this the best way to solve the issue? Yes. Reusing the canonical bounded transcript projections removes the retired storage reader at its owner boundary, and the former embedded-dispatch omission is now covered by the lane composition test. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5d3bd15130a2. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
1324162 to
c65c055
Compare
…d file `transcript-file-resolve` returns the session key as a process-local routing token, but CLI history still treated it as a filesystem path: it resolved a JSONL file, ran a runtime migration over it, and suppressed ENOENT by returning an empty list. A session that lives only in SQLite therefore projected as an empty conversation, and the runner fell back to the current prompt alone. Hook history, reseed history, context-engine bootstrap, and the embedded fallback marker all inherited that silent emptiness. All five CLI callers now pass the session target they had already selected, and the embedded attempt passes its own; cron shares its explicit per-prompt target across user persistence and the CLI path. Presence comes from the transcript watermark rather than a file's existence, and history comes from the canonical bounded active-context reader, preserving raw-reseed eligibility, summary pinning, and truncation notices. The retired JSONL reader, its path resolution, and its runtime migration are deleted rather than kept as a fallback: runtime consumes only the canonical shape. Net production -348 lines.
…arget The lifecycle test still encoded the retired storage premise, asserting the loader was called with sessionFile/sessionKey/agentId. It now supplies a real session target on the prepared fixture and asserts that exact target is forwarded, which is the invariant the repair actually establishes.
Use vaporeon-alpha under the existing test provider in the persisted assistant-message fixture. Production behavior and assertions are unchanged. Validation: 59 attempt-execution tests passed, including SQLite assistant history detection, abandoned branches, and reset boundaries.
Carry the selected SQLite transcript target through embedded CLI dispatch and context-engine bootstrap/finalization. Keep custom-store transcript mirrors with that owner and retain the post-admission writer claim. Extend real SQLite and lifecycle regressions for PR #132185. Local behavioral tests and autoreview pass. The full changed-files gate is blocked by missing playwright-core; the additional fault-sequence E2E setup is blocked by missing @lit/context.
52699c6 to
7183bdf
Compare
|
Merged via squash.
|
…d file (openclaw#132185) * fix(cli): read session history from the canonical store, not a retired file `transcript-file-resolve` returns the session key as a process-local routing token, but CLI history still treated it as a filesystem path: it resolved a JSONL file, ran a runtime migration over it, and suppressed ENOENT by returning an empty list. A session that lives only in SQLite therefore projected as an empty conversation, and the runner fell back to the current prompt alone. Hook history, reseed history, context-engine bootstrap, and the embedded fallback marker all inherited that silent emptiness. All five CLI callers now pass the session target they had already selected, and the embedded attempt passes its own; cron shares its explicit per-prompt target across user persistence and the CLI path. Presence comes from the transcript watermark rather than a file's existence, and history comes from the canonical bounded active-context reader, preserving raw-reseed eligibility, summary pinning, and truncation notices. The retired JSONL reader, its path resolution, and its runtime migration are deleted rather than kept as a fallback: runtime consumes only the canonical shape. Net production -348 lines. * test(cli): assert the context engine receives the forwarded session target The lifecycle test still encoded the retired storage premise, asserting the loader was called with sessionFile/sessionKey/agentId. It now supplies a real session target on the prepared fixture and asserts that exact target is forwarded, which is the invariant the repair actually establishes. * test(cli): name the synthetic fallback-history model fixture Use vaporeon-alpha under the existing test provider in the persisted assistant-message fixture. Production behavior and assertions are unchanged. Validation: 59 attempt-execution tests passed, including SQLite assistant history detection, abandoned branches, and reset boundaries. * fix(cli): preserve canonical targets across dispatch and lifecycle Carry the selected SQLite transcript target through embedded CLI dispatch and context-engine bootstrap/finalization. Keep custom-store transcript mirrors with that owner and retain the post-admission writer claim. Extend real SQLite and lifecycle regressions for PR openclaw#132185. Local behavioral tests and autoreview pass. The full changed-files gate is blocked by missing playwright-core; the additional fault-sequence E2E setup is blocked by missing @lit/context.
Upstream openclaw#132185 moved bounded CLI history onto SessionManager.openBounded, so this branch's fallback tail reader lost its last caller. The barrel re-exports kept deadcode:exports satisfied, hiding that nothing — not even a test — called loadTranscriptTailWindowSync or transcriptTailOmitsBranchControlSync. Removes both functions, their private helpers, and the re-export lines. No production caller existed, so behavior is unchanged.
What Problem This Solves
A CLI session that lives only in SQLite projected as an empty conversation.
transcript-file-resolvereturns the session key as a process-local routing token, but CLI history still treated it as a filesystem path: it resolved a JSONL file, ran a runtime migration over it, and its catch deliberately suppressed ENOENT by returning[]. Nothing recorded that the history had not been found — it simply looked empty.Every downstream consumer inherited that emptiness: hook history, reseed history, context-engine bootstrap, the presence check, and the embedded fallback marker. The runner then selected only the current prompt, so a fresh CLI session that needed prior compacted context silently ran without it.
Reproduced against real SQLite: with a session holding a user message, a compaction summary, and a tail message, the canonical
SessionManager.open(target).buildSessionContext()returns all three while the CLI readers return{"cliHistory":[],"cliReseed":[],"contextEngineMessages":[],"cliHasTranscript":false,"reseedPrompt":null}.Why This Change Was Made
This is the repo's worst bug class — an action ending in no visible outcome and no recorded reason — and it comes from reading a retired storage shape at runtime. The architecture rules are explicit that core runtime consumes only current canonical shapes, and that retired shapes normalize in doctor/migration code, never behind a runtime fallback reader.
So the retired reader is deleted, not kept as a fallback. All five CLI callers now pass the session target they had already selected; the embedded attempt passes its own; cron shares its explicit per-prompt target across user persistence and the CLI path. Presence comes from the transcript watermark — a recorded fact — rather than a file's existence.
User Impact
CLI sessions resume with their real prior context, including compaction summaries, instead of starting effectively blank. Raw-reseed eligibility, summary pinning, and bounded truncation notices are preserved exactly.
Evidence
session-history,prepare,cli-runner.reliability,attempt-execution, cron session-key isolation, live-model-switch, model-registry, andcommands/agent.check-changedclean apart from anoxfmt: command not foundPATH artifact in the worktree; formatting verified directly with the repo binary (17/17 files correct).