Skip to content

refactor(state): remove speculative runtime bookkeeping - #168674

Merged
steipete merged 5 commits into
mainfrom
deslop/p15-state-20261010
Oct 11, 2026
Merged

steipete merged 5 commits into
mainfrom
deslop/p15-state-20261010

Conversation

@steipete

@steipete steipete commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

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

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 eb5d1a9215f5ccc8260f7be74503ada3042e5671 completed hosted run 38100826020. All selected jobs passed except checks-node-changed-compact-small-10 (114356461669) and its aggregate openclaw/ci-gate (114358633506); no product job was cancelled. The test job reports three 120-second timeouts in the unchanged session-native-binding.reclamation.test.ts, followed by an 8 GB worker heap exhaustion. All three exact timeout cases also reproduce on independently installed clean main 626eeac26d62c8ab45b09218b2216c27a9eea00d: 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.

  • Production TypeScript and the state/infra test type graphs pass. Type-aware lint passes. Runtime import cycles: 0; Madge cycles: 0. git diff --check passes.
  • The full unit-state run completed with 1,184 passed, 8 failed and 4 skipped across 143 files (1,407.66s Vitest; 1,599.51s wrapper). The full native-state run completed with 1,365 passed, 8 failed and 3 skipped across 88 files (6,228.90s Vitest). These are original-candidate results, not claimed clean runs.
  • Investigating those failures restored the real retained-cache schema-admission guard. Tests requiring completed startup inspection now explicitly use the existing nondeferred mode. The resident no-SQL fixture stops unrelated WAL maintenance before observing the read. The physical-identity fixture applies its selected synthetic timestamps to both pathname and descriptor stats. Ordinary cancellation/deletion/security tests remain; only the synthetic cleanup-after-accepted-read abort case was removed with its guard.
  • Corrected unit proof: 43 passed, 1 failed across five files (300.64s Vitest; 484.11s wrapper). The exact remaining snapshot-close marker deadline reproduced on clean current main 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 with close-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.
  • Corrected native proof: 107 passed, 1 failed across six files (725.40s Vitest). All five modified native files pass, including schema refusal, typed worker errors, completed startup inspection and physical-identity checks. The unchanged Doctor ownership test reaches its 120-second timeout. The exact case also reproduced on clean main f3af0db8fcee85e181c86876f24740f9ec928fae using node 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.
  • Gateway shared/personal publication boundaries: 13 passed across two files (404.02s Vitest). TTS preferences: 3 passed (63.23s Vitest). Session pending-input operations: 12 passed (222.06s Vitest). All three boundary shards pass, 28 tests total (847.78s wrapper).
  • The required suppression test completed (2 passed, 1 failed; 51.62s wrapper) with only the coordinator-owned improve: reduce repeated SQLite work during chat turns #168002 allowlist mismatch. No suppression was added by this PR.
  • Isolated P2 review found and resolved the avatar receipt-stage mismatch and realistic concurrent profile-preparation retry removal. The retained-worker schema-admission regression was also restored. Rejected findings and their source evidence cover duplicate deletion predicates, unsupported external startup file changes, impossible private registration failures, internal callback DDL policing, and a second TTS lookup inside synchronous host code. The actual late-worker TTS installation continues to prefer the current host publication. Review emitted a finding; this is a resolved review, not a claim of a clean automated verdict.
  • First hosted CI run 38091697654 passed 85 jobs and exposed a missed direct-caller fixture cutover in src/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.
  • The follow-up required one conflict-only rebase: main had added an exact error-identity assertion in that same test. The resolution retains the assertion. On the rebased tree all 9 health tests pass (533.72s Vitest / 591.49s wrapper), production/config types and focused lint pass, runtime and Madge cycles remain zero, and the suppression guard passes all 3 cases. The production reduction remains 814 lines.
  • That run also failed the untouched model-picker mock-isolation ratchet, fixed on main by 00e095399b2, and a global fake-timer count in subagent-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.mjs passed 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: 471035c7b7c8ea066ed302006ab3780994d27324 split the existing 218 chat tests into ui-e2e-chat without 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 untouched tools/solid-lint/index.mjs default export (already addressed on main by 61621f7b594). 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

retained src/state/openclaw-agent-execution-native.ts
retained src/state/openclaw-agent-execution-operations.ts
retained src/state/openclaw-agent-execution-incognito.ts
retained src/state/openclaw-agent-execution.worker.ts
simplified src/state/openclaw-agent-execution-owner.ts
retained src/state/openclaw-agent-execution-scope.ts
retained src/state/openclaw-agent-execution-domain.ts
retained src/state/openclaw-agent-execution-maintenance.ts
retained src/state/openclaw-agent-execution-contract.ts
retained src/state/openclaw-agent-execution-cleanup.ts
retained src/state/openclaw-agent-execution-close.ts
retained src/state/openclaw-agent-execution-incognito.worker.ts
retained src/state/openclaw-agent-execution.ts
retained src/state/openclaw-agent-execution-voice-operations.ts
retained src/state/openclaw-agent-execution-incognito-absence.ts
retained src/state/openclaw-agent-execution-admission-contract.ts
retained src/state/openclaw-agent-execution-work.ts
retained src/state/openclaw-agent-execution-cleanup.worker.ts

agent storage

retained src/state/openclaw-agent-schema.sql
retained src/state/openclaw-agent-db-validation-cache.ts
retained src/state/openclaw-agent-db-lifecycle.ts
retained src/state/openclaw-agent-db.ts
retained src/state/openclaw-agent-db-admission.ts
retained src/state/openclaw-agent-db-lease.ts
retained src/state/openclaw-agent-db-schema.ts
retained src/state/openclaw-agent-worker-store.ts
retained src/state/openclaw-agent-db-session-migrations.ts
simplified src/state/openclaw-agent-schema-inspection-worker.ts
retained src/state/openclaw-agent-db-session-nodes-migration.ts
retained src/state/openclaw-agent-db-readonly-scope.ts
retained src/state/openclaw-agent-db-schema-helpers.ts
retained src/state/openclaw-agent-db.paths.ts
retained src/state/openclaw-agent-db-resources.ts
retained src/state/openclaw-agent-db-readonly-open.ts
retained src/state/openclaw-agent-canonical-validation-schema.ts
retained src/state/openclaw-agent-db-registry.ts
retained src/state/openclaw-agent-db-disposal.ts
retained src/state/openclaw-agent-schema-inspection.ts
retained src/state/openclaw-agent-write-admission.ts
retained src/state/openclaw-agent-canonical-validation-migration.ts
retained src/state/openclaw-agent-db-maintenance.ts
retained src/state/openclaw-agent-db-maintenance-lease.ts
retained src/state/openclaw-agent-transcript-payload-migration.ts
simplified src/state/openclaw-agent-db-readonly-companion.ts
retained src/state/openclaw-agent-db-readonly.ts
simplified src/state/openclaw-agent-schema-inspection.worker.ts
retained src/state/openclaw-agent-db-identity.ts
retained src/state/openclaw-agent-standing-intents-schema.ts
retained src/state/openclaw-agent-session-snapshots-migration.ts
simplified src/state/openclaw-agent-pending-inputs-schema.ts
retained src/state/openclaw-agent-db-metadata.ts
retained src/state/openclaw-agent-board-schema.ts
retained src/state/openclaw-agent-db-validation-facts.ts
retained src/state/openclaw-agent-db-lease-provenance.ts
retained src/state/openclaw-agent-canonical-validation-receipt.ts
retained src/state/openclaw-agent-transcript-fts-schema.ts
retained src/state/openclaw-agent-db.wal.ts
retained src/state/openclaw-agent-db-schema-read.ts
retained src/state/openclaw-agent-db-path-repair.ts
retained src/state/openclaw-agent-participants-migration.ts
retained src/state/openclaw-agent-db-contract.ts
retained src/state/openclaw-agent-db-write.ts
retained src/state/openclaw-agent-db-schema-compatibility.ts
retained src/state/openclaw-agent-db-transaction.ts
retained src/state/openclaw-agent-db-terminal.ts
retained src/state/openclaw-agent-storage-schema.ts
retained src/state/openclaw-agent-db-media-migration.ts
retained src/state/openclaw-agent-db-permissions.ts
retained src/state/openclaw-agent-db-metadata-write.ts
retained src/state/openclaw-agent-db-readers.ts
retained src/state/openclaw-agent-db-read-error.ts
retained src/state/openclaw-agent-message-tool-outcome-schema.ts
retained src/state/openclaw-agent-legacy-acp-schema.ts
simplified src/state/openclaw-agent-schema-inspection-response.ts
retained src/state/openclaw-agent-db-existing-write.ts
retained src/state/openclaw-agent-db-registry.worker.ts
retained src/state/openclaw-agent-db-additive-columns.ts
retained src/state/openclaw-agent-session-sharing-schema.ts
retained src/state/openclaw-agent-db-legacy-schema.ts
retained src/state/openclaw-agent-progress-card-schema.ts
retained src/state/openclaw-agent-goal-operations-schema.ts
retained src/state/openclaw-agent-db-session-provenance.ts
retained src/state/openclaw-agent-operation-context.ts
retained src/state/openclaw-agent-session-transcript-archive-schema.ts
retained src/state/openclaw-agent-session-snapshots-schema.ts
retained src/state/openclaw-agent-context-engine-turn-outbox-schema.ts
retained src/state/openclaw-agent-write-admission-state.ts
retained src/state/openclaw-agent-db-discovery-paths.ts
retained src/state/openclaw-agent-session-participants-schema.ts
retained src/state/openclaw-agent-db-migration-required.ts
retained src/state/openclaw-agent-schema.ts

state database

retained src/state/openclaw-state-db-cache.ts
simplified src/state/openclaw-state-db-read-connection.ts
retained src/state/openclaw-state-db-async-lifecycle.ts
retained src/state/openclaw-state-db-readonly.ts
retained src/state/openclaw-state-db.ts
simplified src/state/openclaw-state-db-current-reader.ts
retained src/state/openclaw-state-db-legacy-backfills.ts
retained src/state/openclaw-state-db-table-retirements.ts
retained src/state/openclaw-state-db-repair.ts
simplified src/state/openclaw-state-db-schema-additive.ts
retained src/state/openclaw-state-db-startup-checkpoint.ts
simplified src/state/openclaw-state-db-existing-write.ts
retained src/state/openclaw-state-db-audit-migration.ts
retained src/state/openclaw-state-db-borrow.ts
retained src/state/openclaw-state-db-schema-v13-widerow.ts
retained src/state/openclaw-state-db-task-delivery-recovery.ts
retained src/state/openclaw-state-db-open.ts
retained src/state/config-machine-state-write.ts
retained src/state/openclaw-state-db-schema-v12-foldin.ts
retained src/state/openclaw-state-db-admission.ts
retained src/state/openclaw-state-db-schema-runtime.ts
retained src/state/openclaw-state-db-cache.wal.ts
retained src/state/openclaw-state-db-additive-columns.ts
retained src/state/openclaw-state-db-operator-approval-migration.ts
simplified src/state/config-machine-state.ts
retained src/state/openclaw-state-db-readonly-reuse.ts
retained src/state/openclaw-state-db-schema-policy.ts
retained src/state/openclaw-state-db.paths.ts
retained src/state/openclaw-state-db-fast-path.ts
retained src/state/openclaw-state-db-integrity-admission.ts
retained src/state/openclaw-state-db-session-watch-migration.ts
retained src/state/openclaw-state-db-existing-schema.ts
retained src/state/openclaw-state-db-schema-version.ts
retained src/state/openclaw-state-db-delivery-queue-backfill.ts
retained src/state/openclaw-state-db-doctor-schema.ts
retained src/state/openclaw-state-db-handle.ts
retained src/state/openclaw-state-db-cache.idle.ts
retained src/state/openclaw-state-db-cache.admission.ts
retained src/state/openclaw-state-db-schema-helpers.ts
retained src/state/openclaw-state-db-initialization.ts
retained src/state/openclaw-state-db-permissions.ts
retained src/state/openclaw-state-db-read-schema.ts
retained src/state/openclaw-state-db-transaction.ts
retained src/state/openclaw-state-db-schema-migration-required.ts
retained src/state/openclaw-state-db-failure.ts
retained src/state/openclaw-state-db-snapshot-owner.ts
retained src/state/openclaw-state-db-schema-discovery.ts
retained src/state/openclaw-state-db-cache.types.ts
retained src/state/openclaw-state-db-content-version.ts
retained src/state/openclaw-state-db-cron-delivery-migration.ts

shared workers

simplified src/state/openclaw-state-worker-owner.ts
retained src/state/openclaw-state-read.types.ts
retained src/state/openclaw-state-lease.ts
retained src/state/openclaw-state-read.worker.ts
retained src/state/openclaw-state-lease-heartbeat.ts
simplified src/state/openclaw-state-lease-worker-owner.ts
retained src/state/openclaw-state-read-worker.ts
simplified src/state/openclaw-state-read-operation.ts
retained src/state/openclaw-state-worker-error-identity.ts
simplified src/state/openclaw-state-worker-error.ts
retained src/state/openclaw-state-ownership.ts
retained src/state/openclaw-state-lease-heartbeat.worker.ts
retained src/state/openclaw-state-worker-lease.ts
retained src/state/openclaw-state-lease-worker-storage.ts
retained src/state/openclaw-state-worker-contract.ts
retained src/state/openclaw-state-worker-runtime.ts
retained src/state/openclaw-state-lease-worker.ts
retained src/state/openclaw-state-worker-registry.ts
retained src/state/openclaw-state-lease-store.ts
retained src/state/openclaw-state-lease-storage.ts
simplified src/state/openclaw-state-ownership-operations.ts
retained src/state/openclaw-state-lease-acquisition.ts
retained src/state/openclaw-state-read-scope.ts
retained src/state/openclaw-state-worker-store.ts
retained src/state/openclaw-state-worker-operation.ts
retained src/state/openclaw-state-worker-context.ts
retained src/state/openclaw-state-worker-context.capture.ts
retained src/state/worker-operation-registry.ts
retained src/state/openclaw-state-lease-options.ts
retained src/state/openclaw-state-lease-cleanup.ts
retained src/state/openclaw-state-lease-error.ts
retained src/state/openclaw-state-read-registry.ts
simplified src/state/openclaw-state-lease-heartbeat-cleanup.ts
retained src/state/openclaw-state-read-diagnostics.ts
retained src/state/openclaw-state-lease-heartbeat-shared.ts
retained src/state/openclaw-state-lease-worker-operation.ts
retained src/state/openclaw-state-ownership-worker.ts
retained src/state/openclaw-state-lease-context.ts
retained src/state/openclaw-state-read-session-rows.worker.ts
simplified src/state/openclaw-state-worker-store.types.ts
retained src/state/openclaw-state-lease-process-exit.ts
retained src/state/openclaw-state-read-mcp-oauth.ts
retained src/state/openclaw-state-read-stream.ts
retained src/state/openclaw-state-ownership.worker.ts
retained src/state/openclaw-state-worker-memory-pressure.ts
retained src/state/openclaw-state-worker-context.types.ts
retained src/state/openclaw-state-lease.types.ts

user state

retained src/state/user-model-accounts.ts
simplified src/state/user-profile-list.ts
retained src/state/user-profile-github-identity.ts
retained src/state/user-profile-writes.worker.ts
retained src/state/user-profiles-internal.ts
retained src/state/user-channel-identities.ts
retained src/state/user-profile-events.ts
retained src/state/user-profile-identity.read.ts
simplified src/state/session-repository-workspaces.ts
simplified src/state/user-profiles-avatar.ts
retained src/state/user-github-connections.ts
retained src/state/user-channel-identity-operations.ts
retained src/state/user-profiles.ts
simplified src/state/github-publication-receipts.ts
simplified src/state/user-profiles.worker.ts
simplified src/state/user-profile-writes.ts
retained src/state/github-personal-publication-lifecycle.ts
retained src/state/user-model-account-operations.ts
retained src/state/user-preferences.store.ts
retained src/state/session-repository-workspaces.kernel.ts
retained src/state/user-profile-catalog-identity.read.ts
retained src/state/user-profiles-schema.ts
retained src/state/session-repository-workspaces.publication.ts
simplified src/state/user-background.ts
retained src/state/onboarding-recommendations.kernel.ts
simplified src/state/user-preferences.ts
retained src/state/local-onboarding-state.ts
retained src/state/user-profiles.types.ts
retained src/state/user-background.kernel.ts
retained src/state/user-profiles-owner-migration.ts
retained src/state/user-channel-identities.worker.ts
retained src/state/user-profiles-tailscale-migration.ts
retained src/state/user-background.store.ts
retained src/state/user-profiles-owner.ts
retained src/state/user-profiles-merge.ts
retained src/state/user-profile-mutation.ts
retained src/state/github-publication-requester.ts
retained src/state/onboarding-recommendations.contract.ts
retained src/state/session-repository-workspaces.worker.ts
retained src/state/onboarding-recommendations.ts
retained src/state/user-background-image.ts
retained src/state/user-preferences-publication.ts
retained src/state/user-preferences.worker.ts
retained src/state/user-preferences.validation.ts
retained src/state/user-profile-reads.ts
retained src/state/github-publication-session-lifecycles.ts
retained src/state/user-profile-read.worker.ts
retained src/state/github-publication-read.types.ts
retained src/state/user-model-accounts.read.worker.ts
retained src/state/user-profiles-tailscale-avatar.ts
retained src/state/user-profile-email.kernel.ts
retained src/state/user-profiles-avatar.types.ts
retained src/state/session-repository-workspaces.types.ts
retained src/state/user-preferences.types.ts
retained src/state/user-profile-email.ts
retained src/state/session-repository-workspaces.receipts.ts
retained src/state/user-profiles-tailscale-login.ts
retained src/state/user-background.worker.ts
retained src/state/user-background.types.ts
retained src/state/user-model-account-id.ts
retained src/state/user-profile-display-validation.ts
retained src/state/session-repository-workspaces.worker-contract.ts

misc

retained src/state/openclaw-state-schema.sql
retained src/state/openclaw-quarantine-store.ts
retained src/state/openclaw-migration-witness.ts
simplified src/state/agent-database-startup.ts
simplified src/state/agent-deletion-journal.ts
retained src/state/openclaw-database-preflight.ts
simplified src/state/openclaw-state.worker.ts
retained src/state/agent-database-admission.ts
retained src/state/agent-deletion.worker.ts
retained src/state/agent-deletion-cleanup.ts
retained src/state/openclaw-database-verify.impl.ts
retained src/state/agent-deletion-journal.read.ts
simplified src/state/state-domain-publication.ts
retained src/state/agent-creation-claim.ts
retained src/state/openclaw-schema-retirements.json
retained src/state/openclaw-database-verify.ts
retained src/state/agent-deletion-discovery.ts
retained src/state/openclaw-state-maintenance-context.ts
simplified src/state/openclaw-state-settlement-read.ts
retained src/state/openclaw-database-preflight-agent-scheduler.ts
retained src/state/openclaw-state-schema-preflight.ts
retained src/state/openclaw-database-preflight-targets.ts
retained src/state/openclaw-state-schema-compatibility.ts
retained src/state/openclaw-database-verify.worker.ts
simplified src/state/agent-deletion-cleanup.worker.ts
retained src/state/backup-run-records.ts
retained src/state/agent-deletion-final-guard.ts
retained src/state/agent-deletion-journal-recovery.ts
retained src/state/openclaw-database-preflight-state-path.ts
retained src/state/backup-run-records.contract.ts
retained src/state/openclaw-state-schema-publication.ts
simplified src/state/openclaw-database-preflight.types.ts
retained src/state/agent-deletion-journal-recovery.kernel.ts
retained src/state/agent-provenance.kernel.ts
retained src/state/openclaw-database-preflight.messages.ts
retained src/state/claw-package-lifecycle-lease.ts
retained src/state/openclaw-database-preflight-contexts.ts
retained src/state/agent-provenance.ts
retained src/state/agent-lifecycle-read.kernel.ts
retained src/state/openclaw-state-snapshot-sanitizer.ts
retained src/state/artifact-preserving-state-reads.ts
retained src/state/backup-run-records.kernel.ts
retained src/state/openclaw-update-schema-refusal.ts
retained src/state/incognito-session-error.ts
retained src/state/openclaw-state-schema-inspection.ts
retained src/state/claw-package-adoption.ts
retained src/state/openclaw-schema-versions.ts
retained src/state/agent-deletion-cleanup-admission.ts
retained src/state/openclaw-database-preflight-cleanup.ts
retained src/state/openclaw-state-feature-schema.ts
retained src/state/agent-deletion-recovery.worker.ts
retained src/state/agent-deletion-journal.snapshot.worker.ts
retained src/state/agent-deletion-journal-history.ts
retained src/state/claw-mcp-adoption.ts
retained src/state/secret-state-tables.ts
retained src/state/agent-deletion-journal-authority.worker.ts
retained src/state/agent-deletion-journal-transport.ts
retained src/state/agent-deletion-worker.types.ts
retained src/state/agent-deletion-recovery.ts
retained src/state/creator-namespace-migration.ts
retained src/state/agent-database-admission-error.ts
retained src/state/openclaw-quarantine-error.ts
retained src/state/agent-database-path-discovery.ts
retained src/state/agent-database-preparation-context.ts
retained src/state/agent-deletion-recovery.read-contract.ts
retained src/state/agent-deletion-worker-contract.ts
retained src/state/claw-package-lifecycle-lease-key.ts
retained src/state/session-metadata-unavailable-error.ts
retained src/state/agent-deletion-cleanup.types.ts
retained src/state/openclaw-database-schema-contracts.ts
retained src/state/agent-provenance.types.ts
retained src/state/openclaw-state-schema.ts
retained src/state/session-watch-cursor-provenance.ts
retained src/state/agent-provenance.schema.ts

protected

protected src/state/openclaw-agent-db-registry-listing.ts
protected src/state/openclaw-state-read-request.ts
protected src/state/openclaw-state-db-maintenance.ts
protected src/state/openclaw-state-read.validation.ts
protected src/state/openclaw-state-db-schema-repair.ts
protected src/state/openclaw-state-db-contract.ts
protected src/state/openclaw-state-read-operation-registry.ts
protected src/state/openclaw-agent-db-registry.read.ts
protected src/state/agent-deletion-journal.types.ts

Deleted config watcher is documented in the tradeoffs above. No compatibility stub retained.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation scripts Repository scripts size: XL labels Oct 10, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: Configuration publication immediately starts retiring the old executor.
  • After: New requests use current routing, while the old executor expires through the existing 30-minute timeout, LRU eviction, or shutdown.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The coherent refactor has meaningful boundary-test support and no identified defect, with confidence limited to the supplied harness evidence.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; state-worker tests support the changed owners, while the inspected historical screenshots do not prove this head’s shipped runtime behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes · Fix scope: Complete
Reason: The maintainer’s direction accepts the documented tradeoffs, and the change reduces duplicate ownership while retaining the central storage contracts.

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
Reviewed head: eb5d1a9215f5ccc8260f7be74503ada3042e5671

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not demonstrate this refactor through a shipped Gateway scenario.
Agent review details

How this fits together

Gateway 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
Loading

Technical review

Best 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

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

  • Introduced changes and merge composition: Read the pinned merge-base-to-head production and test hunks; the verified test merge retains the reader, schema, and health-fixture changes against fetched main. (eb5d1a9215f5)
  • Accepted direction: The maintainer-authored body explicitly accepts normal executor expiry, native transaction sequencing, and completed-read acceptance without cleanup-time readmission; these choices require no renewed product decision. (eb5d1a9215f5)
  • Retained live lease authority: Every grant still checks current authority, exact lease identities, and applicable expiry; commit admission repeats the authority and expiry checks after the caller callback. (src/state/openclaw-state-lease-worker-owner.ts:134, eb5d1a9215f5)
  • Avatar receipt cutover: Avatar adoption validates canonical transaction and commit facts and reconciles confirmed native receipts after ordinary reply loss; the changed test runs the real worker and injects failure after its result. (src/state/user-profiles-avatar.ts:321, eb5d1a9215f5)
  • Verified no-migration case: The pending-input and completion installers still select the existing canonical table definitions, pending-input index, and consumed_event_id repair; repository-workspace column installation remains, with no changed persisted schema declaration or version. (src/state/openclaw-agent-pending-inputs-schema.ts:32, eb5d1a9215f5)
  • Historical media attribution: Inspected all four prepared screenshots and verified that their attachment URLs belong to fix: retain accepted browser follow-ups across restarts #133457, where they demonstrate browser-input collection and restart recovery. (5f0aa4f7c568)

Likely related people:

  • Vincent Koc: Raw commit a442673 adds src/state/user-profile-list.ts:33 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: a442673ebe4a; files: src/state/user-profile-list.ts)

PR surface

Source -814, Tests -1191, Docs 0, Other -1. Total -2006 across 57 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 35 211 1025 -814
Tests 20 443 1634 -1191
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 57 655 2661 -2006

Review metrics

Metric Value Why it matters
Production versus test LOC Production +211/-1025; tests +443/-1634 The reduction removes duplicate runtime owners and their obsolete tests while retaining focused state-boundary coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is an internal ownership cleanup without an established urgent user-facing regression.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-10T22:28:29.611Z sha b9bb91a6c0a9d36cb3d82e195e24c7b939f1eef6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T22:36:00.755Z sha b9bb91a6c0a9d36cb3d82e195e24c7b939f1eef6 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-10T22:53:31.385Z sha b9bb91a6c0a9d36cb3d82e195e24c7b939f1eef6 :: needs maintainer review before merge. :: none

Reviewed October 10, 2026, 9:16 PM ET / October 11, 2026, 01:16 UTC (Revision 4).

@steipete
steipete marked this pull request as ready for review October 10, 2026 22:30
@steipete
steipete force-pushed the deslop/p15-state-20261010 branch from b9bb91a to eb5d1a9 Compare October 11, 2026 01:08
@steipete

steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Exact-head CI attribution

Reviewed head: eb5d1a9215f5ccc8260f7be74503ada3042e5671.
Hosted run: 38100826020, attempt 1. The complete exact-head check-run census contains two failures and no cancelled jobs. All other selected product checks, including production/test types, lint, architecture guards, builds, security, and the repaired config-health shard, passed.

  • 114356461669, checks-node-changed-compact-small-10: inherited native-reclamation failure. Its runtime-config group reports the following three tests in the unchanged src/config/sessions/session-native-binding.reclamation.test.ts, each at the unchanged 120-second timeout:
    • settles typed reset and native reclamation without replacing a successor (false)
    • settles typed reset and native reclamation without replacing a successor (true)
    • reclaims lifecycle artifacts with the native veto off the caller thread
      All three reproduce on independently installed clean main 626eeac26d62c8ab45b09218b2216c27a9eea00d (120011ms, 120001ms, and 120006ms respectively) using node scripts/run-vitest.mjs src/config/sessions/session-native-binding.reclamation.test.ts --reporter=verbose. The test file is byte-identical between that baseline and this head (SHA-256 97a344deb7d17b8a853685dbd5b3e61476101d1773cc1e52a4d4b1625b4413c8). The baseline additionally times out the maintenance changed: false case and passes the other three cases. The failing test, fixture, native-binding implementation, and plugin codec were not changed by this PR. A focused candidate probe reproduces the two reset timeouts (627.39s Vitest / 660.21s wrapper). Temporary diagnostics, removed afterward, confirm native kernel and codec preparation finish; no differential failure caused by the committed-reader cutover was identified.
      CI also exhausts the worker's 8 GB heap after those three timeouts. The local baseline does not reproduce that exact heap-exhaustion event; after reporting all seven cases, its teardown stalled for more than twelve minutes and the task-owned invocation was intentionally terminated. This is not a natural full-suite completion. All of its child processes are confirmed stopped. The underlying native-settlement stall and CI's eventual OOM cause are unresolved, and this evidence does not claim otherwise. No timeout, retry, skip, or assertion was weakened.
  • 114358633506, openclaw/ci-gate: aggregate failure caused by the test job above; not an independent product failure.

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.

@steipete
steipete merged commit e2689b0 into main Oct 11, 2026
176 of 179 checks passed
@steipete
steipete deleted the deslop/p15-state-20261010 branch October 11, 2026 02:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
)

* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts 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