Repository navigation
refactor(sessions): run rewind and branch transactions in the agent executor (compound 2b) - #164753
Conversation
…xecutor (compound 2b)
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed October 4, 2026, 2:24 AM ET / 06:24 UTC (Revision 5). ClawSweeper reviewWhat this changesMoves durable conversation rewind and branch-switch transactions into the existing agent database worker while preserving history, identity publication, and native-session cleanup. Merge readiness✅ Ready for maintainer review This remains useful, distinct work that current main does not implement. The reviewed patch has no supported blocking correctness or security finding, and the supplied production-boundary evidence supports the execution cutover. Priority: P2 Review scores
Verification
How this fits togetherGateway session requests select conversation history and authorize changes. The agent database executor applies those changes, then acknowledged receipts refresh session identity, branch summaries, and native subscriptions. flowchart TD
A[Rewind or branch request] --> B[Capture source and authority]
B --> C[Prepare history and native custody]
C --> D[Agent database worker]
D --> E[Recheck authority and transact]
E --> F[Acknowledged commit receipt]
F --> G[Publish identity and refresh branches]
G --> H[Settle native subscription cleanup]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +444, Tests +800, Docs +13, Other +1. Total +1258 across 19 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Use the existing executor and receipt owners for durable history navigation, preserving synchronous SDK hooks and the established transcript format. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug report; current-main source establishes caller-thread transaction execution, and the supplied before/after Gateway measurement demonstrates the placement change. Is this the best way to solve the issue? Yes. Reusing the existing executor, transcript kernel, and native settlement owner is a focused approach that preserves established storage and SDK contracts. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f0af328d2475. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
Integrate main dac9277, including the preview fixture publication-order fix and native duration formatter import fix. The compound2b patch remains unchanged relative to main. Validation: 27 focused close, native settlement, build-graph, and import-boundary tests passed. All 3,644 public SDK exports retain the same reachable union surface against main. Fresh P2 review completed; the callback-registration/deletion claim was rejected by tracing the existing deletion owner.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…xecutor (compound 2b) (openclaw#164753)
What Problem This Solves
Rewind and branch switching synchronously scan and clone transcript graphs, rebuild indexes, and rotate session entries on the Gateway thread.
Why This Change Was Made
Run the complete durable rewind/switch transaction through the existing agent database executor. Capture the physical source and selected lifecycle before yielding, prepare cold history and native-generation custody outside the transaction, and reread authoritative source/model-lock/branch predicates inside the synchronous worker transaction. Publish entry, identity, branch-cache, and subscription changes through the existing receipt owner.
Reuse the reversible native-binding settlement from #164391: the shared-state veto still precedes agent COMMIT; confirmed agent rollback conditionally restores the removed binding; unknown outcomes retain custody and block reuse without replay. The reusable extension points are
SessionNativeBindingParticipants,runSessionNativeBindingWorkerOperation, andrunSessionNativeBindingTransaction.User Impact
No new product behavior, schema, persistent cache, retention, durability, configuration, or update migration. This converts rewind and branch switching only. Fork-at-message belongs to #158030; the fork family remains C6/compound 3. This does not adopt the new native fork command in #162287. Per coordinator direction, overlap with retained-history authority #163592 and the inactive #162433 design draft is intentional; hunks stay within this lane.
Production: 12 files, +602 / −158 / net +444 (760 changed lines). Static T1: 915 → 915 against
e25a98150544d4848f4296e79b1d5384ed8f6ab6; mixed native/worker kernels retain their conservative classification. No newOPENCLAW_*names.Evidence
sessions.rewindandsessions.branches.switchhandler tests prove zero caller-thread SQL for the moved operations, preserve transcript history, and refresh branch identity/cache state. The same boundary tests failed on the original implementation.The synthetic real-Gateway C3 workload passed four turns, rewind/divergence/switch history assertions, and clean shutdown, with no SQL errors. Measurement baseline is clean
2df2d8455db0bec1488ccfe8790b093f90362a4b; candidate uses the built production bytes committed inda930b8ae63c757672c6157421ded154af17b6b0(only mechanical test lint edits followed the build). The original C3 kernel/handler/native settlement sources were unchanged between that baseline and the pinned merge base.The remaining 35 caller statements are outside C3: 12 session preflight, 6 upstream-link preflight, 17 placement read/reconciliation. Original kernel-only attribution remains 217/256 before and 0/0 after. These instrumented single runs on a loaded host establish execution placement, not an overall latency improvement. Candidate workload wall time was 352.44 s, including 282.67 s startup; all owned processes exited.
All focused commands used
pnpm test <files> --maxWorkers=1. Local wall times include the heavily loaded host and compilation:Earlier failures were investigated, not counted as clean commands: worker read scopes initially carried a function and were narrowed to data; implicit preparation initially adopted a newer lifecycle and now retains the initial acquisition; native test injection now waits for lease quiescence and distinguishes known-not-entered readiness retries; the close fixture now uses suite setup, synchronous seeding, and an admin-scoped synthetic client. The final native/close run passes without timeout overrides. Per-file CI seconds were not recoverable from the published artifacts or bounded log inspection; the local wall times remain the measured per-file evidence.
The
node scripts/check-changed.mjs --base e25a98150544d4848f4296e79b1d5384ed8f6ab6run verified its prefix of guards, production/test type graphs, formatting, and dead exports in 2,835.79 s, then reported four test-only lint issues. The shadowed parameter, unbound helper reference, and redundant type arguments were corrected; the exact planner-selected lint step then passed in 89.85 s. Earlier unused type export was removed. The original planner's remaining script/schema/legacy-store/media/sidecar/import/webhook/auth checks were then run in order and all passed in 982.42 s, including 0 runtime value cycles. No gate was skipped. The final P2 review covers the functional patch; only these mechanical test lint corrections followed it.qaRuntimebuild passed: 583.3 s build phases, 1,032.53 s including artifact-ownership wait. The committed-ref SDK diff completed locally: 151 public entrypoints and 3,644 direct exports are unchanged, with no additions/removals or direct signature changes. Its 131 reachable-closure changes (digest 415a211f) arise from internal executor/kernel declarations, equivalent participant factoring, and worker error registration retained by conservative declaration closure traversal. A source-semantic audit of all 131 affected public export types, repeated against the patch base, found no newly exposed operation or error union case; both traversals exhausted the same 23,104 types without unresolved types. The v2026.9.8 private-local inventory and package exclusions confirm that the SQLite executor facades are not released third-party type contracts. Public ModelSelectionLockedError and harness mutation callback signatures are preserved. Existing exhaustive switches over released SDK unions need no additional cases for this change. SDK diff wall time, including isolated-worktree cleanup: 1,850.74 s; semantic audit: 8.07 s head / 10.01 s base.Retained contracts and follow-up debt
Opaque released SDK mutation hooks retain synchronous transaction visibility (
v2026.9.8,src/agents/harness/types.ts:490,508, publicly reachable throughsrc/plugin-sdk/agent-harness-runtime.ts:113). Incognito keeps its process-owned native database; maintenance/Doctor and excluded fork paths retain their existing owners.The pre-existing operator-role fallback can read indexed shared-state profile metadata during a live caller grant:
src/gateway/operator-role-policy.ts:240(cache miss at:48) →src/state/user-profiles.ts:128→src/state/user-profiles-internal.ts:231. Prepared-profile grants are memory-only. This other-owner authority read remains follow-up debt and is outside the moved-transaction SQL claim.Codex subscription behavior was personally checked against sibling
../codexHEADade0ccacf9182e665cf784de041c51a79e35bc31,codex-rs/app-server/src/request_processors/thread_processor.rs:1011–1037: unsubscribe is connection-scoped and distinguishes not-loaded, unsubscribed, and not-subscribed. Existing subscription cleanup remains after acknowledged settlement.The cross-database crash window is unchanged; unknown outcomes are blocked, not replayed. Testbox was not leased because of the stated organization cost cap. Full repository/release suites were not part of this focused local proof; normal PR CI remains required before merge. This PR is ready for review; it has not been landed.
Landing update
Head
9a3deb4fc1771c7871d55f052a49e7b344596ed7merges maindac9277a4126b87f2c0b6e0fcca1de9565dc66d7without rebasing or conflicts. The PR remains exactly 19 files, +1,450 / -192, and its stable patch ID is unchanged:5790ce7952b894a3a2302c58649b863c41b280f6. Main's independent auth-profile error registration from #164588 composes with the model-lock registration; its behavior is preserved.The original CI run 37175895301 had two independently inherited failures: the global-session preview fixture omitted
lastMessagePreview(also observed in scheduled main run 37173736148), and the declaration fixture's native Node import could not resolveformat-duration-internal.js(reproduced 5/5 on main). Main subsequently fixed them in217efe0ad5974aand3c0f7e4c5cdade; both fixes are included in this merge. The old admin-attribution evidence is historical and is not being used to waive fresh-head CI. The earlier PR-context heading failure was corrected and its check passed.Fresh merged-tree proof passed 27 tests across seven files / five Vitest shards in 1,254.43 s, using
node scripts/run-vitest.mjs <files> --maxWorkers=1: runtime-process build graph, get-reply imports, shared-state worker imports, worker-runtime imports, PR wrapper source closure, the real close-prelude regression, and all six native message-cut settlement cases. The close assertion itself took 5.57 s. The local run used supported Node 26.10.0; slow collection completed without timeout overrides or retries.The canonical SDK diff at the original head (digest
415a211f) is retained for the identical PR patch; it is not relabeled as a new-head render. A fresh semantic comparison of merged tree3dfb414803aa83f1803f659ed7bec01b96858f5aagainst integrated main checked all 151 public entrypoints / 3,644 exports, including constructor/value and instance types. Both traversals exhausted 39,951 types / 49,515 nodes, with no unresolved types, cuts, or newly exposed operation/error union member. Existing exhaustive consumers need no additional cases.Fresh P2 review completed. Its single rejected finding conflated registration of the native deletion callback with invoking it:
withSqliteSessionDeletionWorkerParticipantonly installs the callback (session-accessor.sqlite-deletion.ts:73), and the kernel's non-created outcomes return beforecommitSqliteSessionDeletion(session-accessor.sqlite-message-cut.ts:281–317). Pending participants settle as rolled back. No code was changed to suppress the finding, and no accepted/actionable findings remain.The original preview case passed five local observations; passing replays were not treated as a fix. The main declaration reproduction additionally hit one unrelated local fixture timeout, recorded separately from the PR CI roots. A planned remote baseline comparison was superseded once both main fixes landed; no Testbox lease or remote test ran. Fresh CI and a completed ClawSweeper review of this new head remain required before merge.