Repository navigation
refactor(sessions): run turn append+entry operations in the agent executor (compound 1a) - #163889
Conversation
…cutor (compound 1a)
|
🦞👀 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 3, 2026, 1:01 AM ET / 05:01 UTC (Revision 8). ClawSweeper reviewWhat this changesMoves atomic conversation-message appends, pending-input consumption, session updates, and Goal receipts into the existing agent database worker while preserving released callback behavior. Merge readiness✅ Ready for maintainer review The worker cutover remains useful and is not implemented on current main. No actionable correctness or security finding remains in the pinned diff; the recorded boundary proof supports the change. Priority: P2 Review scores
Verification
How this fits togetherSession persistence turns admitted conversation inputs and agent results into durable transcript and session state. The Gateway retains live authority checks and publishes acknowledged results to observers after the worker commits. flowchart TD
A[Conversation inputs and results] --> B[Host preparation]
B --> C[Existing agent executor]
C --> D[Atomic transcript and session transaction]
D --> E[Live commit authorization]
E --> F[Native commit receipt]
F --> G[Custody and observer publication]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +1298, Tests +963, Docs +14, Other +2. Total +2277 across 60 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep compound persistence atomic in the existing executor, with live host grants, acknowledged publication, and the released native callback compatibility path. Do we have a high-confidence way to reproduce the issue? Not applicable as a refactor; current-main source confirms the native compound transaction, and the recorded worker-boundary controls measure the intended cutover. Is this the best way to solve the issue? Yes. Reusing the existing executor, atomic kernel, commit receipt, and publication owner is a coherent path, with released opaque callbacks retaining their established transaction visibility. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7ff3b3be3713. 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 (7 earlier review cycles)
|
Preserve the caller's append predicate context and select runtime targets through the existing admitted history reader. Carry the physical source through host validation so replaced databases cannot return stale targets. Settle acknowledged entry publication when reconciliation scheduling throws, while preserving the original error, committed custody, and FIFO ordering. Adapt existing fixtures to worker connections, clocks, and explicit handoff barriers without weakening persistence or refusal assertions. Validation: clean P2 repair review; production and selected test typechecks; 11 publication, 13 identity, 6 configured-store SDK, and 2 missing-store tests pass. Both new regressions fail before their fixes. Earlier focused turn, Goal, abort, preview, reclamation, and SDK callback proof is retained.
Integrate sandbox broker routing, publication and Doctor fixture retirement, and the retired Doctor config fixture fixes. Resolve the cached-handle test conflict with main's equivalent turn fix and label-owner close repair. Validation: full candidate P2 review is clean; check-changed against the merged main parent passes; 58 turn/Goal/abort/handle tests and the compiled PR-wrapper inventory pass. The reviewed merge tree is unchanged.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Create the rejected runtime-persistence promise only after dispatch owns the recorder, then settle it through the existing persistence contract. Keep private receipt and admission faults on their native connection with TEMP triggers so worker admission sees the canonical durable schema. Preserve all turn, SQLite-failure, retry, and continuation assertions. Five head/base comparisons establish each regression. The repaired directive file passes 131 cases, private completion passes five runs of 23 cases, and the original five-file CI selection passes all 27 cases. Scoped changed checks and fresh P2 review pass; production is unchanged.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Merge main 9d876b7 to resolve the transcript-turn return-object conflict. Preserve predicateSkipped while adopting main's inline append count and retaining its worker history routing. The merged compound, Goal, and physical-identity suite passes all 43 cases; compiled-wrapper inventory passes. Fresh P2 review was completed; both findings were rejected against the existing admission and redaction owners: the former checks live authority before each grant, and transcript headers consume the preserved cwd rather than configuration.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Resolve the real conflict with main 9e34368 by retaining the reviewed shared SqliteSessionTurnOptions owner and the exact compound-turn accessor implementation. Preserve main's assistant-text cleanup. Production types, targeted lint, formatting and diff checks pass. The compound and Goal suite passes 30 cases; three assistant-text cases and compiled-wrapper inventory pass. Earlier physical identity, fixture and storage guard proof remains valid for unchanged inputs.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…cutor (compound 1a) (openclaw#163889) * refactor(sessions): run turn append+entry operations in the agent executor (compound 1a) * fix(sessions): preserve worker turn identity and publication Preserve the caller's append predicate context and select runtime targets through the existing admitted history reader. Carry the physical source through host validation so replaced databases cannot return stale targets. Settle acknowledged entry publication when reconciliation scheduling throws, while preserving the original error, committed custody, and FIFO ordering. Adapt existing fixtures to worker connections, clocks, and explicit handoff barriers without weakening persistence or refusal assertions. Validation: clean P2 repair review; production and selected test typechecks; 11 publication, 13 identity, 6 configured-store SDK, and 2 missing-store tests pass. Both new regressions fail before their fixes. Earlier focused turn, Goal, abort, preview, reclamation, and SDK callback proof is retained. * test(gateway): align persistence faults with their owners Create the rejected runtime-persistence promise only after dispatch owns the recorder, then settle it through the existing persistence contract. Keep private receipt and admission faults on their native connection with TEMP triggers so worker admission sees the canonical durable schema. Preserve all turn, SQLite-failure, retry, and continuation assertions. Five head/base comparisons establish each regression. The repaired directive file passes 131 cases, private completion passes five runs of 23 cases, and the original five-file CI selection passes all 27 cases. Scoped changed checks and fresh P2 review pass; production is unchanged.
What Problem This Solves
Per-turn transcript append, pending-input consumption, entry updates, and Goal receipts still shared a Gateway-thread SQLite transaction. Moving only individual writes would split predicates from their writes and could publish custody before COMMIT.
Solution
Register typed turn preparation and commit kernels on the existing agent executor. Reuse S10's transfer, native COMMIT receipt, publication, and operation settlement. Authoritative entry/Goal/idempotency/latest-assistant checks, ordered message appends, entry writes, and receipts execute together on the worker connection. Host preparation runs once; current authority remains host-owned; acknowledged custody and cursors install before observers; accepted postcommit work settles before physical FIFO ownership is released. Unknown outcomes block without replay or native fallback.
Initial Goal routing uses the existing lookup policy with transaction-local rows, including aliases and configured/default-store collisions. The host retains live configuration, creator, cancellation, and lifecycle checks. Media completion and fresh unstaged input retain their live guards through COMMIT admission. Native receipt replay also rechecks routing.
The existing worker error graph now reconstructs
SessionGoalOperationErrorandSessionPendingInputCustodyErroron the host. Goal refusals retainGOAL_OPERATION_REJECTED; custody refusals prevent message-injection fallback. Host admission failures retain their original error objects, and writer/cold rebound errors are constructed on the host from typed outcomes. The Goal constructor lives alongside its contract so the shared codec does not import session writers.Impact
captureSettlement(checkedEntries)remains the reset/delete companion owner; turn publication uses S10's existing owner.OPENCLAW_*names.prepareMessageAfterIdempotencyCheckandbeforeFreshMessageCommitsignatures and native transaction visibility are preserved. Audited bundled preparation is separate. No released signature changed, so no additional deprecation record is needed.src/infra/heartbeat-session-publication.ts:88,src/gateway/internal-source-reply-persistence.ts:81). The measurements below cover the compound operation and COMMIT grant, not all reads in a chat request.Evidence
Runtime host-SQL negative controls and candidate measurements:
The compound suite covers acknowledged COMMIT with lost ordinary reply, definite rollback, revocation at COMMIT, concurrent append FIFO and completion joining, commit-only custody/cursor publication, consumed-input replay, latest-assistant predicates, Goal intent identity, captured state roots, native routing replay, and fresh-input versus replay authority. Media retention adds real revocation at its worker COMMIT grant. Negative controls fail when the corresponding live guards are removed.
Fixture repairs use actual receipt-capacity failure and explicit expiry instead of schema-invalid triggers and parent-only clocks. Cold-storage refusal is observed at its actual worker admission boundary. Existing transcript/state/custody assertions remain intact; the Goal preflight read/byte bound is tighter.
Original-head validation at
4e7ae88c(retained evidence; focused invocations usepnpm test ... --maxWorkers=1):check-changed: passed, 1,189.04s wall. Madge: 0 cycles (23.04s). Database-worker ratchet: passed against59c4f37a8f95cbf194436f77477209b48876afd3; no static T1 growth (11.33s).beforeMessageWritecallback was rejected after the released-SDK and runtime-caller audit: the cited assistant option is internal, the released SDK callbacks retain native execution, and state-dependent internal checks now remain live through grants. Audited hook preparation follows the approved C1 design. No accepted/actionable finding remains.Landing repairs and current proof
The original-head CI run 37081275425 exposed worker-cutover defects. Preserve the original
shouldAppendcontext instead of substituting the executor database path. Move runtime target selection to the existing history reader, capture storage routing before awaiting it, and retain the physical source through host validation. A real file-replacement regression failed in both target modes before the physical-source repair.An acknowledgment callback can throw after native COMMIT while scheduling reconciliation. The committed entry publication must still settle before the error propagates. Its regression confirmed that the entry and message were durable while readers remained blocked; the fix releases publication custody, emits identity/completion once, and preserves the original error.
Existing fixtures now inject abort faults on the writing worker connection, propagate the thinking test clock to workers, bound CLI timestamps around the actual operation, mutate revision through the canonical writer, pause identity races at the selected-row barrier, register preview observers before seeding, and drain seeding's idle executor before checking reclamation. Persistence, refusal, cancellation, and turn-flow assertions remain intact. No added sleeps, retries, production test hooks, environment names, or dependencies.
Repairs are committed in
d17a7c2819b748b1892856f743dfcc9ad0e26430. Merge commitf0c139d3cc9230c9ea4385f090f348cdd55673bdincorporates main7924cf37a22795de1ecf90c10dc8b275ae3bdb06, including these inspected upstream fixes: sandbox broker routing (0eef5790), publication fixture retirement (f419f3c1), Doctor auth-profile fixture retirement (68f76fc9), retired Doctor preflight config (23bc4d7b), and cached-handle/label-owner fixture eviction (3c397d0021ad4, #163605). The only conflict was resolved with main's complete cached-handle test file; its turn repair is equivalent and its label-owner repair fixes the separately observed baseline hang.Current local proof:
codeandgoalCode; all seven wire round-trips and mismatch rejection passed.node scripts/check-changed.mjs --staged --base 7924cf37a22795de1ecf90c10dc8b275ae3bdb06: passed, 1,192.25s wall. All core production/test type graphs, lint, dead-export scans, storage and compatibility guards passed; 0 runtime import cycles, 477/477 existing environment names. Commit hooks preserved the reviewed tree.Commit
6a17ccb744cda059711a0a694c4e7fd8ab5495c6repairs two further fixtures exposed by the worker awaits. The directive fixture now creates and observes its rejecting promise during dispatch through the required transcript recorder. Private-completion faults use TEMP triggers on their actual native writer, preserving the canonical durable schema and every SQLite abort, retry, and continuation assertion.f0c139d3cc9230c9ea4385f090f348cdd55673bd: passed, 342.66s wall, including the selected Gateway type graphs, lint, guards, and dead-export scans. Fresh Codex review through P2 is clean. This commit changes only the two fixtures (+9/−9); production is unchanged.CI run 37091786486 completed on
f0c139d3cc9230c9ea4385f090f348cdd55673bdwith those two fixture failures and one independently inherited parent-recovery failure. The latter isdefers a yielded parent only while its continuation remains owned: settled batchinsubagent-parent-recovery.restart-integration.test.ts: its shared fixture omits the requiredchatAbortControllers, reached by cleanup introduced on main infdbf48d1383bf(#163558). Five singly run PR-head comparisons and five main-base comparisons all reproduce that case alone (13 cases pass); scheduled main run 37091047803 repeats the identicalsubagent-registry-execution-cleanup.ts:55stack. These comparisons used Node 24.21.0. The failing fixture and cleanup inputs are unchanged by this PR. The inherited-red admin route is explicitly authorized if the next exact-head attempt has only independently qualified inherited failures.Merge commit
6bb3ac7005f8fa502383b4a07bfa4976a1b973f5incorporates main9d876b7d6cb7198b2f465bd6529eba77446bef0efor a real conflict introduced by main's transcript-turn helper inlining. The resolution keepspredicateSkippedand main's inline append count; main's worker history routing is preserved. The PR remains 60 files with the same production footprint.session-accessor.sqlite-replacement-worker.ts:121-139invokes the supplied authority check before every transaction/COMMIT grant;session-accessor.sqlite-transcript-message-append.tsuses configuration for the host-prepared redaction, whileensureTranscriptHeaderaccepts the preserved cwd and has no configuration/lock lookup. The COMMIT-revocation regressions above pass. No accepted/actionable finding remains.ClawSweeper completed
6bb3ac7005f8fa502383b4a07bfa4976a1b973f5at 2026-10-03T04:20:12.956Z (review run), with no correctness/security finding and no before-merge item. It independently inspected the live-authority admission owner and confirmed the conflict is resolved.Prior prepared-head CI run 37095941989, attempt 1 completed with 102 successful jobs, 20 skipped jobs, no cancellations, and two failures:
checks-node-changed-compact-small-8(job111125943101) and its downstreamopenclaw/ci-gate(111127428903).security-fastpassed. The tested merge isb8bda2e88213236a2f766b3524880d39ecfb9ec1, with ordered parents maincdfe6cf00705aa2f59dbbe8040d333cd7d597984and this exact PR head. Its tree matches a fresh Git merge of those parents. The prior parent-recovery fixture defect is fixed in that main parent; the repaired Gateway fixture failures did not recur.The sole root failure is independently inherited:
session-accessor.sqlite-byte-size.test.ts→sizes active context without reading transcript overflow payloads. Main346b89d81d8c3(#163990) combined header discovery and byte sizing into one SELECT; the byte-size test now inspects an existing JSON header-navigation read whose opcode lacks the byte-length-only flag. This is a query/test contract mismatch; the assertion does not establish newly introduced overflow I/O. This PR changes neither the test nor its active-context, payload, or read-byte owners. Their blobs are identical on the PR head, merge base, actual CI main/merge, and independently failing scheduled main run 37094503398, attempt 1, job111121626866.Five PR-head and five merge-base full-file runs on Node 24.21.0 each reproduce only that failure, with 19 other cases passing. Head wall times: 76.65, 36.95, 40.94, 27.86, 27.20 seconds; baseline: 75.82, 36.57, 41.23, 27.87, 27.22 seconds. The fixture has no expected session ID or persisted entry and uses individual transcript appends, so it never enters the compound guarded owner. No later fix was found through inspected main
d5c4c19fe1863. Both failed CI logs were fetched once; no CI rerun was requested.The operator explicitly authorized native admin landing past independently proven pre-existing main failures in untouched files. Complete version-1 evidence binds this exact failed attempt, tested merge, unchanged source blobs, independent main and ten local replays, both failed jobs, and the passing scoped checks above. Hosted CI remains failed, and the 20 skipped jobs remain skipped; this qualification does not relabel either as passing.
Latest main integration
Published head
83821f0fe1ad3a434f077ac867b0fc2159ab69dfmerges main9e34368e594b358692f552624d4879f316ab3ddcafter #163960 introduced a real import/options-type conflict. The resolution retains the exact reviewed compound accessor and its sharedSqliteSessionTurnOptionsowner. Main's assistant-text cleanup remains intact. This changes the diff's comparison baseline, not the authored compound implementation.ClawSweeper completed this exact head at 2026-10-03T04:46:22.820Z (review run): no correctness/security findings and no before-merge item. Native
prepare-runcompleted for83821f0ingithub_pendingmode without claiming CI success.Current CI run 37097343356, attempt 1 completed with 106 successful jobs, 20 skipped jobs, no cancellations, and only the same inherited byte-size root (
111130040796,checks-node-changed-compact-large-7) plus downstream gate (111131478029). The failing runtime-config group passed its other 461 cases, andsecurity-fastpassed. Actual tested mergeafb61098f0298d9933e159f69d5e1c2305e2cf21has ordered parents maincf3aa7fbcc157db1af526aa95f01bce3183b8e46and this head, with a tree identical to Git's merge of those parents.All four qualified byte-size test/query/payload blobs are identical on this head, that CI main/merge, and the independently failing five-head/five-base and scheduled-main evidence above. That valid attribution is reused for unchanged inputs. Both failed logs for the new run were retrieved once, and no rerun was requested. Current native inherited-failure evidence binds the new run/head/merge and 22 hashed artifacts, with exhaustive job accounting and current passing scoped checks. Hosted CI remains failed; skipped coverage remains skipped. The operator's explicit inherited-red admin authority applies through the native verifier and its live security/review gates.
No rebase, dependency change, schema change, or new environment name was introduced.
Original CI attribution and remaining limits
The failed original attempt tested synthetic merge
322b1433ca2704ace5c232f45aebc39ec883247f, with main parent9b67f5df4240abec26b3430f34a3e4194d9fea42. Five singly run original-head/base comparisons reproduced the abort, CLI-clock, participant-read, accessor-context/environment, transcript-revision, thinking-clock, preview-observer, and reclamation-lease failures only on the PR. The cached-handle target also failed five head runs and passed on the baseline; further baseline handle runs were superseded by main's explicit fix after a separate label-owner timeout. Doctor auth-profile failures reproduced on the old Linux baseline five times before their upstream fix.Sandbox, cache identity, cleanup, and Talk each passed five head plus five baseline local runs. Cache and cleanup also passed their original CI selections on the exact tested merge (299 and 353 tests). Those two CI failures remain unexplained, not claimed fixed or inherited; local Node 24.21/macOS differs from CI Node 24.19/Linux. Talk's Linux-Bun evidence is separately one passing head run with no valid baseline replay after Testbox setup/queue failures. No old failing CI run was rerun merely to obtain green.
Independent main evidence establishes the same sandbox/Talk host-broker failures, four placement-evidence failures, publication-restart
SQLITE_BUSY, and Doctor auth-profile maintenance refusal in unchanged inputs. Scheduled main reference: 37077835919. The named upstream fixes above are now incorporated; no corresponding placement/Talk fix was found in the inspected main history. Current-head classification and the explicitly authorized inherited-failure exception are documented above; older unexplained outcomes are not reused as current-head evidence.