Repository navigation
refactor(state): remove speculative runtime bookkeeping - #168674
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. What this changesThis PR removes duplicate SQLite lifecycle, schema, and publication bookkeeping while retaining existing state owners. Example: An operator changes agent main’s storage path while its executor is idle.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it implements the maintainer’s recorded simplification direction, remains distinct from main, and has no actionable introduced defect identified. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway state owners capture caller and database authority, dispatch SQLite worker operations, and publish committed receipts into retained read projections. flowchart LR
A[Gateway callers] --> B[Captured authority]
B --> C[State worker owner]
C --> D[SQLite transactions]
D --> E[Committed receipts]
E --> F[Read projections]
F --> A
Technical reviewBest possible solution: Use existing reader, schema, transaction, and receipt owners while preserving live authority, integrity, destructive-effect, and ordinary concurrency checks. Do we have a high-confidence way to reproduce the issue? This refactor claims no new product defect; source inspection confirms the duplicate mechanisms being removed. Is this the best way to solve the issue? The patch consolidates responsibilities into existing owners and records accepted edge cases without adding another policy or persistence layer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against fab68f488caf. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource -814, Tests -1191, Docs 0, Other -1. Total -2006 across 57 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 10, 2026, 9:16 PM ET / October 11, 2026, 01:16 UTC (Revision 4). |
b9bb91a to
eb5d1a9
Compare
Exact-head CI attributionReviewed head:
The earlier head's health fixture failure was PR-caused and fixed before this head. Its timer-count failure did not recur and is not claimed fixed or main-red. No workflow was rerun, dispatched, or re-pushed for a green result. This landing uses the campaign's authorized inherited-failure exception; the failed hosted run is not being described as green. The native-reclamation stall remains a coordinator follow-up. |
) * refactor(state): consolidate read and schema ownership * refactor(state): publish profile changes from native receipts * refactor(state): remove speculative worker bookkeeping * refactor(state): reuse startup facts and deletion predicates * test(config): keep health fixtures in one module lifetime
What Problem This Solves
State storage carries duplicate lifetime owners and defensive protocols for unsupported concurrent file/configuration changes and internal re-entry.
User Impact
Normal storage, permissions, crash recovery, and public configuration remain unchanged. Warm executors no longer drain just because configuration changes; existing work keeps its selected physical store and idle resources expire normally. No schema, persisted data format, retention policy, or permission change.
Why This Change Was Made
This maintainer-requested pragmatic simplification removes speculative protocols while preserving the checks at actual security, destructive-write, integrity, and concurrent-session boundaries. Committed readers use the existing reader lifecycle; avatar publication uses the native committed receipt rather than a separate settlement reader.
Best-effort tradeoffs accepted
1240759624a, perf(state): switching between agents reopens agent database executors on every request #165993): the reported problem was repeated opens during normal agent switching, not config changes during work. Existing executors now expire through normal LRU/TTL/shutdown; caller-owned routing selects new requests.140ae96507a, improve: reduce repeated session read stalls #148868): the duplicate timer/cache and one-shot nested-reader fallback were performance scaffolding, not a reported nested-read failure. The normal read scope owns cleanup and snapshots; nontransactional nested callbacks may share it.5f0aa4f7c56, fix: retain accepted browser follow-ups across restarts #133457): these duplicated the current schema-admission owner. Existing shared facts/ensurer now own installation and rollback; accepted-input durability and same-version migration stay unchanged.0f748036332, improve(doctor): speed up schema checks for large databases #143802): the same-build child already owns SQLite validation and emits typed results. Its response now uses one shared producer-checked type; request matching, process failure, cancellation, actual integrity checks and error serialization remain.2fe7995d5c6, perf(auth-profiles): offload peer settlement and catalog reads #166183; later improve: reduce SQLite work during chat turns #167965): this repeated the same admitted-fact lookup without a new snapshot. Owner-published schema revisions still apply; external concurrent DDL remains unsupported.7517981b5e6, improve: reduce repeated SQLite work during chat turns #168002): no asynchronous work can publish between the first lookup and synchronous SELECT. Normal writer invalidation remains.82bff47f981, fix(sqlite): keep foreign changes visible during refresh #167687): private Set/Map insertion invokes no callbacks. Allocation failure is not a recoverable registration protocol; real maintenance registration retains its cleanup catch.bb7d32e55d4, perf(sqlite): reuse admission across workers and reopens #167739;9324ed61ca5, refactor: move exec policy writes off the Gateway thread #167115): these only catch an internal read callback closing or changing its own reader. Entry admission remains; such a callback may return the value it already read.000af986dc9, feat(update): retain compatible package rollback and safe recovery admission #140339): fixed repository row-write callbacks do not run arbitrary DDL. Schema changes belong to their migration owner/review, not a listener and catalog comparison around every row transaction.140d9e705ea, feat: start cloud sessions without a Gateway checkout #138900): shared admitted schema facts replace this competing cache; existing rollback and first-use installation remain.cd2330cd69d, refactor(skills): run Workshop storage operations in the shared worker #156110): internal contexts are immutable by contract; captured live authority callbacks remain. Mutating the context object mid-call is unsupported.cd2330cd69d, refactor(skills): run Workshop storage operations in the shared worker #156110;65bc5f6ed94, refactor(mcp): run OAuth writes and leases in the state worker #148859): trusted native transactions own stage order. Every effect still checks current authority; duplicate internal delivery no longer gets a separate host FSM.c69b8b986867, fix: recognize verified team admins as channel owners #153508): the native transaction already owns stage order; live role, identity, and publication checks remain.1b66d30351da, fix: retain human co-author credit through delegation #157268): internal transaction/commit sequencing no longer has another host counter; coauthor/publication validation remains.afafe747c340, feat: personalize session backgrounds #168301): the native transaction owns sequencing; current caller authority and cancellation remain at every grant.124ddc0a49fe, refactor(storage): run repository workspace SQL in workers #161124): removed only the host stage counter; current session, receipt, and cleanup authority remain.19c6ef8d9e0, fix(proxy): keep capture persistence off the main thread #158848): timer identity, active operation count and owner membership already reject obsolete inspections.8b16e5328ec, fix: prevent temporary-file exhaustion from SQLite coordination #157413): Node's terminate promise already joins the exit event; existing startup/renewal joins remain.f31d9d8fa92, fix: prevent externally supervised state schema drift #121069): the same connection was checked immediately above without an await or DDL.3ec01cec1b8, fix(sqlite): preserve worker error identity for each caller #146741): the guarantee was tested with resetModules, not a reported deployment failure. Initial typed decoding, shared/cyclic causes, redaction and independent raw cached errors remain; decoded errors keep their original constructors across manual reload.9c93bc347ce, fix: retain shared-state snapshots through worker failures #160946; synthetic cleanup-abort teste0d80000067, perf(sessions): publish transcript projections off thread #154069): the result already passed its post-query authority check. A scope changing during cleanup no longer discards that accepted value; cleanup still joins all resources. Actual startup cancellation and deletion authority remain checked at publication.7b741f627c8, improve: run post-login avatar persistence off the Gateway thread #152670; refactor(runtime): deslop runtime #165914): known commits now publish their native receipt even if ordinary reply delivery fails. Unknown writes are not replayed; no-overwrite SQL and current database admission remain.73039895153, fix: preserve approval and workspace state after lost worker replies #168094; fix(storage): publish sandbox, worktree, and GitHub authority receipts #168025): current internal installers/subscribers do not issue writes. Commit receipts and all-facts-before-observers ordering remain; unsupported recursive writes are not given a separate protocol.8a3d30de7d5, fix: prevent large-fleet Gateway startup failures and stalls #151805): large-fleet startup was the reported issue, not out-of-band WAL/file mutation between passes. Bootstrap can reuse compatibility metadata; explicit readiness/Doctor and native write admission still validate their own contracts.8a5b4af6607, fix(gateway): make agent deletion transactional #111678; refactor(core): deslop state, skills, logging, ACP and session helpers #160382): unrelated completed rows no longer abort a deletion claim. Every current pending row, operation ID, path fence, lease and destructive effect remains checked.24d599636ab, perf(agents): reduce main-thread SQLite during retirement #167547): the immediately following canonical predicate checks the same agent/operation/completion fields; missing rows still explicitly refuse.215f1c6e2a6, improve(state): keep healthy databases open for 30 idle minutes #152341): idle resource inspection need not re-certify the admitted schema. Operation entry keeps its retained-cache lookup, including schema and terminal-failure admission; invalid stores still refuse writes.Kept deliberately: real #162750 contention recovery, native/WAL shutdown joins, pending-registration concurrency (#166860), physical identity and corruption/receipt handling (#166867, #168361), credential/authorization checks, and ordinary concurrent profile preparation retries.
Evidence
The candidate removes 814 net production source lines (plus one obsolete wrapper-inventory entry); tests are counted separately. No new lint suppressions, retries, skips, timeout increases, schema versions or dependencies.
The replacement head
eb5d1a9215f5ccc8260f7be74503ada3042e5671completed hosted run38100826020. All selected jobs passed exceptchecks-node-changed-compact-small-10(114356461669) and its aggregateopenclaw/ci-gate(114358633506); no product job was cancelled. The test job reports three 120-second timeouts in the unchangedsession-native-binding.reclamation.test.ts, followed by an 8 GB worker heap exhaustion. All three exact timeout cases also reproduce on independently installed clean main626eeac26d62c8ab45b09218b2216c27a9eea00d: typed reset without/with a successor and native-veto artifact reclamation. The candidate's focused two-case probe also reproduces both timeouts (627.39s Vitest / 660.21s wrapper). Temporary instrumentation, removed afterward, confirmed native module loading and codec preparation complete before the stall; no causal regression from the committed-reader cutover was found. The underlying settlement timeout and exact cause of CI's eventual heap exhaustion remain unresolved. This is inherited-failure evidence, not a claim that the failing run is green.git diff --checkpasses.f3af0db8fcee85e181c86876f24740f9ec928fae, independent installation and identical test bytes:node scripts/run-vitest.mjs src/state/openclaw-database-preflight.lifecycle.test.ts -t 'joins all snapshot children and closes their readers before close-failure settlement'failed at line 218 withclose-0=false(16.023s test, 241.23s wrapper). This qualifies only that exact inherited failure. The two other lifecycle deadlines and concurrent-WAL case passed the corrected probe, which does not establish their prior cause.f3af0db8fcee85e181c86876f24740f9ec928faeusingnode scripts/run-vitest.mjs --config test/vitest/vitest.infra.config.ts src/state/openclaw-state-ownership.test.ts -t 'refuses unauthorized Doctor admission before staging a public snapshot'(297.83s Vitest, including cleanup). No timeout or retry change was made; the underlying timeout cause remains unknown.38091697654passed 85 jobs and exposed a missed direct-caller fixture cutover insrc/config/io.health-state.test.ts: two artificial module reloads poisoned later error-class assertions after the intentionally removed reload re-tagging. The same whole-file failure reproduced locally (7 passed, 2 failed); removing only those reloads while preserving broker reuse, live retirement, and maintenance/audit assertions passes all 9 (529.05s Vitest / 576.82s wrapper). Focused config types, lint, and a fresh P2 review pass. The required pre-push suppression check again reports only the coordinator-owned improve: reduce repeated SQLite work during chat turns #168002 mismatch.00e095399b2, and a global fake-timer count insubagent-registry-lifecycle.test.ts. Both targeted and full-file current-main probes passed the timer-count case; the full baseline had a different detached-cleanup timeout. The timer-count failure remains unattributed, not claimed as main-red or fixed by the health fixture change. All remaining selected CI suites completed; no product job was cancelled.node scripts/check-changed.mjspassed its first 19 gates and stopped at the branch's unchanged UI test-root budget (722 roots versus 720). This PR adds no test files or UI roots. Current main passes that gate:471035c7b7c8ea066ed302006ab3780994d27324split the existing 218 chat tests intoui-e2e-chatwithout raising the 720 limit. This is a stale-base local check failure, not current-main red. Remaining relevant checks have separate focused proof. The final Knip production scan passes with zero entries; its full-tree scan exhausted the unchanged 600-second limit, and the script scan names the untouchedtools/solid-lint/index.mjsdefault export (already addressed on main by61621f7b594). The candidate's former unused native-error runtime export is removed. Exact-head hosted CI remains the gate; the local full-tree timeout is missing proof, not a green result. Existing native subprocess tests dominate runtime; no new test files or process/timer budgets were added. The coverage log below records the full 333-path state sweep for the 500–999-line lane threshold.Coverage log: largest-first state inventory
The sweep covered every inventoried production path; schema SQL and persisted manifests were inspect-only. Changed files are marked
simplified; retained files keep their public/persisted, integrity, destructive-effect, real-concurrency, or ordinary dispatch/type contract. Protected heartbeat files were inventoried but not edited. The authorized one-sentence database documentation correction and obsolete wrapper inventory entry are outside this source list.execution
agent storage
state database
shared workers
user state
misc
protected
Deleted config watcher is documented in the tradeoffs above. No compatibility stub retained.