feat(tasks): harden maintenance repair paths#57439
Conversation
4cf55c9 to
646590f
Compare
Greptile SummaryThis PR closes the two-pass gap in task maintenance:
Confidence Score: 5/5Safe to merge — all remaining findings are P2 style suggestions that do not affect correctness or runtime behaviour. The core logic change (single-pass cleanupAfter stamping for lost tasks) is correct and well-tested. The status hint is guarded by the right condition. Only two P2 style issues remain: a missing blank-line separator in the status output and a minor redundancy in the cleanupAfter derivation. Neither affects functionality. src/commands/status.command.ts (missing blank line before maintenance hint)
|
| Filename | Overview |
|---|---|
| src/tasks/task-registry.maintenance.ts | markTaskLost now stamps cleanupAfter in the same reconciliation pass; projectTaskLost mirrors this for inspection paths. Logic is correct; minor redundancy in cleanupAfter derivation. |
| src/commands/status.command.ts | Adds maintenance hint after the overview table when taskAudit.errors > 0. Missing blank-line separator before the hint (P2 style). |
| src/tasks/task-registry.test.ts | New test asserts single-pass lost reconciliation with immediate cleanupAfter stamping and cleanupStamped: 0. Coverage is correct and targeted. |
| src/commands/status.test.ts | Adds mocks for getInspectableTaskRegistrySummary and getInspectableTaskAuditSummary plus a test confirming the maintenance hint appears when audit errors > 0. |
Prompt To Fix All With AI
This is a comment left during a code review.
Path: src/commands/status.command.ts
Line: 546-550
Comment:
**Missing blank-line separator before maintenance hint**
Every other conditional hint block in this function (`pairingRecovery`, `pluginCompatibility`) starts with `runtime.log("")` to visually separate it from the preceding table. The new maintenance hint is emitted immediately after the trimmed table output with no blank line, so it will appear "glued" to the table rows on terminals.
```suggestion
if (summary.taskAudit.errors > 0) {
runtime.log("");
runtime.log(
theme.muted(`Task maintenance: ${formatCliCommand("openclaw tasks maintenance --apply")}`),
);
}
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/tasks/task-registry.maintenance.ts
Line: 111
Comment:
**Redundant double-computation of `cleanupAfter`**
`projectTaskLost(task, now)` already computes and stores `cleanupAfter` on the returned record (via its own `resolveCleanupAfter` call). Wrapping its result in another `resolveCleanupAfter(...)` call re-derives the same value from `endedAt`/`lastEventAt` — the two computations are always equal, but it's unnecessarily indirect. Using the projected record's field directly is clearer and avoids repeating the derivation logic:
```suggestion
const cleanupAfter = task.cleanupAfter ?? projectTaskLost(task, now).cleanupAfter;
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into feat/task-healt..." | Re-trigger Greptile
|
🤖 We're reviewing this PR with Aisle We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛ Progress:
Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-03-30T09:12:07Z |
|
🤖 We're reviewing this PR with Aisle We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛ Progress:
Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-03-30T09:40:20Z |
* feat(tasks): harden maintenance repair paths * fix(tasks): address follow-up maintenance review comments
* feat(tasks): harden maintenance repair paths * fix(tasks): address follow-up maintenance review comments
Summary
lostdid not getcleanupAfteruntil a later pass, andstatussurfaced audit errors without telling operators the repair command.cleanupAfterin the same pass that marks a tasklost, inspection-time lost projections mirror that retention, andopenclaw statusprints a direct maintenance hint when task audit errors are present.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause / Regression History (if applicable)
loststate and retention in two separate passes.cleanupAfterimmediately.git blame, prior PR, issue, or refactor if known): follow-up to the task maintenance/status work in feat(tasks): add status health and maintenance command #57423.Regression Test Plan (if applicable)
src/tasks/task-registry.test.ts,src/commands/status.test.tslostis immediately cleanup-eligible, and status shows the maintenance command when task audit errors exist.User-visible / Behavior Changes
openclaw statusnow prints a directopenclaw tasks maintenance --applyhint when task audit errors are present.cleanupAfterimmediately in the same maintenance pass.Diagram (if applicable)
Security Impact (required)
Yes/No) NoYes/No) NoYes/No) NoYes/No) NoYes/No) NoYes, explain risk + mitigation: N/ARepro + Verification
Environment
Steps
Expected
lostand stampscleanupAfterimmediately.Actual
Evidence
Human Verification (required)
cleanupStamped: 0for the lost reconciliation path because retention is applied as part of the reconciliation itself.pnpm testsuite;pnpm checkon currentmain.Review Conversations
Compatibility / Migration
Yes/No) YesYes/No) NoYes/No) NoRisks and Mitigations
pnpm checkis still red on latestmaindue to the unrelatedsrc/agents/skills.test-helpers.ts:34error.AI Assistance
pnpm test -- src/tasks/task-registry.test.ts src/commands/status.test.tscodex review --base origin/main: not re-run in this tiny follow-up because the local transport issue to127.0.0.1remained unresolved in the earlier PR cycle.