Skip to content

fix: restore session state after nested transcript rollback - #159807

Merged
steipete merged 3 commits into
mainfrom
codex/session-manager-transaction-rollback-20260927
Sep 28, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/session-manager-transaction-rollback-20260927

Conversation

@steipete

@steipete steipete commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A transcript transaction could roll back a nested append while its SessionManager still retained the deleted entry and selected it as the next message’s parent.

User Impact

Retries after a rejected transcript write use the restored conversation state. Nested synchronous reads and successful writes remain visible within their enclosing transaction. Target changes are checked before commit, preserving the selected target’s view. No schema, stored format, or public API changes are required.

Why This Change Was Made

Enlist the manager’s loaded view with the existing SQLite transaction-state owner. Reverse-order restoration preserves nested writes, bounded and deliberate branches, lazy headers, same-target reloads, and provisional keyed replay. Ordinary top-level appends add no SQL read or view copy. The private snapshot kernel retains the existing transaction sequence while keeping the writer within its line limit.

Evidence

The original 12-case regression file fails nine cases on pre-fix production and passes after the repair. A further provisional keyed-replay case also fails causally on the original code. The final candidate passes 13 rollback and nine idempotency cases, with zero unhandled errors, using real incognito and file-backed SQLite. Earlier focused hydration, target, and bounded-view coverage passed 69 cases; broader sibling proof is retained.

The exact six-file candidate passes selected session types, typed lint, formatting, both line-cap checks, and fresh independent P2 review. Final source hashes match the published tree. The snapshot-kernel extraction preserves its function body byte-for-byte apart from its export.

Measured on Linux x64, Node 24.19.0: the 22-case Vitest run took 11.66 seconds. The rollback module took 11.26 seconds from queue to end, including 7.59 seconds of suite execution with hooks. The maintained test command took 26.17 seconds, including worker preparation and verification. These are elapsed measurements, not summed test-body durations.

Exact-head CI run 36362124382 stopped at one independently attributed main-only installer assertion: it expects assert-release-versions in the top-level smoke script after main extracted that implementation into a sourced helper. The test, script, and helper are byte-identical in the actual tested main parent and merge. Other tooling groups passed 2,126 cases; the run’s 117 canceled jobs remain missing coverage. Scoped passing proof does not turn that CI result green.

@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: L labels Sep 27, 2026
@steipete
steipete marked this pull request as ready for review September 27, 2026 17:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@clawsweeper

clawsweeper Bot commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 27, 2026, 9:29 PM ET / September 28, 2026, 01:29 UTC (Revision 8).

ClawSweeper review

What this changes

The branch restores a session manager’s loaded conversation view when a nested SQLite transcript write rolls back and adds rollback and replay tests.

Merge readiness

✅ Ready for maintainer review

Current main still has the reported rollback gap, and this PR remains a useful fix. The prior review’s blockers have been addressed; I found no actionable defect in the pinned head.

Priority: P2
Reviewed head: 3797fb701c29631c884f6897336d2974635504da

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Focused real-SQLite boundary evidence and a coherent owner-level repair support a good patch rating, with the reported CI interruption handled by the normal landing gates.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The reported after-fix run exercises production SessionManager appends through real incognito and file-backed SQLite, injects nested rollback through the transaction boundary, and observes restoration and the next append parent. The review did not rerun that evidence; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The reported after-fix run exercises production SessionManager appends through real incognito and file-backed SQLite, injects nested rollback through the transaction boundary, and observes restoration and the next append parent. The review did not rerun that evidence; no stored-data contract changes.
Evidence reviewed 8 items Introduced production change: The pinned PR diff connects transcript writes to a view guard and stages a copy of the loaded view for reverse-order rollback.
Current main remains unfixed: Current main calls the transcript snapshot writers without the proposed manager-view rollback guard.
Transaction owner: SQLite transaction state rolls back staged callbacks in reverse order, matching the ordering this PR uses for nested writes.
Findings None None.
Security None None.

How this fits together

The session manager keeps a conversation view in memory while SQLite stores transcript entries. An append updates both; transaction rollback must leave the manager ready to choose the correct parent for the next message.

flowchart LR
  A[Session append] --> B[Session manager view]
  A --> C[SQLite transcript write]
  C --> D{Transaction outcome}
  D -->|Commit| E[Retained conversation]
  D -->|Rollback| F[Restore loaded view]
  F --> G[Next message parent]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +100, Tests +483. Total +583 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 178 78 +100
Tests 2 483 0 +483
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 661 78 +583

Review metrics

