Repository navigation
fix(session-worker): isolate receipts between sequential commits - #165904
Conversation
Keep prepared initialization rollback and opaque SDK deletion mutations on native planning and transaction paths. Ordinary host-minted binding participants retain worker execution and receipt settlement. Remove worker-only initialization finalizers and protect the same-store authority boundary with a real rollback regression.
Join accepted native lock operations in FIFO order before releasing the reservation, including callback failure and Gateway close. Preserve prepared receipt authority and its original cleanup receiver through harness adapters. Add awaited locked-message preparation with physical identity and fresh-insert version checks. Keep the released synchronous option deprecated and compatible, and migrate bundled catalog and Codex callers. No schema or durability change.
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. Reviewed October 6, 2026, 6:43 AM ET / 10:43 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR clears each session worker commit’s receipt and transfer state so later transcript writes cannot reuse an earlier acknowledgment. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still carries receipt state across sequential commits. The focused repair has relevant production-boundary proof, and no introduced correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetherSession workers persist session entries and transcript events in SQLite. Their settlement owner matches transferred candidates to commit receipts before publishing results to callers. flowchart TD
A[Session operation] --> B[Retained writer reservation]
B --> C[Fresh commit state]
C --> D[Worker transaction]
D --> E[Candidate transfer and receipt]
E --> F[Confirm native settlement]
F --> G[Publish acknowledged result]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +8, Tests +64. Total +72 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep one receipt-settlement owner with fresh transfer and admission state for every sequential commit while preserving the existing writer reservation and live authorization checks. Do we have a high-confidence way to reproduce the issue? Yes: two awaited event commits within one retained worker operation expose the stale receiver and acknowledgment path, with durable-row assertions distinguishing false success. The PR records a failing before-control; this review verified the mechanism from source without executing it. Is this the best way to solve the issue? Yes: resetting the existing owner’s per-commit state directly repairs the leak without adding another writer, replay path, or public contract. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8dc04b001e10. 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)
|
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
Preserve the landed host source authority and worker test routing. Keep one SDK compatibility record after the foundation merge. The remaining PR delta is the receipt owner reset and its real-worker regression.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…nclaw#165904) * fix(sessions): preserve native rollback authority Keep prepared initialization rollback and opaque SDK deletion mutations on native planning and transaction paths. Ordinary host-minted binding participants retain worker execution and receipt settlement. Remove worker-only initialization finalizers and protect the same-store authority boundary with a real rollback regression. * test(sessions): retain rollback observer receiver * fix(sessions): settle accepted locked transcript appends Join accepted native lock operations in FIFO order before releasing the reservation, including callback failure and Gateway close. Preserve prepared receipt authority and its original cleanup receiver through harness adapters. Add awaited locked-message preparation with physical identity and fresh-insert version checks. Keep the released synchronous option deprecated and compatible, and migrate bundled catalog and Codex callers. No schema or durability change. * style(sessions): avoid shadowing transcript lock parameters * fix(sessions): prevent stale worker commit acknowledgments
What Problem This Solves
A retained session worker operation can report two successful commits while storing only the first event. The second transfer is refused because its receiver is still occupied; settlement then accepts the first operation’s old acknowledgment and returns success again.
Solution
Reset candidate, admission, transfer identity, receiver, and transfer-completion state before each sequential commit. Keep candidate and admission in an explicit per-commit state object so asynchronous worker callbacks own the actual receipt state.
The regression sends two real event-append commands through the existing worker owner and checks both acknowledgments and durable row order. No new worker, schema, transport, authority bypass, or replay path is introduced. Existing single-commit native settlement and entry-publication callers retain their current behavior; the multiple-commit consumer is the following locked transcript adapter, whose candidates do not carry entry-replacement publication state.
Impact
Prevents a refused later operation from borrowing an earlier successful receipt. This is a prerequisite for independent transcript commits within one retained writer reservation. Production diff: +24/−16, net +8; 40 changed lines. Static T1: 846 → 846; this repair moves no SQL sites. New
OPENCLAW_*names: 0. No schema, retention, durability, permission, migration, or SDK signature changes.Evidence
Original head (
2da280d69e9b)2, but durable rows contained only the first new event.--maxWorkers=1, 491.19 s wall. The new regression’s body took 1.664 s. The suite includes lost replies, callback failures, unknown native settlement, prepared-source cleanup, live authority, binding compensation, and lifecycle projection.node scripts/check-changed.mjs --base 89072df2366088a3b3239e494a889baafcda47edpassed in 1,740.37 s wall, including types, budgets, dead exports, lint, and architecture guards. The exact-head SDK comparison passed in 372.66 s, with no Plugin SDK API changes (digestff7b090f). The canonical package/tarball check passed in 892.06 s. The published 2026.9.8 → candidate update cell passed in 684.87 s, preserving durable and incognito sessions, returningreadyz=200, and verifying the running version. Exact-head proof ran on Hetzner through the repository wrapper (cbx_ee42738387cf, runrun_c6fc0b7afbcab764a346b01c67a4cc14). CI test seconds are not yet available; the parent stack's CI dependency audit is blocked by inheritedsource-map-jsadvisory GHSA-68fv-2mgg-jv7q. This repair changes no dependency manifests or lockfile.The native locked-append settlement foundation #165894 has merged. Related work: #165793, #165764, and #162433. This keeps the receipt owner repair separate so the locked worker cutover remains within its production-line cap.
Integration (
9d06ca108e11)Merged main at
86e2107b5269with a merge commit. Kept main's consolidated host authority and worker routing unchanged and removed an automatically duplicated compatibility record. The final delta against that baseline is only the receipt owner and its regression: production +24/−16 and tests +64. The inherited source-map-js advisory fix is included.Fresh independent P2 Codex autoreview is scoped clean. Production and all core-test typechecks pass; Madge reports zero cycles. The changed-lane planner selects only core and core tests. Formatting and
git diff --checkpass.Focused proof: 62 passed, 2 failed across 8 files, 1,117.83 s wall with
--maxWorkers=1. The sequential receipt regression passes (5.319 s test body), as do native locked FIFO shutdown, entry publication/lost replies, live authority, native-binding settlement, Goal persistence, and ordered reads. Exact-head CI run 37449041132 succeeded with zero failed jobs and 8,233 aggregate job-seconds. The PR-context check initially rejected a renamed Evidence heading; restoring that required heading passed without a code change or CI rerun.The two local failures are in unchanged
session-accessor.reply-init-concurrency.test.ts:commits after same-session activity from another processhit the fixture's 10 s scenario watchdog, andrejects a transcript rewrite after another process commits an appendhit the 15 s test deadline. The first path invokes the changed owner only once per operation; the second uses native transcript writes after setup. Neither exercises the repeated-commit reset. The watchdog spans multiple phases and does not join the timed-out child request, so the second failure may follow unfinished work. The full file then passed five candidate runs (36/27/31/30/35 s) and five baseline runs (31/40/39/43/33 s), each singly with--maxWorkers=1and original file order on Testbox run 37450913977. The verified capsule changed only the receipt owner to its exact merge-base bytes for baseline runs; all other tested production sources are identical. No timeout, assertion, or retry policy changed. The precise stalled macOS phase and contribution of host load remain unknown; these are recorded unreproduced local failures, not an inherited-CI bypass claim. Testbox command exit was 0 and the lease was stopped/completed; backing workflow cancellation during one-shot cleanup is expected.Released SDK check: inspected
v2026.10.1-beta.1andv2026.9.8. The repaired owner is internal, has no SDK/runtime export or documented subpath, and this repair changes no signature. The existing released async facades and compatibility record remain unchanged. The post-integration SDK API report passed locally with no API changes against the integrated main baseline (digestff7b090f). No worker import, launcher module, host-SQL site, orOPENCLAW_*name is added; existing runtime-config fork routing covers the regression.ClawSweeper completed the exact-head review at
2026-10-06T10:23:55.280Zwith no correctness or security findings and no before-merge items.