Skip to content

perf(state): admit agent databases once off the main thread - #165680

Merged
steipete merged 22 commits into
mainfrom
dbasync/coldadmit
Oct 6, 2026
Merged

steipete merged 22 commits into
mainfrom
dbasync/coldadmit

Conversation

@steipete

@steipete steipete commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

The first runtime opener of an agent database performs hundreds of schema and index inspections on the Gateway thread; moving individual callers only transfers that cold-admission cost to the next opener. Integration testing also exposed background observer persistence borrowing a foreground writer context and blocking turn cleanup; this change gives that work its own async context while preserving observer cancellation and shutdown ownership.

User Impact

Cold writable schema, index, and integrity scans move to the existing agent worker. Drift, damage, owner mismatch, stale leases, late revocation, and replacement still refuse admission. Migration ownership, native generation claims, FIFO ordering, crash recovery, and accepted-work settlement stay with their existing owners. No new worker service, schema, persistent cache, retention/durability policy, or environment names are introduced.

Released synchronous open/borrow and arbitrary synchronous guard contracts keep native admission when invoked without prepared facts. Bundled runtime callers use the new admission entry point. Startup migration, Doctor/maintenance, deletion cleanup, and process-held incognito retain their existing owners. There are no Gateway-context service signature changes or operator migration steps.

Landing status: published head 429eb5f7fc1dd6824d07cdbffaf7180388188bbf integrates main through ac304b9f9944 and the existing inventory deduplication repair. It has clean P2 review, a successful real CI manifest replay, all five passing type lanes, zero Madge cycles, a fresh SDK report with no direct or entrypoint changes, and 422 focused passing cases with one existing platform skip. Publication preflight merges it cleanly with main e48b6092788e and preserves exactly one admission-test entry. Exact-head CI is green (120 successful jobs, 22 skipped), and trusted ClawSweeper review completed with no actionable correctness or security findings. Merged through the native workflow as b8b094b57a113f676ce8f76e77a93e5638d2701a on October 6, 2026. No admin CI bypass was used. Frozen attribution is complete: all five pre-fix head runs fail the same suppression case; all five baseline runs pass. One undelivered baseline result was lost during the host restart and only that missing run was replaced.

Why This Change Was Made

Runtime acquisitions enter the existing agent executor and publish admitted schema facts through its validation receipt. Native handles adopt that proof against physical identity and committed schema markers. Revoked facts, host-handle eviction, and retained-worker readmission return to that same owner; stale facts cannot trigger a fallback schema scan on the Gateway thread. Schema mutations revoke the physical receipt, including mutations through older live aliases. Readmission validates and republishes facts before returning a new or retained handle.

The cloud transcript owner binds and restores the original turn object’s transcript target while retaining its admitted handle through execution and finalization. Creation claims keep host authority and cleanup while passing a typed witness to the worker. Corrective integration work also preserves remote-execution attachment handoff, prevents false creation registrations during retained-worker readmission, and accepts freshly validated admission beside another live Gateway without weakening live receipt or lease checks.

Runtime cutover, compatibility, and retained debt

The path is withOpenClawAgentDatabaseRuntime → withWorkerAdmission → existing executor preparation → openclaw-agent-execution.worker.ts → native schema admission → validation publication → host adoption. Callers include auth usage, SessionManager/outbox, session storage/sharing/transcript writes, board/progress/heartbeat/trajectory stores, Gateway agent and Talk preparation, cloud execution, generic write admission, and bundled memory storage. Main's newer auth SQLite worker owner supersedes the earlier adapter; that file now matches main.

Released signatures were checked against stable v2026.9.8 and latest v2026.10.1-beta.1, including sqlite-runtime, channel-inbound, session-store-runtime, agent-sessions, indirect transcript commit guards, and api.runtime reachability. Synchronous open/borrow and opaque guard signatures are unchanged. Removed cleanup helpers are internal. The board owner retains native admission for opaque or cross-store guards and incognito; prepared durable authority uses runtime admission. No deprecation compatibility record is needed for an unchanged shipped contract.

The committed SDK comparison (ac304b9f9944 → 429eb5f7fc1dd) reports zero entrypoint additions/removals, zero direct declaration changes, and 131 reachable-only changes from admission metadata and owner type moves; acknowledgement digest 1d1a48d0. The memory fault helper uses the existing private testing facade, excluded from ordinary builds and npm exports.

Pre-existing short indexed authority reads of other owners remain follow-up debt: shared-state lease validation at src/state/openclaw-agent-db.ts:351 → src/state/openclaw-agent-db-lease.ts:444, and cloud liveness in src/gateway/worker-environments/worker-turn-launcher.ts:427,432 and worker-turn-execution.ts:107,123, through placement-store.ts:130–131 and placement-turn-claims.ts:421–423. The zero-SQL assertions cover moved agent-schema operations; they do not assert zero host SQL for those live-authority checks.

