Repository navigation
test(gateway): preserve primary database recreation failures - #170435
Conversation
|
🦞👀 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 settles a pending database read before closing its worker pool so cleanup preserves an earlier test failure. Example: The agents.delete assertion fails before the paused database read is released.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR makes a focused, correct test-cleanup repair that current main still needs; no actionable patch defects were found. Priority: P3 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe Gateway integration test sends agent lifecycle RPCs and uses a real worker-backed database reader to verify deletion and recreation; its cleanup must release that reader without replacing the test’s diagnostic result. flowchart TD
A[Gateway integration test] --> B[Agent lifecycle RPCs]
A --> C[Paused database read]
B --> D[Lifecycle assertions]
D --> E[Release and settle read]
C --> E
E --> F[Close worker pool]
Technical reviewBest possible solution: Settle the released read before pool closure while retaining every successful-path assertion. Do we have a high-confidence way to reproduce the issue? Source establishes the masking path: an early assertion failure enters finally, pool closure rejects the unfinished ordinary read, and the subsequent await replaces the earlier error; no local execution was performed. Is this the best way to solve the issue? The ordering repair is appropriately narrow, and the cleanup-only catch cannot hide a read failure on the successful path because the body already awaits and asserts that read. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4ca02f6c720e. Provenance checked
TestingProof path: none. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +1. Total +1 across 1 file. 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 Reviewed October 12, 2026, 8:20 PM ET / October 13, 2026, 00:20 UTC. |
…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 `8a5b4af660748aef0c95c47e21be52375b00482c`; the duplicate-deletion fixture in `b1cadeefe0b6fb2f6157ddcfedcb2447041e7fbe`; the bounded-wait contract in `a620ab692463e0ade44db3745ea3da9ab01e0f90`. ## 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 independent `a8f00d61f689ef68e7254b1df0e6c7d01a31ac3a` cleanup optimization; verified blob `71b3c9900f2870420b7b43ed8c97a956a948d7d8`. That optimization and its updated quarantine API are preserved. Dependency #170308 landed as `e4f463159d0ae54c4858bf2ab22ba79600fe23cb`; 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 `6315f8adc18ab275a4c933c497113a65bc3f783b`. 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. #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 `9c3cd35208b2abe21da17f04c4f1afc6fdddc749`; the original lock holder remains unproven. - Recreation cleanup masked an earlier failure with `worker task pool closed`. #170435 preserves the initiating error and landed as `5da455d1ca0f102a68812dfa7a11174e6a3890c8` after both cases passed. The historical initiating failure remains unresolved. - Three cloud-startup assertions matched scheduled main with identical test source. #170436 addresses that separate failure and landed as `bac32528c89133383bcd8c31a397ae76c00b3953` 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 `96db2f6dfa4f47fd579a6d8408011950b8af53e1` 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 `f68922d432000e0907d7788aa586948d9329d1c7`. 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 `61edf206c15d201e857e6bf8419b30ff4dd1673f` 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.
…w#170435) Release and settle the pending fixture read before pool cleanup, preserving earlier errors. Both recreation tests and selected CI checks pass. The initiating historical error was not reproduced and remains unknown.
…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
The agent-database recreation proof could replace an earlier assertion failure with
worker task pool closed: itsfinallyblock closed a pending ordinary read before awaiting it. Release and settle that read before closing the pool, and preserve the original failure. The successful body already awaits and asserts the same read result.The masking pattern originated in 40d284f (#159013). Run 38322093813, job 115052831765, reported the cleanup error; its external-state-directory sibling passed. The initiating error is not visible in that log and remains unresolved until corrected-fixture execution. No timeout, retry, production path, or assertion is removed.
Evidence
Test-only change: +2/-1 lines. No schema, SQL/T1 path, SDK surface, or update behavior changes. Focused formatting, basic lint and git diff --check pass. Isolated Codex review found no actionable P0–P2 issues. CI 38326286002 executes head
9cab60b7e5d35116e65d7ea243ba8f7b37f77216at synthetic merge28040809ad5d4a95b232c2e476ff181bdca406dawith main4ca02f6c. Both changed-file cases pass: recreation 45.627 seconds and external Trash 16.879 seconds. This execution did not reproduce the initiating historical failure; its cause remains unknown.The complete selected CI run passed, including its aggregate, type, lint, source-contract, architecture, boundary and baseline-ratchet checks. Production source, imports, exports, graph, SQL, worker inventory and dialect inputs are unchanged; broad build, SDK and published-driver proof is outside this fixture-only delta. No skipped job is claimed as a pass.