Skip to content

refactor(sessions): move prepared metadata patches into workers - #163378

Merged
steipete merged 16 commits into
mainfrom
dbasync/s10
Oct 2, 2026
Merged

steipete merged 16 commits into
mainfrom
dbasync/s10

Conversation

@steipete

@steipete steipete commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Per-turn session metadata patches still execute their durable SQLite transaction and COMMIT on the Gateway thread. This change moves prepared patches onto the existing agent executor while preserving physical-store FIFO, transaction-held predicates, caller authority, and committed publication.

User Impact

This is an internal execution change with no new configuration or public callback contract. Session metadata writes leave the Gateway thread, and automatic retention/cap maintenance continues after worker-only commits.

Why This Change Was Made

Usage accounting, unguarded compaction accounting, restart cleanup, activity recaps, prepared entry upserts/replacements, and route metadata explicitly select the worker path. The worker rereads authoritative rows before CAS, delivers a bounded provisional result before the final grant, and confirms that result with a native receipt. Lost replies retain committed custody and never replay the write. Persisted column comparison is independent of object prototypes changed by IPC.

Maintenance cutover

Landing CI exposed a silent regression: a worker-only entry commit leaves no host SQLite handle, so the old maintenance kick returned without scheduling retention or cap cleanup. Maintenance now belongs to the physical database path, live admission, and asynchronous resource lifecycle. The host retains coalescing, the one-second quiet window, bounded rejection backoff, and timers. It borrows the executor only during each pass, preserving idle worker cleanup.

The canonical worker connection owns age capture and deadline probes. Main's retained preparation runs before write admission; apply revalidates rows and revision under the writer lane. Committed receipts publish compact activity changes before row observers; native-compatible writers use the same post-commit boundary. Coalescing preserves newer backdates, restores, and inserts across settlement. No-op plans validate connection incarnation, revision, and age capture; activity arriving during the final deadline probe triggers the existing bounded replan. Preservation checks, post-writer finalization, and restart drain behavior remain intact. Scheduling never opens a host SQLite handle. Closing the physical store revokes scheduling and joins the complete active maintenance pass and executor releases before cleanup custody is removed. Alias paths share the physical agent identity for close selection; logical session ownership remains unchanged. Once finalization completes, its write-protection keys are spent; a changed deadline probe cannot restore them into another cap decision. New writes after finalization keep the one-second quiet window, while pre-finalization input retries keep their existing rejection limit.

The maintenance repair adds 347 net production lines on top of the original cutover. It adds no new main-thread SQL call sites or inventory reclassifications.

Post-commit consumer audit

Consumer Verdict
Identity publication (session-entry-patch.ts) Receipt settlement and committed callbacks precede identity notifications; no host handle prerequisite.
Cache invalidation and sharing/generation custody (session-accessor.sqlite-entry-cache-publication.ts) Physical identity and session-key custody invalidate existing caches and install committed facts. An absent host cache leaves nothing stale to invalidate.
Gateway row adoption (session-row-projection-materialize.ts) Prepared worker metadata is installed directly.
Usage and compaction (session-usage.ts, session-updates.ts) Committed entries update summaries and counters. Usage intentionally sets skipMaintenance:true; activity changes still reach an existing maintenance owner.
Activity summaries and restart cleanup (session-activity-summaries.ts, restart-recovery-claim.ts) Returned entries and retained authority/projection facts drive publication; no absent-handle no-op.
Disk-budget maintenance (session-history-eviction.ts) Captured store/environment and worker lifetime remain independent of logical-maintenance skipping; existing throttle/policy skips remain intentional.
Logical maintenance (session-accessor.sqlite-maintenance-kick.ts) Repaired path/resource owner and worker age state preserve worker-only commits. Other migrated entry callers retain the default kick.
ACP (src/acp/runtime/session-meta-entry.ts, session-meta-write.ts) Uses the same receipt publication and maintenance kick, preserving explicit maintenance configuration and skipMaintenance. Shared-state publication remains receipt driven.

Evidence

Current candidate

Candidate ed61a14bd55d55b6b7212fb4d0928e6a12dead66 merges main f02d16e75852f082b25ea3963ef98f254143a614 without rebasing. The current canonical-maintenance integration and its proof are detailed below. Final-head CI passed in run 37033204437: 62 successful jobs, 20 skipped, zero failed. Trusted ClawSweeper completed this head at 2026-10-02T16:26:24.849Z with no actionable correctness or security findings. No admin exception or CI rerun was used. The earlier integration in 1ee6ec5727eac464226ef26a33afb68ad7df5a79 resolved the sole conflict by retaining main's worker-status coverage and S10's remaining teardown changes. The later integrations were clean and follow #163485's execution-type move to its canonical contract module, main's session validation, and awaited SDK persistence.

Automatic-maintenance close revokes scheduling immediately and retains async-resource custody until the active pass and all executor releases settle. Close errors remain rejected and retain custody. Requested and canonical paths register under the physical database agent, including aliased and relocated shared stores. Two deferred-gate regressions failed before repair: canonical close settled while finalization was held, and physical shared-store close missed the logical-agent registration. Both pass after repair, without sleeps or timer-based pending assertions.

Earlier session integration proof at c9aed89d: 158 tests passed across ten files on Node 24, 449.44 s harness wall, covering patch boundaries, maintenance worker/kick/cadence/admission/close, recap retries, generation readiness, replacement publication, and ACP metadata worker writes. Six wrapper closure/extraction tests passed in 20.92 s. Core types and fresh full-candidate Codex review through P2 passed. Package declaration compilation passed: 209 SDK roots emitted and Codex/Slack/Telegram compiled, 305.414 s. The negative package-boundary canary passed in 4.044 s.

Pre-conflict integration proof at 17d7de0c: all 17 wrapper closure/extraction tests passed, 47.95 s, and all 210 subagent lifecycle tests passed, 103.45 s, including main's complete delivery-context fixture from 779c5aae5e882. Fresh full-candidate Codex review through P2 is clean against main 2aa2bd66. This repairs duplicate inventory entries in the CI merge tree; all five dependencies remain present exactly once, byte-identical to main's manifest.

The maintenance-close candidate 1ee6ec57 also passed the complete scoped source-check runner, all 27 test type graphs, and 152 tests in its eight-file selection. The new close test file measured 2.912 s test execution / 91.61 s harness wall standalone, including worker compilation. Before the later maintenance-owner merge, trusted ClawSweeper completed 17d7de0c800fabb57ec15d1ba325d13a32ad2faa at 2026-10-02T14:51:47.303Z with no actionable correctness or security findings, confirming both close fixes. Its technical review explicitly rejects the generic migration-proof checkbox because the stored-data contract is unchanged.

Canonical maintenance integration