Main integrations preserve sharing custody (#165600), memory admission (#165611), session authority (#165028), board preflight/publication (#165799), incognito source capture (#165628), and shutdown settlement (#165785). The lane reuses landed lifecycle/header (#165401), create-target (#165360), trajectory preparation (#165410), and channel-envelope (#165436) owners. Test cleanup overlap (#165743) preserves main's reduced case table and cold-admission refusal assertions; incidental #162433 overlap does not adopt its restructuring. The latest integration also retains transaction-local source predicates and foreground patch planning (#165819), bulk registry/maintenance ownership (#165684), and compiled cloud-worker import closure (#165669). All integrations use merge commits, never rebases.

Evidence

The current main integration passes all five selected typecheck lanes and Madge with zero cycles (11.74s). Focused admission, readmission, maintenance, cloud execution, routing, and import proof passes 436 tests with one existing platform skip across 17 files, using --maxWorkers=1 (443.62s wall). Merge-file lint exposed a namespace shadow and the launcher exceeding its existing line cap; the fix aliases the namespace and moves temporary target binding/restoration into the existing transcript owner. That final cleanup passes core types, focused lint, 74 cloud caller/owner cases across four files (222.66s), and fresh full-candidate P2 review with no actionable findings. API signatures and import edges are unchanged. The preceding 3b8fd22 integration also passed full changed checks, including lint, dead-export scans, formatting, and guards; those are reused only for unchanged inputs. These local results are distinct from published-head CI.

Performance and update proof

The pre-integration isolated Linux comparison pins 2a6621fa → approved 9d84354e on Node 24.21.0 with identical measurement harnesses. Both sides pass all 13 turns, child, compaction, and shutdown assertions, with no native errors or surviving fixture children.

Gateway-thread statements Before After
First turn 673 289
Second session 531 534
First-turn agent-schema cohort 379 0
First-turn canonical-index subset 352 0
First-turn writable-open stack 440 56
First-turn sharing-store admission stack 440 0

Cohorts overlap. The first turn removes 384 statements (57.1%); the entire non-boot workload's agent-schema cohort falls 379 → 0. The second-session increase is three existing read-only/entry/participant reads, with schema/index work still zero. Retained-worker readmission records 59 statements and zero schema-owner/index/catalog/table/integrity scans; three scalar adoption probes remain. Full-workload wall time is 65.23s before versus 66.67s after, so this proves caller-thread SQL removal, not end-to-end latency improvement.

Published-driver update proof (2026.9.8 → verified candidate tarball) passes in 436.15s: readiness 200 before/after, durable transcript retained, incognito transcript absent after restart, and all 20 command receipts successful. Mandatory packaging validation passes (79.15s). Tarball SHA-256 bd68d89777e39e01815ad0e9ad7931277bdfa012e8d7bab654f2fe550d6cf326. Its manifest/patch bind the artifact to 9d84354e; the installed build ID and changed service PID prove replacement despite an unchanged package version. Later main integrations retain that evidence as historical, not as a new-head update run.

CI repairs and attribution

Original integrated-head CI exposed the three production regressions described above plus stale worker-fault/admission fixtures. The corrected 31 non-E2E files pass 645 cases locally; isolated Linux proof passes the two E2E files' 19 cases. Fault fixtures now inject worker-local TEMP triggers at the intended statement without invalidating persistent schema, preserving native error, rollback, retry, and publication assertions. Host-owner test routing, shared-worker shutdown, and timer-installation synchronization were corrected without weaker assertions or longer budgets.

The immutable attribution campaign is complete: 33 files × five runs × two revisions = 330 valid file-runs. Baseline a33accd27f3d passes all 165; original failed head 4147114af298 fails 164 and passes one. Setup/interruption attempts are excluded and replaced; all 346 downloaded artifacts have verified hashes. This confirms the original failures were PR-reachable and were not admin-qualified as inherited. The original head will not be merged.

Shared-import proof includes the runtime-process build graph and eager/state-worker/get-reply/history/reconcile/launcher/runtime closures. Earlier broad Linux proof collected 74 requested files (1,054 passes, 393 explicitly filtered/existing skips) and a final 17-file follow-up (126 passes, no skips), with successful full builds. Meaningful slow contracts use actual workers, process shutdown, CLI logout, or Gateway delivery; helper-only tests cannot establish those boundaries. Current integration timing is recorded above; published CI provides per-job costs.

Published-head CI at 1f66105a5c9a2 completes with 115 successful jobs, 22 skipped, two E2E failures, and their aggregate failure. Its tested merge be7df4a97dc88bc4a9fd70f61ea8e4599926c857 has ordered parents main a2e8b347d79415984e6ce621fbe7eabfa1286cb9 and the PR head; reconstruction yields the identical tree. The corrected admission suite passes. Security/dependency contexts succeed. ClawSweeper completed exact-head review at 2026-10-06T00:47:05Z with no actionable correctness/security findings. The newly published 7f465246636a2 requires fresh CI and completed trusted review; those older results are historical evidence only.

The Slack suppression failure reproduces on the exact earlier CI merge and its main parent: five complete file runs per side each fail only that case (15 sibling passes), plus one targeted run per side. Each side includes one debugger-observed full run and four ordinary full runs. All twelve attempts reach terminal task state with delivery pending and the visible marker; eleven show trajectory-flush timeout, while baseline full run 2 does not. Baseline instrumentation proves observer preamble background digest persistence outlives its ordered-reader FIFO slot; trajectory then takes a fresh outer slot and queues its nested worker write behind itself. Both revisions reach the database-admission callback within 1ms, but the enclosing helper never settles. The head capture does not identify the earlier reservation setter. Causal owner files are unchanged; changed admission adapters and intervening baseline reader changes remain explicitly disclosed. This is independent historical baseline evidence, not a claim that the changed path is unreachable or that CI passed. Main #165819 now changes the exact worker-patch reservation/planning inputs, so this old attribution is not being carried over to the new candidate. The fresh ordinary run on fdb8d72 reproduces the same suppression failure (one failed, 15 passed), with the full diagnostic again naming trajectory flush and seven pending rows. New five-run comparisons are pinned to fdb8d72 and current baseline 30b5c8e4; they remain distinct from the repair below. All five complete baseline runs pass all 16 cases, with no cleanup timeout. All five pre-fix head runs fail the suppression case with 15 sibling passes and repeat the trajectory-flush timeout with seven pending rows. All ten runs are ordinary full-file runs on Node 24.19.0 with --maxWorkers=1; artifacts and source identity are hash-verified. Machine/provider differences are retained as a limitation, so these timings are not used for a performance comparison. This failure is not qualified as inherited. No native admin qualification has been completed.

The cron registry comparison on exact merge be7df4a9 versus parent a2e8b347, Node 24.19.0, passes three of five head runs and all five baseline runs. Retained Gateway logs distinguish two failures: startup catch-up defers the scheduled test job by 120,000ms, and a separate chat lifecycle operation rejects with Worker placement inventory changed. The synthetic scheduler now waits for the documented cron_reconciled event; its separate P2 review, root-test types, and formatting pass. Assertions and 30s RPC/45s observation/180s test budgets are unchanged. On 3b8fd22 plus the readiness fix, five full-file runs pass all three cases each: 918.87s including cold build, then 73.48s, 78.76s, 68.66s, and 72.85s. One run was debugger-observed; it resolved all 14 logpoints but captured no refusal. The final run had no observer. Artifact collection failed after product testing because its broad glob included the Vitest cache; wrapper exit 7 is not represented as a successful aggregate gate. All five result rows and source hashes remain, with full Gateway logs available only for runs 1–2. Missing logs are explicitly unavailable. The subsequent ordinary fdb8d72 cron run passes all three cases in 67.64s, with no inventory-refusal or cleanup-timeout warning in its complete rolling log. All 59 declared artifacts from that combined QA/cron campaign were downloaded, hash-verified, and acknowledged before teardown; native artifact collection also succeeded. The ordinary repaired-candidate run described below also passes all three cron cases. Cron is not qualified as inherited, and the readiness change is not claimed to fix the placement rejection.

The pre-fix observer producer starts independent background persistence under the publishing reader’s writer context. Commit 7f465246636a2 enters the existing detached async root before entering the observer’s own work scope, so digest writes queue normally while preserving explicit source/run guards and shutdown settlement. A regression through the real observer and real foreground/worker admission fails before the fix because the digest callback enters before its publisher releases the permit. It passes after the fix and also joins a successor nested write and observer disposal. The new case takes 20ms; the complete four-case file takes 24.39s including imports. All 120 observer/import cases across 15 files pass in 47.63s, with core/core-test types, scoped lint, zero-cycle Madge, docs links, and P2 review passing. No timers, retries, weaker assertions, new production test seam, or admission-guard changes were added. The ordinary repaired-candidate Gateway campaign, pinned to 7f465246636a2 on Node 24.19.0 with --maxWorkers=1, passes 16/16 channel-progress cases and 3/3 cron cases, with native aggregate exit 0. Channel proof takes 939.58s including cold build; cron takes 72.72s. Suppressed Slack delivery settles with explicit delivery_suppressed / cancelled_by_message_sending_hook, and the restart turn delivers. All 14 configured QA Gateway logs and the cron rolling log have no relevant cleanup-timeout, teardown-budget, or placement-inventory warning. Declared artifacts were downloaded and hash-verified before acknowledgement and teardown; the native archive was independently verified, and the lease is released. This campaign uses no debugger, source instrumentation, signals, or test-budget changes.

One local startup-admission proof initially returned an unexpected mixed unavailable/newer-schema assertion result (12 passes). A targeted diagnostic and ten complete head/baseline host-routed comparisons subsequently pass, but no cause or production fix is claimed. This observation remains in the exact-head review's investigated-local-failure record.

The local production audit reproduced the HIGH source-map-js advisory (GHSA-68fv-2mgg-jv7q, versions below 1.2.2). Merge 0de2f708ac271 incorporates main's fix #165902 without a separately authored dependency change. The same production audit now passes its high-severity threshold; this is not a claim of comprehensive vulnerability clearance. No audit exception or gate weakening is used.

The final main integration also includes the QA auth-save host routing fix. All five post-integration type lanes pass (340.18s combined); Madge reports zero cycles (12.32s), and full-candidate P2 review is clean. The refreshed SDK report retains all direct signatures; its 131 affected exports are reachable-only changes (the previous baseline reported 129). Its only conflicts were adjacent additions in the two host-owned test inventories; both sides are preserved. The local 13-file focused invocation stopped before running any test because native artifact admission could not verify separation from two managed Gateways. No artifact or service was changed. The isolated invocation on committed 0de2f708ac271, Node 24.19.0, passes 282 cases across all 13 files and eight native shards, with --maxWorkers=1 (314.64s runner wall, 315.16s outer cell). There are no skipped cases, product failures, or cleanup warnings. Source and artifacts were hash-verified before acknowledgement; the secondary native archive matches. A queued Testbox allocation and an initial capsule-path setup refusal ran no tests and are excluded from product results. The corrected task helper reused the same owned AWS machine; product source was unchanged.

The subsequent conflict integration preserves main 2983dfcfb319 through merge 78515ed21eb4e. The only conflict was the extension host-owned test list: main's LiteLLM auth case and the cold-admission channel cases are all retained. Main's session authority B1 (#165370), birthtime checks, incognito steering facts, and session-row invalidation (#165932) remain intact. No authored production code changed in this integration. Full-candidate P2 review is clean. All five type lanes pass (344.04s combined), Madge reports zero cycles (17.42s), and the refreshed SDK report retains zero direct or entrypoint changes with 131 reachable-only changes (digest facb4789); the focused source-level invocation passes 346 cases across 17 files with one existing native-WAL platform skip (253.51s wall, nine native shards, --maxWorkers=1). The standard prerequisite planner selected no runtime rebuild; the unchanged private-QA delivery-cache suite retains its separate passing 0de2f708 proof.

Preflight inventory repair

The PR's earlier host-routing fix and main's independent host-routing fix added the same admission suite at different positions. Main's subsequent deduplication removes the upper entry; this integration retains the lower one, so the test remains in its host-owned project exactly once. No planner guard, scheduling budget, test assertion, or production behavior is changed to clear the preflight. The real manifest replay on 78515ed21eb4 fails with the exact CI duplicate/stripe error in 221.39s. On the merged tree, the existing host-routing and exactly-once infrastructure scheduling cases pass (two cases, 112 intentionally filtered cases, --maxWorkers=1, 88.00s wall). The corrected full manifest replay exits zero in 236.20s, emits 86 Node rows, and its decoded output schedules the admission test exactly once in the infrastructure config; an initial local replay omitted its required output sink after the plan was generated, which is retained as an inspection-fixture failure rather than product proof.

The final recovery integration at 429eb5f7fc1dd retains that repair and current main's session-reader and worker-inference owners. All five selected type lanes pass (1,247.96s combined), Madge reports zero cycles (98.72s), and full-candidate P2 review has no actionable findings. The focused run passes 422 cases across 20 files and ten native shards, with one existing platform-dependent native-WAL skip, using --maxWorkers=1 (2,296.14s wall). It covers cold/readmission, integrity and authority refusal, observer settlement, exact session reads, cloud launcher/execution, shared-state reads, host routing, build-graph and import-closure contracts. The new SDK comparison reports zero entrypoint additions/removals, zero direct declaration changes, and 131 reachable-only changes; digest 1d1a48d0. Source remained unchanged throughout these checks. No assertion, timeout, scheduling budget, or guard was weakened.

Keep the real worker backends and persisted-row assertions in memory failure fixtures. Remove the unused plugin policy wrapper left by main and retain its policy tests against the shared owner.
Bind executor release to its owner and complete inherited lint cleanup while preserving authorization cases and schema boundaries.
@clawsweeper

clawsweeper Bot commented Oct 5, 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.

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 429eb5f7fc1dd6824d07cdbffaf7180388188bbf
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/inline-usage.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime extensions: memory-core Extension: memory-core agents Agent runtime and tooling plugin: file-transfer size: XL labels Oct 5, 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 5, 2026
@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 6, 2026, 3:50 AM ET / 07:50 UTC (Revision 14).

ClawSweeper review

What this changes

Moves cold agent-database validation into existing workers, reuses revocable schema facts, and gives background observer persistence its own write admission.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/infra/sqlite-schema-facts.ts, src/state/openclaw-agent-db-schema-helpers.ts, src/state/openclaw-agent-db-schema.ts. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR remains useful: current main lacks the worker-owned cold-admission path. No actionable introduced defect was found, the inventory finding is resolved, and the earlier generic compatibility warning is unsupported by the inspected change.

Priority: P2
Reviewed head: 429eb5f7fc1dd6824d07cdbffaf7180388188bbf

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent worker cutover with strong source-bound runtime evidence, preserved compatibility, and no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (logs): The source-bound Linux Gateway workload exercises worker admission through real turns, compaction, and shutdown, recording zero caller-thread agent-schema scans after the change. Recorded repaired Gateway runs also show observer persistence settling. Historical published-driver proof preserves durable state and restart behavior; current-head CI and focused cases supplement it. No stored-data contract changes were identified.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (logs): The source-bound Linux Gateway workload exercises worker admission through real turns, compaction, and shutdown, recording zero caller-thread agent-schema scans after the change. Recorded repaired Gateway runs also show observer persistence settling. Historical published-driver proof preserves durable state and restart behavior; current-head CI and focused cases supplement it. No stored-data contract changes were identified.
Evidence reviewed 10 items Pinned introduction and current-main necessity: Reviewed the introduced delta from ac304b9 to 429eb5f. Fetched main still provides the native asynchronous admission driver without withWorkerAdmission or the runtime admission companion; related merged performance work does not replace this central change.
Compatibility warning disposition: The released asynchronous helper retains its parameters and explicitly selects native admission; bundled runtime callers select worker preparation. The inspected delta adds no config option, operator setting, schema version, or serialized format. The new facade export is on the documented private-local sqlite-runtime surface. Consequently the previous generic config/default confirmation request does not establish a remaining blocker.
Private runtime boundary: The subpath documentation identifies sqlite-runtime as private-local; sqlite-runtime-testing remains repo-local. The PR body records stable and beta signature checks and a pinned SDK comparison with zero direct declaration or entrypoint changes.
Findings None None.
Security None None.

How this fits together

Agent databases store session transcripts and other agent state used by Gateway turns and plugins. Admission validates their physical identity, schema, integrity, and current authority before runtime callers receive a usable connection.

flowchart TD
  A[Gateway and plugin requests] --> B[Database admission owner]
  B --> C[Existing agent worker]
  C --> D[Identity and schema validation]
  D --> E[Revocable admitted facts]
  E --> F[Native connection adoption]
  F --> G[Authorized runtime operations]
  E --> B
Loading

Before merge

  • Review config compatibility - Confirm compatibility and upgrade impact for the changed config or default surface before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

PR surface statistics unavailable: the file list is incomplete.

Review metrics

Metric Value Why it matters
Production versus test growth production net +765; tests/support net +1141 Production growth implements admission transfer and revocation; test growth covers the worker cutover, refusal, and settlement contracts.
Measured cold schema work 379 → 0 Gateway-thread agent-schema statements The pinned historical workload demonstrates SQL relocation, while its wall times do not establish an end-to-end latency improvement.

Stored data model

Persistent data-model change detected: database schema: src/infra/sqlite-schema-facts.ts, database schema: src/state/openclaw-agent-canonical-validation-schema.ts, database schema: src/state/openclaw-agent-db-schema-helpers.ts, database schema: src/state/openclaw-agent-db-schema-read.ts, migration/backfill/repair: src/state/openclaw-agent-db-schema-helpers.ts, migration/backfill/repair: src/state/openclaw-agent-db-schema-read.ts, and 5 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: canonical
Canonical: #165680
Summary: This PR owns cold agent-database admission; the linked merged lanes and executor-retention follow-up address distinct portions of database runtime cost.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Use the existing executor for cold admission while preserving native SDK guards, revocable physical-schema facts, and complete accepted-work settlement.

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

Not applicable as a new bug reproduction: this is a performance and lifecycle refactor with source-bound before/after Gateway measurements and regression evidence; no runtime was executed in this review.

Is this the best way to solve the issue?

Yes. The change extends the existing admission and executor owners, preserves synchronous compatibility, and avoids introducing another worker service or persistent cache.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves cold database admission and observer settlement without evidence of a current emergency or release-blocking failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (logs): The source-bound Linux Gateway workload exercises worker admission through real turns, compaction, and shutdown, recording zero caller-thread agent-schema scans after the change. Recorded repaired Gateway runs also show observer persistence settling. Historical published-driver proof preserves durable state and restart behavior; current-head CI and focused cases supplement it. No stored-data contract changes were identified.
  • proof: sufficient: Contributor real behavior proof is sufficient. The source-bound Linux Gateway workload exercises worker admission through real turns, compaction, and shutdown, recording zero caller-thread agent-schema scans after the change. Recorded repaired Gateway runs also show observer persistence settling. Historical published-driver proof preserves durable state and restart behavior; current-head CI and focused cases supplement it. No stored-data contract changes were identified.

Evidence

What I checked:

  • Pinned introduction and current-main necessity: Reviewed the introduced delta from ac304b9 to 429eb5f. Fetched main still provides the native asynchronous admission driver without withWorkerAdmission or the runtime admission companion; related merged performance work does not replace this central change. (src/state/openclaw-agent-db-admission.ts:240, ca43d1919788)
  • Compatibility warning disposition: The released asynchronous helper retains its parameters and explicitly selects native admission; bundled runtime callers select worker preparation. The inspected delta adds no config option, operator setting, schema version, or serialized format. The new facade export is on the documented private-local sqlite-runtime surface. Consequently the previous generic config/default confirmation request does not establish a remaining blocker. (src/state/openclaw-agent-db-admission.ts:226, 429eb5f7fc1d)
  • Private runtime boundary: The subpath documentation identifies sqlite-runtime as private-local; sqlite-runtime-testing remains repo-local. The PR body records stable and beta signature checks and a pinned SDK comparison with zero direct declaration or entrypoint changes. Public docs: docs/plugins/sdk-subpaths.md. (docs/plugins/sdk-subpaths.md:447, 429eb5f7fc1d)
  • Authority and revocation: Creation witnesses carry agent/state identity while the captured host scope supplies live authority. Worker admission checks that scope, caller cancellation, physical identity, and the executor binding before granting preparation. Schema adoption checks shared revocation and committed schema markers; publication rejects revocation during verification. Inspected regressions cover outside-scope access, aliases, replacement, owner mismatch, and late revocation before operation consumption. (src/state/agent-creation-claim.ts:157, 429eb5f7fc1d)
  • Real runtime and upgrade evidence: Read the complete 22,050-unit PR body and verified it matches captured SHA-256 428466582843dceb79147e06e315ac3718ba6d23bd8ab71b6b9b4f0fe872b128. Its isolated Linux workload pins 2a6621f to 9d84354, completes 13 turns plus child, compaction, and shutdown flows, and records agent-schema MAIN statements falling from 379 to zero. The published 2026.9.8 driver update preserves durable transcripts, discards incognito transcripts on restart, and completes 20 command receipts. These are historical source-bound runtime results, not a newly executed final-head update. (9d84354e1dbd)
  • Observer settlement evidence: The changed producer enters the existing detached async context before its observer work scope. The complete body records a failing-before/passing-after admission regression and a repaired Gateway campaign with 16 channel-progress and three cron cases passing, including explicit suppressed-delivery settlement and subsequent restart delivery. The linked hosting workflow reports cancelled, so its workflow conclusion is not counted as a successful CI gate; the recorded native command result is separate evidence. (src/gateway/session-observer-work.ts:45, 7f465246636a)

Likely related people:

  • Peter Steinberger: Raw commit c55f16f adds src/gateway/session-observer-work.ts:46 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c55f16f14211; files: src/gateway/session-observer-work.ts)
  • goutamadwant: 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 (13 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-05T23:38:29.785Z sha 1e4bb97 :: blocked before merge. :: none
  • reviewed 2026-10-06T00:47:05.452Z sha 1f66105 :: blocked before merge. :: none
  • reviewed 2026-10-06T01:01:12.864Z sha 1f66105 :: blocked before merge. :: none
  • reviewed 2026-10-06T04:26:00.483Z sha 7f46524 :: blocked before merge. :: none
  • reviewed 2026-10-06T05:08:45.101Z sha 0de2f70 :: blocked before merge. :: none
  • reviewed 2026-10-06T05:20:16.524Z sha 78515ed :: blocked before merge. :: none
  • reviewed 2026-10-06T06:36:58.305Z sha 78515ed :: blocked before merge. :: [P2] [P2] Keep the admission suite in the host inventory only once
  • reviewed 2026-10-06T07:27:01.269Z sha 429eb5f :: blocked before merge. :: none

@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Integrate a33accd, preserving sharing custody, memory admission, and session authority. Retain both worker test routing sets and the clearer metadata activation test description.
@openclaw-barnacle openclaw-barnacle Bot closed this Oct 5, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 5, 2026
@steipete

steipete commented Oct 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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 5, 2026
steipete added a commit that referenced this pull request Oct 7, 2026
* perf(sqlite): reuse admitted catalog facts across schema owners

Carry index names and trigger definitions in the existing admitted catalog snapshot. Reuse those facts for canonical session validation and first-use schema installation, removing separate committed-schema caches while preserving foreign changes, rollback, reopen, and dynamic authorizer checks.

* perf(sqlite): retain admitted facts across managed transactions

Keep schema facts collected under synchronous read admission after data-only transaction settlement. Unmanaged snapshots and sibling schema publications observed in a transaction still expire, and the next operation still checks foreign commits. Cover warm worker commands after lazy schema installation.

* fix(sqlite): attach schema query rationale to guarded call

* fix(sqlite): break the agent schema admission loop

Reuse settled native preparation and unchanged admitted schema facts. Keep explicit host readmission, startup journal checks, and schema receipt revocation for observed foreign DDL. Skip covered standing-intent DDL instead of repeating post-commit structural scans.

Addresses repeated schema preparation attributed to #165680; builds on the schema-fact owner in #166102. Schemas, stored bytes, and update behavior are unchanged.

* fix(sqlite): avoid shadowing preparation options

* test(sdk): preserve released agent preparation call forms

* test(sessions): preserve canonical leases after reconcile shutdown
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…#165680)

* perf(state): admit agent databases once off the main thread

* test(state): exercise native faults without schema drift

Keep the real worker backends and persisted-row assertions in memory failure fixtures. Remove the unused plugin policy wrapper left by main and retain its policy tests against the shared owner.

* test(state): verify admission through the shared SQL observer

Bind executor release to its owner and complete inherited lint cleanup while preserving authorization cases and schema boundaries.

* fix(state): preserve cold admission behavior across worker cutover

Retain the caller turn object for remote attachment prompts, avoid restarting
agent creation registration during native readmission, and allow freshly
worker-validated admission beside another live Gateway lease.

Move existing fault and admission fixtures onto real worker boundaries while
preserving rollback, ordering, revocation, publication, and shutdown assertions.
Corrective proof passes 645 cases across all 31 non-E2E files from the failed CI
run; isolated CLI/Gateway E2E proof remains in progress before landing.

* test(memory): use the SQLite testing facade for worker faults

Route the shared worker fault fixture through the existing repo-local testing
facade instead of importing across the plugin package boundary. The facade
remains excluded from production builds and npm exports.

The extension boundary guard and all 34 memory index tests pass. P2 review
found no actionable findings; merged-tree gates remain in progress.

* test(state): normalize only string SQLite worker filenames

Preserve URL objects and pass only string filenames through pathToFileURL.
This matches the Worker contract across Node and DOM type contexts without
casts. All merged-tree type lanes pass, and P2 review is clean.

* test(gateway): split process-exit settlement coverage

* test(state): run startup admission under its host owner

* test(cron): wait for scheduler readiness before registry churn

Wait for the plugin cron_reconciled hook before scheduling the fixture's jobs. Scheduling before detached startup completed let catch-up defer the owner job by 120 seconds, beyond the unchanged observation budget.

Five full-file Linux runs pass all three cases each on Node 24.19.0. One run was debugger-observed; the final run was ordinary. Root-test types, focused lint, formatting, and P2 review pass. The separate historical placement-inventory refusal did not reproduce and is not claimed fixed. Final artifact retrieval failed after product testing; retained result rows bind every run to the verified source manifest.

* fix(gateway): prevent observer persistence from blocking turn cleanup

Start independent observer background work outside the publisher's async context, then enter the observer's existing work scope. Digest writes acquire their own FIFO admission while retaining explicit source/run authority and shutdown settlement.

A real observer/write-admission regression fails before the fix because its background worker enters before the publisher releases the permit. It passes after the repair, including a successor nested write and disposal. All 120 observer/import tests pass; core and core-test types, scoped lint, zero-cycle Madge, docs links, and P2 review pass. Full ordinary Gateway validation remains a publication prerequisite.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 7, 2026
…#166253)

* perf(sqlite): reuse admitted catalog facts across schema owners

Carry index names and trigger definitions in the existing admitted catalog snapshot. Reuse those facts for canonical session validation and first-use schema installation, removing separate committed-schema caches while preserving foreign changes, rollback, reopen, and dynamic authorizer checks.

* perf(sqlite): retain admitted facts across managed transactions

Keep schema facts collected under synchronous read admission after data-only transaction settlement. Unmanaged snapshots and sibling schema publications observed in a transaction still expire, and the next operation still checks foreign commits. Cover warm worker commands after lazy schema installation.

* fix(sqlite): attach schema query rationale to guarded call

* fix(sqlite): break the agent schema admission loop

Reuse settled native preparation and unchanged admitted schema facts. Keep explicit host readmission, startup journal checks, and schema receipt revocation for observed foreign DDL. Skip covered standing-intent DDL instead of repeating post-commit structural scans.

Addresses repeated schema preparation attributed to openclaw#165680; builds on the schema-fact owner in openclaw#166102. Schemas, stored bytes, and update behavior are unchanged.

* fix(sqlite): avoid shadowing preparation options

* test(sdk): preserve released agent preparation call forms

* test(sessions): preserve canonical leases after reconcile shutdown
steipete added a commit that referenced this pull request Oct 12, 2026
Repeated publication of an unchanged admitted schema invalidated the proof already held by workers. A worker returning an earlier receipt could therefore fail admission even though the database had not changed. The unconditional revocation was introduced in #165680.

Reuse the live schema validity cell when the same owner republishes its admitted facts. Real DDL still revokes that cell, and fresh admission then creates its replacement. Physical replacement, corruption, identity, and schema-admission guards remain intact. A receipt captured before an unchanged republication intentionally stays valid; no extra check or handshake is added.

The existing symlink/receipt regression now covers delayed publication, and the DDL cases verify that actual mutations still revoke the shared proof after republication. The obsolete test requiring healthy republication to revoke proof is removed. This changes two files (+13/−27), with no stored-schema, migration, durability, public API, or update behavior change. It adds no SQL or worker request path.

Validation:

- `pnpm test src/state/openclaw-agent-db-validation-cache.test.ts --maxWorkers=1`: 53/53 passed; 204.95 seconds in Vitest, 471.16 seconds including the wrapper.
- Production-only reversal with candidate tests retained: 1 expected failure and 52 passes; 149.32 seconds in Vitest, 307.14 seconds including the wrapper. The receipt regression fails at the shared validity cell identity assertion before delayed publication. The checkout was restored cleanly with no surviving test processes.
- Codex review: scoped-clean, no actionable findings; original review retained.
- [Composed-head CI](https://github.com/openclaw/openclaw/actions/runs/38298120555) passed production types, state test types, lint, source contracts, Knip, Madge, and the T1/dialect ratchets.

Runtime proof used `8d087040fefe324e5ff7fa76faf497fadb542c08`: the test and changed publisher body are exact. That head also contained separate stale-error diagnostics, excluded from this change, which did not alter acceptance predicates. No claim is made that this independently resolves the previously observed Gateway/UI admission failure. A published-driver update cell is not applicable to this in-memory receipt fix.

Both final publication file blobs exactly match the reviewed source after integrating main. Direct-main pushes were refused by the repository ruleset, so this emergency repair uses the authorized head-pinned PR squash fallback.

The focused schema-admission sibling also passed all 27 cases on the same composition (194.55 seconds in Vitest, 272.05 seconds including the wrapper), with a clean checkout and no surviving test processes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…aw#170194)

Repeated publication of an unchanged admitted schema invalidated the proof already held by workers. A worker returning an earlier receipt could therefore fail admission even though the database had not changed. The unconditional revocation was introduced in openclaw#165680.

Reuse the live schema validity cell when the same owner republishes its admitted facts. Real DDL still revokes that cell, and fresh admission then creates its replacement. Physical replacement, corruption, identity, and schema-admission guards remain intact. A receipt captured before an unchanged republication intentionally stays valid; no extra check or handshake is added.

The existing symlink/receipt regression now covers delayed publication, and the DDL cases verify that actual mutations still revoke the shared proof after republication. The obsolete test requiring healthy republication to revoke proof is removed. This changes two files (+13/−27), with no stored-schema, migration, durability, public API, or update behavior change. It adds no SQL or worker request path.

Validation:

- `pnpm test src/state/openclaw-agent-db-validation-cache.test.ts --maxWorkers=1`: 53/53 passed; 204.95 seconds in Vitest, 471.16 seconds including the wrapper.
- Production-only reversal with candidate tests retained: 1 expected failure and 52 passes; 149.32 seconds in Vitest, 307.14 seconds including the wrapper. The receipt regression fails at the shared validity cell identity assertion before delayed publication. The checkout was restored cleanly with no surviving test processes.
- Codex review: scoped-clean, no actionable findings; original review retained.
- [Composed-head CI](https://github.com/openclaw/openclaw/actions/runs/38298120555) passed production types, state test types, lint, source contracts, Knip, Madge, and the T1/dialect ratchets.

Runtime proof used `8d087040fefe324e5ff7fa76faf497fadb542c08`: the test and changed publisher body are exact. That head also contained separate stale-error diagnostics, excluded from this change, which did not alter acceptance predicates. No claim is made that this independently resolves the previously observed Gateway/UI admission failure. A published-driver update cell is not applicable to this in-memory receipt fix.

Both final publication file blobs exactly match the reviewed source after integrating main. Direct-main pushes were refused by the repository ruleset, so this emergency repair uses the authorized head-pinned PR squash fallback.

The focused schema-admission sibling also passed all 27 cases on the same composition (194.55 seconds in Vitest, 272.05 seconds including the wrapper), with a clean checkout and no surviving test processes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation extensions: memory-core Extension: memory-core gateway Gateway runtime P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed 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