Skip to content

[3472 by Claude Opus 5.5] Give the epic execution queue per-issue state instead of a single cursor - #3507

Merged
integry merged 4 commits into
3470-epic-scheduler-primitives-nrjfrom
3472/claude-opus-5-5-give-the-epic-execution-q-20261112-1932-t6n
Nov 12, 2026
Merged

integry merged 4 commits into
3470-epic-scheduler-primitives-nrjfrom
3472/claude-opus-5-5-give-the-epic-execution-q-20261112-1932-t6n

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3472

Branch: 3472/claude-opus-5-5-give-the-epic-execution-q-20261112-1932-t6n
Commits: ✅ Changes committed (ab27450)


AI Processing Completed

Execution Details:

Summary:
Each issue in an epic execution now has its own persisted state, and sequential and parallel epics behave as before. All 259 tests in the affected suites pass: the five core epic-queue suites plus my new one, autoMergeGate, mcpEpicDispatch, mcpIntegration, and ten root suites. Core, API, root and UI all typecheck, and lint passes on the changed source files.

Storage

  • New table: a migration adds epic_execution_queue_issues, keyed by execution id and issue number. Each row stores its position, state, its own dispatch claim time, and for blocked issues a reason kind plus the readable text. Timestamps are epoch milliseconds.
  • States: pending, dispatched, done, blocked, skipped. The reason kinds are the seven cases from the issue: closed without merge, missing from plan, dispatch failure, agent blocker, awaiting human merge, label handoff wait, setup not ready.
  • Migrating existing queues: issues before the cursor become done. The head keeps its claim and its reason, with the kind worked out from the old text patterns. Later issues are pending. Children of an active parallel queue become dispatched, and the one named in a blocker message is marked blocked. Completed queues become all done. Running the migration twice adds nothing, and rolling it back puts the cursor, claim and reason back.
  • Old columns: cursor, head_started_at and blocked_reason stay on the queue table but are no longer read. blocked_reason now only holds the note for a queue cancelled before it ever started.

Code

  • New module epicQueueState.ts: loads a queue with its per-issue rows, derives the old fields (issues, cursor, head, headStartedAt, blockedReason), and holds the guarded writers.
  • Guarded writes: every block, unblock, done, claim or completion only changes a row if the issue is still in the expected state and its execution is still the plan's active one. Dispatch claims compare on that issue's own claim time, so two processes can't dispatch the same issue twice.
  • Per-issue lookups: the queue logic, blocked head, human merge, label handoff, the API route (appendToActiveQueue now calls a new core appendEpicQueueIssues), MCP implement_plan (now reads a queue.unstarted flag instead of comparing the string), and the two src/jobs files all use the per-issue state instead of issues[cursor]. The src/jobs files read queue.items directly, because the root tests mock @propr/core with a fixed export list.
  • Responses: summarizeEpicQueue, and through it MCP and the REST queue endpoint, keeps all its old fields and adds issueStates (issue, state, reason kind, reason). The UI type PlanExecutionQueue has the new field as optional.

Tests

  • Existing suites: only fixtures changed. They apply the new migration, mocked queues now carry items, and a few exact-match summary assertions now include issueStates.
  • New epicQueueIssueStates.test.ts:
    • Migration of an active sequential queue, an active parallel queue and a completed queue.
    • How each old reason text maps to a kind.
    • A restart mid-execution: the 15-minute retry still applies and an agent-blocked head is still held.
    • Two concurrent advances, two concurrent claim retries, and append protection.
  • Negative check: with the done-state guard and the claim guard both removed, the two concurrency tests fail.

Small behaviour differences you may want to review

  1. Marking setup complete now clears only the setup reason. Before, it cleared any reason, including an agent blocker recorded during setup.
  2. A parallel execution's blockedReason is now the most recently blocked child that is still blocked. Before, clearing one child looked up the others' latest runs in task history to decide which blocker to show. The tests show the same values.
  3. For a parallel execution, the first issue's PR used to be logged with the auto-merge opportunity "epic queue advance". Parallel executions now have no head, so it's logged as an initial PR. Only that label changes, not whether auto-merge is armed.

There are no previews, because nothing visible in the UI changed.

Detailed Logs:

  • Conversation: 177 messages
  • Session: eb7aa26d-f403-410d-a3ea-1a18009c6fa0

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3472-2026-11-12T19-49-45-091Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3472-2026-11-12T19-49-45-091Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: Each issue in an epic execution now has its own persisted state, and sequential and parallel epics behave as before. All 259 tests in the affected suites pass: the five core epic-queue suites plus my ...


This PR was created automatically by ProPR after processing issue #3472.


💡 Need changes?

Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!

…sequential and parallel epics behave as before. All 259 tests in the affected suites pass: the five core epic-queue suites plus my new one, `autoMergeGate`, `mcpEpicDispatch`, `mcpIntegration`, and ten root suites. Core, API, root and UI all typecheck, and lint passes on the changed source files.

Storage
- New table: a migration adds `epic_execution_queue_issues`, keyed by execution id and issue number. Each row stores its position, state, its own dispatch claim time, and for blocked issues a reason kind plus the readable text. Timestamps are epoch milliseconds.
- States: pending, dispatched, done, blocked, skipped. The reason kinds are the seven cases from the issue: closed without merge, missing from plan, dispatch failure, agent blocker, awaiting human merge, label handoff wait, setup not ready.
- Migrating existing queues: issues before the cursor become done. The head keeps its claim and its reason, with the kind worked out from the old text patterns. Later issues are pending. Children of an active parallel queue become dispatched, and the one named in a blocker message is marked blocked. Completed queues become all done. Running the migration twice adds nothing, and rolling it back puts the cursor, claim and reason back.
- Old columns: `cursor`, `head_started_at` and `blocked_reason` stay on the queue table but are no longer read. `blocked_reason` now only holds the note for a queue cancelled before it ever started.

Code
- New module `epicQueueState.ts`: loads a queue with its per-issue rows, derives the old fields (`issues`, `cursor`, `head`, `headStartedAt`, `blockedReason`), and holds the guarded writers.
- Guarded writes: every block, unblock, done, claim or completion only changes a row if the issue is still in the expected state and its execution is still the plan's active one. Dispatch claims compare on that issue's own claim time, so two processes can't dispatch the same issue twice.
- Per-issue lookups: the queue logic, blocked head, human merge, label handoff, the API route (`appendToActiveQueue` now calls a new core `appendEpicQueueIssues`), MCP `implement_plan` (now reads a `queue.unstarted` flag instead of comparing the string), and the two `src/jobs` files all use the per-issue state instead of `issues[cursor]`. The `src/jobs` files read `queue.items` directly, because the root tests mock `@propr/core` with a fixed export list.
- Responses: `summarizeEpicQueue`, and through it MCP and the REST queue endpoint, keeps all its old fields and adds `issueStates` (issue, state, reason kind, reason). The UI type `PlanExecutionQueue` has the new field as optional.

Tests
- Existing suites: only fixtures changed. They apply the new migration, mocked queues now carry `items`, and a few exact-match summary assertions now include `issueStates`.
- New `epicQueueIssueStates.test.ts`:
  - Migration of an active sequential queue, an active parallel queue and a completed queue.
  - How each old reason text maps to a kind.
  - A restart mid-execution: the 15-minute retry still applies and an agent-blocked head is still held.
  - Two concurrent advances, two concurrent claim retries, and append protection.
- Negative check: with the done-state guard and the claim guard both removed, the two concurrency tests fail.

Small behaviour differences you may want to review
1. Marking setup complete now clears only the setup reason. Before, it cleared any reason, including an agent blocker recorded during setup.
2. A parallel execution's `blockedReason` is now the most recently blocked child that is still blocked. Before, clearing one child looked up the others' latest runs in task history to decide which blocker to show. The tests show the same values.
3. For a parallel execution, the first issue's PR used to be logged with the auto-merge opportunity "epic queue advance". Parallel executions now have no head, so it's logged as an initial PR. Only that label changes, not whether auto-merge is armed.

There are no previews, because nothing visible in the UI changed.
@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

/ultrafix goal=8 max=10
Triggered automatically by the requested execution settings.

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔄 Ultrafix loop started (goal: 8/10, max cycles: 10)

First action: /review

💡 Tip: Remove the ultrafix label from this PR to stop further ultrafix cycles.

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR introduces persisted per-issue state and centralizes queue transitions, but needs localized corrections before merge, particularly around migration compatibility.

✅ Guarded dispatch claims — Dispatch compares the issue’s persisted claim timestamp and rechecks execution ownership, pause state, and pending status.

✅ Recoverable completion — A sequential execution interrupted after settling its last issue can complete during recovery.

✅ Targeted concurrency coverage — New tests exercise competing advances and expired-claim retries.

This review is based on static analysis; no commands were run. The supplied current checks show 11 passed, five pending, and no failures.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F1: 🔴 Preserve all legacy parallel blockers

  • Required behavior: Migrating existing executions must preserve unresolved agent blockers and their observable explanations.

  • Evidence: packages/core/src/db/migrations/20261112130000_add_epic_queue_issue_states.js, legacyQueueIssueRows; packages/core/src/services/taskPlanning/epicQueueBlockedHead.ts, clearEpicQueueHeadBlocked.

    1. Before upgrade, two children of an active parallel execution finish with agent blockers. Their latest task histories retain those outcomes, while the legacy queue’s single reason names only the second child.
    2. Migration marks that second child blocked and marks the first child dispatched, without consulting its persisted task history.
    3. The second child subsequently finishes a normal rerun. clearEpicQueueHeadBlocked clears its per-issue blocker.
    4. No blocked row remains, so the summary reports no blocker and describes the first child as dispatched, although its unresolved agent blocker still holds the epic.

    The previous clearing implementation explicitly inspected sibling task histories and restored the first child’s explanation. This PR removes that fallback without migrating the evidence it depended on. Ownership and state guards cannot recover the omitted information.

    static trace: verified against the migration mapping and the removed siblingStillBlocked implementation. The new migration test covers only one blocked child.

  • Minimum fix: Backfill unresolved parallel sibling blockers from their latest persisted task outcomes, or retain a transitional reconciliation path that persists those blockers before relying exclusively on per-issue rows. Cover migration with two blocked children followed by clearing the named child.

F2: 🔴 Retain support for requeueing settled issues

  • Required behavior: Extending an active execution must continue accepting pending issues that previously settled in that execution, and migration must accept queue shapes the previous append path could persist.

  • Evidence: packages/core/src/services/taskPlanning/epicQueueState.ts, appendEpicQueueIssues; packages/api/routes/planIssueEpicQueue.ts, enqueueRemainingBehindRunning; packages/core/src/db/migrations/20261112130000_add_epic_queue_issue_states.js, up.

    1. A sequential execution settles issue A and advances to B. A is subsequently reset to pending while B remains in flight; the supplied status writer permits pending status updates.
    2. The user requests queueing remaining pending issues. enqueueRemainingBehindRunning excludes done rows from its owned set, so it correctly identifies A as missing.
    3. After configuring A’s selectors, appendEpicQueueIssues rejects A because queue.issues.includes(A) includes settled issues too.
    4. The request returns a conflict. Refreshing cannot resolve it: the same persisted state produces the same rejection.

    There is also an upgrade consequence: the previous append implementation accepted this request and persisted an issue list such as [A, B, A]. Migrating that valid legacy queue now inserts two rows with the same (execution_id, issue_number) primary key, causing migration to fail.

    static trace: verified through the caller’s unsettled-membership filter, the new unconditional duplicate rejection, the previous JSON append, and the migration’s unfiltered insertion of every occurrence. Existing tests cover appending new numbers, not requeueing settled ones or migrating repeated legacy occurrences.

  • Minimum fix: Allow a settled issue to be requeued by resetting and repositioning its existing row at the tail. Normalize legacy repeated occurrences during migration while preserving outstanding work and order. Add regression coverage for both paths.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The guarded state transitions and focused tests are useful, but migration can lose blocker information or reject previously valid queues, and requeueing settled issues now fails. These compatibility defects require correction before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 46s
  • Tokens: 71,945 (69,524 in / 2,421 out)
  • Cost: $0.71

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F1 F2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 827b4d5

Addressed 1 AI review comment (IDs: 6834426242)

Addressed findings F1, F2

Summary of Changes

That notification is from the earlier PROPR_DEMO_MODE=true run. Its mcpEpicDispatch failures came from that environment (GitHub auth) and don't affect the result. The rerun with NODE_ENV=test passed both API suites, 75 tests with no failures, so the summary above still stands.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 18m 26s
  • Tokens: 3,287,623 (3,287,036 in / 587 out)
  • Cost: $1.11

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…` run. Its `mcpEpicDispatch` failures came from that environment (GitHub auth) and don't affect the result. The rerun with `NODE_ENV=test` passed both API suites, 75 tests with no failures, so the summary above still stands.

That notification is from the earlier `PROPR_DEMO_MODE=true` run. Its `mcpEpicDispatch` failures came from that environment (GitHub auth) and don't affect the result. The rerun with `NODE_ENV=test` passed both API suites, 75 tests with no failures, so the summary above still stands.

PR: #3507
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR adds persisted per-issue queue state, structured blocker reasons, and compatible response fields. It needs changes before merge because reusing settled rows allows stale observers to settle newly requeued work.

✅ Migration coverage — The migration preserves sequential dispatch claims and reconstructs parallel agent blockers from task history, with targeted tests.

✅ Ordinary concurrency protection — Per-issue claim comparisons and settled-state guards address concurrent retries and advances, with tests exercising both.

The supplied current-head checks report 17 passed, no failures, and no pending checks. This review used static analysis only; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F3: 🔴 Fence writes across issue requeues

  • Required behavior: A delayed observer of an earlier queue occurrence must not settle or dispatch a newly requeued occurrence of that issue.

  • Evidence: packages/core/src/services/taskPlanning/epicQueueState.ts, markQueueIssueDone, appendEpicQueueIssues, and ownedIssue; packages/core/src/services/taskPlanning/epicExecutionQueue.ts, advanceEpicQueue and dispatchPendingQueueHead.

    1. A sequential execution contains issues #10 and Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20. Issue #10 merges, and two observers enter advanceEpicQueue for #10. Both read its terminal status and await releaseEpicIssueLabels.
    2. Observer A remains inside that awaited label handoff. Observer B finishes it, marks #10 done, and starts Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20.
    3. While Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 runs, #10 is reset to pending and queued again through enqueueRemainingBehindRunning. This supported flow is also illustrated by the new requeue test. appendEpicQueueIssues moves #10 to the tail and resets its existing row to pending, retaining the same execution ID and issue number.
    4. Observer A's label handoff returns. Its markQueueIssueDone matches that reused row: the execution remains active and the row is no longer settled. It marks the newly queued #10 done.
    5. After Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 finishes, the queue can complete without running #10 again, leaving its plan issue pending and its requested execution lost.

    The append transaction does not prevent this sequence: A's write occurs after it commits. The done-state guard only rejects a row while it remains settled; resetting it to pending makes the stale write eligible again. The previous cursor comparison rejected A after B advanced the cursor.

    Sibling inspection shows the same missing occurrence identity in blocker writers and dispatch claims. In particular, an observer that read an initially unclaimed head can match dispatched_at = NULL again after requeue and dispatch that tail issue while its predecessor runs.

    static trace: Derived from the supplied advance, append, and claim implementations. Existing concurrency tests do not interleave a requeue between observers. proposed regression: Hold A at label handoff, let B advance, requeue #10, then release A and assert #10 remains pending at the tail.

  • Minimum fix: Fence occurrence-specific writes with the position read by the observer, or a dedicated generation incremented on requeue. Apply that fence to settlement, blocker changes, and dispatch claims so stale observers cannot mutate a later occurrence.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The migration and tests provide a solid foundation, and current checks pass. The demonstrated requeue race can silently skip requested work and requires correction before merge.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 48s
  • Tokens: 74,594 (73,509 in / 1,085 out)
  • Cost: $0.68

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F3

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 7dd33ca

Addressed 1 AI review comment (IDs: 6836135335)

Addressed finding F3

Summary of Changes

I fixed F3. A delayed observer of an earlier queue occurrence can no longer settle, block, unblock or dispatch the requeued occurrence of that issue.

The fence. Requeuing (appendEpicQueueIssues) always moves the issue's row to a new tail position, above every existing one. So the position an observer read identifies which occurrence it saw, and no new generation column is needed. ownedIssue now takes { issueNumber, position } and matches on both, so every guarded writer built on it carries the fence:

  • Settlement: markQueueIssueDone in advanceEpicQueue and the parallel completion path.
  • Blocker writes: blockQueueIssue and unblockQueueIssue for closed-unmerged, missing-from-plan, dispatch-failed, label-handoff, setup-not-ready, awaiting-human-merge and agent-blocked.
  • Reopened-head clearing in startEpicQueueHead: it was a raw update and now goes through ownedIssue.
  • Dispatch claim in dispatchPendingQueueHead: it still compares on the issue's own claim time, and now on position as well.

Every caller passes the occurrence it read. releaseEpicIssueLabels, markEpicQueueAwaitingHumanMerge and the blocked-head helpers now carry the queue item instead of a bare issue number. The exported functions the API and root code call keep their signatures.

Regressions (in packages/core/test/epicQueueIssueStates.test.ts):

  1. The F3 sequence: observer A is held in the label handoff while B advances #10 and starts Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20, then #10 is requeued and A is released. #10 stays pending at the tail, and it runs again after Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 merges.
  2. A stale blocker: an observer held before its plan-issue read sees the requeued #10 closed. The requeued row is not blocked.
  3. A stale dispatch: an observer that read #10 as an unclaimed head is held before its claim, then #10 merges and is requeued. Nothing is dispatched while Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 runs.

With the position condition removed, all three fail; with it in place, they pass. In this suite the label-handoff module is mocked, so I covered blocker writes with test 2 rather than a failing-handoff variant, which would have passed whether or not the fix was in place.

Verification: all six epic-queue suites pass (76 tests), as do both autoMergeGate suites and the root issueJobBlocked suite. Core typechecks and lint passes on the changed source files. The ESLint config ignores the test file.

Not changed, and not affected by this defect:

  • readyEpicExecutionQueue clears setup blocks by kind, not from a queue it read earlier.
  • Execution creation replaces rows wholesale.
  • One race can't be closed in the database: if a stale observer is held inside GitHub's label-removal call long enough for the requeued issue to be dispatched again, its removal could still hit the new run's labels on GitHub. The database fence stops that observer's writes but can't make the external call atomic with them.

🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 6m 52s
  • Tokens: 1,889,303 (1,871,153 in / 18,150 out)
  • Cost: $1.14

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…ce can no longer settle, block, unblock or dispatch the requeued occurrence of that issue.

I fixed F3. A delayed observer of an earlier queue occurrence can no longer settle, block, unblock or dispatch the requeued occurrence of that issue.

**The fence.** Requeuing (`appendEpicQueueIssues`) always moves the issue's row to a new tail position, above every existing one. So the position an observer read identifies which occurrence it saw, and no new generation column is needed. `ownedIssue` now takes `{ issueNumber, position }` and matches on both, so every guarded writer built on it carries the fence:
- **Settlement:** `markQueueIssueDone` in `advanceEpicQueue` and the parallel completion path.
- **Blocker writes:** `blockQueueIssue` and `unblockQueueIssue` for closed-unmerged, missing-from-plan, dispatch-failed, label-handoff, setup-not-ready, awaiting-human-merge and agent-blocked.
- **Reopened-head clearing** in `startEpicQueueHead`: it was a raw update and now goes through `ownedIssue`.
- **Dispatch claim** in `dispatchPendingQueueHead`: it still compares on the issue's own claim time, and now on position as well.

Every caller passes the occurrence it read. `releaseEpicIssueLabels`, `markEpicQueueAwaitingHumanMerge` and the blocked-head helpers now carry the queue item instead of a bare issue number. The exported functions the API and root code call keep their signatures.

**Regressions** (in `packages/core/test/epicQueueIssueStates.test.ts`):
1. **The F3 sequence:** observer A is held in the label handoff while B advances #10 and starts #20, then #10 is requeued and A is released. #10 stays pending at the tail, and it runs again after #20 merges.
2. **A stale blocker:** an observer held before its plan-issue read sees the requeued #10 closed. The requeued row is not blocked.
3. **A stale dispatch:** an observer that read #10 as an unclaimed head is held before its claim, then #10 merges and is requeued. Nothing is dispatched while #20 runs.

With the position condition removed, all three fail; with it in place, they pass. In this suite the label-handoff module is mocked, so I covered blocker writes with test 2 rather than a failing-handoff variant, which would have passed whether or not the fix was in place.

**Verification:** all six epic-queue suites pass (76 tests), as do both `autoMergeGate` suites and the root `issueJobBlocked` suite. Core typechecks and lint passes on the changed source files. The ESLint config ignores the test file.

**Not changed, and not affected by this defect:**
- `readyEpicExecutionQueue` clears setup blocks by kind, not from a queue it read earlier.
- Execution creation replaces rows wholesale.
- One race can't be closed in the database: if a stale observer is held inside GitHub's label-removal call long enough for the requeued issue to be dispatched again, its removal could still hit the new run's labels on GitHub. The database fence stops that observer's writes but can't make the external call atomic with them.

PR: #3507
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR introduces persisted per-issue state with centralized transition guards and backward-compatible queue summaries. It needs a localized correction before merge: parallel children that restart after settling are no longer tracked correctly.

✅ Occurrence guards — Writes check execution identity and issue position, preventing delayed observers from modifying a requeued occurrence.

✅ Migration coverage — The added tests cover legacy claims, blocker classification, duplicate issue normalization, and parallel sibling blockers.

The supplied checks report 16 passed, none failed, and one pending. This review used static analysis only; no commands were run.

Merge blockers

Every finding below was introduced by this PR and must be resolved before merging.

F4: 🔴 Keep restarted parallel children tracked

  • Required behavior: Parallel executions must retain their existing behavior and expose accurate per-issue blockers when a child is processed again while the execution remains active.

  • Evidence: packages/core/src/services/taskPlanning/epicExecutionQueue.ts, completeParallelEpicQueue and reconcileQueueHead; packages/core/src/services/taskPlanning/epicQueueState.ts, isEpicQueueIssueInFlight; packages/core/src/services/taskPlanning/epicQueueBlockedHead.ts, activeQueueFor.

    1. A parallel execution contains issues #10 and Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20. Issue #10 closes while Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 remains running. The changed completeParallelEpicQueue immediately persists #10 as done.
    2. Issue #10 is reopened and processed again before Epic: Claude-Powered GitHub Issue Processor - Stage 16: Explore Claude Code SDK Integration #20 finishes. The supplied enqueueAutoMergeImplementation permits implementation while a queue is active by returning params.implement() directly; it does not reset the queue issue row.
    3. The new run stops on an agent blocker. syncEpicQueueBlocker calls markEpicQueueHeadBlocked, but activeQueueFor rejects #10 because isEpicQueueIssueInFlight excludes done parallel children.
    4. The execution therefore reports #10 as done, with no blocker explanation, although its current run is blocked. Recovery also filters #10 out in reconcileQueueHead, and completeParallelEpicQueue never resets settled rows when their plan issue becomes nonterminal.

    static trace: The supplied callers and changed state transitions establish this sequence without a concurrency assumption. Previously, parallel blocker lookup accepted every issue in the execution, and recovery inspected every parallel child. Execution and position guards do not help because the new run belongs to the same active execution and no transition restores its eligibility.

  • Minimum fix: Restore tracking when a settled parallel child starts another run during the active execution. Ensure blocker handling and recovery can recognize that transition instead of permanently excluding the child. Add a regression covering a closed child that restarts and reports a blocker while a sibling remains active.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The migration and concurrency guards are well developed, but the parallel restart regression leaves persisted state and blocker reporting incorrect. The passing checks provide useful coverage; the remaining validation check is pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 11s
  • Tokens: 75,529 (73,936 in / 1,593 out)
  • Cost: $0.71

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

Copy and edit to choose records from this review:

/fix F4

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit a7864d0

Addressed 1 AI review comment (IDs: 6836842314)

Addressed finding F4

Summary of Changes

I fixed F4: a parallel child that was closed and then runs again while its sibling is still running is tracked again. When its new run stops on a blocker, the execution now shows it as blocked with the agent-blocker reason instead of done.

What changed

  • New writer reopenParallelQueueIssue (epicQueueState.ts): moves a done parallel child back to dispatched. It only writes if the execution is still active and the child's issue is open again, and that issue check runs in the same statement as the write. A late event from the child's earlier closed or merged state can't reopen it.
  • Blocker handling (epicQueueBlockedHead.ts): activeQueueFor reopens a done parallel child before it marks or clears the blocker. This still works when the status update for the reopen was lost.
  • Status changes (completeParallelEpicQueue): a done child whose issue is open again is reopened. On the same path, marking a child done now requires its issue to still be merged or closed at write time. Completing the execution also requires that no child's issue is open. Without these checks, a status read just before a reopen could settle the reopened child, or complete the execution while it is running.
  • Recovery (reconcileQueueHead): looks at every parallel child again, as it did before this PR. The stale-run cleanup only acts on in-progress issues, so a child that really is closed is left alone.
  • markQueueIssueDone: takes { timestamp, guard } instead of a bare timestamp, to stay within the lint parameter limit. The sequential call passes { timestamp }, so its behaviour is unchanged.

The terminal statuses (merged, closed) are written as literals in epicQueueState.ts. Importing PlanIssueStatus there broke autoMergeGate.test.ts, which mocks planIssueManager without that export.

New tests in epicQueueBlockedHead.test.ts:

  • A closed child is reopened and reports a blocker while its sibling runs. This is run twice: once with the status update and once without it. In both cases the child shows as blocked with its reason, recovery and the sibling's merge leave it blocked and the execution active, and a later normal run plus merge completes the execution.
  • Recovery closes the stale run of a reopened child whose row is still done.
  • A late blocker report for a child that is still merged doesn't reopen it.

Against the unfixed code, the first three fail. The fourth passes either way, because it checks that a late report changes nothing.

Verification

  • All six core epic-queue suites plus autoMergeGate: 110 passed, 0 failed.
  • After rebuilding core dist, mcpEpicDispatch and mcpIntegration: 75 passed. The seven root no-change and plan-issue suites: 64 passed.
  • Core typecheck and lint on taskPlanning/ with zero warnings are clean.

I found nothing outside F4 that needed reporting.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 9m 38s
  • Tokens: 3,273,512 (3,250,509 in / 23,003 out)
  • Cost: $1.63

View Task Execution


💡 ProPR Slash Commands
Command Description Example
/merge Merge target branch into this PR and resolve conflicts /merge
/review Request an AI code review /review or /review claude-sonnet
/fix Address review blockers, or blockers and suggestions with /fix all /fix, /fix all, or /fix F3 S5
/switch Change the AI model for this PR /switch claude-opus
/use Override the model for a single follow-up run /use claude-sonnet
/ultrafix Loop review→fix cycles until score goal is met /ultrafix or /ultrafix goal=8 max=10

🤖 Generated by ProPR

…again while its sibling is still running is tracked again. When its new run stops on a blocker, the execution now shows it as `blocked` with the agent-blocker reason instead of `done`.

I fixed F4: a parallel child that was closed and then runs again while its sibling is still running is tracked again. When its new run stops on a blocker, the execution now shows it as `blocked` with the agent-blocker reason instead of `done`.

**What changed**
- **New writer `reopenParallelQueueIssue`** (`epicQueueState.ts`): moves a `done` parallel child back to `dispatched`. It only writes if the execution is still active and the child's issue is open again, and that issue check runs in the same statement as the write. A late event from the child's earlier closed or merged state can't reopen it.
- **Blocker handling** (`epicQueueBlockedHead.ts`): `activeQueueFor` reopens a `done` parallel child before it marks or clears the blocker. This still works when the status update for the reopen was lost.
- **Status changes** (`completeParallelEpicQueue`): a `done` child whose issue is open again is reopened. On the same path, marking a child `done` now requires its issue to still be merged or closed at write time. Completing the execution also requires that no child's issue is open. Without these checks, a status read just before a reopen could settle the reopened child, or complete the execution while it is running.
- **Recovery** (`reconcileQueueHead`): looks at every parallel child again, as it did before this PR. The stale-run cleanup only acts on in-progress issues, so a child that really is closed is left alone.
- **`markQueueIssueDone`**: takes `{ timestamp, guard }` instead of a bare timestamp, to stay within the lint parameter limit. The sequential call passes `{ timestamp }`, so its behaviour is unchanged.

The terminal statuses (`merged`, `closed`) are written as literals in `epicQueueState.ts`. Importing `PlanIssueStatus` there broke `autoMergeGate.test.ts`, which mocks `planIssueManager` without that export.

**New tests** in `epicQueueBlockedHead.test.ts`:
- A closed child is reopened and reports a blocker while its sibling runs. This is run twice: once with the status update and once without it. In both cases the child shows as blocked with its reason, recovery and the sibling's merge leave it blocked and the execution active, and a later normal run plus merge completes the execution.
- Recovery closes the stale run of a reopened child whose row is still `done`.
- A late blocker report for a child that is still merged doesn't reopen it.

Against the unfixed code, the first three fail. The fourth passes either way, because it checks that a late report changes nothing.

**Verification**
- All six core epic-queue suites plus `autoMergeGate`: 110 passed, 0 failed.
- After rebuilding core dist, `mcpEpicDispatch` and `mcpIntegration`: 75 passed. The seven root no-change and plan-issue suites: 64 passed.
- Core typecheck and lint on `taskPlanning/` with zero warnings are clean.

I found nothing outside F4 that needed reporting.

PR: #3507
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

@propr-dev

propr-dev Bot commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

🔍 AI Code Review — codex:gpt-6-astra

Overall Evaluation

The PR replaces cursor-based progression with persisted per-issue state while retaining the existing queue response fields. It is ready to merge within the reviewed scope.

✅ Guarded progression — Issue writes check execution ownership and occurrence position; dispatch claims additionally compare the observed claim timestamp.

✅ Migration compatibility — The migration preserves sequential claims and blockers, recovers parallel blockers from task history, and restores legacy fields on rollback.

✅ Focused regression coverage — Added tests cover concurrent advancement, expired-claim retries, requeued occurrences, and reopened parallel children.

This was a static review of the supplied diff and context; no commands or tests were run. The authoritative current-head checks report 17 passed and no failures or pending checks.

Merge blockers

No merge blockers.

Suggestions

These are optional follow-ups and are not sent to /fix.

No suggestions.

Score

The implementation addresses the intended state migration with consistent ownership guards and targeted regression coverage. The supplied code reveals no verified merge blocker, and current-head checks are passing.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 4s
  • Tokens: 78,253 (77,173 in / 1,080 out)
  • Cost: $0.72

View Task


💡 Next step: Comment /fix to address every F# merge blocker, /fix all for every pending blocker and suggestion, or name records explicitly, as in /fix F3 S5.
F# and S# IDs increment across review comments and remain permanent, so selectors such as /fix F3 F5 stay unambiguous across cycles. S# suggestions stay optional: they are implemented only when you name them or request /fix all, and they never relax a merge blocker.

🤖 Review by ProPR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant