Repository navigation
Description
Problem
The epic queue is an ordered list with one cursor, one dispatch claim (head_started_at) and one free-text blocked_reason whose meaning is told apart by string patterns. Every guard assumes exactly one issue is in flight. That model cannot hold several ready issues, cannot say which issue is blocked or why in a structured way, and offers no way to skip an issue: closing a queued issue stalls a merge-advancing epic permanently.
Goal
A behaviour-preserving refactor: the queue tracks state per issue, so later issues can run a dependency graph on it. After this issue a sequential epic and a parallel epic behave exactly as they do today.
Acceptance criteria
- Each issue in an execution has its own persisted state: at least pending, dispatched (with its own dispatch claim time), done, blocked, skipped; and for blocked issues a structured reason kind plus the human-readable text. Reason kinds cover every case that exists today: closed without merge under the merged policy, issue missing from the plan, dispatch failure, agent-reported blocker, awaiting a human merge, label handoff wait, setup not ready.
- Existing active queues are migrated in place: issues before the cursor become done, the head keeps its claim and blocked reason, later issues are pending. A restart in the middle of an execution loses nothing.
- Every write that advances, claims or blocks an issue stays a guarded compare-and-set on that issue's state and the execution id. Two processes can never dispatch the same issue twice, and a stale execution can never write.
- The dispatch retry after 15 minutes, the pause check, the label handoff, the agent-blocked hold (never re-dispatched by recovery), the human-merge wait and the reconcile sweep all keep their behaviour, now per issue.
summarizeEpicQueue, MCPget_plan/get_operationand the REST execution-queue response keep their current fields (issues,cursor,head,status,advanceOn,blockedReason) with the same values for sequential and parallel executions, and add a per-issue list with state and blocked reason kind.- Code that asks "is this issue the head" (
src/jobs/issueJobPostProcessingHelpers.ts,src/jobs/noChangeCompletion.ts,epicQueueBlockedHead.ts,epicQueueHumanMerge.ts,epicIssueLabelHandoff.ts,packages/api/routes/planIssueEpicQueue.ts) uses the per-issue state instead ofissues[cursor]. - No scheduling change: sequential still starts one issue at a time in order, parallel still fans out at request time.
- All existing epic queue tests pass with at most fixture changes for the new schema, and new tests cover the in-place migration of an active sequential queue, an active parallel queue and a completed queue, plus duplicate-dispatch protection under two concurrent advances.
Out of scope
- Dependency-aware readiness and
max_parallel(next issue). - Events, skip and retry actions (later issue).
Implementation
Key files: packages/core/src/services/taskPlanning/epicExecutionQueue.ts (createEpicExecutionQueue, advanceEpicQueue, decideEpicAdvance, startEpicQueueHead, dispatchPendingQueueHead, completeParallelEpicQueue, finalizeCompletedEpicQueue, reconcileEpicExecutionQueues and its repair helpers, summarizeEpicQueue, RETRY_PENDING_AFTER_MS), epicQueueBlockedHead.ts, epicQueueHumanMerge.ts, epicIssueLabelHandoff.ts, epicQueueModelLabel.ts, draftPauseResume.ts, packages/api/routes/planIssueEpicQueue.ts (appendToActiveQueue compares the issues JSON string), packages/api/mcp/tools.ts (implement_plan; UNSTARTED_EPIC_REASON is compared by equality), src/jobs/issueJobBlocked.ts (syncEpicQueueBlocker), src/jobs/issueJobPostProcessingHelpers.ts, src/jobs/noChangeCompletion.ts, packages/core/src/services/autoMergeGate.ts (surfaceEpicHumanMerge), propr-ui/src/api/planIssuesApi.ts (PlanExecutionQueue).
The queue table is epic_execution_queues (primary key draft_id; migrations 20261003000000…040000). Add per-issue rows in a new table keyed by execution and issue number, or an equivalent structure, through a new migration; keep epoch-millisecond timestamps like the existing queue columns.
Note that plan_issues.status moves from pending to processing only when the labeled webhook arrives, after the dispatch claim, so "in flight" must come from the queue's own per-issue claim, not from plan_issues.status.
Tests: packages/core/test/epicExecutionQueue.test.ts, epicQueueBlockedHead.test.ts, epicExecutionQueueFinalization.test.ts, epicExecutionQueueLabelHandoff.test.ts, epicExecutionQueueSelectorRecovery.test.ts (in-memory knex, hand-built minimal tables, queue migrations applied directly), packages/api/test/mcpEpicDispatch.test.ts (full migrations), packages/api/test/mcpIntegration.test.ts (applies a hand-picked migration list that must include the new one), test/issueJobBlocked.test.ts, test/noChangePlanIssueCompletion.test.ts. Verify with the standard commands.
Activity
propr-dev commentedon Nov 12, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53472/claude-opus-5-5-give-the-epic-execution-q-20261112-1932-t6n3470-epic-scheduler-primitives-nrjissue-3472-20261112-1932-claude-opus-5-5-t6n🔍 Track Task Execution