Skip to content

refactor(sessions): unify checkpoint mutation flow - #122597

Merged
vincentkoc merged 4 commits into
mainfrom
refactor/session-checkpoint-mutation
Aug 19, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
refactor/session-checkpoint-mutation

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

The SQLite compaction checkpoint owner maintained separate branch and restore
mutation flows even though both operations require the same key normalization,
scope resolution, writer queue, transaction, identity snapshots, validation,
transcript fork, entry write, and post-commit identity publication. That
duplication made the transaction boundary and result handling easier to drift.

What Changed

Both operations now use one private discriminated mutation flow and one
synchronous transaction helper.

  • Branch keeps the checkpoint label behavior, records the normalized requested
    parent, and drops checkpoint history.
  • Restore preserves the existing label, parent, and checkpoint history.
  • The exported branch and restore functions remain small delegates.

Architectural owner:
src/config/sessions/session-accessor.sqlite-checkpoint.ts.

Production delta: +69/-140, net -71. Tests, docs, config, schema, protocol,
generated output, and changelog delta: 0.

User Impact

No intended user-visible behavior change. Branch and restore retain their
existing checkpoint selection, conflict/model-lock handling, transcript copy,
session-entry projection, and post-commit identity notifications.

Final Landing Proof

Branch identity

  • Head: f5a25fccd76c26be2c00d4d813d4eea6e26fefce
  • Tree: bd208f6a8d0ac23c6a5b4dc340d56dea8a06e16e
  • Main parent: b62df3a99ab968ad442943273d89d5fc49716afd
  • Original signed patch ancestor: 39aa62355c87b185041ec492962a5ad6c3ad7272
  • Patch ID: eb329eafdbfff410c4bcb7ce7bf6d441225ac39a
  • Target blob: 7d840ff828446ef5db30c6c396254ad50b110f2a

The two server-generated main refreshes changed only merge ancestry. The
checkpoint patch and resulting target blob remained identical.

Exact-head hosted CI

CodeQL, Critical Quality, OpenGrep, Workflow Sanity, iOS Periphery, macOS
Periphery, and Shared OpenClawKit Periphery also passed at this exact head.

Blacksmith Testbox

All 80 current focused tests passed (46 + 9 + 25). Targeted test types,
the exact target changed gate (core, coreTests), target formatting, target
oxlint, and git diff --check passed. The primary workflow completed
successfully through SSH cleanup, post steps, runner cleanup, and final job
completion. Build was correctly skipped in this lane.

AWS Crabbox

Literal public AWS proof passed pnpm build, all 80 current focused tests, and
built CLI/launcher version and help smokes. The lease was released and owned AWS
inventory was empty.

Review

  • Exact-head local autoreview used gpt-5.6-sol with high reasoning, exited 0,
    found no actionable issue, and scored correctness 0.98.
  • Independent diff review found no issue and judged the canonical mutation flow
    the best fix.
  • Repo-native review artifacts were refreshed, guarded, and validated at the
    exact head with recommendation READY FOR /prepare-pr and zero findings.
  • The fresh exact-head ClawSweeper review found no concrete patch defect and
    again recommended landing the canonical flow after checks and owner
    confirmation.

ClawSweeper's session-owner rank-up move is explicitly satisfied/skipped under
the repository's maint/refactor/tests owner-review exemption and the
maintainer's scoped land if good authorization. This is a one-file,
behavior-neutral, net-negative maintainer refactor with no schema, config,
protocol, security, or product change.

Collision and moving-main check

  • Live main retained target blob
    decaa60e228bfe17cbe081bb830cd2165c48da45.
  • The current merge-tree was clean.
  • Draft PR feat(memory): retain transcript policy lineage #123545 remains open and must rebase/adapt its memory-policy work
    onto this canonical mutation flow after this lands.
  • Behind-main movement alone does not invalidate the patch-identical proof;
    landing stops if main changes the target blob or introduces a real conflict.

AI-assisted: yes.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 12, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels Aug 12, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 2:43 AM ET / 06:43 UTC.

ClawSweeper review

What this changes

The PR routes SQLite checkpoint branch and restore mutations through one discriminated transaction flow while preserving their distinct session-entry outputs.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open. Current main still has separate checkpoint branch and restore flows; this focused refactor consolidates them without a concrete correctness finding. The protected maintainer label and member-authored status require explicit session-owner approval before landing.

Priority: P3
Reviewed head: f0e49b9d5bfa8fbadd5bf94f6654256ad78080cd
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused net-negative owner refactor with preserved caller contracts and behavior-level coverage, pending required owner approval.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored protected refactor is not subject to the external-contributor proof gate; its supplied focused Testbox and clean-machine evidence is supplemental.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored protected refactor is not subject to the external-contributor proof gate; its supplied focused Testbox and clean-machine evidence is supplemental.
Evidence reviewed 6 items Current-main behavior: Current main still contains separate branch and restore wrappers with duplicated normalization, queue, transaction, and identity-snapshot setup, so this PR's central consolidation is not already implemented.
Proposed owner boundary: The PR makes the exported operations thin delegates to one discriminated operation and keeps the branch-only label/parent/checkpoint projection separate from restore's preserved checkpoint projection.
Caller boundary: Gateway prepares legacy checkpoint input once per public operation and continues to call the same exported branch and restore APIs; the refactor does not broaden the Gateway contract.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

pnpm openclaw --help
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-122597-DEJqIV/target$ pnpm openclaw --help
$ node scripts/run-node.mjs --help
pnpm openclaw --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 400.66 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 111.12 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 12.6s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 3880ms (slowest: built plugin control-plane loads 3242ms)

OpenClaw 2026.8.1 (f0e49b9) — All your chats, one OpenClaw.

Usage: openclaw [options] [command]

Options:
  --container ‹name›   Run the CLI inside a running Podman/Docker container named ‹name› (default: env OPENCLAW_CONTAINER)
  --dev                Dev profile: isolate state under ~/.openclaw-dev, default gateway port 19001, and shift derived ports (browser/canvas)
  -h, --help           Display help for command
  --log-level ‹level›  Global log level override for file + console
… output truncated …

Assertions:

  • PASS expect_output: Usage:

How this fits together

SQLite session checkpoints let Gateway compaction branch or restore a conversation. Gateway prepares any legacy transcript source, then the SQLite accessor validates state, forks transcript rows, updates the session entry, and publishes identity changes.

flowchart LR
A[Gateway checkpoint request] --> B[Checkpoint store]
B --> C[SQLite session accessor]
C --> D[Branch or restore decision]
D --> E[Queued database transaction]
E --> F[Transcript and entry update]
F --> G[Session identity notification]
Loading

Decision needed

Question Recommendation
Does the session owner approve landing this behavior-preserving consolidation of SQLite checkpoint branch and restore mutations? Approve the canonical mutation flow: Land the refactor after the current head's required checks complete because it retains the two distinct entry projections under one transaction owner.

Why: The patch changes the owner of persisted session and transcript mutations, and the protected maintainer label requires explicit human ownership approval despite no code finding.

Before merge

  • Resolve merge risk (P1) - The supplied check rollup is incomplete; verify required checks on the current PR head before landing.
  • Complete next step (P2) - No mechanical repair is needed; the protected maintainer label requires session-owner approval and completed exact-head checks.
Agent review details

Security

None.

PR surface

Source -71. Total -71 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 69 140 -71
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 69 140 -71

Review metrics

Metric Value Why it matters
Production versus test LOC production +69/-140 (net -71); tests 0 The refactor removes duplicated mutation paths while relying on existing behavior-level SQLite and Gateway coverage.

Stored data model

Persistent data-model change detected: serialized state: src/config/sessions/session-accessor.sqlite-checkpoint.ts, unknown-data-model-change: src/config/sessions/session-accessor.sqlite-checkpoint.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the single discriminated checkpoint-mutation owner after session-owner approval and exact-head required checks complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the single discriminated checkpoint-mutation owner after session-owner approval and exact-head required checks complete.

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

Not applicable: this is a behavior-preserving refactor, and the relevant review path is direct comparison of branch and restore contracts plus existing conformance coverage.

Is this the best way to solve the issue?

Yes. One discriminated operation removes duplicated transaction ownership while retaining the branch-specific and restore-specific entry projections at the sole required decision point.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a behavior-preserving internal cleanup with no reported user-facing regression.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This member-authored protected refactor is not subject to the external-contributor proof gate; its supplied focused Testbox and clean-machine evidence is supplemental.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Recent merged commits consolidated the session-accessor exports and fenced lifecycle transcript writers in this owner area. (role: recent session-accessor contributor; confidence: high; commits: 992126e382af, d7cdb2e60b7a; files: src/config/sessions/session-accessor.sqlite-checkpoint.ts)
  • Patrick Erichsen: Recent merged work maintained the related Gateway session lifecycle behavior. (role: adjacent session-lifecycle contributor; confidence: medium; commits: 678a3c18a941; files: src/config/sessions/session-accessor.sqlite-checkpoint.ts, src/gateway/session-compaction-checkpoints.ts)

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 (8 earlier review cycles)
  • reviewed 2026-08-12T11:04:17.295Z sha 39aa623 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T11:57:05.271Z sha 39aa623 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T12:10:17.644Z sha 39aa623 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T12:20:27.541Z sha 789b083 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-12T13:07:23.435Z sha 789b083 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T02:17:49.386Z sha 789b083 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T03:05:46.309Z sha 789b083 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-15T05:02:10.837Z sha 789b083 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc marked this pull request as ready for review August 12, 2026 11:37
@vincentkoc
vincentkoc marked this pull request as draft August 12, 2026 11:51
@vincentkoc
vincentkoc marked this pull request as ready for review August 12, 2026 11:51
@vincentkoc
vincentkoc requested a review from steipete August 12, 2026 12:45
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 12, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@vincentkoc

Copy link
Copy Markdown
Member Author

Landing review is complete at
f5a25fccd76c26be2c00d4d813d4eea6e26fefce.

ClawSweeper's session-owner rank-up move is explicitly satisfied/skipped under
the repository's maint/refactor/tests owner-review exemption and the
maintainer's scoped land if good authorization. This is a one-file,
behavior-neutral, net-negative maintainer refactor with no schema, config,
protocol, security, or product change.

Draft PR #123545 remains open and should rebase/adapt onto this canonical flow
after landing.

@vincentkoc
vincentkoc merged commit 0151ef1 into main Aug 19, 2026
229 checks passed
@vincentkoc
vincentkoc deleted the refactor/session-checkpoint-mutation branch August 19, 2026 07:39
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M 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