fix(tasks): harden task-flow restore and maintenance#59672
Conversation
🔒 Aisle Security AnalysisWe found 1 potential security issue(s) in this PR:
1. 🟡 Delayed detection of orphaned managed TaskFlows due to stale-threshold gate
DescriptionThe
Vulnerable code: if (
flow.syncMode === "managed" &&
(flow.status === "running" || flow.status === "waiting" || flow.status === "blocked") &&
ageMs >=
(flow.status === "running"
? staleRunningMs
: flow.status === "waiting"
? staleWaitingMs
: staleBlockedMs) &&
linkedTasks.length === 0 &&
!hasBlockingMetadata(flow)
) {
// ... createFinding({ code: "missing_linked_tasks", ... })
}RecommendationIf orphaned managed flows are a security/operational signal, emit a finding immediately and add a separate stale-threshold escalation (e.g., warn immediately, error when stale), rather than suppressing the signal for up to Example approach: if (
flow.syncMode === "managed" &&
(flow.status === "running" || flow.status === "waiting" || flow.status === "blocked") &&
linkedTasks.length === 0 &&
!hasBlockingMetadata(flow)
) {
const threshold = flow.status === "running" ? staleRunningMs
: flow.status === "waiting" ? staleWaitingMs
: staleBlockedMs;
findings.push(createFinding({
severity: ageMs >= threshold ? (flow.status === "running" ? "error" : "warn") : "warn",
code: "missing_linked_tasks",
flow,
ageMs,
detail: "managed TaskFlow has no linked tasks or wait state",
}));
}Alternatively, introduce a short, dedicated threshold (e.g., 30–60s) for missing-linked-tasks detection distinct from stale-running/waiting/blocked thresholds. Analyzed PR: #59672 at commit Last updated on: 2026-04-02T13:57:35Z |
Greptile SummaryThis PR hardens the task-flow registry by catching restore failures and degrading them into audit findings, and adds new Two minor points worth noting:
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/tasks/task-flow-registry.audit.ts
Line: 225-240
Comment:
**`missing_linked_tasks` has no minimum-age gate**
Unlike `stale_running` (which requires `ageMs >= 30 min`), the `missing_linked_tasks` check fires immediately — including for a managed flow that was just created in `"running"` status before its first child task is linked. If task linkage can lag flow-status promotion by even one tick, this will emit a spurious error-severity finding. Consider guarding with a small minimum threshold (e.g. the same `staleRunningMs`) or restricting to the already-stale case:
```ts
if (
flow.syncMode === "managed" &&
(flow.status === "running" || flow.status === "waiting" || flow.status === "blocked") &&
ageMs >= (flow.status === "running" ? staleRunningMs : staleWaitingMs) &&
linkedTasks.length === 0 &&
!hasBlockingMetadata(flow)
) {
```
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/commands/tasks.ts
Line: 231-238
Comment:
**Breaking change to `--json` audit summary shape**
The `summary` object previously returned `{ total, errors, warnings, byCode }` (from `summarizeTaskAuditFindings`). It now returns `{ total, errors, warnings, tasks: {…byCode…}, taskFlows: {…} }`, so `summary.byCode` is gone. Any downstream consumers (scripts, integrations) reading `summary.byCode` directly will silently break. Similarly, the maintenance `--json` output's `auditBefore`/`auditAfter` moved from a flat `TaskAuditSummary` to `{ tasks, taskFlows }`, which is also a structural break. Worth a note in the PR or a changelog entry if external consumers exist.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into vk/taskflow-har..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c8918427e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Addressed the three review points in
Verification:
|
b6887a1 to
e1c85f9
Compare
Summary
openclaw tasks auditandopenclaw tasks maintenanceTesting