Repository navigation
fix: allow updates when deleted agents retain their databases - #154136
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: blocked before merge. Reviewed September 22, 2026, 3:05 AM ET / 07:05 UTC (Revision 10). ClawSweeper reviewWhat this changesThe PR uses agent deletion records to exclude retained databases from update migrations, Doctor repairs, and Gateway discovery while continuing work on active stores. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readiness⛔ Blocked before merge - 8 items remain The update fix remains necessary and has credible runtime proof, but all three previously reported correctness findings remain unchanged. The stacked reconstruction work does not supersede this PR. Priority: P0 Review scores
Verification
How this fits togetherUpdate rehearsal and Doctor discover agent databases before checking or migrating them. The new deletion classifier also feeds credential repair and Gateway session discovery, determining which preserved stores remain untouched. flowchart TD
A[Agent configuration and database registry] --> C[Deletion classifier]
B[Completed deletion records] --> C
C --> D[Active database owners]
C --> E[Retained databases]
D --> F[Update and Doctor migrations]
E --> G[Preserve files and report warning]
C --> H[Gateway session discovery]
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +194, Tests +889, Docs +8, Other 0. Total +1091 across 47 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one deletion classifier that respects logical ownership, holds only genuinely pending legacy auth work, and supplies worker-prepared facts to Gateway readers. Do we have a high-confidence way to reproduce the issue? Yes: current-main discovery and the reported retained-deletion state establish the update refusal, while source traces establish the three patch defects. This read-only review did not execute tests or target code. Is this the best way to solve the issue? The shared classifier is the right owner, but the current implementation is incomplete: canonical auth ownership must precede the hold, exact deleted identity must precede path fallback, and Gateway queries must consume prepared facts. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5c42f636bb9b. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
4201825 to
312028a
Compare
Classify completed retained deletions before agent database opens and share the disposition across migration planning, Doctor repair scans, and Gateway projection startup. Preserve pending deletion fences and surviving physical store owners. Fixes #154002. Thanks @joshpetras for the report.
Classify completed retained deletions before migration, preflight, and Doctor store scans. Record held-store guidance as recoverable and defer dependent auth work through its skipped receipt while unrelated repairs continue. Keep unknown history closed; Doctor reconstruction is a separate follow-up.
d945989 to
ef83035
Compare
…aw#154136) * fix: keep retained deleted-agent databases from blocking updates Classify completed retained deletions before agent database opens and share the disposition across migration planning, Doctor repair scans, and Gateway projection startup. Preserve pending deletion fences and surviving physical store owners. Fixes openclaw#154002. Thanks @joshpetras for the report. * fix: keep retained agent stores from blocking updates Classify completed retained deletions before migration, preflight, and Doctor store scans. Record held-store guidance as recoverable and defer dependent auth work through its skipped receipt while unrelated repairs continue. Keep unknown history closed; Doctor reconstruction is a separate follow-up. * fix(doctor): keep retained-database contracts consistent across preflight consumers * fix(doctor): preserve active legacy auth migrations * test(doctor): seed active history for legacy transcript fixtures
…hema verification (#172975) A managed update could pass rehearsal and live Doctor, then fail after activation because post-activation verification required every agent database to reach the candidate schema, while Doctor intentionally preserves held deleted-agent stores at their older schema (#154136). The failed verdict left the Gateway unloaded. The candidate-owned state snapshot now reports held deleted-agent paths using Doctor's deletion classifier, and verification exempts only those; pending deletions still require migration and rollback inventory stays complete. Stopped-Gateway recovery is handled separately by #172784. Fixes #172740
…hema verification (openclaw#172975) A managed update could pass rehearsal and live Doctor, then fail after activation because post-activation verification required every agent database to reach the candidate schema, while Doctor intentionally preserves held deleted-agent stores at their older schema (openclaw#154136). The failed verdict left the Gateway unloaded. The candidate-owned state snapshot now reports held deleted-agent paths using Doctor's deletion classifier, and verification exempts only those; pending deletions still require migration and rollback inventory stays complete. Stopped-Gateway recovery is handled separately by openclaw#172784. Fixes openclaw#172740
Closes #154002. Thanks @joshpetras for the report and retained-store diagnosis.
What Problem This Solves
Fixes update rehearsal stopping when a deleted agent intentionally kept its database.
User Impact
Updates preserve retained stores, record a warning naming the agent, database path, and Doctor guidance, and continue migrating active agents. Doctor records held shared-auth work as an intentional skip and continues unrelated repairs without an
auth-profile-migration run failedmessage.Why This Change Was Made
Migration discovery treated remaining databases as active. The deletion journal now supplies one classification consumed by migration planning, preflight, Doctor readers, and Gateway admission. A surviving physical database owner can remain active; a deleted logical alias and its separate credential directory stay held. Preflight preserves each configured logical ownership claim even when migration discovery deduplicates hardlinked files.
This PR contains only the update-unblock half. Doctor-owned journal reconstruction, receipts, initialization freshness, and explicit restore handling are in #155024, stacked on this branch.
Pending file deletion keeps its existing safety checks. Backup and rollback ownership are unchanged. No schema, dependency, configuration, or CLI options change.
Evidence
CI repair r5 — active transcript fixtures
Head:
b75317069ad19eda690163daa2be227a0c4e23e6. The delta fromef83035c774df0fd0197f3f51ff4d61aa825ec2dis production +0/−0; tests +2/−0 insrc/infra/state-migrations.transcript-directives.test.ts. Every assertion remains unchanged.Main commit
c65911334f8(#153683) replaced three runtime-open fixtures with frozen V21 database seeds. Those active-store fixtures lost the known-empty shared deletion history previously established by the runtime open. This PR correctly holds existing SQLite when history is unavailable, so those fixtures stopped before their intended migrations. The fixture owner now opens canonical shared state before writing the legacy agent bytes. Unknown-history and retained-store behavior stay covered by the existing preservation tests. The reported 17-versus-23 assertion was a schema version, not a migration-target count.Head-versus-main matrix ran before editing, with the original 58-path storage shard plan and runner settings from job
106582028850. Main was pinned to485fa310fc91ac09cd897f194998cf270452afd5, with its own frozen dependency installation. Both affected test files were byte-identical on the two heads.loadSqliteVecExtensionreturningok=false, before purge assertions. The complete 25-case suite passed N=3 on A and N=3 on main. A run walls: 34.168/28.877/29.363 s; main: 36.647/31.846/31.284 s.Final whole-tree proof on Testbox run 35681597725, lease
tbx_01m33gyt3h412c3bq6nt5bkymk, Linux x64 / Node 24.19.0:node scripts/check-changed.mjs --base 55b3d3ecfe9b44430d8d47e1cf87d1a1b8d59d53 --head HEAD --timed: exit 0 in 1445.071 s, including all 25 test-type shards and every selected check.785d42dbdc36b2f19b4f58f250f33285a63d2a55; before/after whole-source manifests match. Slowest repaired-shard case: 20.072 s; longest file: 81.865 s test execution.A's total against its pinned main base is production +537/−343 (net +194); tests/support +1065/−176 (net +889); docs +8; assertion baseline +1/−1, shrink-only. Auto-merge remains off for lead review. B remains the separate reconstruction follow-up linked above. Earlier packaged updater proof below is historical and was not rerun for this test-only repair.
Earlier CI repair r4
Published repair head:
ef83035c774df0fd0197f3f51ff4d61aa825ec2d.The first repair push could not attach CI because main had advanced and the PR was conflicting. This head rebases the same production delta onto main
55b3d3ecfe9b44430d8d47e1cf87d1a1b8d59d53. The base-relative production interdiff fromd945989e2ffis empty: zero files, zero bytes. Conflict resolutions only combine main's static V21 fixture and async worker-store setup with this PR's known deletion history, environment binding, and fail-fast cleanup.Rebased exact-source proof on Testbox run 35672409556, lease
tbx_01m338f64gwwfhb68je6xyn52e:node scripts/check-changed.mjs --base 55b3d3ecfe9b44430d8d47e1cf87d1a1b8d59d53 --head HEAD --timed: exit 0 in 1890.390 s, including all 25 test-type shards and all selected checks.ac7dd210188ba19753de50f3061d4630be8fed1e; before/after source hashes match. The candidate also merges cleanly with subsequently advanced main4dcc499701ewithout changing the tested source.Current total against that main base: production +537/−343 (net +194); tests/support +1063/−176 (net +887); docs +8; baseline +1/−1, allowance shrinks 3→2. Auto-merge stays off pending lead r4 review. Doctor reconstruction remains stacked separately in B.
R4 attribution and pre-rebase proof
The two red rows in run 35649852525 are owned by this change. The three auth suites contain live, migratable legacy credentials; their existing assertions are unchanged. Discovery now permits those directory sources only when no shared, configured, or adjacent SQLite family exists. Existing databases with unavailable deletion history remain held. Retained status still comes from completed keep-files deletion records. Receipt inspection now reads an existing shared database without creating one.
The worker failure is a shared-fixture ownership defect exposed by the new classification. Worker setup changes the process environment, and the in-process Gateway then resolves sessions against the worker's state directory. The fixture now binds the real resolver to its Gateway environment, scoped to its own config. Event waits also fail when the worker finishes early; no timeout, retry, or assertion was relaxed.
Head/main matrix ran before edits on Linux x64, Node 24.19.0, non-root UID 1001. Main was pinned to
32c12d3eba7e78093e41393cbbaf9ff033a651c3; all four test files were byte-identical.Pre-rebase frozen-tree proof used Testbox run 35667901924, lease
tbx_01m334xpxyetgczsft5tq2cq2q:node scripts/check-changed.mjs --base 90e52dde35df3074ee3f4a34e6d0cad3a13f4d3d --head HEAD --timed: exit 0 in 530.026 s, including all 25 test-type shards and all selected guards. The final disposable-binding rename also passed two cleanup cases (29.032 s command wall). Whole-tree manifests matched before/after, and the final tested tree is69faba74b4f43d8a2f954758d47692a1e8bb8c13.312028acba2: scoped-clean. The initial changed gate reached core lint after all 25 type shards passed and caught a disposable-binding name violation; the binding now uses the existingusing _convention, with remote lint and fixture cleanup rechecked.Repair interdiff versus
312028acba2: production +89/−44, net +45, five files; tests/support +186/−48, net +138. The assertion allowance shrinks from 3 to 2. Pre-rebase A against its prior main base: production +537/−343 (net +194), tests/support +1065/−181 (net +884), docs +8, baseline +1/−1. Production is now net +194, above the earlier +150 target; the additional protection avoids admitting uncertain SQLite families or creating shared state during read-only inspection. The lead's r4 review is pending; auto-merge remains off. No dependency, schema, config/CLI option, or baseline expansion was introduced.Earlier r3 evidence
The rebased candidate
312028acba2237c3df4f21cfab97c1ff32f0f900was verified against main90e52dde35df3074ee3f4a34e6d0cad3a13f4d3don Testbox, Linux x64 / Node 24.19.0:node scripts/check-changed.mjs --base 90e52dde35df3074ee3f4a34e6d0cad3a13f4d3d --head HEAD --timed: exit 0 in 2031.477 s, including core types, all 25 test-type shards, lint, docs, formatting, line-cap and storage guards.ea27b4d83310af07c7297cd4c69ddb02a903a303. Whole-tree manifests matched before and after proof.4201825432b90825eb5ce57f65794334ac6801eais empty: comparing each base-to-head patch's added/removed production lines, excluding hunk coordinates and unchanged main context, yields no changed files. A remains +452/−303, net +149 production.Measured test time: shared-auth 6.534 s; refusal receipts 3.913 s; compiled Doctor output 46.681 s across eight cases; v17 repair 12.068 s and rollback 3.729 s; CLI history about 2.25 s; preflight lifecycle 44.082 s; artifact preservation 34.576 s; worker abort 5.751 s. No selected test exceeded 30 s or file exceeded 120 s of test time. The longer artifact/lifecycle and compiled-output files exercise real reader/lock/cleanup and CLI contracts. No timeout, retry, assertion, or baseline was relaxed.
Named main-side follow-up: windows-1 fixture cleanup
Run 35630941017, job
106437235755, failedsrc/agents/provider-local-service.env-case.test.ts— “lets configured env override inherited keys case-insensitively on Windows.” The environment assertions passed;afterEachfailed because local provider port 35000 remained bound after cleanup. This fixture was introduced by main commit5084bde521886acb92ea836ce4a2ed496fdf2632(#154133). Its provider/process/port owners are byte-identical to this PR's main parent. The hosted failure class is Windows process/socket cleanup; delayed listener release versus a competing bind remains unproven. No native Windows replay or fix is claimed here. This is a separate main-side fixture follow-up, intentionally not changed by this PR.The same run's small-7 Bun canvas thread-termination warning was nonfatal: the test passed and its shard exited 0. Other unchanged main-side cost findings remain with their owners: the backup audit-lease fixture deliberately waits 61 s (66.047 s test, #130962); the Windows descendant fixture uses a 60 s timeout (60.727 s test, #140927); July Doctor compositions perform four CLI calls per case (34.829/33.754 s); plugin-deferral Doctor performs six preflights (45.886 s). These are recorded follow-ups, not claimed as fixed or used to relax this PR's gates.
Earlier update-unblock proof
node scripts/check-changed.mjs --base 480fa421af89af663f88038e885530607ee54f8c --head HEAD --timed: exit 0 on the full frozen source. All selected type, lint, unused-export, storage, import-cycle, formatting, and ratchet gates passed.ok; active schema 19 → 21; retained-store warning in update JSONdoctor --fix --non-interactiverun failedlineBoth held database families and completed deletion records remained identical. Shared auth was not relocated. The independent exec-approvals import completed and removed its source with a
legacy-importedreceipt. The warning names the retained agent, database path, andopenclaw doctor --fixguidance.The runtime package was built from the verified production source; final follow-up edits only establish active test fixtures, move an erased TypeScript display type, and rename local bindings for lint. Independent transpilation of the two type-move modules yields byte-identical JavaScript; the binding changes preserve scope and property names. This proof covers Linux x64 with synthetic isolated state and a loopback inference provider; ARM64/systemd was not reproduced.
Earlier r3 production against main base
90e52dde35df3074ee3f4a34e6d0cad3a13f4d3d: +452/−303 (net +149). Tests/test support: +895/−149. Docs: +8. This repair's interdiff againstd7cf5944ab5222ec97da48bc4412468bbb02bfa2: production +22/−21 (net +1); tests/support +256/−139.