Metric Value Why it matters
Production and test growth production +100 net lines; tests +482 lines The production growth is explained by rollback enlistment and extraction of the existing snapshot writer; the added tests exercise distinct transaction outcomes.

Technical review

Best possible solution:

Keep the manager’s loaded view aligned with SQLite savepoint outcomes so retries and later appends use durable conversation ancestry.

Do we have a high-confidence way to reproduce the issue?

Yes. Current main lacks manager-view rollback enlistment, and the PR supplies a focused nested-write failure path with reported pre-fix failures; this read-only review did not run it.

Is this the best way to solve the issue?

Yes. The patch uses the existing SQLite transaction-state owner and checks target rebinding before commit, without adding a persistence owner or changing the stored format.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fb2487a903ab.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The fix addresses a real but bounded session-state failure after a rejected nested write.
  • merge-risk: 🚨 session-state: Rollback restoration changes which in-memory conversation view supplies the next message’s parent.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The reported after-fix run exercises production SessionManager appends through real incognito and file-backed SQLite, injects nested rollback through the transaction boundary, and observes restoration and the next append parent. The review did not rerun that evidence; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The reported after-fix run exercises production SessionManager appends through real incognito and file-backed SQLite, injects nested rollback through the transaction boundary, and observes restoration and the next append parent. The review did not rerun that evidence; no stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (7 earlier review cycles)
  • reviewed 2026-09-27T17:53:20.398Z sha 18584efec5b5d0bd45ed3377a28a8342da239369 :: blocked before merge. :: none
  • reviewed 2026-09-27T18:46:09.473Z sha 18584efec5b5d0bd45ed3377a28a8342da239369 :: blocked before merge. :: [P2] Skip rollback restoration for committed idempotent replays
  • reviewed 2026-09-27T20:25:24.573Z sha f329aabbc8d38b73556dde43db37150d7b368dfb :: blocked before merge. :: [P2] Preserve adopted keyed users across unrelated rollback
  • reviewed 2026-09-27T21:32:19.246Z sha f329aabbc8d38b73556dde43db37150d7b368dfb :: needs maintainer review before merge. :: none
  • reviewed 2026-09-27T23:48:23.875Z sha c98913a :: needs maintainer review before merge. :: none
  • reviewed September 27, 2026, 8:17 PM ET / September 28, 2026, 00:17 UTC (Revision 6) sha unknown :: needs maintainer review before merge. :: none
  • reviewed 2026-09-28T00:31:26.907Z sha 3797fb7 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 27, 2026
@steipete
steipete force-pushed the codex/session-manager-transaction-rollback-20260927 branch from 18584ef to f329aab Compare September 27, 2026 20:17
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Sep 27, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

I reproduced the reported cache observation on f329aabb with real SQLite and checked the next user append. The outer error was preserved, SQLite retained the precommitted keyed row, and the manager restored its prior loaded view. The next append selected the durable keyed row as its parent, and the reused and fresh manager views converged.

The rollback contract here restores the transaction-local loaded view, including bounded or deliberately selected state; it does not promise automatic freshness after an aborted transaction. The reported observation does not establish data loss or incorrect next-parent persistence. The existing view snapshot and reverse-order rollback owner intentionally preserve that boundary.

Skipping rollback enlistment for appended: false would introduce a real failure: another writer can create the keyed row inside the same outer transaction, and a no-op replay can adopt that provisional row. On rollback, that adoption must disappear. A new focused regression fails against the original main implementation and passes with this repair. The full 13-case rollback file and nine idempotency cases pass, with zero unhandled errors; selected types, typed lint, formatting, and line-cap checks also pass.

A fresh independent review of the full PR found no actionable P2 issue and agreed that the proposed post-abort freshness requirement was not established. I’m retaining the production implementation and preparing the additional provisional-replay regression for the next update. The current CI failure is a separately owned Codex retry-timer assertion; its original log and test order are retained for diagnosis rather than an unchanged retry.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 27, 2026
@steipete
steipete force-pushed the codex/session-manager-transaction-rollback-20260927 branch from 27d01fd to c98913a Compare September 27, 2026 23:41
@steipete

Copy link
Copy Markdown
Contributor Author

/allow-security-sensitive-change

@steipete
steipete merged commit 15bb24e into main Sep 28, 2026
125 of 247 checks passed
@steipete
steipete deleted the codex/session-manager-transaction-rollback-20260927 branch September 28, 2026 06:40
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 29, 2026
…#159807)

* fix: restore session state after nested transcript rollback

* test: cover rollback after provisional user replay

* refactor(sessions): isolate transcript write snapshots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant