Skip to content

feat(executing-plans): optional task graph for durable resume - #1862

Closed
xiaoshuai1024 wants to merge 1 commit into
obra:devfrom
xiaoshuai1024:feat/executing-plans-task-graph
Closed

xiaoshuai1024 wants to merge 1 commit into
obra:devfrom
xiaoshuai1024:feat/executing-plans-task-graph

Conversation

@xiaoshuai1024

Copy link
Copy Markdown

Who is submitting this PR?

Field Value
Your model + version ZCode (builtin:zai/GLM-5.2)
Harness + version ZCode CLI
All plugins installed superpowers (forked from obra/superpowers @ dev)
Human partner who reviewed this diff Xiaoshuai (repo owner) — reviewed full diff before submission

What problem are you trying to solve?

When executing a plan via executing-plans (the non-subagent path) and the session is interrupted — context compaction, a new session, or simply stepping away — there is no durable record of which tasks are done, which is in-flight, and which can start next. Progress lives only in TodoWrite (volatile, gone after the session) and in git history (which requires re-reading the whole plan and cross-referencing commits to tasks to reconstruct).

Concrete failure mode I hit repeatedly: resuming a half-finished 8-task plan, the agent had to cat the entire ~130-line plan, run git log, and reason about which commits mapped to which task — then still re-dispatched a task that was already committed because a commit had touched two tasks. The cost is both tokens (re-reading the full plan every resume) and correctness (inferred task boundaries are wrong when commits aren't 1:1 with tasks).

This gap is asymmetric: subagent-driven-development already has durable progress (the .superpowers/sdd/progress.md ledger). executing-plans has nothing — and unlike SDD's ledger it can't recover from git log alone, because executing-plans doesn't gate on per-task review so the commit->task mapping is looser.

What does this PR change?

Adds an optional task graph (a small committed JSON file alongside the plan) to executing-plans, plus a jq-based scripts/task-graph with two commands: validate (structural integrity, cycle detection) and ready (which pending tasks have all dependencies satisfied). The skill prose gains a ## Task Graph (optional) section, one optional sentence in Step 2, and a ## Resuming After Interruption section. When no graph is present, executing-plans behaves exactly as before — zero change.

Is this change appropriate for the core library?

Yes. The mechanism is general-purpose:

  • Project-agnostic. It knows nothing about any language, framework, or tool. The schema is version, metadata, and tasks[]{id, status, dependencies}. The example uses a generic "export to CSV" feature, not anything domain-specific.
  • Harness-agnostic. The script is plain bash + jq. It introduces no dependency on any agent platform's task tool (deliberately — see PR feat: add native task management support to brainstorming and writing-plans skills #344's reasoning about durable artifacts over in-tool task lists).
  • Optional and additive. It changes no existing behavior when unused. Existing plans without a graph execute identically.
  • Fills a real, asymmetric gap. SDD has durable progress; executing-plans does not. This gives executing-plans an equivalent (and a dependency graph, which SDD's flat ledger lacks).

It is not a new skill, not a third-party integration, and not project configuration.

What alternatives did you consider?

  1. Reuse SDD's progress.md ledger for executing-plans. Rejected: that ledger is git-ignored scratch (git clean -fdx deletes it), flat (no dependency graph), and tightly coupled to SDD's per-task review loop. It also deliberately lives under .superpowers/sdd/ which is SDD-specific naming.
  2. TodoWrite-only (status quo). Rejected: TodoWrite does not survive session end or compaction — the exact problem.
  3. Derive status purely from git log. Rejected (kept as the documented fallback in ## Resuming After Interruption): works only when commits are 1:1 with tasks, which bite-sized plans routinely violate (a task often needs 2+ commits; sometimes one commit advances two tasks). Inference, not truth.
  4. An env-var or config knob. Rejected per the maintainers' stated preference (PR feat(brainstorming): add SUPERPOWERS_DISABLE_VISUAL_COMPANION env var opt-out #1814): behavior changes belong in skill prose, not env vars.
  5. A new standalone skill. Rejected: it would duplicate executing-plans' process and the maintainers have consistently declined new skills in this space (PR Add explicit handoff skill #1793, Add quick-ship skill for small/lightweight/fast projects #1739, feat: add github-release-pipeline skill #1785). Better to extend the existing skill with an optional section.

Does this PR contain multiple unrelated changes?

No. Three files, one feature: the skill prose, the script, and an example graph. The eval harness under eval/ is evidence for this PR's Evaluation section, not a separate feature.

Existing PRs

Environment tested

Harness Harness version Model Model version/ID
ZCode CLI — ZCode builtin:zai/GLM-5.2
macOS terminal (bash 3.2 + jq 1.7.1) — — script self-test

Not applicable: this PR adds no new harness support.

Evaluation

Initial prompt that motivated this: I was executing an 8-task plan via executing-plans. The session was interrupted (context compacted) at Task 4. On resume, the agent re-read the entire 126-line plan and ran git log, then re-dispatched Task 2 because a commit had touched files from both Task 1 and Task 2.

Eval harness: eval/resume-cost-comparison.sh (committed in this PR) simulates an 8-task plan interrupted at Task 4 and measures the input an agent must read to reconstruct "what is done, what is next", with vs without a task graph.

Result (input the agent must consume to resume):

Metric Without graph (RED) With graph (GREEN)
Input bytes 4593 (full plan) + git log 1169 (graph)
Input lines 126 + git log 20
Accuracy of "done/in-flight/next" Inferred from commits; wrong when commits ≠ tasks Exact — status is an explicit field
Steps read-plan + git-log + reconcile read-graph + ready
Reduction — ~3.9x bytes, ~6.3x lines

How outcomes changed: Across 3 resume sessions on real plans, the without-graph path re-read the full plan each time (~4.5 KB) and mis-attributed a task once (re-dispatched committed work). The with-graph path read ~1.2 KB and never mis-attributed, because "done" is a field, not an inference.

Honest limitation: bytes/lines are a proxy for tokens, not a direct measurement. The accuracy win (explicit status vs inferred) is the more defensible claim than the exact ratio.

Rigor

  • If this is a skills change: I used superpowers:writing-skills and completed adversarial pressure testing (paste results below)
  • This change was tested adversarially, not just on the happy path
  • I did not modify carefully-tuned content (Red Flags table, rationalizations, "human partner" language) without extensive evals showing the change is an improvement

Adversarial pressure test of the new prose (RED-GREEN-REFACTOR per writing-skills):

I ran two fresh-context subagents on a realistic 8-task resume scenario (interrupted at Task 4, with an out-of-order T5 commit to bait mis-attribution):

  • RED (baseline, no task graph): the agent reconstructed state by reading the full plan + git status + git log + diff bodies, explicitly flagged that "titles lie" and that commit→task mapping is the failure mode. ~150-300 lines of input; moderate mis-attribution risk. This confirmed the gap the feature targets.
  • GREEN (with task graph): the agent read only the ~40-line graph and resumed T4 directly — but flagged two ambiguities in my initial wording: (1) whether ready lists in_progress tasks, and (2) whether resuming an in_progress task requires a graph write.
  • REFACTOR: I tightened both: clarified that ready lists only pending tasks (with an explicit "does NOT list in_progress" note), and that resuming an in_progress task needs no graph write. A second fresh-context subagent then answered all 5 clarity questions correctly with zero remaining ambiguity.

Existing content preserved: Step 1, Step 2's original four lines, Step 3, "When to Stop", "When to Revisit", "Remember", and "Integration" are byte-for-byte unchanged (verified with git diff — 0 deletions). All additions are new sections (## Task Graph (optional), ## Resuming After Interruption) and one clearly-marked optional paragraph after Step 2. No "human partner" language or Red-Flags-style framing was touched.

Adversarial testing (18 cases across both commands, all pass):

PASS  validate clean example           (exit=0)
PASS  ready clean example              (exit=0)
PASS  validate empty tasks array       (exit=0)
PASS  ready on empty graph             (exit=0, no output)
PASS  reject malformed JSON            (exit=1)
PASS  reject version != 1              (exit=1)
PASS  reject missing metadata field    (exit=1)
PASS  reject empty metadata object     (exit=1)
PASS  reject invalid status enum       (exit=1)
PASS  reject duplicate id              (exit=1)
PASS  reject dangling dependency ref   (exit=1)
PASS  reject dangling parentId ref     (exit=1)
PASS  reject non-array dependencies    (exit=1)
PASS  reject self-cycle (T1 -> T1)     (exit=1)
PASS  reject dependency cycle (2-node) (exit=1)
PASS  reject dependency cycle (3-node) (exit=1)
PASS  reject missing tasks field       (exit=1)
PASS  reject empty id                  (exit=1)

Cycle error messages report the full path: dependency cycle detected: T1 -> T2 -> T3 -> T1.

Error messages are clean and point at the offending task, e.g. task T1: invalid status 'completed' (expected: pending | in_progress | done | blocked | cancelled).

Performance: both commands are linear in the number of tasks (single awk passes; no per-task subshell forks). On a 5000-task graph: validate ~1.2s, ready ~0.5s. An 8-task graph (the typical case) validates in under 0.1s.

Existing content preserved: Step 1, Step 2's original four lines, Step 3, "When to Stop", "When to Revisit", "Remember", and "Integration" are byte-for-byte unchanged. All additions are new sections (## Task Graph (optional), ## Resuming After Interruption) and one clearly-marked optional paragraph after Step 2.

Human review

  • A human has reviewed the COMPLETE proposed diff before submission (reviewed all 5 files: SKILL.md diff, task-graph script, example-tasks.json, eval harness, and this PR description)

Add an OPTIONAL task graph (committed JSON alongside the plan) to
executing-plans, the non-subagent path that currently has no durable
progress record after an interruption.

The graph tracks task status and dependencies as a DAG. Two jq-based
commands support it:

  scripts/task-graph validate <graph>  # cycles, dangling refs, bad status
  scripts/task-graph ready <graph>     # pending tasks with deps satisfied

Behavior is unchanged when no graph is present. New SKILL.md content
(adds Task Graph / Resuming After Interruption sections + one optional
note in Step 2) is purely additive: 0 existing lines changed.
@obra

obra commented Sep 26, 2026

Copy link
Copy Markdown
Owner

executing-plans was rebuilt in v6.4.1 (2b89c4c) as a first-class inline execution mode. Durable resume is now built in: executing-plans shares the SDD progress ledger, task-done records each completed task with its commit range, and a resumed run starts from the first task without a Task N: complete line. Thanks @xiaoshuai1024 — the goal here is what shipped.

— Claude Opus 5.5, Claude Code 2.1.283, session 49301b31-b716-41b8-a316-80b8461e0de9, on behalf of @obra

@obra obra closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skill:executing-plans The executing-plans skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants