You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adopt Symphony's reconciliation tick. Every N seconds, batch-fetch the GitHub state of all running pipelines' source issues. If the issue has been closed or has a terminal label (`wontfix`, `duplicate`, etc.), cancel the pipeline and clean its worktree. Stops shipcode from burning tokens on issues a human has already abandoned.
Implementation Checklist
New scheduler loop in `packages/pipeline/src/` (or extend existing `IssueGroupScheduler`) ticking every `reconcileIntervalMs`
Tick batches running threads by repo, calls `gh issue list --json number,state,labels --search ""` (or per-issue `gh issue view`)
For each running thread whose issue is `closed` or has any label in `terminalLabels`, invoke pipeline `cancel(threadId)`
Worktree cleanup proceeds via existing `WorktreeManager.remove(path, branch)`
API failure during reconcile must not crash; log and retry next tick
Problem Statement
If a teammate closes a GitHub issue while shipcode is running on it, the pipeline keeps planning, reviewing, executing, and verifying until done. Tokens are spent. Worktree litter accumulates. The user then has to notice and manually cancel from the UI.
Goals
Reconciliation tick runs every `reconcileIntervalMs` (default 30000).
For each `running` thread, refresh the GitHub issue state in one batched call.
Issue `closed` or carrying a terminal label (configurable list) → cancel the pipeline.
Cancellation uses the same SIGHUP→SIGKILL escalation as `killAllAndWait`.
Reconciliation across multiple repos in one tick (single-repo per tick is fine for v1).
User Stories
As a teammate who decides to close an issue mid-pipeline, I want shipcode to notice within a poll interval and cancel the run, so we do not waste API tokens or land an unwanted PR. Acceptance:
Closing the issue mid-pipeline cancels within `reconcileIntervalMs`.
Adding a `wontfix` label cancels.
Worktree is cleaned up post-cancel.
Reason logged and surfaced in UI as `cancelled: issue terminal`.
Functional Requirements
New scheduler loop in `packages/pipeline/src/` (or extend existing `IssueGroupScheduler`) ticking every `reconcileIntervalMs`.
Tick batches running threads by repo, calls `gh issue list --json number,state,labels --search ""` (or per-issue `gh issue view`).
For each running thread whose issue is `closed` or has any label in `terminalLabels`, invoke pipeline `cancel(threadId)`.
Worktree cleanup proceeds via existing `WorktreeManager.remove(path, branch)`.
API failure during reconcile must not crash; log and retry next tick.
Non-Functional Requirements
Tick must complete in <2s for 20 running threads.
API rate limits must not be exceeded — coalesce per-repo into one query when possible.
Success Criteria
Unit test with fake timers and a mocked GH API: closing the issue triggers cancel within one tick.
Label-based cancel: `wontfix` label triggers cancel; non-terminal labels do not.
API-failure test: reconcile error does not crash; running threads survive.
Manual: close a real GH issue mid-pipeline; verify cancel within 30s and worktree cleaned.
Out of Scope
Pre-flight check at dispatch time (handled by existing eligibility gate).
PRD: cancel-on-issue-state-change
Executive Summary
Adopt Symphony's reconciliation tick. Every N seconds, batch-fetch the GitHub state of all running pipelines' source issues. If the issue has been closed or has a terminal label (`wontfix`, `duplicate`, etc.), cancel the pipeline and clean its worktree. Stops shipcode from burning tokens on issues a human has already abandoned.
Implementation Checklist
Problem Statement
If a teammate closes a GitHub issue while shipcode is running on it, the pipeline keeps planning, reviewing, executing, and verifying until done. Tokens are spent. Worktree litter accumulates. The user then has to notice and manually cancel from the UI.
Goals
Non-Goals
User Stories
Acceptance:
Functional Requirements
Non-Functional Requirements
Success Criteria
Out of Scope
Dependencies
Verification Plan
Risks & Open Questions