Skip to content

fix: allow updates when deleted agents retain their databases - #154136

Merged
steipete merged 9 commits into
mainfrom
upd/deleted-agent-retained-db
Sep 22, 2026
Merged

steipete merged 9 commits into
mainfrom
upd/deleted-agent-retained-db

Conversation

@steipete

@steipete steipete commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

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 failed message.

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 from ef83035c774df0fd0197f3f51ff4d61aa825ec2d is production +0/−0; tests +2/−0 in src/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 to 485fa310fc91ac09cd897f194998cf270452afd5, with its own frozen dependency installation. Both affected test files were byte-identical on the two heads.

Red row in run 35675727131 Evidence Verdict
compact-small-8, core-runtime-infra-storage-state-hosted-13 A reproduced exactly the three transcript-directive failures: stopped-writer upgrade, unreadable-target continuation, renewal/fencing; 1,190 other tests passed. Main passed all 1,191 executed tests. After fixture repair A passed all 1,193 executed tests. Ten existing platform skips remain. OWN consumer fixture: restore known-active setup; no production change or assertion relaxation.
changed-extensions-bundle-29, memory-forget The hosted txt-corpus case failed at loadSqliteVecExtension returning ok=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. Hosted intermittent SQLite-extension load failure; not reproduced, underlying cause unproven. No memory repair claimed.

Final whole-tree proof on Testbox run 35681597725, lease tbx_01m33gyt3h412c3bq6nt5bkymk, Linux x64 / Node 24.19.0:

  • Repaired original storage shard: 1,193 tests passed, 311.659 s wall. Standalone transcript suite: 15 passed, 23.874 s wall / 8.560 s test execution / 1.826 s slowest case. Memory suite: 25 passed, 31.688 s wall.
  • A's existing regression cohort: 478 passed, 198.330 s wall; both relevant v17 process cases passed, 74.094 s command wall. Eight unrelated process cases remained excluded by the existing named filter.
  • 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.
  • Fresh P1 autoreview of the delta: scoped-clean. Tested and committed tree: 785d42dbdc36b2f19b4f58f250f33285a63d2a55; before/after whole-source manifests match. Slowest repaired-shard case: 20.072 s; longest file: 81.865 s test execution.
  • Lease stopped after evidence collection. A portal status-sync timeout occurred after successful remote completion; the command exit, downloaded evidence, source hashes, and lease cleanup all verified independently.

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 from d945989e2ff is 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:

  • 480 cases passed: 478 across the original regression cohort, r4 auth/worker suites and conflict consumers (272.347 s wall), plus the two relevant v17 process cases (37.971 s wall; eight unrelated cases excluded by the named filter).
  • Full architecture passed in 159.193 s; full build passed in 489.027 s. Conflict-file lint passed before those gates. Build time includes cold plugin SDK declaration generation.
  • Slowest case 26.045 s; longest file 62.495 s of test execution. Worker fault-injection: 15 cases, 24.726 s test execution, slowest 7.354 s. No test-time threshold breach.
  • 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.
  • Fresh complete-branch P1 autoreview against the pinned main base: scoped-clean. Source manifests and committed/tested tree: ac7dd210188ba19753de50f3061d4630be8fed1e; before/after source hashes match. The candidate also merges cleanly with subsequently advanced main 4dcc499701e without 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.

CI row Exact suites A312 Pinned main Verdict
compact-small-9 doctor-auth-source-owner, doctor-auth-flat-profiles, doctor-auth-oauth-sidecar 56 failed / 102; 41.493 s wall 102 passed; 62.394 s wall OWN: directory discovery held live legacy-only auth
compact-small-5 worker.fault-injection 9 failed / 15; 1000.274 s wall 15 passed; 55.997 s wall OWN: fixture resolved Gateway sessions under worker state; eight 120 s waits plus invalid-batch

