Skip to content

refactor(gateway): move startup database work off the main thread - #169880

Merged
steipete merged 20 commits into
mainfrom
dbasync/bootmain
Oct 12, 2026
Merged

steipete merged 20 commits into
mainfrom
dbasync/bootmain

Conversation

@steipete

@steipete steipete commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway startup still ran business initialization SQL on its main thread, even though the relevant owners already support worker access.

User Impact

Startup recovery and configuration retain their existing behavior and finish before accepting requests. Database admission, schema versions, stored bytes, consent checks, and update behavior are unchanged.

Why This Change Was Made

Approval recovery now closes orphaned requests and prunes terminal rows in one worker request and one transaction. Gateway startup awaits that recovery after registering cleanup. Browser notification recovery follows the committed result as retained background work.

The config revision key uses an atomic, key-preserving upsert through the existing writer. Applied config publication awaits asynchronous preparers, including Claw consent provenance. Remote catalog startup uses its existing worker preparation. Internal hooks share one worker-read selection across startup outcomes, sidecars, and the loader. The secrets startup fast path prepares shared-auth ownership through its existing worker-backed cache before inspecting legacy sources, preserving lazy loading of the full secrets runtime.

Cron resolves its partition once through the shared read worker alongside the existing bootstrap preparations; service construction and reload consume that prepared path. A measured 7.52-second late worker-dispatch wait led to moving this read earlier, where it overlaps startup preparation without adding a request. Late Claw policy registration uses published provenance facts without opening SQLite. Standalone agent setup prepares those facts alongside secrets before activation, then binds the returned configuration through the existing captured-config preparation operation. Secrets activation publishes a clone, so the returned configuration needs its own binding to those already loaded facts. This adds no SQL. The supported provenance writers publish updates or invalidate the cache, so consent still uses current owner-held authority.

The synchronous startup paths are removed. Unrelated released synchronous interfaces retain their existing contracts. GitHub OAuth and placement hydration were already worker-backed on the integrated base of this PR; this PR claims no savings for them.

Removed duplicate work and accepted edge cases:

  • Approval recovery no longer enters separate/nested transaction wrappers for close and prune. A crash before commit rolls back the batch; the next boot retries it.
  • Hook startup no longer rereads the same installed-hook selection for each consumer. An install after capture takes effect on the next explicit reload or startup.
  • Revision-key creation no longer performs read/insert/read checks. The upsert retains an existing key, and invalid stored key material still fails closed.
  • Cron construction no longer rereads the partition after the lazy service captured it. A configuration change takes effect through the existing reload path.
  • Late consent registration no longer synchronously reloads provenance. Without prepared facts it fails closed until the worker preparation publishes; supported in-process writes keep those facts current.

Real approval, credential, placement-effect, and consent authority checks remain in their owning boundaries.

Evidence

Basic changed-file formatting, lint, and whitespace checks passed. Regression coverage includes rejected approval recovery aborting real Gateway startup, off-main recovery with immediate readback, persisted and corrupt revision keys, applied-config publication ordering, hook read-after-write, and shared-auth startup without caller-thread SQL or loading the full secrets runtime. Tests and required static checks run in PR CI under the campaign's relaxed testing policy.

Codex autoreview completed two rounds with no actionable P0–P2 findings, covering startup ordering and failure cleanup, approval recovery, key persistence/corruption, captured hook selection, and shared-auth fast-path behavior. The final live-boot trace exposed three remaining synchronous statements; the completion commit removes them through the existing cron and provenance owners and adds direct regression coverage for both. That completion was manually reviewed and checked against writer publication and standalone-agent behavior; no third routine review was run under the two-round limit.

The integration includes main's existing fixture and database-admission repairs. CI exposed two stale test expectations: the startup trace now includes the parallel cron.store-path preparation; the corrupt-key test inspects preserved corrupt bytes through a raw read-only handle because the managed opener correctly rejects corruption on readmission. Both assertions retain their original contract.

Pre-conflict CI 38276082392, head b42322c71212, passed production and test types, lint, source/architecture guards, worker/dialect/baseline ratchets, and Madge (zero cycles). Both test-only corrections passed. The earlier Doctor process and node-execution timeout cases passed on the runtime-identical head (29.514 and 96.021 seconds).

The complete 71-job audit found four failing cases in two jobs: historical transcript normalization in doctor-config-preflight.test.ts; fresh revisions and both large-shrink deletion variants in server.config-patch.test.ts. All are unchanged against integrated main 32c839147a80. The Doctor case reproduces identically there: its transcript-directives step refuses with “Transcript payload preparation requires admitted SQLite schema facts,” leaving the same inline directives unchanged. The failure is recorded for the main repair owner.

The config CI log records a session-worker prune callback timeout followed by teardown errors. A focused Node 24 run on integrated main also failed all three cases: fresh revisions and deletion with authority open timed out in server-start hooks (180.453 and 268.607 seconds); deletion with authority revoked reached the test, then agents.create hit its 10-second client timeout. The first case spent 129.343 seconds in cold import. The candidate diagnostic under Node 26 also failed all three: fresh revisions in the server-start hook (182.510 seconds), both deletion cases at agents.create with 10-second client timeouts after completed setup. These different phases are not claimed as exact reproductions of the CI failure. Node 24 candidate preparation refused to overwrite Node 26 artifacts because unrelated managed-service metadata could not prove separation; the supported Node 26 diagnostic is not a matching-runtime CI replay. No product regression was demonstrated by these runs, and all timeout failures remain recorded.

Of the 46 explicitly tracked owner/consumer suites, 40 passed in CI, Doctor failed as above, and five were unselected. Focused consumer execution recorded 52 passes and three 120-second timeouts: the first health import, Telegram owner closure between deliveries, and the next send preflight case. The health test only awaits a dynamic import before synchronous assertions; later imports passed. The send fixture retains queued one-shot mocks across tests, so the timed-out Telegram case may contaminate subsequent deferred signals; this is a source-supported possibility, not a proven cause. That run was interrupted through native cleanup to stop the cascade, retaining every failure. A fresh process then ran only unexecuted coverage: 82 passed, with the 13 previously executed send cases excluded. Total supplemental consumer execution: 134 passed, three preserved timeouts. No assertions, retries, or time budgets were changed.

Integrated-head Knip found an unused TransactionRecipes export in the unchanged database-engine owner. The identical production scan on integrated main reports the same rule, file, and symbol; source and configuration are byte-identical. This inherited finding is recorded for the main repair owner and already fixed upstream by 4cdac89. The script scan passed. The concurrent full-tree scan timed out at its existing 600-second budget. Its standalone retry completed in 570.48 seconds and found only the same TransactionRecipes type export, with no other entries. No scan budget, rule, or exclusion was changed.

Same-engine inventory of baseline and measured candidate shows startup T1 calls 9 → 0 (revision key 4 → 0, approval boot 5 → 0), global T1 calls 502 → 493, and deprecated-only calls 2 → 2. Across all touched files T1 is 10 → 1: the unchanged generic config-row helper remains classified runtime/mixed, but live stacks show no remaining MAIN business initialization in this lane. All three dialect groups remain 0 → 0. Madge passed. Knip production and full-tree scans have only the independently reproduced inherited export finding; its script scan passed. All tracked owner/consumer suites have executed, with failures and runtime limits recorded above. This landing uses the authorized relaxed CI exception for the recorded inherited failure and investigated timeout results; it does not label those runs green.

Published-driver × candidate update cell: not applicable. This changes runtime business initialization, with no changes to the installed updater, schema/migrations, plugin loading, or OS service lifecycle. Startup ordering and readiness are exercised by the live boot proof.

Pre-conflict ClawSweeper review completed with no findings or concrete security violation. Its request for consent proof is covered by the completed 14-case integration suite, including restarted frozen-tool use and changed/closed provenance failing closed.

The shared live harness completed the same 13-turn workload on baseline c6a2ce08ac91 and candidate ddf8ed89bc9e, including child execution, cron, compaction, and clean shutdown. One live pair follows the campaign's relaxed testing policy. Ten warmed turns per run give these medians [min–max]:

Warmed metric Baseline Candidate
All-thread statements 430 [408–523] 416.5 [373–515]
Worker requests 102.5 [96–133] 96 [83–120]
MAIN statements 0 [0–1] 0 [0–1]

The one MAIN statement on each run is outside this startup lane. Across the full workload, statements were 11,409 → 10,788 and requests 2,070 → 1,847. These raw reductions include integrated session-owner changes and are not claimed as this lane's saving.

Startup business statements on MAIN Baseline Candidate
Approval recovery 10 0
Config state 8 0
Revision key 7 0
Tool-policy provenance 2 0
OAuth / placement hydration 0 / 0 0 / 0
Total observed 27 0

Per-operation startup evidence, including worker admission/transaction envelopes: approval recovery is one request / four statements (the old MAIN path executed ten statements); revision-key preparation is one request / eight statements (old MAIN seven); provenance preparation is two statements (old MAIN two); install-schema loading is one request / two statements (old MAIN two); cron selection is one request / one statement. The comparable config.* operations total five requests / eleven statements on both baseline and candidate (health.patch 1/3, health.read 2/2, snapshot.read 1/1, snapshot.upsert 1/5). These are cold startup operations, not per-turn work. Stack-attributed family counts omit worker envelopes, so they are not used to claim an additional query reduction. Moving calls to workers alone is not counted as a query saving.

Shared read-family statements per warmed turn did not increase:

Family Baseline Candidate
Exact-entry facts 9.0 8.6
Actor hydration 6.8 6.6
Entry-cache snapshot loads 2.0 1.8
Selected row facts 19.5 15.1
Participant row facts 21.6 17.1
Transcript watermarks 6.4 2.1

The first candidate's TCP-listen timing was 100.441 seconds versus baseline 83.484 seconds on the loaded host; the late cron read demonstrably occupied 7.52 seconds. Commit 16c179920a56 moved that same read into existing parallel preparations. The final short boot used that exact runtime with only the two test changes in b42322c71212: business MAIN remained 0, TCP listen was 43.010 seconds, readiness 50.421 seconds, and the early cron preparation span 84.6 milliseconds. Baseline readiness was 99.922 seconds. Both runs used isolated state and completed connection/clean-shutdown checks. These are single runs on a heavily loaded host, not a claimed stable speedup; the final trace shows no startup latency regression and confirms removal of the late serial cron wait.

The final diff against integrated main 428b3c2ec545 is 69 files, +941/−625 lines, including regression tests and the test-only CI corrections.

Final conflict integration: efd33dfe3c16 merges main 428b3c2ec545. It retains the async startup cutover while adopting main’s committed provenance-cache reuse and inferred config-worker result type. The provenance regression uses supported install/delete writers; the removed foreign-writer test contradicts the Gateway’s single-owner contract. Focused provenance proof passed all 26 tests in 276.78 seconds; its worker preparation took 226.10 seconds on the loaded host. Formatting and syntax lint passed. The broad local lint wrapper timed out after 300 seconds in SDK declaration preparation, before linting; required type-aware proof remains in CI. Earlier SQL measurements remain historical evidence for the unchanged startup cutover, not measurements of this integrated head.

The integrated-head CI exposed two redundant failure-reply branches in the cron and hook readers after main narrowed the shared read result type. 1b21e2d730aab removes those six lines: executeExistingOpenClawStateRead already throws on failure or a mismatched reply and returns only the validated success. There is no new SQL or runtime fallback. The session canonical-validation test also failed at its pending-dirty assertion (server-methods.canonical-validation.test.ts:262). The identical test and assertion fail on scheduled main c66da3d764b0, run 38292584060, job 114956275365; the unchanged files and exact failure are recorded for the main repair owner. Final static CI passed after this type fix.

Final integration CI also recorded a 120-second timeout in install.npm-spec.e2e.test.ts (the real npm-pack successor lifecycle case). Its test and owners are unchanged against the merged main parent, but scheduled-main CI does not select that E2E file, so this is recorded as an unresolved timeout, not a proven inherited failure. No timing budget or assertion was changed.

Additional integration failures are recorded separately: all four session-cost-usage-cache.creation-race.test.ts cases match scheduled main c66da3d764b0, job 114956274659, including the offline-maintenance error versus expected fencing/schema-refresh errors. memory-dreaming-reload.test.ts fails during the light phase with “Runtime config is not prepared.” Its initial runtime-facade read succeeds; the later transcript-corpus host read is the unresolved boundary. Scheduled main excludes this release-only suite, so this is an unclassified follow-up, not proven inherited. The fixture uses the unchanged synchronous snapshot setters; no bootmain product regression has been demonstrated. Both are recorded for the main repair owner.

Final-head CI: 38298010221 at 1b21e2d730aab; all production/test type partitions, type-aware lint, source contracts, architecture/Madge, boundaries, and baseline/worker/dialect ratchets passed. Knip was not selected by CI; the separate production, full-tree, and script export scans all passed with zero entries on this exact head. Remaining CI test failures are recorded below.

Final-head integration CI repeats the exact Doctor, creation-race, canonical-validation, and memory-dreaming failures described above. The npm-pack successor lifecycle test passed in final-head CI; its prior timeout remains recorded, without a claim that a code change fixed it. Required static gates are green, including the separate final-head Knip production, full-tree, and script export scans (zero entries).

The final cron-message integration shard also failed three cases: the Claude CLI/read case timed out after 60 seconds; the trusted-operator Discord edit hit a closed shared-state read admission; the Discord 429 retry case observed startup recovery marking its job interrupted. Scheduled main does not execute this unchanged integration file, so these are unclassified, not proven inherited. The fixture does not cancel a timed-out scenario body before its shared-process cleanup can overlap later scenarios; the first timeout was followed by a passing channel-info scenario, then the two lifecycle failures. That supports possible cleanup fallout but does not prove it, and the first blocked boundary is unknown. The live SQL harness independently completed its cron flow. All three cases are recorded for the main repair owner; no timeout, retry, or assertion was changed.

Landing: all final-head static gates passed. The completed CI run retains three independently proven inherited failures and the explicitly unclassified memory/cron integration failures above. This uses the authorized relaxed landing policy; those tests are not represented as passing or as all inherited. There is no demonstrated product regression in the startup cutover, and the isolated live boot/turn proof remains recorded above.

Latest conflict integration: 3e29d8e9bfa0 merges main 930bb545e38b. The only textual conflict was the worker-module inventory; resolution retains both this lane’s provenance reader and main’s profile-worker entries. Automatically merged cron code uses main’s authoritative deletion facts, and shutdown retains main’s shared-state option. No new startup behavior or SQL was added. Earlier measurement and behavioral evidence are reused for the unchanged startup cutover; final-head static verification is in progress.

New integrated-head test failures at 3e29d8e9bfa08: session wait dedupe (three cases; job 114984186793), pending Stop producer binding (three cases; job 114984187078), and board broadcasts (two cases; job 114984186820) fail at resident user-profile catalog readiness; pending Stop also reports its abortability assertion. All failing test files plus user-profile-list.ts and operator-role-policy.ts are byte-identical to merged main 930bb545e38b. Scheduled main c66da3d764b0 predates the latest profile-worker changes and passed the wait/stop cases, so these new failures are unclassified, not claimed as independently reproduced inherited failures. They are assigned to the main repair inbox without changing tests or adding bypasses. The canonical-validation case repeats its already verified inherited assertion failure.

The same integrated CI also records two session-pending-input-foreign-rewrite.test.ts catalog-readiness failures (job 114984187017) and four session-processes.test.ts process-control projection failures under Bun (job 114984186808). These are outside the authored diff and remain unclassified; no current-main reproduction is claimed. The four creation-race failures repeat the already independently confirmed offline-maintenance mismatch (job 114984186782).

The integrated head also repeats the unresolved memory-dreaming runtime-config preparation failure (job 114984186868). Fresh Knip production/full-tree/script scans all pass with zero entries. The local worker ratchet passes (484 → 471 T1 calls using the current inventory engine against its selected comparison base 428b3c2ec545; this is separate from the measured historical 502 → 493 comparison).

Job 114984186755 reports startup-migration.registry-recovery.test.ts failing with database is locked; the test and migration owner are outside this PR’s authored diff. It remains an unclassified follow-up; no inherited reproduction or timing fix is claimed.

Merge-head static verification is complete for 3e29d8e9bfa08: CI 38300953486 passed production types, every test-type partition, every lint partition, source contracts, architecture/Madge, boundaries, guards, security, and worker/dialect/baseline ratchets. Fresh production/full-tree/script Knip scans all passed with zero entries. Later test failures include three chat-read-scope cases (visibility assertion plus two asynchronous-read timeouts, job 114984187056) and one session-resolution projection assertion (job 114984187297). These unchanged owner/test files are recorded as unclassified, not claimed inherited. At the static-gate decision there were ten failed test jobs and two still-running test jobs; this landing does not claim a green full suite. The campaign's explicitly authorized relaxed landing rule permits landing once static gates pass unless a product regression in this change is demonstrated; none has been established here.

Final change size remains 69 files, +941/−625 lines. Both Codex review rounds and the historical isolated boot/turn proof remain valid for the unchanged startup migration; there is no third routine review or repeated live measurement for the conflict-only integration.

Await worker-backed approval recovery, revision key loading, config preparation, hook selection, shared-auth ownership, and placement hydration before publishing startup state. Reuse owner operations and batch approval recovery without changing stored data or authority checks.
@clawsweeper

clawsweeper Bot commented Oct 12, 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 12, 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: 3e29d8e9bfa08f8625df1648bc911bbb70175998
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/security/audit-extra.summary.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.
  • src/security/audit.ts: Controls product security checks or trust decisions. Check whether the change weakens detection, protection, or remediation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling size: XL labels Oct 12, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR moves Gateway startup database initialization into existing workers and awaits prepared results before publishing runtime state.

Example: Restart with a pending approval from runtime-a.

  • Before: Startup cancels the orphaned approval through main-thread SQLite operations.
  • After: Startup awaits worker-backed cancellation with the same gateway-restart outcome.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is coherent and has meaningful startup evidence, but required authority and upgrade coverage remain incomplete.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) Security review found an item that needs attention.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
User problem: Gateway startup business initialization still blocks the main thread with SQLite work.
Reason: The maintainer-authored direction removes demonstrated startup debt through existing worker owners without adding product surface.

Merge readiness

⛔ Blocked before merge - 4 items remain

Keep open: this maintainer-directed refactor addresses remaining startup database work on main, and the reviewed diff establishes no discrete introduced bug.

Priority: P2
Reviewed head: 1b21e2d730aabd68f59324a88485444bae32d891

Before merge

  • Add real behavior proof - Authority-chain proof required: reported Gateway workload and boot traces support the startup worker cutover, but standalone coverage stops at capability construction. Supply redacted terminal output, logs, or a production-path harness entering through resolveAgentRuntimeConfig, showing valid consent permits the approved tool, mismatched consent rejects it, and supported provenance invalidation or database closure prevents subsequent filesystem/process I/O. Also show a v2026.10.2 upgrade retaining the installation key, approval recovery, settings, and retained data; redact credentials, IPs, phone numbers, and private endpoints. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve security review attention item - No concrete security violation was established, but the standalone consent authority handoff remains unproven.
  • Resolve merge risk - Before merge, establish that the standalone consent handoff rejects mismatched or invalidated authority before filesystem or process effects.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Missing coverage combines the changed standalone startup resolver with allowed, mismatched, and subsequently invalidated consent at real tool effects, plus an upgrade from v2026.10.2 preserving settings and retained state; baseline-failing regression execution was not shown.
Agent review details

How this fits together

Gateway startup consumes configuration and persisted state, prepares approval recovery, installation keys, consent, hooks, and cron selection, then publishes runtime state for request handling.

flowchart TD
Startup --> ReadWorker
Startup --> WriteWorker
ReadWorker --> SQLite
WriteWorker --> SQLite
SQLite --> PreparedFacts
PreparedFacts --> Runtime
Runtime --> Effects
Loading

Technical review

Best possible solution:

Keep startup preparation in the existing workers while preserving readiness ordering, installation identity, retained data, and current consent enforcement.

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

Current main still performs synchronous approval boot recovery and revision-key initialization; source inspection establishes the paths, and the PR reports matching live startup traces.

Is this the best way to solve the issue?

Reusing existing workers, batching approval recovery, and carrying prepared selections is a coherent solution that follows the repository's single-owner design.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Hold for the remaining boundary evidence (recommended)
    Keep this PR open while its owner supplies standalone consent final-effect evidence and a stable-release upgrade preserving existing state.

Provenance checked

  • Approval startup recovery changes intended behavior with a stated reason (8d86209: The preceding worker cutover explicitly retained orphan cleanup and pruning as synchronous boot exceptions; this PR completes that remaining lane.)
  • Opaque installation revision key keeps the original intent (a4f1783: Installation-local HMAC tokens prevent deterministic config-identity disclosure and must retain their key across restarts and fail closed on corruption.)
  • Claw provenance preparation changes intended behavior with a stated reason (1ec4e45: Installed tool authority is frozen to consent provenance; later merged owner work permits committed cache reuse with lifecycle invalidation.)
  • Internal hook selection keeps the original intent (4c3bf14: Canonical directory discovery and named allowlists replace retired inline handlers; the async selection preserves that policy.)
  • Catalog startup capture keeps the original intent (21dc7d5: Model rows and prices must share one startup snapshot; worker preparation remains awaited before bootstrap consumers.)

Testing

Proof path: shipped entry point.

Security

Needs attention: No concrete security violation was established, but the standalone consent authority handoff remains unproven.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 7e48efb adds src/claws/provenance-runtime-read.ts:271 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7e48efba1047; files: src/claws/provenance-runtime-read.ts)
  • Josh Avant: Raw commit a4f1783 adds src/gateway/config-revision-token.ts:29 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a4f17833ada0; files: src/gateway/config-revision-token.ts)
  • Gio Della-Libera: Raw commit 1ec4e45 adds src/claws/provenance-runtime-read.ts:99 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1ec4e4582eac; files: src/claws/provenance-runtime-read.ts)

PR surface

Source +11, Tests +307, Docs +18, Other -20. Total +316 across 69 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 34 377 366 +11
Tests 32 533 226 +307
Docs 1 30 12 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 2 1 21 -20
Total 69 941 625 +316

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P2: Normal-priority startup responsiveness and ownership improvement; no demonstrated urgent user regression.
  • merge-risk: 🚨 security-boundary: Consent preparation changes an execution-authority handoff whose standalone final effects have not been demonstrated.
  • merge-risk: 🚨 compatibility: Startup config publication and persisted-state recovery change without the requested latest-stable upgrade evidence.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof through standalone startup for valid, mismatched, and subsequently invalidated consent.
  • Show an upgrade from v2026.10.2 preserving the installation key, approval recovery, settings, and retained data.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-12T13:40:05.229Z sha 1c24e2f :: blocked before merge. :: none
  • reviewed 2026-10-12T14:06:51.588Z sha dfe9314 :: blocked before merge. :: none
  • reviewed 2026-10-12T14:28:06.876Z sha c060697 :: blocked before merge. :: none
  • reviewed 2026-10-12T15:17:51.673Z sha ddf8ed8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T15:42:05.339Z sha ddf8ed8 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T16:32:25.668Z sha b42322c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T17:41:07.566Z sha b42322c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-12T19:26:56.782Z sha efd33df :: needs real behavior proof before merge. :: none

Reviewed October 12, 2026, 3:39 PM ET / 19:39 UTC (Revision 11).

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 12, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 12, 2026
@clawsweeper clawsweeper Bot removed the status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. label Oct 12, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 12, 2026
@steipete steipete self-assigned this Oct 12, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 12, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Coordination note from a parallel landing attempt (stopped; nothing was pushed to this branch).

The PR removes the synchronous main-thread provenance read behind setRuntimeConfigSnapshot and moves the regression test to the async setter, so the public synchronous consent path lost its coverage. That direction matches the database doctrine in AGENTS.md: the Gateway owns the state DB, in-process writer receipts refresh caches, and foreign-commit probes go away. A trace of the supported provenance writers found none that bypass the Gateway. Claw CLI mutations need exclusive offline ownership, Gateway writers update the cache, Doctor repairs need maintenance ownership, and the plugin SDK has no provenance mutator.

A test restoring synchronous-path coverage is on steipete/169880-consent-sync-test, commit 4e4430c, on top of b42322c. See src/claws/tool-policy-runtime.integration.test.ts. It proves cached consent is used, a supported provenance change is reflected without SQL during publication, and a closed DB fails closed (15/15 passed locally). The rest of that commit is line-cap helper extractions; take them or leave them.

Local classification on a heavily loaded host (timings unreliable): src/commands/doctor-config-preflight.test.ts fails identically on origin/main (missing schema-admission facts after reopen). The server.config-patch.test.ts CLIENT_TIMEOUT on agents.create also reproduces on origin/main; its owner is unproven.

@steipete
steipete merged commit 04d4e9c into main Oct 12, 2026
160 of 173 checks passed
@steipete
steipete deleted the dbasync/bootmain branch October 12, 2026 20:08
steipete added a commit that referenced this pull request Oct 12, 2026
## What Problem This Solves

Two generated fixtures in `test/non-isolated-runner.test.ts` fail before completing their intended lifecycle proof. After #170162 (`17c9b482ee5d`), the native cron module gained runtime dependencies that Node could not resolve from TypeScript source. Fixing relative imports exposed a workspace alias, then a parameter property in the existing retry package that Node's strip-only mode cannot load. Separately, #169880 (`04d4e9cd3fbf`) removed the synchronous provenance initializer still called by both generated Gateway lifetime tests.

## Why This Change Was Made

Prime the real cron module through the fixture's native CommonJS entry point with a temporary synchronous resolution hook for relative source imports and exact aliases from `tsconfig.json`. Always deregister the hook in `finally`, and enable Node's native TypeScript transformation only in this generated child project's `execArgv`. Vite still imports the same native generation. Migrate both Gateway fixtures to await the existing `prepareClawInstallSchemaVersions(options)` owner and publish its result. Carry the Gateway project's plugins into the child and give its newly asynchronous worker calls the same managed compiled-worker setup and joined disposal used by the cleanup child. Run this generated host fixture in a fork: shared-state admission requires a process main thread, as the existing live and agents-support test configurations already document. Keep the Gateway isolation and custom cleanup runner.

## User Impact

The combined change touches three test files (+59/−17). It preserves native cache identity, reset behavior, partial-mock metadata, readiness and close notifications, `afterAll` ordering, awaited resource drains, retired-generation isolation, and every lifecycle assertion and aggregate count. The pool metadata assertion now expects `forks`. Readiness failures include the captured provenance error before the intentional close replaces that snapshot. Production code, timeouts, and test counts are unchanged.

## Evidence

At final head `b59341be18c2`, [CI run 38314652902](https://github.com/openclaw/openclaw/actions/runs/38314652902) passes both tests in `test/non-isolated-runner.test.ts`: shared runner cleanup in 60.697 seconds and Gateway worker lifetimes in 38.036 seconds. Vitest duration is 100.66 seconds; the CI test step takes 104 seconds and its job takes 172 seconds including setup. This is exact-head runtime proof for the complete patch; the earlier failed runs below only establish the causes. The focused reproduction command is `pnpm test test/non-isolated-runner.test.ts --maxWorkers=1`; no separate local runtime run is claimed.

The two earlier resolver changes each passed targeted formatting/lint, diff checks, normal commit hooks, and an independent Codex P0–P2 review. The fixture follow-ups passed targeted lint, formatting, diff checks, and normal hooks; the transform/provenance follow-up also received a separate maintainer diff inspection. The two completed review rounds are retained without a third round.

CI run [38302535736](https://github.com/openclaw/openclaw/actions/runs/38302535736) showed the original relative-import failure; [38306200884](https://github.com/openclaw/openclaw/actions/runs/38306200884) reached the workspace-alias failure. At the prior PR head `2fe45983c46b`, run [38310484484](https://github.com/openclaw/openclaw/actions/runs/38310484484) passed the selected type, lint, baseline, source-contract, and architecture checks, but both parent tests failed: cleanup encountered the unsupported retry parameter property, and Gateway lifetime encountered the removed initializer. The cleanup report expected six failed modules/suite errors from intentional fixtures and observed ten/nine because of the unexpected import failures. Those intentional MCP, watcher, and cancellation failures are not product regressions.

At head `3703bbbc703d`, run [38312339272](https://github.com/openclaw/openclaw/actions/runs/38312339272) passed cleanup in 63.515 seconds, confirming the native import and transformation fixes. Gateway lifetime still failed with `A:state-error` and `B:state-error`. That log did not emit the underlying exception, and no retained fixture artifact was uploaded. The following patch restored omitted Gateway plugins and managed compiled-worker ownership and added error diagnostics.

At head `aefd7bcd3712`, run [38313572251](https://github.com/openclaw/openclaw/actions/runs/38313572251) again passed cleanup and exposed the exact Gateway error: `Shared-state admission requires the host broker`. The native `isMainThread` guard in `openSharedStateSqliteWorkerStore` rejects the inherited thread pool before broker admission. The final fixture-only change selects `forks` and updates the pool metadata expectation; it does not mock or weaken that owner boundary.

All selected static leaf checks pass at the final head: changed-test, source-contract, boundary, lint, production-type, all five core test-type stripes, root test-type, and baseline-ratchet checks. The architecture job executes both cycle checks with zero cycles and passes Kysely guardrails.

The PR does not select Knip. Scoped Knip evidence comes from the actual V28 scan at `0c4b38b77adf`: its only findings were three unrelated Team-scale fixture exports, fixed on main by `36e78f215f1f`. Comparing the three fixture files and their configs shows no new static module edges, exports, dependencies, or test entry selection after that scan. The generated provenance import switches symbols within the same owner module; runtime changes are proven by this PR's passing tests. The only Knip-config difference is the unrelated PostgreSQL generator entry already landed as `e2f58e771393`. This qualifies the fixture scope; it does not claim that the full V28 Knip scan passed.

The diff is test-only: no SQL statements, requests, T1 calls, SDK APIs, schema, updater, or service lifecycle behavior changes are claimed. Build and published-driver jobs are skipped by PR selection. The final exact-head CI run is green, including `openclaw/ci-gate`: 28 jobs succeeded and 28 were skipped by selection.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…enclaw#169880)

Move approval recovery, config revision-key creation, config preparation,
hook selection, cron partition selection, and Claw provenance preparation
through their existing database workers. Await required preparation before
Gateway readiness and remove the superseded synchronous startup paths.

Keep approval and consent authority with their existing owners. Batch
approval recovery in one transaction, retain the durable revision key with
an atomic upsert, and reuse committed facts and captured startup selections.

No schema, stored-format, retention, or update behavior changes.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…0263)

## What Problem This Solves

Two generated fixtures in `test/non-isolated-runner.test.ts` fail before completing their intended lifecycle proof. After openclaw#170162 (`271e435a9bbe`), the native cron module gained runtime dependencies that Node could not resolve from TypeScript source. Fixing relative imports exposed a workspace alias, then a parameter property in the existing retry package that Node's strip-only mode cannot load. Separately, openclaw#169880 (`c8a40c7a9dab`) removed the synchronous provenance initializer still called by both generated Gateway lifetime tests.

## Why This Change Was Made

Prime the real cron module through the fixture's native CommonJS entry point with a temporary synchronous resolution hook for relative source imports and exact aliases from `tsconfig.json`. Always deregister the hook in `finally`, and enable Node's native TypeScript transformation only in this generated child project's `execArgv`. Vite still imports the same native generation. Migrate both Gateway fixtures to await the existing `prepareClawInstallSchemaVersions(options)` owner and publish its result. Carry the Gateway project's plugins into the child and give its newly asynchronous worker calls the same managed compiled-worker setup and joined disposal used by the cleanup child. Run this generated host fixture in a fork: shared-state admission requires a process main thread, as the existing live and agents-support test configurations already document. Keep the Gateway isolation and custom cleanup runner.

## User Impact

The combined change touches three test files (+59/−17). It preserves native cache identity, reset behavior, partial-mock metadata, readiness and close notifications, `afterAll` ordering, awaited resource drains, retired-generation isolation, and every lifecycle assertion and aggregate count. The pool metadata assertion now expects `forks`. Readiness failures include the captured provenance error before the intentional close replaces that snapshot. Production code, timeouts, and test counts are unchanged.

## Evidence

At final head `b59341be18c2`, [CI run 38314652902](https://github.com/openclaw/openclaw/actions/runs/38314652902) passes both tests in `test/non-isolated-runner.test.ts`: shared runner cleanup in 60.697 seconds and Gateway worker lifetimes in 38.036 seconds. Vitest duration is 100.66 seconds; the CI test step takes 104 seconds and its job takes 172 seconds including setup. This is exact-head runtime proof for the complete patch; the earlier failed runs below only establish the causes. The focused reproduction command is `pnpm test test/non-isolated-runner.test.ts --maxWorkers=1`; no separate local runtime run is claimed.

The two earlier resolver changes each passed targeted formatting/lint, diff checks, normal commit hooks, and an independent Codex P0–P2 review. The fixture follow-ups passed targeted lint, formatting, diff checks, and normal hooks; the transform/provenance follow-up also received a separate maintainer diff inspection. The two completed review rounds are retained without a third round.

CI run [38302535736](https://github.com/openclaw/openclaw/actions/runs/38302535736) showed the original relative-import failure; [38306200884](https://github.com/openclaw/openclaw/actions/runs/38306200884) reached the workspace-alias failure. At the prior PR head `2fe45983c46b`, run [38310484484](https://github.com/openclaw/openclaw/actions/runs/38310484484) passed the selected type, lint, baseline, source-contract, and architecture checks, but both parent tests failed: cleanup encountered the unsupported retry parameter property, and Gateway lifetime encountered the removed initializer. The cleanup report expected six failed modules/suite errors from intentional fixtures and observed ten/nine because of the unexpected import failures. Those intentional MCP, watcher, and cancellation failures are not product regressions.

At head `3703bbbc703d`, run [38312339272](https://github.com/openclaw/openclaw/actions/runs/38312339272) passed cleanup in 63.515 seconds, confirming the native import and transformation fixes. Gateway lifetime still failed with `A:state-error` and `B:state-error`. That log did not emit the underlying exception, and no retained fixture artifact was uploaded. The following patch restored omitted Gateway plugins and managed compiled-worker ownership and added error diagnostics.

At head `aefd7bcd3712`, run [38313572251](https://github.com/openclaw/openclaw/actions/runs/38313572251) again passed cleanup and exposed the exact Gateway error: `Shared-state admission requires the host broker`. The native `isMainThread` guard in `openSharedStateSqliteWorkerStore` rejects the inherited thread pool before broker admission. The final fixture-only change selects `forks` and updates the pool metadata expectation; it does not mock or weaken that owner boundary.

All selected static leaf checks pass at the final head: changed-test, source-contract, boundary, lint, production-type, all five core test-type stripes, root test-type, and baseline-ratchet checks. The architecture job executes both cycle checks with zero cycles and passes Kysely guardrails.

The PR does not select Knip. Scoped Knip evidence comes from the actual V28 scan at `0c4b38b77adf`: its only findings were three unrelated Team-scale fixture exports, fixed on main by `2531250f6525`. Comparing the three fixture files and their configs shows no new static module edges, exports, dependencies, or test entry selection after that scan. The generated provenance import switches symbols within the same owner module; runtime changes are proven by this PR's passing tests. The only Knip-config difference is the unrelated PostgreSQL generator entry already landed as `19581446c556`. This qualifies the fixture scope; it does not claim that the full V28 Knip scan passed.

The diff is test-only: no SQL statements, requests, T1 calls, SDK APIs, schema, updater, or service lifecycle behavior changes are claimed. Build and published-driver jobs are skipped by PR selection. The final exact-head CI run is green, including `openclaw/ci-gate`: 28 jobs succeeded and 28 were skipped by selection.
RomneyDa added a commit that referenced this pull request Oct 13, 2026
#170162 backport

The #170162 backport (cf6f760) added a runtime import of agents/run-termination.js to cron/service/active-run-cancellation.ts. The non-isolated runner fixture loads that source through native CommonJS require, which cannot resolve .js specifiers to TypeScript sources, so 09-d and 09-i failed with 'Cannot find module .../run-termination.js' (FRV run 38333371459, job 115088198455).

Port the cron fixture portion of main's companion fix #170263 (aeaae03): prime the native generation through a temporary synchronous resolve hook for relative .js and tsconfig alias imports, and enable --experimental-transform-types in the generated child project. The Gateway lifetime hunks of #170263 are not ported: they follow #169880, which is not on this branch, and that test passes here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant