Skip to content

fix(tasks): skip completed deleted-agent stores - #130554

Merged
vincentkoc merged 1 commit into
mainfrom
fix/tasks-maintenance-deleted-store
Aug 27, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/tasks-maintenance-deleted-store

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • skip session-registry stores whose agent deletion journal is already complete
  • continue maintaining healthy stores and report completed-deletion skips explicitly
  • preserve terminal behavior for incomplete deletions, corrupt stores, and unreadable cron facts

Root cause

Aggregate task maintenance treated every discovered session store as openable. A completed agent deletion intentionally fences its retained database, so the loop threw after earlier healthy stores had already been maintained and never returned a report.

The deletion lifecycle owns that state. Maintenance now recognizes only a completed deletion tombstone as a per-store skip; every other database failure remains terminal.

Validation

  • pre-fix reproduction: preview and apply aborted on the retained deleted-agent store; apply had already pruned the healthy store
  • focused command tests: 33 passed
  • fresh post-rebase branch autoreview: clean, correctness 0.98
  • changed-file checks: all applicable checks passed; dead-export scan discarded findings because the shared dependency tree could not resolve three existing Control UI config modules
  • Testbox tbx_01m10bk0ete6wtkx8sdvzawnnk: infrastructure blocked after roughly six hours without a terminal summary; the task-owned lease and processes were stopped, and no second heavy run was started

Scope

  • production: +25 / -7, net +18
  • tests: +171 / -40, net +131
  • no schema, migration, retention, transaction, discovery, lease, or config behavior changes

The positive production delta is the explicit lifecycle-state result and aggregate reporting; no downstream fallback path was added.

This is user-visible and release-note worthy; the landing release workflow owns the changelog entry.

Fixes #130237

Reported by @andersonjeccel.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@vincentkoc vincentkoc self-assigned this Aug 27, 2026
@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 27, 2026 01:10
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 9:18 PM ET / August 27, 2026, 01:18 UTC.

ClawSweeper review

What this changes

The PR skips session stores for agents with completed deletion journals, reports those skips, and continues task maintenance for healthy stores.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. The patch is a clean lifecycle-aware repair with no blocking correctness finding; it is a maintainer-owned PR and its exact-head CI is still running.

Priority: P2
Reviewed head: e6c29904be11f5f04fadc98a922f86b622e15d14

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, type-safe repair with credible boundary coverage; exact-head CI remains the final merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless records a deterministic pre-fix scenario and focused test result.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless records a deterministic pre-fix scenario and focused test result.
Evidence reviewed 5 items Current-main failure path: Current main iterates every discovered target and opens it without checking the deletion journal, so a retained deleted-agent store reaches the fenced database path.
Lifecycle contract: The deletion journal rejects a same-agent database claim before exempting completed cleanup paths; completed tombstones therefore still block the retired agent identity.
Patch boundary and regression coverage: The new guard recognizes only completed deletion journals; the focused tests cover healthy-store continuation in preview/apply plus incomplete-deletion and corruption terminal behavior.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw tasks maintenance --help

Result: PASS (completed)

$ node scripts/run-node.mjs tasks maintenance --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 110.66 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.8s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

[tsdown-build] invocation 2/2 finished in 14.5s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 11 phases completed in 4379ms (slowest: built plugin control-plane loads 3622ms)
│
◇

OpenClaw 2026.8.1 (e6c2990) — All your chats, one OpenClaw.

Usage: openclaw tasks maintenance [options]

Preview or apply tasks and TaskFlow maintenance

Options:
  --apply     Apply reconciliation, cleanup stamping, and pruning (default: false)
  -h, --help  Display help for command
  --json      Output as JSON (default: false)
$ node scripts/run-node.mjs tasks maintenance --help
│
◇

OpenClaw 2026.8.1 (e6c2990) — All your chats, one OpenClaw.

Usage: openclaw tasks maintenance [options]

Preview or apply tasks and TaskFlow maintenance

Options:
  --apply     Apply reconciliation, cleanup s
… output truncated …

Assertions:

  • PASS expect_output: Preview or apply tasks and TaskFlow maintenance

How this fits together

Task maintenance discovers configured and retained session stores, then prunes stale cron-run rows. Completed agent deletions intentionally fence their retained store identity, so this sweep must record that per-store outcome without hiding other stores' maintenance.

flowchart LR
  A[Tasks maintenance command] --> B[Discover session stores]
  B --> C[Read deletion journal]
  C --> D{Deletion complete?}
  D -->|Yes| E[Record skipped retired store]
  D -->|No| F[Prune eligible session rows]
  E --> G[JSON and terminal summary]
  F --> G
Loading

Before merge

  • Resolve merge risk (P1) - Production code grows by 18 net lines for a bug fix; the explicit skipped-store result and dual JSON/text reporting appear necessary, but the lifecycle-specific surface should remain this narrow.
Agent review details

Security

None.

PR surface

Source +18, Tests +131. Total +149 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 25 7 +18
Tests 1 171 40 +131
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 196 47 +149

Review metrics

Metric Value Why it matters
Production versus test LOC production +18 net; tests +131 net The production growth is confined to a typed lifecycle skip result and reporting, while regression coverage exercises preview, apply, terminal, JSON, and text paths.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #130237
Summary: This PR is the explicit candidate repair for the reported completed-deletion maintenance abort.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the completed-tombstone-only skip after exact-head CI, retaining explicit per-store reporting while leaving incomplete deletions and unrelated database failures terminal.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the completed-tombstone-only skip after exact-head CI, retaining explicit per-store reporting while leaving incomplete deletions and unrelated database failures terminal.

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

Yes, by source: retain a deleted agent's store with a completed journal, then run task maintenance; current main opens every discovered store and hits the same-agent deletion fence. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes. The guard consumes the deletion lifecycle's authoritative completed state before the session-store open, and it preserves terminal handling for incomplete deletion and corruption rather than masking all open failures.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b13993af1554.

Labels

Label changes:

  • add P2: The defect blocks a supported maintenance command for retained deleted-agent stores but does not affect normal gateway availability.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless records a deterministic pre-fix scenario and focused test result.

Label justifications:

  • P2: The defect blocks a supported maintenance command for retained deleted-agent stores but does not affect normal gateway availability.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored PR is exempt from the external-contributor proof gate; its body nevertheless records a deterministic pre-fix scenario and focused test result.

Evidence

What I checked:

Likely related people:

  • steipete: Introduced the maintenance module and has the strongest recent history across the session-target and deletion-lifecycle boundary. (role: feature owner and recent area contributor; confidence: high; commits: 95161c233530, 9d0c1f8f8c59, 8a5b4af66074; files: src/commands/tasks-session-registry-maintenance.ts, src/state/agent-deletion-journal.ts, src/config/sessions/targets.ts)
  • SunnyShu: Recent history includes work preserving retired-store discovery, the neighboring invariant this repair relies on. (role: adjacent session-store contributor; confidence: medium; commits: 79095b5a3f59; files: src/config/sessions/targets.ts)

Rank-up moves

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

  • Let the current-head CI complete before landing.
  • A redacted terminal transcript showing one healthy store maintained alongside one completed-deletion skip would further strengthen operator-facing evidence.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

ClawSweeper rank-up moves:

  • Exact-head CI: complete. Run 33029277494 attempt 2 is green at e6c29904be11f5f04fadc98a922f86b622e15d14; the retry recovered an unrelated hosted-runner loss in a node shard.
  • Mixed-store terminal transcript: not claimed. The task-owned Testbox run remained nonterminal for roughly six hours and was stopped without a second run. Focused command integration coverage proves a healthy store continues alongside a completed-deletion skip in preview and apply modes, while incomplete deletion and corruption remain terminal.

No ClawSweeper code findings remain.

@vincentkoc
vincentkoc merged commit 57cedf5 into main Aug 27, 2026
582 of 584 checks passed
@vincentkoc
vincentkoc deleted the fix/tasks-maintenance-deleted-store branch August 27, 2026 02:39
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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.

[Bug]: Task maintenance aborts on retained deleted-agent store

1 participant