Skip to content

feat(implement): pre-flight check skips closed/already-merged issues (#936)#1113

Open
akaszubski wants to merge 4 commits into
masterfrom
batch-20260523-214713
Open

feat(implement): pre-flight check skips closed/already-merged issues (#936)#1113
akaszubski wants to merge 4 commits into
masterfrom
batch-20260523-214713

Conversation

@akaszubski
Copy link
Copy Markdown
Owner

Summary

STEP 0 of /implement now fast-fails when the target issue is already CLOSED or recently merged, preventing wasted pipeline cycles.

  • Extends existing gh issue view --json title,body to also fetch state (no additional API call)
  • Adds an 18-line bash pre-flight block that:
    • Exits with BLOCKED + exit 1 when ISSUE_STATE != "OPEN"
    • Exits with BLOCKED + exit 1 when git log -n 20 --grep "#${N}\b" returns matches
    • Skips silently for free-text mode (no #N in args) and when gh is unavailable
  • --force flag overrides both checks
  • 4 structural unit tests in tests/unit/commands/test_implement_preflight_issue_check.py
  • Documented --force flag and BLOCKED behavior in docs/PIPELINE-MODES.md

Closes #936

Test plan

Known follow-ups (will file separately)

  • MEDIUM (security-auditor): grep -q -- "--force" matches substrings like --force-push; should use word-boundary regex
  • WARNING (reviewer): \b in git --grep not portable to Linux git (BRE doesn't recognize); use [^0-9] instead

Pipeline notes

Ran via /implement batch mode in worktree .worktrees/batch-20260523-214713. 9 agents dispatched (planner, plan-critic, planner re-plan, implementer, spec-validator, reviewer, security-auditor, doc-master, CIA). Spec-validator PASS 9/9 ACs. Doc-master also updated CHANGELOG.

🤖 Generated with Claude Code

akaszubski and others added 4 commits May 23, 2026 12:42
Add three pieces of automation for unattended /implement runs:

- scripts/drain-backlog.sh: one-shot sequential drainer for 16 thematic
  batches. Each batch runs in its own `claude -p` process (fresh context,
  full harness, all hooks/agents/gates active). Uses --permission-mode
  acceptEdits (auto-approves writes; hook decisions still block) plus
  --max-budget-usd cap. Stream-json + hook-event capture per batch.
  Resume via --from N.

- scripts/triage-and-implement.sh: recurring entry point for cron/launchd.
  Runs /triage --auto-improvement --json, picks the top cluster's first
  N issues (default 8), filters out closed/PR-linked, then runs the
  harness headless. Aborts cleanly when working tree is dirty
  (cron-safe — never destroys in-progress work).

- scripts/launchd/: macOS launchd plist + README to wire the recurring
  script to 02:30 daily local.

No --bare, no --dangerously-skip-permissions — the full harness runs
exactly as it does interactively, just without the prompt loop.

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

The first scheduled run hit a hook deadlock at ~5 minutes:

- /implement --batch creates a worktree (.worktrees/batch-TIMESTAMP) for
  multi-issue isolation
- This repo gitignores .claude/* (line 141 of .gitignore)
- `git worktree add` skips untracked files → worktree gets empty .claude/hooks/
- Once the coordinator cd's into the worktree, $(git rev-parse --show-toplevel)
  in the PreToolUse hook resolves to the worktree root
- Hook can't find its own script → every tool call blocked → hook-deadlock
  protocol fires → Claude correctly waits for a user that isn't there →
  run exits with 0 work done

Workaround: run /implement one issue at a time. Single-issue mode stays on
master, no worktree, no deadlock. Slightly slower per-issue (no batch-wide
research/plan-critic caching) but reliable for unattended runs.

Also: drop --max-budget-usd flag from both scripts and the launchd plist.
User is on Max plan subscription auth (claude.ai, firstParty), not API
billing — the cap was synthetic and irrelevant. Subscription usage quotas
remain the real limit, handled by the CLI directly.

The --batch path still works in scripts/drain-backlog.sh for manual
attended use where the user can resolve hook deadlocks if they surface.

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

Lists all open issues (excluding epics and PR-linked), runs single-issue
/implement N on each in sequence. Per-issue markers in logs/drain-all/state/
make the script idempotent and resumable — re-running picks up where it
left off, skipping completed and previously-failed issues.

Single-issue mode avoids the /implement --batch worktree-hook-deadlock bug.
Background-friendly: progress.log is human-readable; events.json per issue
captures the full stream for diagnostics.

Two modes:
  --phase1            top auto-improvement cluster (~36 issues, focused)
  (default)           full backlog (~80 issues after epic/PR exclusion)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
STEP 0 of /implement now exits with BLOCKED + exit 1 when the target
issue is CLOSED, or when a recent commit (last 20) references the
issue number. Honors --force to override. No-op for free-text mode
and graceful when gh CLI is unavailable.

Prevents ~10min of wasted pipeline cycles per occurrence (cf. session
2026-04-25 burn on already-merged #926).

Closes #936

Known follow-ups (file post-batch):
- security-auditor MEDIUM: --force grep matches --force-something
  substrings; should use word-boundary regex
- reviewer WARNING: \\b in git --grep is not portable to Linux git

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

[CI] Coordinator starts pipeline before verifying issue is not already merged

1 participant