Skip to content

fix(agents): release model and auth readers when deleting agents - #159013

Merged
steipete merged 14 commits into
openclaw:mainfrom
ceckert:codex/fix-deleted-agent-resources
Oct 2, 2026
Merged

steipete merged 14 commits into
openclaw:mainfrom
ceckert:codex/fix-deleted-agent-resources

Conversation

@ceckert

@ceckert ceckert commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Closes #159007

What Problem This Solves

Deleting an agent can leave model/auth readers and native memory owners alive, or allow later workers to reopen its retained database. A stale deleted-agent registration can also point to a surviving agent's database; path-only cleanup must not close or fence that survivor.

User Impact

Deletion retires model and memory owners and drains physical readers before completion and file cleanup. Current and replacement workers keep retained deleted stores fenced until legitimate recreation. Independently surviving agents remain readable, including when a historical registration names their database. A failed worker revival message does not turn a committed recreation into failure.

There is no schema, stored-format, configuration, credential-policy, or retained-history migration. The configured-candidate flag and reader fences are transient lifecycle facts.

Why This Change Was Made

The deletion plan now separates all registration paths, needed for removal under the deleted agent ID, from survivor-filtered reader paths, used for path-only auth-reader closure and cross-worker fencing. Historical directories remain available to model retirement, which checks both agent ID and directory.

New runtime journal checks read exact operation identity and completion state through the existing state-read worker, then verify live lease ownership through the existing heartbeat worker. They recheck closure, cancellation, and captured state admission after awaiting. Existing transaction and native cleanup commit checks retain their current contracts. Authority is also verified after lazy imports and before the first model-retirement effect.

Main integration preserves current catalog-publication and session-history scope owners. Contributor ancestry remains intact.

Owner direction

On October 1, 2026, repository owner Peter Steinberger, an active organization admin, explicitly directed: “contributor PRs that fit into our plan: improve and land.” This PR is included in that approved scope. That direction supplies owner involvement for its restricted/security paths under AGENTS.md; final-head CI and review gates remain enforced.

Evidence

Candidate: c724689570f625a9606ee5f7266fbc4bca632bd3. Integrated main: 9fc095cae88889df55309cf4bfd73fe7920f09c9.

  • The existing real Gateway recreation flow now recovers an incomplete deletion journal whose directory and database belong to the surviving agent. It retains an actual parent auth reader, reads persisted synthetic credentials in the current and replacement workers, and verifies session data, database identity, ownership, and registration cleanup. No revival hides the survivor assertions, and no additional Gateway boot or agent creation was added.
  • Real-worker authority tests prohibit parent data SQL during successful and stolen-lease guards, reject missing/completed/replaced/unreadable journals, and reject a held worker reply when rollback closes the operation. Existing asynchronous cleanup owners drain worker resources before fixture roots are removed.
  • Added Gateway routing assertions ensure shared/relocated survivor paths are omitted from path-only fencing while owned paths remain included.
  • Independent Codex autoreview completed clean through P2 across the full candidate. Trusted formatting and PR-scoped whitespace checks passed.
  • Runtime validation is secretless GitHub CI. No contributor code, build, typecheck, lint, or tests executed on the maintainer host. Prior-head CI run 36962111463 passed, including the enforced CI gate; measured hosted case times are below. New regression cases have not been executed against the old production tree; no failing-before runtime result is claimed for those additions.

Main integration before landing

GitHub reported a real conflict after native preparation of the passing ad6e209 candidate. Main had independently landed the same deterministic archive-LRU fixture assertions; the sole conflict was their comment wording. The merge keeps main's wording, current transcript read owners, the PR's generic reader-close handling and catalog-worker test routing. The integrated candidate passed full independent review through P2. ClawSweeper revision 14 accepted its unchanged production-boundary proof with no blocking patch defect; its CI failed as described below; the passing execution results below remain explicitly bound to ad6e209.

Current CI investigation

Run 36965599681 tested e902786 and failed two jobs, with 109 successful jobs and 22 skipped. The aggregate gate reflects those two failures. No failed job was blindly rerun.

The UI native-session action returned a terminal {ok:false} receipt, but its assertion omitted the error reason. That feature and case came from main's #163193 and have no owning fix through inspected main 970faff. The auth product case successfully completed profile logout and refresh, then chat reported a retired plugin generation instead of missing-profile recovery. Its affected source is unchanged from passing ad6e209, and the precise cache/registry retirement source remains unestablished.

The current diagnostic commit preserves all authority rules, assertions and timeouts. It waits for a native command receipt before validating it with its full reason, attaches isolated Gateway logs to the auth assertion, and records four non-sensitive retirement facts through the existing debug logger. Independent review is clean through P2. The diagnostic run completed successfully as recorded below. This passing replay does not identify or repair the earlier intermittent causes; no timeout, assertion or recovery authority was relaxed.

Final-head hosted result

CI run 36967591602 passed for c724689570f625a9606ee5f7266fbc4bca632bd3: 115 successful jobs, 21 skipped, no failures. Its checked-out merge was ad11c77e9e9546ad2620cc451286c698784f12e3, with base 18966380071ee171527a11a914fc6cafb0db05fb. Original hosted logs verify all 282 focused cases, with no selection gaps:

Proof Cases passed Summed case time Exact job
Lifecycle authority 18 12.641 s 110714864699
Catalog-reader survivor 1 2.640 s 110714864699
Real Gateway deletion/recreation 2 10.453 s 110714864857
Model-owner supersession 7 1.722 s 110714864733
Category projection 4 6.602 s 110714864732
Lease retention 2 1.307 s 110714864891
Test planner 248 23.259 s 110714864948

Times are reporter case sums, not file wall time. The previously failing selected-session native action passed in 2.320 s (UI job); removed-profile recovery passed in 11.374 s (Node job). Captured Gateway logs are emitted only on assertion failure, so the successful run does not establish which retirement events occurred internally.

ClawSweeper revision 15 reviewed this exact head at 2026-10-02T05:16:28.229Z: no blocking patch defect, behavior proof sufficient, and no stored-data contract change requiring migration proof. The remaining generated migration checkbox contradicts that explicit assessment and does not apply to this transient lifecycle repair.

Corrective CI attribution

Run 36959800135 tested 7ecc748e25d61c1cb35b43f1d9f105ac721931a8: 102 successful jobs, 22 skipped, and six failed jobs plus the aggregate gate. Each failure was investigated before this corrective push:

  • SQL inventory: the new exact-journal SELECT ran only in the state worker but lived in a mixed host/worker module. Its unchanged implementation now lives in a worker-only module; the baseline and scanner are unchanged.
  • Catalog fixture admission: the integration test now uses the existing forked database-worker lane, required by current catalog publication ownership. The actual-planner regression covers its routing.
  • Survivor recovery: seeding credentials and history left a live writer open. The fixture now closes that writer before retaining the parent/worker readers and creating the stale journal. The production foreign-writer admission check and all survivor-reader assertions remain intact.
  • Archived-category eviction: concurrent materialization did not establish an LRU order. The fixture now reads the 101 prepared rows in a defined order before asserting eviction, preserving the data and invalidation checks.
  • Spawn fixture: inherited scheduler trace logging reached a shared logger mock with no trace method. The mock now supplies that method; no production logging or error handling changed.
  • Lease retention: the new async guard permanently captured its heartbeat. It now borrows the live heartbeat per verification so closing the lease releases the caller scope. The existing retention proof additionally checks live async verification and rejection after close; its GC budget and collection assertion are unchanged.

The same run reported three advisory file-length warnings. Small extractions move transport serialization to its existing worker module, channel-suppression logging to channel restart, and fixture constructors to existing test support. No cap was raised. These warnings did not cause the GitHub ratchet failure.

The existing real model-owner test now calls deletion runtime retirement with replaced journal authority and a closed operation, verifies both published snapshots remain current, then retires the intended owner as a positive control. The Gateway handler test additionally rejects authority lost during session purge before reader fencing, Trash, unregistering, or completion. Existing real-worker tests separately establish stolen-lease rejection and closure during an outstanding journal reply.

The corrective delta passed independent review through P2. Secretless GitHub CI run 36962111463 completed successfully on ad6e209362c8d1b7b03b5e85c271c6aa7f79d893, using its bound synthetic merge 091bfb78. The enforced CI gate, SQL ratchet, type and lint checks passed. Maintainer security approval is recorded for this exact head.

Passing behavior proof on the prior candidate ad6e209

The following results were read from the completed run's original log archive. Times are sums of reporter case durations, not file wall time; imports, setup and teardown are excluded. No contributor code ran locally.

Hosted proof Result Case-time sum Job
Real Gateway deletion, survivor recovery and recreation 2 passed 10.390 s large-12-1
Journal and live lease authority through real workers 18 passed 9.693 s large-32-1
Catalog worker reader retirement and survivor 1 passed 2.338 s large-32-1
Real model-owner supersession and guarded retirement 7 passed 1.852 s small-3
Lease caller-state collection 2 passed 1.329 s large-3
Category projection and eviction 4 passed 6.198 s large-22
Actual test planner and routing 248 passed 26.577 s small-5-2

Selected ad6e209 terminal results, reduced to synthetic test names and durations:

PASS recreates and registers a deleted agent database through one real Gateway process 6935ms
PASS refuses changed journal authority while the original deletion lease is still held 832ms
PASS refuses a stolen lease through the heartbeat worker without querying on the parent 607ms
PASS rejects a current worker reply when deletion closes before the reply is consumed 619ms
PASS closes one agent's database readers without retiring the shared worker 2338ms
PASS retires only the deleted agent's physical owners 1250ms
PASS keeps remaining resources when deletion retires during session purge 7ms
PASS releases caller state after lease timers are completed-worker 636ms

The model-owner case invokes the actual deletion runtime with replaced and closed authority, observes that the real published snapshots remain current, then proves the intended snapshot can be retired. Stolen-lease and held-reply closure semantics are exercised through real journal/heartbeat workers. The handler's post-purge refusal test uses mocked effect boundaries; actual physical reader closure, survivor recovery, fencing and replacement-worker behavior are exercised by the real Gateway/catalog-worker cases. This is complementary boundary coverage, not a claim that the mocked refusal case performs physical reader I/O.

ClawSweeper revision 13 completed on ad6e209 at 2026-10-02T04:16:58.312Z: prior findings resolved, no blocking patch defect, and the recorded production-boundary evidence satisfies the proof request. Its residual data-model checkbox is inapplicable, as the review itself confirms. No schema, journal encoding, durable receipt, retention rule, or configuration migration is introduced; the worker fences and configured-candidate fields are transient lifecycle state, so no stored-data migration proof applies.

Incoming CI attribution

Run 36774346839 belongs to original head de1caeb419fa4ad7d5f54cc0c26cccd9c8e9eaf4 and failed. Three failures have owning fixes included through main: first-signin's incidental confirm-versus-note expectation (5c4041708d66, #161451); shutdown's short polling instead of a model-start signal (22d7946296bf, #162133); and private-completion cancellation losing canonical generation/FIFO ownership (fef7992b3697).

The Bun provider-readiness case failed after 5,124 ms against a 5,000 ms deadline and remains unattributed. Its unchanged loop, a later directory-mismatch diagnostic, and subsequent Bun upgrades do not establish a specific fix. No failed job was blindly rerun; the changed candidate needs its own CI result.

Contributor credit

Thanks to Chris Eckert (@ceckert) for the original repair and real Gateway proof. All ten contributor commits remain in the branch, with human co-author credit preserved for landing.

Historical contributor proof on de1caeb

The following results are contributor evidence for their named earlier heads, not proof of the new candidate.

Original-head contributor evidence

  • RED, later worker: after actual agents.delete(deleteFiles:false) succeeds and the database inode is retained, the first real worker wrongly reads that deleted database. The unchanged expectation fails. The repair also closes the rotated-worker boundary and captures fences after an already-queued asynchronous input finishes.
  • RED, committed revival: with the old worker-first revival ordering restored, the actual agents.create commit succeeds but a precisely targeted failed revive packet leaves the next real worker read fenced. The unchanged expectation fails. With parent-first revival, the pool's next real worker task recovers.
  • Final rebased focused run passes 25 tests in four files / 58.87s: the two existing real Gateway product flows, reader failure/retry/survivor cases, and both resolved native OAuth files. The new assertions extend the existing Gateway boot rather than introducing another test case or fixture.
  • The earlier unchanged consumer proof passes the real catalog worker, session-history worker errors, native interactive worker exchanges, and worker resource closure (five files / 73.53s). The preceding focused owner/mutation proof passes 68 tests / four files / 54.73s.
  • Fresh isolated Codex review of this repair and the complete native worker lifecycle context reports no actionable P0–P2 findings. The lead independently inspected task/resource ordering and the actual envelope producers. This is scoped code review, not maintainer security approval.
  • Native changed-source validation passed core production types, all 27 canonical core-test graphs (1471.16s), zero-unused-export scans, formatting, and no-growth caps. That aggregate stopped at a PR-owned test-only unbound-method lint error; the saved method is now captured through a checked native property descriptor. The corrected real Gateway proof passes two cases / 28.83s, its canonical Gateway-server type graph passes, and every remaining native schema/import/auth guard passes independently. Final whole-delta typed lint, formatting, post-format caps, diff checks, and narrow fixture review also pass. The original aggregate is not claimed exit-zero; full hosted CI and Windows are not claimed green.

@clawsweeper

clawsweeper Bot commented Sep 26, 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.

@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Maintainer security changes approved

A maintainer approved this revision with an explicit security approval comment.

A later push requires a fresh approval comment for an external contributor's PR.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 26, 2026
@clawsweeper

clawsweeper Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed October 2, 2026, 1:31 AM ET / 05:31 UTC (Revision 16).

ClawSweeper review

What this changes

Agent deletion retires model and memory resources, drains database readers across workers, preserves surviving agents’ stores, and restores readers after legitimate recreation.

Merge readiness

⛔ Blocked before merge - 1 item remains

The PR remains necessary and has no identified blocking patch defect. Prior lifecycle findings are resolved, and the previous migration checkbox is inapplicable because the change introduces no stored-data contract.

Likely related people: @steipete (high-confidence routing through current-main area history and recorded owner involvement).

Priority: P2
Reviewed head: c724689570f625a9606ee5f7266fbc4bca632bd3

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A sound lifecycle repair with strong recorded production-boundary proof and no remaining actionable finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Recorded secretless hosted traces exercise actual Gateway deletion/recreation and real SQLite/catalog/heartbeat workers, showing physical closure, retained-store fencing across replacement workers, survivor access, and rejection under revoked or replaced deletion authority. The final-head run is verified successful; original log retrieval was proxy-blocked. No stored-data contract changes, so migration proof is not applicable.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): Recorded secretless hosted traces exercise actual Gateway deletion/recreation and real SQLite/catalog/heartbeat workers, showing physical closure, retained-store fencing across replacement workers, survivor access, and rejection under revoked or replaced deletion authority. The final-head run is verified successful; original log retrieval was proxy-blocked. No stored-data contract changes, so migration proof is not applicable.
Evidence reviewed 12 items Pinned introduction and clean checkout: Reviewed the introduced delta from 9fc095c to c724689. The checkout matches the original PR head; the supplied test merge is stale relative to the pinned base and was not used to infer removal of current-main behavior. Final whitespace inspection passed and git status remained clean.
Deletion authority and retirement: Runtime retirement verifies current deletion authority after lazy imports and before model and memory effects. The asynchronous guard reads exact journal identity through the state worker, verifies the live heartbeat lease, and rechecks closure, cancellation, and database admission after awaits.
Physical ownership and worker generations: The deletion plan separates owner-qualified historical registrations from survivor-filtered reader paths. Parent fences are captured at final task dispatch, installed after preceding resource closures, and cleared in the parent before revival fanout so failed delivery can reconcile on the next task.
Findings None None.
Security None None.

How this fits together

The Gateway’s agent lifecycle coordinates configuration, model and memory owners, and SQLite readers. Deletion must release these resources before file cleanup while preventing later workers from reopening retained deleted stores.

flowchart TD
  A[Agent delete request] --> B[Journal and live lease checks]
  B --> C[Select deleted agent resources]
  C --> D[Retire model and memory owners]
  D --> E[Drain and fence database readers]
  E --> F[Complete cleanup]
  G[Committed agent recreation] --> H[Restore reader admission]
  H --> E
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +539, Tests +943, Other +2. Total +1484 across 58 files.

View PR surface stats
Area Files Added Removed Net
Source 31 692 153 +539
Tests 26 1067 124 +943
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 58 1761 277 +1484

Review metrics

Metric Value Why it matters
Production and test growth production +692/-153; tests and support +1066/-124; tooling +3/-0 Production growth implements cross-worker reader retirement and live deletion guards; proof extends existing Gateway fixtures rather than adding Gateway boots.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/agents/auth-profiles/candidate-stores.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #159007
Summary: This PR is the implementation candidate for the paired deletion-resource issue; the merged shutdown cleanup repair is adjacent and distinct.

Members:

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

Technical review

Best possible solution:

Keep deletion cleanup with the existing lifecycle and worker owners, preserving survivor access and committed recreation outcomes.

Do we have a high-confidence way to reproduce the issue?

Yes, source supports the reported deletion-time leak: current main omits retirement and cross-worker reader fencing. The recorded real Gateway sequence creates a session, refreshes secrets, deletes its agent, and checks retained readers; this review did not execute it locally.

Is this the best way to solve the issue?

Yes, the patch extends existing lifecycle, model, memory, and worker owners and removes superseded reader-close paths. It preserves physical ownership checks and avoids a competing recovery manager.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This repairs bounded agent-deletion resource lifetime and retained-store access without evidence of a broader urgent outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Recorded secretless hosted traces exercise actual Gateway deletion/recreation and real SQLite/catalog/heartbeat workers, showing physical closure, retained-store fencing across replacement workers, survivor access, and rejection under revoked or replaced deletion authority. The final-head run is verified successful; original log retrieval was proxy-blocked. No stored-data contract changes, so migration proof is not applicable.
  • proof: sufficient: Contributor real behavior proof is sufficient. Recorded secretless hosted traces exercise actual Gateway deletion/recreation and real SQLite/catalog/heartbeat workers, showing physical closure, retained-store fencing across replacement workers, survivor access, and rejection under revoked or replaced deletion authority. The final-head run is verified successful; original log retrieval was proxy-blocked. No stored-data contract changes, so migration proof is not applicable.

Evidence

What I checked:

  • Pinned introduction and clean checkout: Reviewed the introduced delta from 9fc095c to c724689. The checkout matches the original PR head; the supplied test merge is stale relative to the pinned base and was not used to infer removal of current-main behavior. Final whitespace inspection passed and git status remained clean. (c724689570f6)
  • Deletion authority and retirement: Runtime retirement verifies current deletion authority after lazy imports and before model and memory effects. The asynchronous guard reads exact journal identity through the state worker, verifies the live heartbeat lease, and rechecks closure, cancellation, and database admission after awaits. (src/agents/agent-lifecycle-registry.ts:185, c724689570f6)
  • Physical ownership and worker generations: The deletion plan separates owner-qualified historical registrations from survivor-filtered reader paths. Parent fences are captured at final task dispatch, installed after preceding resource closures, and cleared in the parent before revival fanout so failed delivery can reconcile on the next task. (src/infra/worker-task-pool-worker.ts:31, c724689570f6)
  • Stored-data compatibility applicability: The introduced fences are an in-memory Map transported in worker messages; configured-candidate metadata is runtime state. Journal authority only selects existing agent_id, operation_id, and cleanup_completed columns. No DDL, journal encoding, credential format, retention policy, or configuration migration changes. The prior migration-proof next step therefore does not apply. (src/infra/agent-database-readers.ts:17, c724689570f6)
  • Recorded production-boundary proof: The fully read PR body matches captured SHA-256 25a109dacceb319b76063d369507fc8bc4d0ef199a63d903b2f5886a60535caa. It records final-head hosted results for two real Gateway deletion/recreation flows, the real catalog-reader survivor case, and real journal/heartbeat-worker authority cases. Source inspection confirms retained-inode fencing, current/replacement-worker reads, failed revival delivery, survivor credentials/history/identity, and rejected retirement under replaced or closed authority. Mocked handler refusal coverage is explicitly supplemental. Original log retrieval was blocked at productionresultssa5.blob.core.windows.net; execution details remain recorded contributor/owner evidence rather than independently reread logs. (src/gateway/server.agent-database-recreation-product-proof.test.ts:145, c724689570f6)
  • Final-head hosted gates: GitHub confirms CI run 36967591602 completed successfully for the exact PR head. The current ci-gate, dependency-review, and security-sensitive-review statuses are successful. The body identifies the tested synthetic merge and its separate base; those identities do not replace original-head parentage. (c724689570f6)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (15 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-30T17:25:31.785Z sha 4f62b8599039904b724a98aab4fe48d9cd4f5968 :: blocked before merge. :: [P2] Propagate deleted-path fences to workers started later
  • reviewed 2026-09-30T20:49:59.600Z sha de1caeb :: blocked before merge. :: none
  • reviewed 2026-10-02T03:30:10.746Z sha 7ecc748 :: needs real behavior proof before merge. :: [P2] [P2] Keep the survivor outside the recovery journal’s owned paths | [P2] [P2] Fix catalog admission before asserting reader retirement | [P3] [P3] Extract coherent code to satisfy the line-cap ratchet
  • reviewed 2026-10-02T03:37:43.052Z sha 7ecc748 :: needs real behavior proof before merge. :: [P2] [P2] Keep the survivor outside the recovery journal’s owned paths | [P2] [P2] Fix catalog admission before asserting reader retirement | [P3] [P3] Extract coherent code to satisfy the line-cap ratchet
  • reviewed 2026-10-02T04:01:07.792Z sha ad6e209 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-02T04:16:58.312Z sha ad6e209 :: blocked before merge. :: none
  • reviewed 2026-10-02T04:49:50.216Z sha e902786 :: blocked before merge. :: none
  • reviewed 2026-10-02T05:16:28.229Z sha c724689 :: blocked before merge. :: none

@ceckert

ceckert commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

The memory-manager follow-up is now included in d0b3ea3948cfa3cba99b6eb5a3bed486c9892945: four production lines use the existing per-agent native close API. The existing real-Gateway test now verifies provider retirement while another agent's memory manager survives; 35 focused cases, types, lint, and fresh code/security review pass.

The latest hosted run has one failing test: deferred-restart SecretRef revalidation timeout. The other 1,525 cases in that shard passed. The preceding SDK-generation timeout and repair-log assertion did not recur in this run.

I investigated without changing or weakening the failing test. Both variants pass on the candidate and pristine pinned base. This case mocks out the secrets preparation and model ownership changed here, and does not perform agent deletion. However, hosted CI tested merge 07a49b434cbcb494d4f57ee9a59ebf009e82472c, which includes upstream ba43505a2cb78c3b2f3b4e69f36b373e6d2de7be and its newer lease-clock fixture. The local pinned-base runs are therefore not an exact reproduction of that hosted fixture, and I am not claiming the timeout is proven harmless or fixed.

Could a maintainer rerun the failed CI jobs? This account is not permitted to rerun them. The cleanup source remains unchanged; if the timeout repeats, the next useful reproduction is that exact merge on Linux/Node 24 rather than increasing timeouts or adding retries to this patch.

@clawsweeper clawsweeper Bot added 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. 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 28, 2026
@ceckert
ceckert force-pushed the codex/fix-deleted-agent-resources branch from 1ad87ed to 00ede2a Compare September 28, 2026 02:39
@ceckert

ceckert commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed both lifecycle findings in 733362b7703400ef614d65798245942f29d07b88.

  • Committed agent creation now uses the existing committed-config revival policy. A failed worker acknowledgment logs a warning and leaves the reader fence retryable; it no longer turns an already-published creation into a failed RPC. The created agent ID is the only selected owner, and the newer native upload guard is preserved.
  • The final reader drain now runs after session cleanup but before any Trash move. Journal completion remains last. The existing retry/recreation case proves that close failure makes no new Trash attempts and retains the pending journal until recovery.

Final focused proof: 321 tests across agent mutations, native reload handlers, and read-only scopes pass; production/Gateway-methods types, typed lint, formatting, native line caps, and fresh scoped review pass. No new Gateway boot was added.

The preceding CI reader failure was also reproduced: a one-shot injected close error lets a second registered closer close the handle. Its fault now persists until the explicit retry, while preserving error identity, custody, and survivor assertions. The Windows sparse-checkout fixture remains unrelated and unchanged. The four hosted verifier-child exits remain unexplained despite a passing exact-file local run, so I am not calling full CI green. Details and original failed-run attribution are in the updated PR body; the exact-head maintainer security gate is still required.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 28, 2026
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

/allow-security-sensitive-change

@steipete
steipete merged commit 40d284f into openclaw:main Oct 2, 2026
212 of 214 checks passed
@steipete

steipete commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

steipete added a commit that referenced this pull request Oct 2, 2026
The complete SubsystemLogger mock from 06d2de9 (#163249) already
provided trace. Merging 40d284f (#159013) added it again and broke
check-test-types-core-4 with TS1117. Keep one trace and every other logger
method; no test case or assertion changes.

Validation: gateway-root tsgo, check-changed, scoped and boundary lint,
and P2 review. Static proof ran locally as authorized for this main repair.
steipete added a commit that referenced this pull request Oct 2, 2026
The catalog-worker deletion test introduced by #159013 expected an idle
WAL reader to keep the surviving agent database locked. That lock is
already absent before deletion on current main.

Verify the actual survivor contract instead: commit a new auth profile
through an independent connection, then read the exact update through
the existing prepared worker. Keep the deleted-database lock-release and
single live-worker assertions.

Validation: five complete local file runs, local and Linux Testbox
check-changed, changed-file and boundary lint, and P2 review passed.
The full infra run was cancelled before completion. Landing uses the
coordinator-approved single-file Testbox exception for this test-only
change; the completed focused and static proof remains valid.
Three additional post-rebase file runs passed.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
…nclaw#159013)

* fix: release deleted agents' model and auth resources

* fix: await only existing deleted-agent builds

* fix: close deleted agents' native memory managers

* fix(agents): close deleted database readers across worker isolates

* fix(agents): revive deleted stores by their captured owner

* refactor(state): remove superseded reader-close entry points

* fix(agents): preserve commit outcomes and close readers before trash

* fix(tooling): include agent readers in native wrapper inventory

* fix(agents): adapt deleted-reader cleanup to native worker owners

* fix(agents): preserve deletion fences across worker generations

* fix(agents): release deletion guards and repair CI proof

Release worker heartbeat references when a deletion lease closes. Keep the
journal authority SELECT in its worker-only module and route the catalog
reader fixture through the existing database-worker lane.

Close the survivor fixture's seed writer before recovery, establish archive
LRU order, and restore the shared logger mock's trace contract. Add effect
boundary coverage for revoked deletion authority and move bounded transport,
channel logging, and fixture code to their existing modules.

Preserves the agent deletion and recreation repair for openclaw#159007.

Co-authored-by: Chris Eckert <[email protected]>

* test(ci): retain native command and auth retirement diagnostics

Wait for a native command receipt before checking its result so a terminal
failure exposes its reason immediately. Include isolated Gateway logs in the
removed-profile assertion, with a debug-only publication retirement summary
that identifies cache, owner, pending-build, and Gateway-loan state.

This diagnoses UI and auth failures from CI run 36965599681 without relaxing
assertions, extending timeouts, or changing retirement/recovery authority.

Co-authored-by: Chris Eckert <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Chris Eckert <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
The complete SubsystemLogger mock from ddd9021 (openclaw#163249) already
provided trace. Merging 69f660d (openclaw#159013) added it again and broke
check-test-types-core-4 with TS1117. Keep one trace and every other logger
method; no test case or assertion changes.

Validation: gateway-root tsgo, check-changed, scoped and boundary lint,
and P2 review. Static proof ran locally as authorized for this main repair.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 3, 2026
The catalog-worker deletion test introduced by openclaw#159013 expected an idle
WAL reader to keep the surviving agent database locked. That lock is
already absent before deletion on current main.

Verify the actual survivor contract instead: commit a new auth profile
through an independent connection, then read the exact update through
the existing prepared worker. Keep the deleted-database lock-release and
single live-worker assertions.

Validation: five complete local file runs, local and Linux Testbox
check-changed, changed-file and boundary lint, and P2 review passed.
The full infra run was cancelled before completion. Landing uses the
coordinator-approved single-file Testbox exception for this test-only
change; the completed focused and static proof remains valid.
Three additional post-rebase file runs passed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts security-sensitive-changed size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted agents retain model and auth database readers

2 participants