Skip to content

feat(decisions): closing a decision as completed unblocks its task - #14

Merged
aicorey merged 24 commits into
mainfrom
feat/decision-auto-resume
Nov 20, 2026
Merged

aicorey merged 24 commits into
mainfrom
feat/decision-auto-resume

Conversation

@aicorey

@aicorey aicorey commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Closing a decision issue as completed now unblocks the task it names: the foreman writes the answer to the task's ledger, then lifts blocked and sets Status Ready on the next tick. Part 1 of docs/superpowers/specs/2026-11-17-decisions-artifact-design.md; the claude.ai decisions page (part 2) is not in this PR.

  • Decision layout (roles/builder.md): a builder's decision issue now has Question / Context / Options (A, B, …) / Recommendation and ends with Blocks: #<issue>. A resumed builder reads the foreman's decision #<n> … line first.
  • Auto-unblock (src/decisions.ts, wired into runOnce): reads decision issues closed in the last ~7 days, only on ticks with an open blocked issue. A task is unblocked when a decision naming it was closed as COMPLETED, opened after the task was last unblocked, no open decision still names it, no role session holds its claim, and no NOT_PLANNED decision in the same spell names it (that one is read with no date window).
  • Ledger: decision #<d> settled: <answer> — unblocked by decision via foreman@<host> or decision #<d> closed; read it before continuing — …. The answer is the earliest Settled: comment on the decision.
  • Failure order: ledger lines first, blocked removed last (unblockEdits(…, { blockedLast: true })), so a partial failure leaves the task blocked with the answer recorded for the owner's Unblock. The owner's Unblock button is unchanged (same calls, same order, tests untouched).
  • A tick that unblocks a task counts as work for the idle backoff (not in --dry-run).

Owner decisions recorded

  • Any NOT_PLANNED decision on a task keeps it blocked.
  • Ledger wording says "unblocked by decision", not "resumed".

Known gaps (README)

  • A blocked label removed by hand on GitHub writes no ledger line, so an earlier settled decision can release a later, unrelated block.
  • Decisions written before this layout have no Blocks: line and still need Unblock.
  • Two foremen on one repo can both unblock a task (duplicate ledger lines, harmless).

Test plan

  • pnpm lint && pnpm typecheck && pnpm test && pnpm build (782 tests on this branch; 818 merged together with #target-branch, both green)
  • Four review rounds tracing real sequences: two Macs, settle-before-session-ends, manual Unblock then re-block, mixed NOT_PLANNED, partial GitHub failures
  • Live check on a served repository: a test task blocked by a test decision, closed as completed, unblocks within one tick — not run yet

🤖 Generated with Claude Code

aicorey and others added 20 commits November 17, 2026 16:06
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ammar

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… "resumed"

"resumed" clashes with the usage-limit session resume and the epic Pause/Resume. The two
lines become `decision #<d> settled: <answer> — unblocked by decision via foreman@<host>` and
`decision #<d> closed; read it before continuing — unblocked by decision via foreman@<host>`.
fmt.decisionResumed, DECISION_RESUMED and decisionResumed() are renamed to match; README and
the design spec quote the new lines.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s line counts

If any decision naming task N was closed as NOT_PLANNED and opened after N was last unblocked,
planDecisionResumes no longer unblocks N, even when another decision for N was closed as
completed. Held tasks are collected first, then skipped; DUPLICATE and other reasons are still
ignored. The Blocks line now tolerates leading and trailing spaces or tabs.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…s a task

unblockEdits takes an optional { blockedLast } that moves the label removal after the PR
verdicts and Status Ready, so a failed edit on the decision path leaves the task blocked with
the answer recorded. The owner's Unblock keeps the original order. Also drops dead code: the
`note` parameter of applyUnblock (no production caller left) and `host` from unblockEdits.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
runOnce keeps the tasks resumeSettledDecisions returns and reports didWork when any were
unblocked outside a dry run, so the idle backoff resets and the claim follows on the next poll
instead of up to half an hour later.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…rs unblock order

Builder step 1 now reads any `decision #<n> …` comment from the foreman and follows it,
running `gh issue view <n> --comments` first when the line says the decision was closed
without an answer. Step 2 asks for `Blocks: #<issue>` alone on the last line with no
indentation and only notes that the foreman unblocks the issue when the decision is closed.
README: a settled decision also lifts the blocked-per-phase build stop, the lookback is about a
week (7-8 days, the cutoff is a date), the decision path lifts the block last, and the known
gaps name duplicate ledger lines from two foremen and the cross-Mac re-block window.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… window

Rule B only saw not-planned decisions closed in the last week, so one closed earlier no longer
held its task once a later decision was completed. listClosedDecisions takes
{ notPlanned: true }, which searches `reason:"not planned"` with no date; resumeSettledDecisions
makes that second read only when the first yields a candidate, merges the two lists by number
and plans again.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Comment thread src/decisions.ts
* way, e.g. closed by hand on GitHub.
*/
export function settledAnswer(comments: Comment[]): string | null {
for (const c of [...comments].sort((a, b) => a.createdAt.localeCompare(b.createdAt))) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Settled answer is taken from any commenter, earliest wins. settledAnswer ignores c.author, so on this public repo any GitHub user can comment Settled: <text> on an open decision issue. When the owner then closes it as completed, the foreman quotes that stranger's text into the task ledger as decision #D settled: <text>, and roles/builder.md now tells the builder to "Follow that decision's answer". Because the earliest Settled: wins, an outsider who comments first also overrides the owner's real answer posted by the decisions page. Net effect: unauthenticated instructions injected into an unattended claude -p session. Restrict to comments authored by the foreman/owner login (the one the decisions page posts as), or to authors with write access.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in a307576: a Settled: comment now counts only when its author has admin, maintain or write permission on the repository (one lookup per author per call); anyone else's is ignored, so the task unblocks with the writer's answer or, failing one, with "closed; read it before continuing".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up in 049c77e: a failed access lookup now defers that task to the next tick instead of counting as a no, and with no writer's answer the ledger line names the writers the builder may follow (follow only: @…, or nobody — ask the owner), which roles/builder.md now obeys.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up in d85349c: the builder now trusts a decision #<n> line only from the login that posted its own session line and acts only on lines since the latest block (no re-block loop), an unanswered completed close means follow the Recommendation, the plan no longer carries an untrusted answer, the not-planned read is newest-first, and a non-rate-limit 403 counts as no access with a warning.

aicorey and others added 4 commits November 19, 2026 15:22
… counts

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ilder may follow

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…lock loop

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@aicorey
aicorey merged commit 4952758 into main Nov 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant