Repository navigation
fix(state): isolate deletion claims from unrelated journal changes - #170309
Conversation
Read current deletion identity and path ownership once in the claim transaction instead of rejecting every change to an earlier journal snapshot. Preserve bootstrap target paths, cleanup authority, tombstones and draining settlement. Cover unrelated deletion progress at the registration boundary alongside current identity and path conflicts. Source review and targeted static checks pass; runtime qualification is pending with the campaign test owner.
The deletion owner has bounded same-agent lease contention to five seconds since a620ab6. Concurrent RPC coverage added in b1cadee assumed the winning cleanup always finished inside that budget. V14 returned one successful deletion and one target-specific OPENCLAW_STATE_LEASE_HELD, an existing allowed outcome. Require exactly one successful deletion. Accept only the exact missing-agent response or the target-specific lease-held Gateway client error for its competitor, and verify that the completed deletion is absent from published runtime config. Preserve production behavior, deadlines, and concurrent coverage.
Carry the original absent-store witness through session patch settlement and await its release. Allow a retained ordinary owner to initialize that same still-absent target. Prepare existing usage writers before scan dispatch so pruning cannot wait on a foreground writer that needs the scan's admission. Preserve physical-file, pending-open, cancellation, and write-authority guards. Missing usage stores stay lazy until a real write. Cover first replacement and upsert through both retained-owner forms, plus concurrent existing-store pruning. Retained composition CI passed all five target files (52 cases). Reuse the scoped-clean source reviews and preserve main's newer preparation-execution helper. Basic formatting, six-file lint, and whitespace checks passed. Current-main causal and final static qualification remain separately recorded.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR checks current deletion identity and path ownership during database claims instead of rejecting unrelated journal changes. Example: Register survivor.sqlite while deletion of agent deleted begins after claim preparation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it repairs a concrete false refusal still present on main, and no actionable introduced defect was identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherAgent database registration, lease admission, and independent schema preparation consult the shared deletion journal before admitting persistent work. flowchart TD
A[Agent database open] --> B[Prepare claim paths]
B --> C[Shared state transaction]
D[Current deletion journal] --> C
C --> E[Identity and path checks]
E --> F[Registration or lease]
F --> G[Agent database]
Technical reviewBest possible solution: Evaluate current deletion ownership in the existing claim transaction while preserving identity, path, cleanup, and settlement protections. Do we have a high-confidence way to reproduce the issue? Main's journal comparison deterministically rejects an unrelated pending deletion introduced between preparation and registration; the new fixture exercises that sequence, but this read-only review executed no target code. Is this the best way to solve the issue? The change fixes the overbroad refusal at its existing transaction owner and removes redundant preparation without introducing a competing admission path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 81e2765b2658. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource -39, Tests +21. Total -18 across 6 files. Added test files: 0. View PR surface stats
LabelsLabel 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 (4 earlier review cycles)
Reviewed October 12, 2026, 8:27 PM ET / October 13, 2026, 00:27 UTC (Revision 5). |
# Conflicts: # src/state/openclaw-agent-execution.creation-witness.test.ts
…penclaw#170309) ## What Problem This Solves Database registration could fail when an unrelated agent deletion changed the journal after claim preparation. The claim compared the whole prepared journal with current rows, rejecting harmless progress even when the claimed identity and paths did not overlap. Check current deletion ownership inside the existing claim transaction. Remove the preparatory journal read, whole-journal equality check and tests that only pinned that check. Lease and registration owners pass their claimed path into state initialization. Current identity, canonical database/WAL paths, cleanup authority, recreation and draining-settlement protections remain. Accepted edge: another deletion may begin or advance after preparation; it blocks the claim only when its current identity or paths overlap. The initialization fixture expects the existing deleted-agent identity error while still requiring refusal before mutation, zero registrations, unchanged schema/version and byte-identical external data. The readiness fixture recognizes the existing five-second competing-deletion wait. Exactly one deletion must succeed; the loser must receive either the target's missing-agent `INVALID_REQUEST` or a typed `UNAVAILABLE` with that target's lease diagnostic and `OPENCLAW_STATE_LEASE_HELD`. The target must disappear from published config after settlement. Accepted edge: the loser can exhaust that existing wait while the winner finishes cleanup. No production deadline changes. The journal refusal originated in `ef196de2fc32663008893b38877ac9672abde03e`; the duplicate-deletion fixture in `4e16a5ba99bbc9666f8c879405db065c1279835b`; the bounded-wait contract in `b24ecd1ba02f5f9611d318821fba8e5b4278a6f3`. ## Evidence Integrated HEAD: `72ac96fc119e4a2d1c31514b057ad892427058df`. Integrated MAIN: `a4bd85e2ec974228d49631e98ddf22113e58ed1e`. The integration was conflict-free. Verified residual: **six files, +93/−111**. Five postimages match reviewed deletion head `ce94ba3922324e3c6169b0472fe6021503cd0cf1`. The lease combines its original one-line initialization-path change with main's independent `dda87805565a1f6a8863961c49b0fd84a29679f0` cleanup optimization; verified blob `71b3c9900f2870420b7b43ed8c97a956a948d7d8`. That optimization and its updated quarantine API are preserved. Dependency openclaw#170308 landed as `22d374c75814dcce24a5e6e9ef61aca992900ccf`; its five files leave this PR's diff. The three source patches (`84104fda0d9aaca059be54d8b6194ed1ef105759`, `1d1fa686923031f262d3597c6f17bcc6493d6477`, `58bd5ad19620164a5732ab3cd6b732dbd7ad998a`) each passed focused formatting/lint, normal hooks and isolated Codex review. Source qualification is separate from execution: the results below belong to logical head `8058068d6c308a9ceae9de52c5eae8d509a65522`, not the new integration. [Ordinary CI](https://github.com/openclaw/openclaw/actions/runs/38321551491) completed **51 successful / 26 skipped jobs**, testing merge checkout `7a7da8312795381bd8f08c024ca090ba574d96de` against main `feb893ca13908081c27230530cc88c59ac7c0158`. All six then-changed test files passed, **75 cases**: readiness 1, initialization 13, fence 10, usage admission 18, creation witness 29 and environment capture 4. Readiness took 25.362 seconds; its Vitest invocation took 40.14 seconds. [Agents-delete integration](https://github.com/openclaw/openclaw/actions/runs/38321551491/job/115050900729) passed **3/3**, covering active deletion and both recovery paths, in a 65.90-second invocation. These combined-input passes do not isolate either repair's contribution or explain every historical timeout. [Full-tier graph CI](https://github.com/openclaw/openclaw/actions/runs/38322093813) completed **78 successful / 7 failed / 18 skipped jobs**: six failed leaves plus aggregate. All selected statics completed. Build, production/test types, lint, contracts, boundaries, ratchets and architecture passed; Madge found zero cycles and Kysely guardrails passed. The only failed static was Knip: the same UI rules/files and identical named source/config/scanner blobs failed [scheduled main](https://github.com/openclaw/openclaw/actions/runs/38322669274/job/115054342044). That inherited failure was separately fixed on main in `61edf`; it is not a retroactive Knip pass for 8058068. Runtime dispositions remain explicit: - Registry recovery failed with SQLite BUSY at `BEGIN IMMEDIATE`. The fixture omitted shared-owner shutdown before offline registry mutation. openclaw#170427 corrects that lifecycle; its [target](https://github.com/openclaw/openclaw/actions/runs/38325835343/job/115064541796) passed **14/14**, including durable-lineage re-registration, in 33.01 seconds. It landed as `63201335d1d8ed0b382d9d8c956c7220de680295`; the original lock holder remains unproven. - Recreation cleanup masked an earlier failure with `worker task pool closed`. openclaw#170435 preserves the initiating error and landed as `5c5c206636177d005f11744b1ac037988cb08279` after both cases passed. The historical initiating failure remains unresolved. - Three cloud-startup assertions matched scheduled main with identical test source. openclaw#170436 addresses that separate failure and landed as `9678fba25e0a3ca4d41456a16fa6469b85008070` after all eight changed-file cases passed. - Collaborator-scroll failed its initial bottom poll, distinct from scheduled main's later assertion. Three QA-lab cases timed out at 180 seconds: PowerPoint replay, delegation approval and host-command state. Their scheduled counterpart passed; uploaded summaries omit initiating Gateway logs. These remain unclassified. Both config-patch large-shrink cases remain a candidate execution gap. Pre-repair scheduled main `3272d64317f9c3020301f0a9718b92a5f038f054` failed both through request/cleanup timeouts and lingering plugin shutdown. That proves earlier main failure, not a repaired-head pass or cause. Under relaxed landing v4, investigated unknowns remain explicit follow-ups unless evidence establishes a product regression; they are not relabeled inherited or infrastructure. Final integrated-head qualification is recorded below. No aggregate-green, measured SQL/request/T1 savings or new SQL/T1 path is claimed. No schema, durability, retention, permission or public API change. The published-driver update cell is not triggered: this changes bookkeeping within an existing claim transaction, not update, Doctor, migrations/schema, plugin loading or service-manager lifecycle. ### Current integrated-head qualification [CI 38326701752](https://github.com/openclaw/openclaw/actions/runs/38326701752) passed at logical head `72ac96fc119e4a2d1c31514b057ad892427058df`: 47 successful and 26 skipped jobs. Its actual merge checkout was `10ce3566fd8c4ea2d625443a117c187ee73e7c6b`, integrating main `85fa0260f57b97bcebba146f724455f1e5aff03b`. All three edited test files passed: readiness 1/1 (29.971 seconds), deletion fence 10/10, and initialization 13/13; the real agents-delete integration also passed 3/3. Build, selected production/test types, type-aware lint, source contracts, boundaries and baseline ratchets passed. This run is green; the older combined-run limitations above remain historical evidence. Static qualification for logical head `72ac96fc119e4a2d1c31514b057ad892427058df`: [ordinary CI 38326701752](https://github.com/openclaw/openclaw/actions/runs/38326701752) completed **47 successful / 26 skipped jobs**, including build, production/test types, lint, contracts and boundaries. Its [baseline-ratchet job](https://github.com/openclaw/openclaw/actions/runs/38326701752/job/115067248326) passed; that job unconditionally runs both `check:database-worker-ratchet` and `check:database-dialect-ratchet` under `set -euo pipefail`, so both gates apply and have current-head CI evidence. No numeric T1 or warmed-turn savings are claimed. Madge and Knip were not selected in this ordinary run. Prior [full-tier architecture proof](https://github.com/openclaw/openclaw/actions/runs/38322093813/job/115052830964) found zero Madge cycles. Source comparison supports reusing that proof for this deletion change: its six-file import/export changes are identical to the tested 8058068 candidate, and the sole changed postimage preserves main's independent lease cleanup without changing imports or exports. This is scoped proof reuse, not a fresh whole-repository Madge pass. Prior Knip failed only on source-qualified inherited UI findings; their separate fix `ab7c19fc6d8f2945864812de80b1b70ecee11fa4` is included in final ancestry. No fresh or retroactive Knip pass is claimed. These static qualifications do not erase the recorded prior runtime failures, remaining config-patch candidate gap, or unclassified QA/collaborator-scroll observations; exact new-head target extraction is recorded separately.
What Problem This Solves
Database registration could fail when an unrelated agent deletion changed the journal after claim preparation. The claim compared the whole prepared journal with current rows, rejecting harmless progress even when the claimed identity and paths did not overlap.
Check current deletion ownership inside the existing claim transaction. Remove the preparatory journal read, whole-journal equality check and tests that only pinned that check. Lease and registration owners pass their claimed path into state initialization. Current identity, canonical database/WAL paths, cleanup authority, recreation and draining-settlement protections remain.
Accepted edge: another deletion may begin or advance after preparation; it blocks the claim only when its current identity or paths overlap. The initialization fixture expects the existing deleted-agent identity error while still requiring refusal before mutation, zero registrations, unchanged schema/version and byte-identical external data.
The readiness fixture recognizes the existing five-second competing-deletion wait. Exactly one deletion must succeed; the loser must receive either the target's missing-agent
INVALID_REQUESTor a typedUNAVAILABLEwith that target's lease diagnostic andOPENCLAW_STATE_LEASE_HELD. The target must disappear from published config after settlement. Accepted edge: the loser can exhaust that existing wait while the winner finishes cleanup. No production deadline changes.The journal refusal originated in
8a5b4af660748aef0c95c47e21be52375b00482c; the duplicate-deletion fixture inb1cadeefe0b6fb2f6157ddcfedcb2447041e7fbe; the bounded-wait contract ina620ab692463e0ade44db3745ea3da9ab01e0f90.Evidence
Integrated HEAD:
72ac96fc119e4a2d1c31514b057ad892427058df. Integrated MAIN:4ca02f6c720e6346a0d57b158cc38484fdf5c8da. The integration was conflict-free.Verified residual: six files, +93/−111. Five postimages match reviewed deletion head
ce94ba3922324e3c6169b0472fe6021503cd0cf1. The lease combines its original one-line initialization-path change with main's independenta8f00d61f689ef68e7254b1df0e6c7d01a31ac3acleanup optimization; verified blob71b3c9900f2870420b7b43ed8c97a956a948d7d8. That optimization and its updated quarantine API are preserved. Dependency #170308 landed ase4f463159d0ae54c4858bf2ab22ba79600fe23cb; its five files leave this PR's diff.The three source patches (
84104fda0d9aaca059be54d8b6194ed1ef105759,1d1fa686923031f262d3597c6f17bcc6493d6477,58bd5ad19620164a5732ab3cd6b732dbd7ad998a) each passed focused formatting/lint, normal hooks and isolated Codex review. Source qualification is separate from execution: the results below belong to logical head8058068d6c308a9ceae9de52c5eae8d509a65522, not the new integration.Ordinary CI completed 51 successful / 26 skipped jobs, testing merge checkout
7a7da8312795381bd8f08c024ca090ba574d96deagainst main6315f8adc18ab275a4c933c497113a65bc3f783b. All six then-changed test files passed, 75 cases: readiness 1, initialization 13, fence 10, usage admission 18, creation witness 29 and environment capture 4. Readiness took 25.362 seconds; its Vitest invocation took 40.14 seconds. Agents-delete integration passed 3/3, covering active deletion and both recovery paths, in a 65.90-second invocation. These combined-input passes do not isolate either repair's contribution or explain every historical timeout.Full-tier graph CI completed 78 successful / 7 failed / 18 skipped jobs: six failed leaves plus aggregate. All selected statics completed. Build, production/test types, lint, contracts, boundaries, ratchets and architecture passed; Madge found zero cycles and Kysely guardrails passed. The only failed static was Knip: the same UI rules/files and identical named source/config/scanner blobs failed scheduled main. That inherited failure was separately fixed on main in
61edf; it is not a retroactive Knip pass for 8058068.Runtime dispositions remain explicit:
BEGIN IMMEDIATE. The fixture omitted shared-owner shutdown before offline registry mutation. test(sessions): drain shared state before offline registry recovery #170427 corrects that lifecycle; its target passed 14/14, including durable-lineage re-registration, in 33.01 seconds. It landed as9c3cd35208b2abe21da17f04c4f1afc6fdddc749; the original lock holder remains unproven.worker task pool closed. test(gateway): preserve primary database recreation failures #170435 preserves the initiating error and landed as5da455d1ca0f102a68812dfa7a11174e6a3890c8after both cases passed. The historical initiating failure remains unresolved.bac32528c89133383bcd8c31a397ae76c00b3953after all eight changed-file cases passed.Both config-patch large-shrink cases remain a candidate execution gap. Pre-repair scheduled main
96db2f6dfa4f47fd579a6d8408011950b8af53e1failed both through request/cleanup timeouts and lingering plugin shutdown. That proves earlier main failure, not a repaired-head pass or cause.Under relaxed landing v4, investigated unknowns remain explicit follow-ups unless evidence establishes a product regression; they are not relabeled inherited or infrastructure. Final integrated-head qualification is recorded below. No aggregate-green, measured SQL/request/T1 savings or new SQL/T1 path is claimed.
No schema, durability, retention, permission or public API change. The published-driver update cell is not triggered: this changes bookkeeping within an existing claim transaction, not update, Doctor, migrations/schema, plugin loading or service-manager lifecycle.
Current integrated-head qualification
CI 38326701752 passed at logical head
72ac96fc119e4a2d1c31514b057ad892427058df: 47 successful and 26 skipped jobs. Its actual merge checkout was10ce3566fd8c4ea2d625443a117c187ee73e7c6b, integrating mainf68922d432000e0907d7788aa586948d9329d1c7. All three edited test files passed: readiness 1/1 (29.971 seconds), deletion fence 10/10, and initialization 13/13; the real agents-delete integration also passed 3/3. Build, selected production/test types, type-aware lint, source contracts, boundaries and baseline ratchets passed. This run is green; the older combined-run limitations above remain historical evidence.Static qualification for logical head
72ac96fc119e4a2d1c31514b057ad892427058df: ordinary CI 38326701752 completed 47 successful / 26 skipped jobs, including build, production/test types, lint, contracts and boundaries. Its baseline-ratchet job passed; that job unconditionally runs bothcheck:database-worker-ratchetandcheck:database-dialect-ratchetunderset -euo pipefail, so both gates apply and have current-head CI evidence. No numeric T1 or warmed-turn savings are claimed. Madge and Knip were not selected in this ordinary run. Prior full-tier architecture proof found zero Madge cycles. Source comparison supports reusing that proof for this deletion change: its six-file import/export changes are identical to the tested 8058068 candidate, and the sole changed postimage preserves main's independent lease cleanup without changing imports or exports. This is scoped proof reuse, not a fresh whole-repository Madge pass. Prior Knip failed only on source-qualified inherited UI findings; their separate fix61edf206c15d201e857e6bf8419b30ff4dd1673fis included in final ancestry. No fresh or retroactive Knip pass is claimed. These static qualifications do not erase the recorded prior runtime failures, remaining config-patch candidate gap, or unclassified QA/collaborator-scroll observations; exact new-head target extraction is recorded separately.