Pre-rebase frozen-tree proof used Testbox run 35667901924, lease tbx_01m334xpxyetgczsft5tq2cq2q:

  • 212 tests passed across the exact suites and eight additional owner/consumer files, in 82.606 s wall. The original auth assertions remain; ten preservation cases cover missing history, shared/adjacent/custom SQLite artifacts, orphan sidecars, dangling links, and relocated agent directories.
  • Worker fault-injection test execution fell from approximately 962 s to 9.005 s for all 15 cases; slowest repaired case 2.948 s. Auth source-owner: 16 cases in 0.570 s; worker abort: 6 cases in 4.686 s. No test exceeded 30 s or file exceeded 120 s of test execution.
  • Controlled worker counterfactual: removing only the fixture environment binding under identical A code/dependencies reproduces invalid-batch in 2.193 s test time (21.560 s command wall). The source was restored and verified afterward. This isolates the cause despite main's different filesystem dependency version.
  • Full architecture passed in 140.213 s, with zero runtime/Madge cycles. Build passed in 298.616 s.
  • 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 is 69faba74b4f43d8a2f954758d47692a1e8bb8c13.
  • Independent P1 autoreview of the final repair versus 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 existing using _ 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 312028acba2237c3df4f21cfab97c1ff32f0f900 was verified against main 90e52dde35df3074ee3f4a34e6d0cad3a13f4d3d on Testbox, Linux x64 / Node 24.19.0:

  • 274 functional tests passed once: the existing 230-test cohort, 28 shared-auth cases covering the conflicted fixture, eight refusal-precedence cases, and eight compiled Doctor-output process cases. Active fixtures carry known empty deletion history; absent history remains held without activation. Preservation and repair assertions remain intact.
  • Full architecture gate passed with zero runtime value cycles and zero Madge cycles. Combined-delta P1 autoreview against the pinned main base returned scoped-clean.
  • 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.
  • The committed tree exactly matches the verified Testbox tree, ea27b4d83310af07c7297cd4c69ddb02a903a303. Whole-tree manifests matched before and after proof.
  • Rebase conflicts were confined to preflight and the shared-auth fixture. Main's removal of canonical mutation APIs and the retired mutation-owner test variant was retained, alongside A's classifier, configured ownership claims, leaf types, and journal seed. Refusal precedence, compiled Doctor fixtures, plugin recovery, approval fixtures, and seeded-store release changes remain inherited.
  • Base-relative production interdiff versus 4201825432b90825eb5ce57f65794334ac6801ea is 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, failed src/agents/provider-local-service.env-case.test.ts — “lets configured env override inherited keys case-insensitively on Windows.” The environment assertions passed; afterEach failed because local provider port 35000 remained bound after cleanup. This fixture was introduced by main commit 5084bde521886acb92ea836ce4a2ed496fdf2632 (#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

  • On the earlier update-unblock candidate, 292 focused tests passed on Linux x64 / Node 24.19.0, including shared physical owners, custom/renamed stores, later Doctor consumers, credential directories, and unchanged pending-deletion behavior. Slowest test: 16.863 s; no test/file exceeded the campaign execution-time thresholds. Active-store fixture helpers explicitly seed an empty deletion history; preservation and repair assertions remain intact.
  • Independent P1 autoreview: scoped-clean on the final staged patch.
  • 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.
  • The isolated Testbox runtime proof used the unchanged published 2026.9.4 updater and real baseline/candidate packages:
Flow Result Time
Published driver → pre-fix baseline Expected candidate migration rehearsal refusal; published install and live schema-19 stores preserved 26.743 s
Published driver → candidate Exit 0, status ok; active schema 19 → 21; retained-store warning in update JSON 54.274 s
Held-main doctor --fix --non-interactive Exit 0; completion reached; no run failed line 6.431 s
Same Doctor repeated Exit 0; same preservation and receipt checks 6.188 s

Both 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-imported receipt. The warning names the retained agent, database path, and openclaw doctor --fix guidance.

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 against d7cf5944ab5222ec97da48bc4412468bbb02bfa2: production +22/−21 (net +1); tests/support +256/−139.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime commands Command implementations size: XL maintainer Maintainer-authored PR labels Sep 20, 2026
@steipete
steipete marked this pull request as ready for review September 20, 2026 22:58
@clawsweeper clawsweeper Bot added P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 22, 2026, 3:05 AM ET / 07:05 UTC (Revision 10).

ClawSweeper review

What this changes

The PR uses agent deletion records to exclude retained databases from update migrations, Doctor repairs, and Gateway discovery while continuing work on active stores.

Regression provenance

Possible 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
Reviewed head: 77a2a3194c191cf3fc6ac34c698547fdcf7825b6

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong update proof supports useful work, but three carried-forward defects prevent a merge-ready rating.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The complete, hash-matched body records real published-updater baseline/candidate runs demonstrating active migration, retained-file preservation, warnings, and repeated Doctor completion. This historical Linux x64 proof supports the central fix but does not resolve the three source findings. No stored schema or encoding changes are introduced.
Patch quality 🦐 gold shrimp (3/6) 3 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The complete, hash-matched body records real published-updater baseline/candidate runs demonstrating active migration, retained-file preservation, warnings, and repeated Doctor completion. This historical Linux x64 proof supports the central fix but does not resolve the three source findings. No stored schema or encoding changes are introduced.
Evidence reviewed 10 items Pinned introduction and review continuity: Reviewed the introduced delta from 2d84bb1 to 77a2a31. Raw test-merge parents match the pinned base followed by the head, and its tree equals the head tree. The three finding locations are unchanged from the previous reviewed head.
Current main still needs the fix: Current main discovers configured, registered, and on-disk databases without consulting completed retained deletions. The linked report documents the resulting refusal during a supported update: #154002.
Latest-release source check: The v2026.9.5 discovery implementation likewise lacks retained-deletion classification. A local historical-blob read failed with HTTP 403; the read-only GitHub contents API supplied the complete release file.
Findings 3 actionable findings [P1] Check canonical auth ownership before holding the legacy source
[P2] Prioritize the requested deleted identity over a path match
[P2] Prepare deletion facts outside the synchronous Gateway resolver
Security None None.

How this fits together

Update 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]
Loading

Before merge

  • Check canonical auth ownership before holding the legacy source (P1) - After shared auth has moved to state-db and cleanup has completed, deleting main while retaining its database is supported. This return nevertheless reports hasLegacy: true, held: true before checking ownership or pending receipts. The resulting skipped receipt makes runAuthProfileMigration bypass active credential and catalog repairs on every Doctor run. Determine whether relocation or cleanup remains pending before applying the hold. This prior blocker remains unchanged.
  • Prioritize the requested deleted identity over a path match (P2) - With two deleted aliases sharing a surviving physical store, find can select the first alias by path before reaching the requested alias by ID. Because a survivor exists, line 73 then returns undefined for the second deleted identity. If that alias precedes a registry-only survivor in migration discovery, it claims the physical file, the survivor is deduplicated away, and database admission refuses the deleted agent. Match the requested identity first, then apply path-based fallback. This prior blocker remains unchanged.
  • Prepare deletion facts outside the synchronous Gateway resolver (P2) - Constructing this matcher calls readAgentDatabaseDeletionSnapshot, synchronously querying SQLite even when topology is cached. projects.list with includeObserved reaches this resolver through loadCombinedSessionStoreForGatewayCoreAsync before its worker reads, so each request now performs journal and registry work on the Gateway thread. Prepare these facts through the existing worker/topology lifecycle with invalidation. The post-materialization projection test does not exercise this path. This prior blocker remains unchanged.
  • Resolve merge risk (P1) - Users who already relocated shared auth and then retained a deleted main database would lose subsequent Doctor auth and catalog repairs.
  • Resolve merge risk (P1) - Multiple deleted aliases sharing a surviving store can still cause migration to select a deleted owner and refuse the update.
  • Resolve merge risk (P1) - Gateway project-list requests gain synchronous journal and registry queries on the event loop, creating avoidable stalls as storage work grows.
  • Complete next step (P2) - Resolve the three carried-forward findings and validate their focused regression scenarios before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P1] Check canonical auth ownership before holding the legacy source — src/infra/state-migrations.shared-auth-store.ts:489-495
  • [P2] Prioritize the requested deleted identity over a path match — src/state/agent-deletion-discovery.ts:51-57
  • [P2] Prepare deletion facts outside the synchronous Gateway resolver — src/config/sessions/combined-store-gateway.ts:494-496
Agent review details

Security

None.

PR surface

Source +194, Tests +889, Docs +8, Other 0. Total +1091 across 47 files.

View PR surface stats
Area Files Added Removed Net
Source 25 537 343 +194
Tests 20 1065 176 +889
Docs 1 8 0 +8
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 47 1611 520 +1091

Review metrics

Metric Value Why it matters
Production versus regression coverage Production net +194 lines; tests/support net +889 lines The body justifies production growth through shared deletion classification and artifact-preserving discovery; most added code provides regression coverage.

Stored data model

Persistent data-model change detected: durable storage schema: src/secrets/storage-scan.ts, migration/backfill/repair: src/commands/doctor-auth-legacy-paths.ts, migration/backfill/repair: src/commands/doctor-model-catalog-credentials.ts, migration/backfill/repair: src/commands/doctor-session-sqlite-readers.ts, migration/backfill/repair: src/commands/doctor-session-transcript-headers.ts, migration/backfill/repair: src/commands/doctor-session-transcript-labels.ts, and 11 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #154002
Summary: This PR is the explicit candidate fix for the retained-database update refusal; journal reconstruction is separate stacked work.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Repair the existing owner boundaries (recommended)
    Resolve the auth ordering, deleted-identity precedence, and Gateway worker-read findings together while retaining the proven update-unblock behavior.

Technical review

Best 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:

  • [P1] Check canonical auth ownership before holding the legacy source — src/infra/state-migrations.shared-auth-store.ts:489-495
    After shared auth has moved to state-db and cleanup has completed, deleting main while retaining its database is supported. This return nevertheless reports hasLegacy: true, held: true before checking ownership or pending receipts. The resulting skipped receipt makes runAuthProfileMigration bypass active credential and catalog repairs on every Doctor run. Determine whether relocation or cleanup remains pending before applying the hold. This prior blocker remains unchanged.
    Confidence: 0.99
  • [P2] Prioritize the requested deleted identity over a path match — src/state/agent-deletion-discovery.ts:51-57
    With two deleted aliases sharing a surviving physical store, find can select the first alias by path before reaching the requested alias by ID. Because a survivor exists, line 73 then returns undefined for the second deleted identity. If that alias precedes a registry-only survivor in migration discovery, it claims the physical file, the survivor is deduplicated away, and database admission refuses the deleted agent. Match the requested identity first, then apply path-based fallback. This prior blocker remains unchanged.
    Confidence: 0.98
  • [P2] Prepare deletion facts outside the synchronous Gateway resolver — src/config/sessions/combined-store-gateway.ts:494-496
    Constructing this matcher calls readAgentDatabaseDeletionSnapshot, synchronously querying SQLite even when topology is cached. projects.list with includeObserved reaches this resolver through loadCombinedSessionStoreForGatewayCoreAsync before its worker reads, so each request now performs journal and registry work on the Gateway thread. Prepare these facts through the existing worker/topology lifecycle with invalidation. The post-materialization projection test does not exercise this path. This prior blocker remains unchanged.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5c42f636bb9b.

Labels

Label justifications:

  • P0: The linked official-release report describes a blocked supported update whose recovery required manually relocating retained agent files.
  • merge-risk: 🚨 compatibility: A deleted alias can claim a surviving database during discovery and preserve the update refusal this PR intends to remove.
  • merge-risk: 🚨 auth-provider: The premature retained-main hold suppresses active auth and catalog repair after completed shared-auth relocation.
  • merge-risk: 🚨 availability: New synchronous SQLite reads run during Gateway request preparation outside the existing worker boundary.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (linked_artifact): The complete, hash-matched body records real published-updater baseline/candidate runs demonstrating active migration, retained-file preservation, warnings, and repeated Doctor completion. This historical Linux x64 proof supports the central fix but does not resolve the three source findings. No stored schema or encoding changes are introduced.
  • proof: sufficient: Contributor real behavior proof is sufficient. The complete, hash-matched body records real published-updater baseline/candidate runs demonstrating active migration, retained-file preservation, warnings, and repeated Doctor completion. This historical Linux x64 proof supports the central fix but does not resolve the three source findings. No stored schema or encoding changes are introduced.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the introduced delta from 2d84bb1 to 77a2a31. Raw test-merge parents match the pinned base followed by the head, and its tree equals the head tree. The three finding locations are unchanged from the previous reviewed head. (77a2a3194c19)
  • Current main still needs the fix: Current main discovers configured, registered, and on-disk databases without consulting completed retained deletions. The linked report documents the resulting refusal during a supported update: [Bug]: Upgrade rehearsal blocked by retained database of intentionally deleted agent #154002. (src/infra/state-migrations.media-persistence-targets.ts, 5c42f636bb9b)
  • Latest-release source check: The v2026.9.5 discovery implementation likewise lacks retained-deletion classification. A local historical-blob read failed with HTTP 403; the read-only GitHub contents API supplied the complete release file. (src/infra/state-migrations.media-persistence-targets.ts, ec9c1a13db89)
  • Canonical auth ownership is checked too late: The retained-main return precedes both canonical ownership and pending-cleanup checks. Its skipped receipt then makes runAuthProfileMigration return before active credential and catalog repairs. The documented contract permits deleting main after shared-auth relocation. (src/infra/state-migrations.shared-auth-store.ts:489, 77a2a3194c19)
  • Logical identity can lose to an earlier physical match: The first matching journal entry can belong to another deleted alias. With a surviving physical owner, the final comparison then returns undefined for the requested deleted identity; migration discovery can select that alias and deduplicate away the surviving owner. (src/state/agent-deletion-discovery.ts:51, 77a2a3194c19)
  • Gateway request path performs new synchronous reads: Every target resolution constructs the matcher, which synchronously reads the deletion journal and registry. The asynchronous combined-store loader calls this before dispatching its worker reads, including projects.list with includeObserved. The added projection test observes only reads after materialization and does not cover this request path. (src/config/sessions/combined-store-gateway.ts:494, 77a2a3194c19)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Verify active auth repairs after completed shared-auth relocation followed by retained main deletion.
  • Cover two deleted aliases sharing a surviving store and require migration under the survivor only.
  • Prepare deletion facts through the worker lifecycle and verify observed-project requests add no host-thread SQLite reads.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-21T11:15:18.772Z sha dc2fb1a :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match
  • reviewed 2026-09-21T12:10:26.743Z sha dc2fb1a :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match
  • reviewed 2026-09-21T17:25:10.666Z sha d7cf594 :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match
  • reviewed 2026-09-21T20:28:26.675Z sha 312028a :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match
  • reviewed 2026-09-22T01:32:57.539Z sha ef83035 :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match | [P2] Prepare deletion facts outside the synchronous Gateway resolver
  • reviewed 2026-09-22T04:12:01.265Z sha b753170 :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match | [P2] Prepare deletion facts outside the synchronous Gateway resolver
  • reviewed 2026-09-22T04:52:33.331Z sha 96042cf :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match | [P2] Prepare deletion facts outside the synchronous Gateway resolver
  • reviewed 2026-09-22T05:58:10.838Z sha 286dd6f :: blocked before merge. :: [P1] Check canonical auth ownership before holding the legacy source | [P2] Prioritize the requested deleted identity over a path match | [P2] Prepare deletion facts outside the synchronous Gateway resolver

@github-actions

github-actions Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components. This comment is informational because the PR author has repository Maintain or Admin access.

  • Current SHA: 77a2a3194c191cf3fc6ac34c698547fdcf7825b6
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/infra/state-migrations.shared-auth-store.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/infra/state-migrations.shared-auth-store.types.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/secrets/storage-scan.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 21, 2026
@steipete
steipete enabled auto-merge (squash) September 21, 2026 17:10
@steipete
steipete disabled auto-merge September 21, 2026 19:05
@steipete
steipete force-pushed the upd/deleted-agent-retained-db branch from 4201825 to 312028a Compare September 21, 2026 20:14
@steipete
steipete enabled auto-merge (squash) September 21, 2026 22:34
@steipete
steipete disabled auto-merge September 21, 2026 22:35
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.
@steipete
steipete force-pushed the upd/deleted-agent-retained-db branch from d945989 to ef83035 Compare September 22, 2026 01:25
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. label Sep 22, 2026
@steipete
steipete merged commit b068eab into main Sep 22, 2026
206 checks passed
@steipete
steipete deleted the upd/deleted-agent-retained-db branch September 22, 2026 07:21
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 23, 2026
…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
steipete added a commit that referenced this pull request Oct 15, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 16, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P0 Emergency: data loss, security bypass, crash loop, or unusable core runtime. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Upgrade rehearsal blocked by retained database of intentionally deleted agent

1 participant