The exact 17d7de0c candidate completed CI run 37022246399 successfully: 61 passed, 20 skipped. Before native dispatch, main advanced to 7555e3f88132bc5915e42141d9a09aa435ed7c2a (#158251), introducing real maintenance-owner conflicts. The native tool confirmed a pre-dispatch abort with no request or outcome record; only that attempt's operation lock was recovered.

The merge preserves main's canonical metadata actor, snapshot preparation, archive publication, and cleanup, and carries S10's age deltas, validated age snapshots, transaction callbacks, and physical-close joins through that owner. Age probes now share the canonical metadata actor. Source inspection proves the preparation call retains the actor's existing open connection; it does not split age state onto a separate reader. No retention, schema, stored format, or durability contract changes.

Focused integration proof covers 153 distinct cases across nine files. The initial run passed 144 and caught nine cadence-fixture calls still using the superseded preparation signature; restoring main's one-argument call and release custody made all 28 cadence cases pass in 29.99 s. The initial nine-file run took 262.01 s. Patch boundary, maintenance close/kick/worker/admission, writer ownership, sharing, and recap retry cases passed on the integrated production code. Core types passed. A fresh full-candidate Codex review through P2, including unchanged connection-lifecycle source, is clean; it accepts the cadence repair and resolves the suspected separate-reader age inconsistency. Exact-head CI and ClawSweeper are requested for c753b985c386c3a3adae5a09ab3a7a787f268b46; no completed evidence for that head is claimed yet.

The local combined ratchet stopped at the inherited environment-variable count: 477 distinct names vs budget 476. The exact owner check also fails on pinned main 7555e3f8; a complete production-source comparison reports identical name sets with no additions or removals. The budget and severity policy are unchanged. scripts/lib/check-limits.mts makes this limit advisory in GitHub Actions. All 29 remaining planned checks passed directly, including all 27 core test type graphs, scoped lint, formatting, export scans, schema/storage guards, import cycles, and authentication boundaries. The historical local budget failure remains recorded; after incorporating main's repair, the committed final candidate passes the same environment check at 477/477. The earlier combined runner is not relabeled as passing.

Final fixture admission repairs

CI run 37027169263 at c753b985 completed with 58 successful, 3 failed, and 20 skipped jobs. The two root jobs were 110905123716 and 110905123710; the third failure was their aggregate gate. CI tested merge cc01e39796e22cd82e2efffcf45c8ea0824f5e00, with main parent a94fa6c9f7dd55176151626e2c89c64e435bd430. All 26 cases across the three affected files pass on that exact main parent; no inherited-failure waiver is claimed for them.

  • Goal corruption/pruning fixtures performed raw writes outside FIFO admission after clearSessionGoal scheduled maintenance. A synchronous busy wait then blocked the host needed to grant the worker's commit. Raw fixture mutations now use the existing writer queue; corruption, replay, expiry, capacity, and rollback assertions remain unchanged.
  • The explicit-deletion fixture seeded updatedAt: 1. A fail-first diagnostic captured archivedAt and archiveReason: age-retention appearing before its intended materialization race, causing an earlier expected-entry rejection. Fresh fixture timestamps preserve the intended late race, both materialization steps, and archive-preservation assertions.
  • The new sharing-authority test measured cold admission that its former native entry seed had performed incidentally. A stack trace bound the first SQL to the unchanged collaboration owner in session-sharing-store.async.ts, not a sharing-row mutation. The fixture now prepares that owner through a no-op collaboration operation before measuring add/list/remove; all SQL and authority assertions remain. Production maintenance stays enabled and no host handle is reopened for maintenance.

Commit ed61a14bd55d55b6b7212fb4d0928e6a12dead66 includes main f02d16e75852f082b25ea3963ef98f254143a614, including the new sharing-authority suite and the separately landed environment-budget repair 1f14ba2cbe2f6. The S10 maintenance production files are unchanged from c753b985.

Post-fix proof: 26/26 tests across all three files passed in 575.70 s harness wall on the loaded host. The exact-main comparison took 976.20 s, including a 248.4 s cold worker build; these setup costs are separate from case execution. The selected gateway-methods and agents-sessions type graphs, scoped lint, and formatting passed. Fresh full-candidate Codex review through P2 is clean. ClawSweeper completed the prior c753b985 head at 2026-10-02T15:32:49.299Z with no actionable correctness or security finding. The repaired ed61a14b head has successful CI and its own completed ClawSweeper review, recorded above; no rerun was used to hide these failures.

Timer comparison

Prior CI run 37003981352, job 110828237183 failed subagent-registry-lifecycle.test.ts:1307, “preserves cleanup exhaustion when another run settles (related=true)”: expected zero fake timers, observed one. The proposed maintenance chain is absent from the earlier fixture cases: the session seed is synchronous, timing writes are mocked, and native lookups are read-only. An artificial worker-write probe demonstrated queued maintenance but could not attribute the original timer; that probe was removed.

Controlled comparisons used Node 24.21.0, with eight workers for the original three-file selection: lifecycle, session-cost-usage archive identity, and session cold-storage backup. These diagnostics are pinned to the maintenance-close candidate and its merge base; they are not represented as final-head CI.

Head Lifecycle alone, five runs Three-file selection, five runs
Base c825f9948e217058b85911d3ea0ef04e9442589b 5 passed, 210 tests per run 4 passed; run 5 failed the same zero-timer assertion in the related=false exhaustion variant (224 passed, 1 failed)
Repair 1ee6ec5727eac464226ef26a33afb68ad7df5a79 5 passed, 210 tests per run 5 passed, 225 tests per run

The differing parameter variant is retained explicitly: the symptom exists on the base, but the original timer's owner remains unknown. The lifecycle assertions are unchanged. One candidate invocation was refused before tests because concurrent lint removed a temporary config during compilation; it was excluded and replaced after the checks settled. Exploratory Node 26 runs were also excluded. No CI rerun or admin exception has been used for this timer failure.

The five inspected scheduled-main runs (37001496682, 36996061103, 36990668433, 36985285320, 36979748808) all passed the exact related=true case. These passes do not negate the local baseline reproduction or prove the intermittent failure fixed.

Integration CI follow-up

Run 37011817398 tested repair head 1ee6ec57 combined with then-current main fc17c21a: 48 successful, 11 failed, 21 skipped jobs. Ten build/type/lint jobs shared one integration error: #163485 moved OpenClawAgentDatabaseExecution out of the implementation module, leaving the maintenance import stale. TS2724 caused downstream TS18048 and redundant-type lint diagnostics; the eleventh failure was the aggregate gate. The package log also recorded a process-group cleanup error after declaration failure, with the process tree marked terminated. There was no separate failing test root; all five Windows jobs and both selected Node runtime jobs passed. The import is corrected in 07d77781, and the same declaration boundary now passes locally. Skipped jobs remain skipped evidence, not passing coverage.

Run 37014942169 on 07d77781 completed canceled: 4 successful, 2 failed, 56 canceled, 20 skipped jobs. The sole root was the wrapper closure test in job 110863828033; the second failed job was the aggregate gate, which attributed cancellation to that root. The same five missing runtime dependencies reproduce on main, introduced by #163171. The repair adds supported-session-store.ts, channel-route.ts, delivery-context.shared.ts, message-channel-constants.ts, and message-channel-core.ts to the existing wrapper inventory; no closure guard was relaxed. Two direct-main publication attempts lost races to advancing main and published no change. The reviewed five-line fix is therefore carried here. Canceled jobs remain incomplete evidence.

Run 37021270197, job 110885128657, exposed a different integration failure at c9aed89d: main independently landed the five inventory additions in ba811fafc1844, at another location in the manifest. GitHub's test merge 8fac127758ff675c36b284b045f23075da099fba therefore had duplicate entries. The duplicate assertion correctly failed; the missing-dependency guard passed. The current merge retains main's inventory exactly and the full 17-case closure suite passes. This is repaired merge interaction, not a flake or an inherited-failure waiver. The run completed with 62 successful, 1 failed, 4 canceled, and 20 skipped jobs after the repaired head was pushed. Canceled jobs remain incomplete evidence. No job rerun was used.

The separate PR-context check required the literal ## Evidence heading; that heading is restored. ClawSweeper completed exact head 1ee6ec57 at 2026-10-02T13:26:39.276Z, confirmed both close findings resolved, and reported no actionable patch or security finding. Its automated migration-proof checkbox conflicts with its technical statement that no stored-data contract changes require migration proof; schemas and persisted formats are unchanged by this PR. ClawSweeper also completed 07d77781 at 2026-10-02T13:48:53Z with no actionable correctness or security findings. That pre-conflict head received its own completed review, recorded above.

Earlier proof

Main cae2f937ce97a48308d67f5f79fbf56f7d3dd0ac was merged without conflicts in b1131d113cb2466f5facf22e97e9c4350df72ef0 to incorporate the named main fixture fix e07172ef9092. No rebase was used. Post-merge proof passed 101 tests across the patch boundary, real maintenance worker, data-version/native-cache owner, recap retry, and sharing-cache suites in 256.61 s harness wall. Core types and fresh full-candidate Codex review through P2 passed against the incorporated main parent. Earlier scoped proof remains valid for unchanged inputs.

The pre-merge head 36a59d791e0766a5dd8dd20ae0ace4497596fc1b passed all attached CI in run 37002603809. This is prior-head evidence; final-head CI remains required. ClawSweeper completed that head at 2026-10-02T11:50:34.113Z with no actionable findings and explicitly rejected its own generic migration-proof checkbox as unwarranted.

  • Latest CI-follow-up proof: 201 passed across eleven files, 623.39 s harness wall. Covers all repaired fixture owners, the previously hanging cap sequence, maintenance admission accounting, native cache identity, aliased sharing, active-owner previews, patch boundaries, and recap retries. Current core/owning test type graphs, lint, line-cap checks, and full-candidate P2 review passed.
  • Earlier maintenance-cutover selection: 135 passed across seven files, 453.98 s harness wall. Covers the patch transaction boundary, maintenance kick and real worker, read-only identity evidence, transcript search, receipt recovery, and ACP worker writes. ACP create/update/close and cold/warm/cap/removal maintenance execute zero host data SQL.
  • Maintenance/cadence/sharing suite before the mechanical transaction-entry consolidation: 102 passed, 206.43 s harness wall / 177.86 s Vitest. The worker-only sharing regression now schedules and completes maintenance without a host handle; the preceding CI timeout is its pre-fix failure evidence.
  • Gateway session groups, recap retry, and chat metadata: 125 passed, with one fixture-only resource assertion failure. The acknowledgment fixture now skips discretionary maintenance, matching the sibling model-catalog fixture while retaining its metadata and resource-leak assertions. Focused correction: 1 passed, 198.55 s wall including a compiler rebuild; test execution was about 9 s. The original three-file run took 514.39 s wall.
  • Revoked idle admission and shared-store migration selection: 6 passed, 142.48 s wall. The scheduler stays retired after admission is restored.
  • The transaction predicate concern is resolved by source and a real commit-handler regression: the scope reader reuses the active writer and nested savepoint. The test sees an uncommitted transcript leaf while an independent connection sees the prior leaf. Temporarily forcing a separate read-only connection fails for the intended unchanged-label reason; that negative-control mutation was removed. No production guard change was needed.
  • Full candidate Codex autoreview against merge-base e32e38eee649befcf0bbd0607b30e0d9eea2802b: clean through P2. Final maintenance/fixture repair review: clean through P2. Subsequent mechanical edits added required braces, removed a default type argument, and made an internal type module-local.
  • Core types, all 27 test type graphs, lint, formatting, worker/storage ratchets, export checks, and the planned import/authentication guards passed. The changed-file runner stopped at one unused type export; after making it module-local, its export check and the remaining planned guards passed directly. No schema or database-worker ratchet exception was added.

Commands use node scripts/run-vitest.mjs <files> --maxWorkers=1 with OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=1800000; wall times include compiler preparation and source verification on the loaded host. The final seven files are session-entry-patch, session-accessor.sqlite-maintenance-kick, session-accessor.sqlite-maintenance-worker, session-accessor.readonly, and session-transcript-search under src/config/sessions/, plus src/commands/doctor-session-sqlite.receipt-recovery.test.ts and src/acp/runtime/session-meta-write.worker.test.ts. Earlier real executor, native compatibility, lifecycle, and lost-reply proof remains valid for unchanged code.

CI attribution

Run 36998748120 completed at 48bc84e1d25a2489be8ec356a96630c84f197280 with six failed shards; every failure was investigated before the next push:

  • The conformance cap test exposed a production retry bug: a write during the final async deadline probe restored an already finalized pass's active key. That incorrectly protected the old row during the next cap decision. The owner repair above passes the original regression.
  • Doctor shared-store and alias-copy fixtures now join worker retirement before reopening/copying. The writer-owner test joins the actual deadline probe and accounts for its required worker admission.
  • Native cache identity/no-reparse tests explicitly exercise the retained synchronous replacement API. Worker receipts intentionally invalidate connection caches, while Gateway projection adoption consumes prepared metadata; existing worker-publication tests independently enforce those contracts. Raw foreign-write visibility assertions remain intact.
  • The aliased sharing fixture seeds its native admission before measuring worker membership mutations. The observed extra statements were canonical-index admission, not membership DML; its original no-host-row-SQL assertion passes unchanged.
  • The active unknown-owner fixture used timestamps 98/99, making its rows eligible for retention. A diagnostic reproduced the missing preview with the ops row already archived. Recent relative timestamps preserve ordering and every identity, sharing, board, and preview assertion.
  • The eight session-sharing-store-cache.test.ts failures are independently inherited. Hourly scheduled main run 36996061103, job 110803162999, at 4ee88721f043567728cb98b01abfdba4e7826c5d fails the same cases with the same INVALID_CONFIG error. The unchanged fixture retains agents.entries.ops.default:true, rejected by the Doctor-only rule introduced in 6785b4d6129c. Config validation fails before worker dispatch. The later main fix e07172ef9092 writes canonical fixture ownership and is now incorporated. The formerly failing suite passes after integration; no admin exception is currently needed.

ClawSweeper completed 48bc84e1d25a2489be8ec356a96630c84f197280 at 2026-10-02T11:08:33.529Z with no actionable findings and confirmed the maintenance repair. Its derived migration-proof checkbox contradicts the review's explicit unchanged-data-contract finding; no schema or serialized format change exists. A fresh review is requested for the next corrected head.

Run 36988825590 failed at the preceding head:

Failure Classification and correction
Worker-only automatic maintenance timeout PR-caused production regression; repaired at the maintenance owner above.
Read-only identity evidence, migration, transcript search, session groups, receipt recovery, chat metadata Fixture admission/environment or missing worker drainage. Repairs retain original behavior assertions and now pass focused/full owning proof.
Windows job 4, Matrix native-library download HTTP 500 Infrastructure failure before tests. A single job rerun is authorized after the code fix if still needed on the current candidate.
Windows job 3, source and compiled TUI provider-hook cases Independently inherited on main; evidence below.

The same two TUI cases fail on hourly scheduled main run 36990668433, job 110786133057, at 0614328f729e36addaaa02d72d114054ca6c9a27. Main commit d0b48d63efb88ac4f9f5eb447a39ea95cb2b0542 changed authentication-error prose while test/scripts/vitest-worker-artifacts.test.ts retained its old expectation. This PR changes none of the fixture, compiler harness, payload, classification, or provider-hook inputs; they remained unchanged through inspected main 41883612e4801aa4b75bb10c70232a8778303e9a. Any admin landing still requires evidence bound to the final PR head and every terminal job; prior failures and canceled jobs are not passing coverage.

Compatibility and update behavior

Opaque plugin updater callbacks and synchronous commit guards retain their native transaction and nested admission contracts. Worker selection is explicit; errors never choose a native replay. Incognito keeps its process-held connection. Doctor/schema maintenance, deletion cleanup, already-running worker contexts, and synchronous SDK entry APIs retain their existing owners. Generic conversation-turn guards remain native because their shared-state authority owner needs a separate migration.

No new configuration, public callback contract, schema, stored format, durability, retention policy, permissions, or update migration changes. Changelog generation remains release-owned. Related: #163030. Existing overlapping work in #125815 and #162316 keeps its CAS and field-writing owners.

Move audited durable metadata updaters through the existing agent executor. Retain host callbacks and authority, physical-database FIFO, full snapshot CAS, and acknowledged publication. Preserve opaque plugin callbacks, incognito storage, and maintenance scopes on their native owners; schemas and update behavior are unchanged.
@clawsweeper

clawsweeper Bot commented Oct 2, 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 docs Improvements or additions to documentation gateway Gateway runtime size: XL labels Oct 2, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 12:43 PM ET / 16:43 UTC (Revision 19).

ClawSweeper review

What this changes

Moves selected session metadata reads and commits into existing database workers while preserving ordered publication and automatic session maintenance.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main still performs these metadata commits on the caller thread. No actionable correctness or security finding remains, and the previous generic migration-proof blocker is unsupported by the unchanged stored-data contract.

Priority: P2
Reviewed head: ed61a14bd55d55b6b7212fb4d0928e6a12dead66

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker cutover with focused boundary regressions, successful reviewed-head CI, and no remaining actionable finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The host classifies the author as MEMBER, so the external-contributor setup-proof gate does not apply. Actual worker/SQLite regressions supplement source review of FIFO, revoked commit authority, lost replies, and close drainage; no unresolved authority-proof requirement was identified. The stored-data contract is unchanged, so migration proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The host classifies the author as MEMBER, so the external-contributor setup-proof gate does not apply. Actual worker/SQLite regressions supplement source review of FIFO, revoked commit authority, lost replies, and close drainage; no unresolved authority-proof requirement was identified. The stored-data contract is unchanged, so migration proof is not applicable.
Evidence reviewed 8 items Pinned introduction and current-main necessity: Reviewed the introduced delta from f02d16e to ed61a14. Current main retains the native patch transaction, so the central worker cutover is still distinct work. The supplied test merge is stale and was not used to infer removals.
Stored-data contract remains unchanged: The worker invokes the existing patch mutation owner and preserves row CAS and entry encoding. New transfer receipts, age observers, capture identifiers, and scheduling maps are runtime state; the introduced diff contains no schema or serialized-entry contract change. The previous migration-proof checkbox therefore does not apply.
Final commit authority: Host authority is checked after asynchronous preparation, at transaction validation, and at the final commit grant. Transcript predicates execute before CAS inside the transaction. The regression harness uses the actual worker executor and verifies revoked authority leaves the stored label unchanged.
Findings None None.
Security None None.

How this fits together

Session metadata stores routing, usage, and lifecycle details consumed by replies and Gateway session views. Prepared updates enter the database executor, and confirmed commits publish updated facts before maintenance and observers proceed.

flowchart TD
  A[Reply and metadata updates] --> B[Prepare patch on host]
  B --> C[Ordered database worker]
  C --> D[Check current authority and rows]
  D --> E[SQLite commit]
  E --> F[Confirm receipt and publish facts]
  F --> G[Gateway session views]
  F --> H[Automatic session maintenance]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +791, Tests +816, Docs +6. Total +1613 across 63 files.

View PR surface stats
Area Files Added Removed Net
Source 27 1041 250 +791
Tests 34 1016 200 +816
Docs 2 30 24 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 63 2087 474 +1613

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +791 lines; tests/support net +816 lines Production growth is explained by worker receipt settlement and preserving automatic maintenance after worker-only commits.

Stored data model

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

Technical review

Best possible solution:

Keep one ordered database executor serving audited metadata patches, with confirmed publication and maintenance cleanup preserving existing persistence and authority contracts.

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

Not applicable to this internal refactor; current-main source confirms the caller-thread transaction being moved, and supplied regression evidence covers the changed boundaries.

Is this the best way to solve the issue?

Yes. The patch reuses existing mutation, executor, publication, and cleanup owners while retaining native execution for opaque callbacks and incognito storage.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 6cd18ec96d30.

Labels

Label changes:

  • remove proof: sufficient: Current real behavior proof status is not_applicable, not sufficient.

Label justifications:

  • P2: This is a normal-priority internal database execution improvement with bounded session-storage scope.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The host classifies the author as MEMBER, so the external-contributor setup-proof gate does not apply. Actual worker/SQLite regressions supplement source review of FIFO, revoked commit authority, lost replies, and close drainage; no unresolved authority-proof requirement was identified. The stored-data contract is unchanged, so migration proof is not applicable.

Evidence

What I checked:

  • Pinned introduction and current-main necessity: Reviewed the introduced delta from f02d16e to ed61a14. Current main retains the native patch transaction, so the central worker cutover is still distinct work. The supplied test merge is stale and was not used to infer removals. (src/config/sessions/session-accessor.sqlite-entry.ts:506, 6cd18ec96d30)
  • Stored-data contract remains unchanged: The worker invokes the existing patch mutation owner and preserves row CAS and entry encoding. New transfer receipts, age observers, capture identifiers, and scheduling maps are runtime state; the introduced diff contains no schema or serialized-entry contract change. The previous migration-proof checkbox therefore does not apply. (src/config/sessions/session-entry-patch.worker.ts:38, ed61a14bd55d)
  • Final commit authority: Host authority is checked after asynchronous preparation, at transaction validation, and at the final commit grant. Transcript predicates execute before CAS inside the transaction. The regression harness uses the actual worker executor and verifies revoked authority leaves the stored label unchanged. (src/config/sessions/session-entry-patch.ts:139, ed61a14bd55d)
  • Prior close-drain findings resolved: Maintenance registers both requested and canonical paths under the physical database agent. Retirement revokes scheduling and awaits the complete active pass plus executor releases before unregistering custody. The dedicated deferred-gate regression covers canonical and aliased shared-store close. (src/config/sessions/session-accessor.sqlite-maintenance-kick.ts:167, ed61a14bd55d)
  • Complete captured discussion inspected: Read the complete PR body and author comments. The exact decoded body hash matches the captured cdd0acb0b274615fdce237f70416a1d641b400cba374d16390abe937a41c56fd snapshot, resolving the prompt's omitted body ranges. It records production-boundary regressions, negative controls, measured validation costs, and unchanged upgrade behavior. (ed61a14bd55d)
  • Successful CI bound to reviewed head: GitHub confirms run 37033204437 completed successfully on ed61a14, attempt 1: https://github.com/openclaw/openclaw/actions/runs/37033204437. No local tests or target-bundled reviewer were executed during this read-only review. (ed61a14bd55d)

Likely related people:

  • steipete: 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 (18 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-02T12:37:09.796Z sha b1131d1 :: blocked before merge. :: [P2] [P2] Join the complete maintenance pass during resource close | [P2] [P2] Register maintenance under the physical database owner
  • reviewed 2026-10-02T13:26:39.276Z sha 1ee6ec5 :: blocked before merge. :: none
  • reviewed 2026-10-02T13:48:53.826Z sha 07d7778 :: blocked before merge. :: none
  • reviewed 2026-10-02T14:43:27.555Z sha c9aed89 :: blocked before merge. :: none
  • reviewed 2026-10-02T14:51:47.303Z sha 17d7de0 :: blocked before merge. :: none
  • reviewed 2026-10-02T15:01:35.496Z sha 17d7de0 :: blocked before merge. :: none
  • reviewed 2026-10-02T15:32:49.299Z sha c753b98 :: blocked before merge. :: none
  • reviewed 2026-10-02T16:26:24.849Z sha ed61a14 :: blocked before merge. :: none

@clawsweeper clawsweeper Bot added 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 Oct 2, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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 Oct 2, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

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 Oct 2, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge main's maintenance actor refactor while retaining worker-only entry
maintenance, age changes and snapshots, and physical database close drainage.
Age probes use the canonical metadata actor. Keep snapshot preparation and
release custody, archive publication, and final patch transaction callbacks.

Focused boundary, maintenance, sharing, writer-owner, and retry proof covers
153 passing cases. Restore the cadence fixture's preparation/release contract.
Review through P2 is clean with the unchanged connection-lifecycle context.
The inherited environment-name budget failure reproduces on pinned main;
the name sets and budget are unchanged by this patch.
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge main and repair fixtures exposed by worker-only entry writes. Queue raw
Goal receipt mutations through the existing FIFO owner, seed fresh entries for
the late deletion race, and prepare collaboration admission before measuring
its RPC SQL. Preserve all behavioral and SQL assertions without changing
production maintenance or reopening a host handle for maintenance.

All 26 affected cases pass. The selected test type graphs and full-candidate
review through P2 are clean. The same cases passed on CI's exact main parent;
these repairs do not rely on an inherited-CI exception.
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Oct 2, 2026
@steipete
steipete merged commit d6929f8 into main Oct 2, 2026
150 of 151 checks passed
@steipete
steipete deleted the dbasync/s10 branch October 2, 2026 17:28
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

steipete added a commit that referenced this pull request Oct 2, 2026
Bisecting the main regression identifies d6929f8 (#163378). Its
worker-backed session writes schedule automatic maintenance, so these
fixtures count an outbox settlement and a separate maintenance-planning
operation behind the held writer.

Seed through the existing patch API with automatic housekeeping disabled,
while retaining the same fallback row and worker-backed write path. Keep
all 26 cases and the exact pending-writer count assertions unchanged.

Validation: authorized single-file test-only exception. Five baseline
runs reproduce both failures; the bisect parent passes. An enabled-
maintenance negative control still fails both counts, while three fixed
full-file runs pass 78/78. Local formatting, lint with boundary guards,
and the agents-tools test type graph pass. Independent P2 review passed with no actionable findings.
steipete added a commit that referenced this pull request Oct 2, 2026
…3777)

Fix red main introduced by d6929f8 (#163378): the Doctor fixture removed its state before native cleanup settled, breaking import receipt validation and subsequent shared-worker teardown.

Await the existing scoped session-state cleanup owner before restoring the environment and deleting the fixture root. Preserve every assertion.

Proof: five consecutive 15/15 runs on both Node 24 and Bun; full shared-worker commands config passes 543 files and 6,824 tests (four skipped); check-changed, independent P2 review, exact-head CI, and ClawSweeper pass.
Co-authored-by: Peter Steinberger <[email protected]>
steipete added a commit that referenced this pull request Oct 3, 2026
…r idle

worker-backed reply accounting (since #163378) can outlive run-terminal/idle events; wait for agent.wait ok before the unchanged hasActiveRun assertion.
steipete added a commit that referenced this pull request Oct 3, 2026
…163852)

* fix(agent): run requested tools before applying mid-turn steering

Treat an assistant message's tool calls as a committed plan until one starts.
Sequential tails still skip for steering; parallel batches never skip.
Poll steering after every batch before stop hooks.

* test(gateway): wait for run settlement before asserting canceled steer idle

worker-backed reply accounting (since #163378) can outlive run-terminal/idle events; wait for agent.wait ok before the unchanged hasActiveRun assertion.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…claw#163378)

* refactor(sessions): commit prepared entry patches in workers

Move audited durable metadata updaters through the existing agent executor. Retain host callbacks and authority, physical-database FIFO, full snapshot CAS, and acknowledged publication. Preserve opaque plugin callbacks, incognito storage, and maintenance scopes on their native owners; schemas and update behavior are unchanged.

* test(sessions): verify patch transaction visibility and drain workers

* test(sessions): complete worker-backed fixture cleanup

* test(sessions): settle workers before retiring database fixtures

* fix(sessions): keep maintenance running after worker entry commits

* test(sessions): respect worker admission and fixture lifetime

* fix(sessions): retire protection after maintenance finalization

* test(sessions): align fixtures with worker-owned commits
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
Bisecting the main regression identifies 9d1cf78 (openclaw#163378). Its
worker-backed session writes schedule automatic maintenance, so these
fixtures count an outbox settlement and a separate maintenance-planning
operation behind the held writer.

Seed through the existing patch API with automatic housekeeping disabled,
while retaining the same fallback row and worker-backed write path. Keep
all 26 cases and the exact pending-writer count assertions unchanged.

Validation: authorized single-file test-only exception. Five baseline
runs reproduce both failures; the bisect parent passes. An enabled-
maintenance negative control still fails both counts, while three fixed
full-file runs pass 78/78. Local formatting, lint with boundary guards,
and the agents-tools test type graph pass. Independent P2 review passed with no actionable findings.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…nclaw#163777)

Fix red main introduced by 9d1cf78 (openclaw#163378): the Doctor fixture removed its state before native cleanup settled, breaking import receipt validation and subsequent shared-worker teardown.

Await the existing scoped session-state cleanup owner before restoring the environment and deleting the fixture root. Preserve every assertion.

Proof: five consecutive 15/15 runs on both Node 24 and Bun; full shared-worker commands config passes 543 files and 6,824 tests (four skipped); check-changed, independent P2 review, exact-head CI, and ClawSweeper pass.
Co-authored-by: Peter Steinberger <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…penclaw#163852)

* fix(agent): run requested tools before applying mid-turn steering

Treat an assistant message's tool calls as a committed plan until one starts.
Sequential tails still skip for steering; parallel batches never skip.
Poll steering after every batch before stop hooks.

* test(gateway): wait for run settlement before asserting canceled steer idle

worker-backed reply accounting (since openclaw#163378) can outlive run-terminal/idle events; wait for agent.wait ok before the unchanged hasActiveRun assertion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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