Skip to content

[3475 by Claude Opus 5.5] Let an automation run when an epic queue issue becomes blocked - #3523

Merged
integry merged 7 commits into
3470-epic-scheduler-primitives-nrjfrom
3475/claude-opus-5-5-let-an-automation-run-whe-20261113-0621-rud
Nov 13, 2026
Merged

integry merged 7 commits into
3470-epic-scheduler-primitives-nrjfrom
3475/claude-opus-5-5-let-an-automation-run-whe-20261113-0621-rud

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #3475

Branch: 3475/claude-opus-5-5-let-an-automation-run-whe-20261113-0621-rud
Commits: ✅ Changes committed (625c538)


AI Processing Completed

Execution Details:

Summary:
The event trigger is in place: an automation can now subscribe to "an epic queue issue became blocked" and is run once per event, with the event as its input. Typecheck and zero-warning lint pass on every file I changed, and the OpenAPI check is up to date.

How it works

  • Opt-in. A definition gets a new eventTriggers field. The only event is plan.issue_blocked, and it can be limited to some repositories and some blocker reasons. No existing or shipped definition subscribes.
  • An event never widens scope. A subscribing automation must name its repositories, and the trigger's repository filter has to stay within them. The API rejects anything else with a 400.
  • Consumed in the daemon, not the queue write. A new step in the existing per-minute agent-run sweep (src/agentRunEventTriggers.ts) reads the blocked-event log with a cursor per definition. The queue transaction never calls automation code.
  • At most one run per event and definition. The run's idempotency key is the event id, and the cursor only moves past an event once its run (or the reason it didn't run) is recorded. A restart or repeated delivery replays the same run. If queueing a run fails, the next sweep queues it again rather than creating a second run.
  • No backlog. When a definition subscribes or is re-enabled, its cursor jumps to the newest event in the same transaction. Events from before, or from while it was disabled, never run.
  • Same rules as a scheduled run. Event runs use a new unattended trigger, event, and go through triggerAgentRun. So the definition's autonomy mode, capabilities, grants, cost gate and spend caps all apply.
  • Event as input. The report and acting prompts get the event as fenced JSON: repository, plan id and name, execution, issue number, reason kind and text, plan and issue links. It is marked as data, not instructions.
  • Loop protection. An automation runs at most 3 times for the same issue of the same plan. Later blocked events for that issue are recorded as skipped runs with the reason "loop protection". The docs say so.
  • No extra work without subscribers. Nothing happens when an issue blocks. With no subscribed definition, the sweep step is a single query that never touches the event table, and a test checks that.

Where it shows up

  • Contract: get_automation_definition_contract now lists event as a run trigger and the eventTriggers rules.
  • REST and MCP: both accept and return eventTriggers on definitions and triggerEvent on runs.
  • Editor: a new Event trigger section with repository and reason filters.
  • Automation list: shows "On blocked issue" instead of "Manual" for an automation that only runs on its event. This wasn't in the issue; I added it after the first preview showed the wrong label.
  • Run list and detail: runs read "Issue Epic: Claude-Powered GitHub Issue Processor - Stage 8: Quality Assurance Framework #12 blocked", and the detail has a "Started by an event" panel with links to the plan and the issue.
  • CLI: propr automation show lists the event triggers, and run output includes the event.
  • Docs: an Event trigger section with an example definition in docs/docs/features/agents.md, plus docs/mcp.md and the CHANGELOG.

A new migration adds event_triggers to definitions, trigger_event and trigger_subject to runs, and a cursor table.

Tests

  • New suite, 12/12: test/agentRunEventTriggers.test.ts covers each case the issue lists:
    • one run per event per definition
    • no run for a non-matching repository or reason kind
    • no duplicate after a restart, a repeated delivery or two sweeps at once
    • no run for events before subscribing or while disabled
    • cost gate skip and defer
    • autonomy captured from the definition
    • the loop bound
    • nothing done without subscribers
    • the event in the prompts
  • Added to existing suites: route validation tests (27/27), UI tests for the new section and run panel (93/93 across the automation UI), and a CLI test.
  • Unchanged and still passing: scheduler (42), trigger, cost gate, run and definition stores, contract, report and action job suites, and mcpAgentRuns.
  • mcpObservableSurface: passes, but only with PROPR_DOCS_DIR=docs set. Without it, it fails on a missing docs bundle in this container, which has nothing to do with this change.
  • Not run: the full Playwright e2e suite.

I captured previews of the editor section, the run list, and the run detail at desktop and phone width. The capture spec was temporary and has been deleted.

Detailed Logs:

  • Conversation: 27 messages
  • Session: f53a0ff2-47bb-48df-a5ff-66f54ca9124d

Log files stored at:

  • conversation: /usr/src/app/logs/executions/issue-3475-2026-11-13T07-11-23-282Z-conversation.json
  • output: /usr/src/app/logs/executions/issue-3475-2026-11-13T07-11-23-282Z-output.txt
Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: The event trigger is in place: an automation can now subscribe to "an epic queue issue became blocked" and is run once per event, with the event as its input. Typecheck and zero-warning lint pass on e...


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


💡 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!


Visual preview

Run detail on a phone

Run detail on a phone

The same event panel at 390px width

Connect sign-in required. Original retained until 2027-02-11T07:11:28.095Z.

View the full-resolution original in ProPR Connect

Run detail: Started by an event

Run detail: Started by an event

An event-started preview run with the blocked issue, reason kind and text, and links to the plan and the issue

Connect sign-in required. Original retained until 2027-02-11T07:11:29.333Z.

View the full-resolution original in ProPR Connect

Event runs in the run history

Event runs in the run history

Runs show which issue's blocked event started them; the list labels the automation 'On blocked issue'; a loop-protected run is skipped

Connect sign-in required. Original retained until 2027-02-11T07:11:30.488Z.

View the full-resolution original in ProPR Connect

Event trigger in the automation editor

Event trigger in the automation editor

The new Event trigger setting set to Plan issue blocked, limited to one of the automation's repositories and two blocker reasons

Connect sign-in required. Original retained until 2027-02-11T07:11:31.582Z.

View the full-resolution original in ProPR Connect

… epic queue issue became blocked" and is run once per event, with the event as its input. Typecheck and zero-warning lint pass on every file I changed, and the OpenAPI check is up to date.

How it works
- Opt-in. A definition gets a new `eventTriggers` field. The only event is `plan.issue_blocked`, and it can be limited to some repositories and some blocker reasons. No existing or shipped definition subscribes.
- An event never widens scope. A subscribing automation must name its repositories, and the trigger's repository filter has to stay within them. The API rejects anything else with a 400.
- Consumed in the daemon, not the queue write. A new step in the existing per-minute agent-run sweep (`src/agentRunEventTriggers.ts`) reads the blocked-event log with a cursor per definition. The queue transaction never calls automation code.
- At most one run per event and definition. The run's idempotency key is the event id, and the cursor only moves past an event once its run (or the reason it didn't run) is recorded. A restart or repeated delivery replays the same run. If queueing a run fails, the next sweep queues it again rather than creating a second run.
- No backlog. When a definition subscribes or is re-enabled, its cursor jumps to the newest event in the same transaction. Events from before, or from while it was disabled, never run.
- Same rules as a scheduled run. Event runs use a new unattended trigger, `event`, and go through `triggerAgentRun`. So the definition's autonomy mode, capabilities, grants, cost gate and spend caps all apply.
- Event as input. The report and acting prompts get the event as fenced JSON: repository, plan id and name, execution, issue number, reason kind and text, plan and issue links. It is marked as data, not instructions.
- Loop protection. An automation runs at most 3 times for the same issue of the same plan. Later blocked events for that issue are recorded as skipped runs with the reason "loop protection". The docs say so.
- No extra work without subscribers. Nothing happens when an issue blocks. With no subscribed definition, the sweep step is a single query that never touches the event table, and a test checks that.

Where it shows up
- Contract: `get_automation_definition_contract` now lists `event` as a run trigger and the `eventTriggers` rules.
- REST and MCP: both accept and return `eventTriggers` on definitions and `triggerEvent` on runs.
- Editor: a new Event trigger section with repository and reason filters.
- Automation list: shows "On blocked issue" instead of "Manual" for an automation that only runs on its event. This wasn't in the issue; I added it after the first preview showed the wrong label.
- Run list and detail: runs read "Issue #12 blocked", and the detail has a "Started by an event" panel with links to the plan and the issue.
- CLI: `propr automation show` lists the event triggers, and run output includes the event.
- Docs: an Event trigger section with an example definition in `docs/docs/features/agents.md`, plus `docs/mcp.md` and the CHANGELOG.

A new migration adds `event_triggers` to definitions, `trigger_event` and `trigger_subject` to runs, and a cursor table.

Tests
- New suite, 12/12: `test/agentRunEventTriggers.test.ts` covers each case the issue lists:
  - one run per event per definition
  - no run for a non-matching repository or reason kind
  - no duplicate after a restart, a repeated delivery or two sweeps at once
  - no run for events before subscribing or while disabled
  - cost gate skip and defer
  - autonomy captured from the definition
  - the loop bound
  - nothing done without subscribers
  - the event in the prompts
- Added to existing suites: route validation tests (27/27), UI tests for the new section and run panel (93/93 across the automation UI), and a CLI test.
- Unchanged and still passing: scheduler (42), trigger, cost gate, run and definition stores, contract, report and action job suites, and `mcpAgentRuns`.
- `mcpObservableSurface`: passes, but only with `PROPR_DOCS_DIR=docs` set. Without it, it fails on a missing docs bundle in this container, which has nothing to do with this change.
- Not run: the full Playwright e2e suite.

I captured previews of the editor section, the run list, and the run detail at desktop and phone width. The capture spec was temporary and has been deleted.
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

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

@propr-dev propr-dev Bot added the ultrafix label Nov 13, 2026
@propr-dev

propr-dev Bot commented Nov 13, 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 13, 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 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds opt-in blocked-issue triggers through a durable event log, per-definition cursors, and the existing automation execution pipeline. It needs a targeted correctness fix before merge: an in-flight sweep can run an event that a subscription reset explicitly excluded.

✅ Scoped subscriptions — API validation requires explicit automation repositories and rejects trigger filters outside them.

✅ Durable run identity — Event-specific idempotency keys use the existing per-definition uniqueness constraint to prevent duplicate run records.

✅ Consistent execution policy — Event runs reuse the trigger, cost gate, captured autonomy, and grant paths.

This review used static analysis of the supplied code; no commands were run. The authoritative checks show zero failures and four pending checks.

Merge blockers

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

F1: 🔴 Fence admission against subscription resets

  • Required behavior: Events from while an automation is disabled must never run later; resetting its cursor must invalidate older in-flight event batches.

  • Evidence: src/agentRunEventTriggers.ts:sweepSubscription, especially the fireEvent call before advanceAgentDefinitionEventCursor; packages/core/src/services/agents/agentEventTriggerStore.ts:resetAgentDefinitionEventCursors.

    1. A sweep reads an enabled subscription and its cursor C, then pauses at the awaited event-list query.
    2. The user disables the automation. A blocked event E is recorded while it is disabled, and the pending event-list query reads E.
    3. Before the sweep's awaited readDefinition reads the definition, the user re-enables the automation. The update transaction resets its cursor to E, correctly excluding that disabled-period event.
    4. readDefinition now returns an enabled subscription. The sweep calls fireEvent for E without checking whether its cursor C or subscription generation remains current.
    5. fireEvent creates and enqueues E's run. Only afterward does the cursor compare-and-set fail because the stored cursor is already E.

    The observable result is an unattended run for an event that occurred while the automation was disabled. The reset transaction protects the definition and cursor updates, but admission does not participate in that transaction or otherwise fence against it. The post-dispatch compare-and-set detects the reset too late; idempotency prevents duplicates but does not prohibit the first excluded run.

    static trace: This follows the awaited reads, admission, and cursor-update order in the supplied implementation. The existing disable/re-enable test finishes those operations before starting another sweep, so it does not exercise this interleaving.

  • Minimum fix: Fence event admission against subscription reset atomically with recording the run receipt, using a cursor or subscription-generation guard shared with reset operations. A failed guard must prevent run creation and dispatch. Add a regression that resets the subscription between fetching its events and admitting one.

Suggestions

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

S1: 🟢 Test concurrent initial delivery

The concurrent-sweep test first creates a run, then rewinds the cursor and exercises replay. Add a separate test where two sweeps encounter a previously unseen event concurrently, asserting one receipt and safe dispatch behavior. This would strengthen coverage of the existing uniqueness-based admission path; it is optional beyond the reset regression required for F1.

Score

The implementation is cohesive and has useful functional coverage, but the subscription-reset race breaks an explicit unattended-execution guarantee. Current checks report no failures, with four still pending.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 37s
  • Tokens: 79,866 (78,164 in / 1,702 out)
  • Cost: $0.74

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 S1

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 4c1b32e

Addressed 1 AI review comment (IDs: 6846973369)

Addressed finding F1

Summary of Changes

F1 is fixed. A sweep that read an event before the definition was re-enabled can no longer start a run for it. The check now happens in the same transaction that records the run, so if it fails, nothing is created or enqueued.

What changed

  • The check (packages/core/src/services/agents/agentEventTriggerStore.ts): new holdAgentDefinitionEventCursor. It updates the cursor row only if it still holds the value the batch was read under, which also locks that row. It then checks that the definition is still enabled and still subscribed to the event.
    • Re-enabling or resubscribing also writes that cursor row, in its own transaction. So either the reset waits until the run is recorded, or the check sees the new cursor and refuses.
    • The check only reads the definition and doesn't lock it, so it can't deadlock with the update that resets the cursor.
  • Run creation (agentRunStore.ts, agentRunTrigger.ts): createAgentRun takes an optional admit callback and runs it in the transaction that inserts the run. If it returns false, nothing is inserted and it throws AgentRunAdmissionRefusedError. triggerAgentRun passes admit through, and since its run is never created, nothing is ever enqueued.
  • Sweep (src/agentRunEventTriggers.ts): fireEvent attaches the check to every run it records: started runs, skipped runs for loop protection, and skipped runs for a definition that no longer validates. If the check refuses, the sweep stops handling that subscription. The next sweep picks up from the reset cursor.

Same flaw elsewhere: the skipped-run paths had the same gap, because they also record a run for an event after a reset. They are covered by the check above. Replaying a run that already exists is not checked again, because that run was recorded before any reset.

Tests (test/agentRunEventTriggers.test.ts, 14/14 pass):

  • The scenario from the finding. The test pauses the event-list query. During the pause it disables the automation, records an event, lets the query read it, and re-enables the automation before the sweep continues. It asserts that no run is created or enqueued, that the cursor sits at the reset value, and that only a later event runs.
  • A skipped run. The same reset happens before a skipped run would be recorded, and nothing is recorded.
  • Checked against the old code: with the check disabled, both new tests fail.

Typecheck (root and core) and zero-warning lint pass on the changed source files. These suites still pass: agentRunStore (17), agentRunTrigger (20), agentDefinitionStore (12) and agentRunScheduler (42).

I found nothing else outside F1. This change isn't visible in the UI, so I made no previews.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 11m 1s
  • Tokens: 1,848,300 (1,829,464 in / 18,836 out)
  • Cost: $1.15

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

…on was re-enabled can no longer start a run for it. The check now happens in the same transaction that records the run, so if it fails, nothing is created or enqueued.

F1 is fixed. A sweep that read an event before the definition was re-enabled can no longer start a run for it. The check now happens in the same transaction that records the run, so if it fails, nothing is created or enqueued.

**What changed**
- **The check (`packages/core/src/services/agents/agentEventTriggerStore.ts`):** new `holdAgentDefinitionEventCursor`. It updates the cursor row only if it still holds the value the batch was read under, which also locks that row. It then checks that the definition is still enabled and still subscribed to the event.
  - Re-enabling or resubscribing also writes that cursor row, in its own transaction. So either the reset waits until the run is recorded, or the check sees the new cursor and refuses.
  - The check only reads the definition and doesn't lock it, so it can't deadlock with the update that resets the cursor.
- **Run creation (`agentRunStore.ts`, `agentRunTrigger.ts`):** `createAgentRun` takes an optional `admit` callback and runs it in the transaction that inserts the run. If it returns false, nothing is inserted and it throws `AgentRunAdmissionRefusedError`. `triggerAgentRun` passes `admit` through, and since its run is never created, nothing is ever enqueued.
- **Sweep (`src/agentRunEventTriggers.ts`):** `fireEvent` attaches the check to every run it records: started runs, skipped runs for loop protection, and skipped runs for a definition that no longer validates. If the check refuses, the sweep stops handling that subscription. The next sweep picks up from the reset cursor.

**Same flaw elsewhere:** the skipped-run paths had the same gap, because they also record a run for an event after a reset. They are covered by the check above. Replaying a run that already exists is not checked again, because that run was recorded before any reset.

**Tests** (`test/agentRunEventTriggers.test.ts`, 14/14 pass):
- **The scenario from the finding.** The test pauses the event-list query. During the pause it disables the automation, records an event, lets the query read it, and re-enables the automation before the sweep continues. It asserts that no run is created or enqueued, that the cursor sits at the reset value, and that only a later event runs.
- **A skipped run.** The same reset happens before a skipped run would be recorded, and nothing is recorded.
- **Checked against the old code:** with the check disabled, both new tests fail.

Typecheck (root and core) and zero-warning lint pass on the changed source files. These suites still pass: `agentRunStore` (17), `agentRunTrigger` (20), `agentDefinitionStore` (12) and `agentRunScheduler` (42).

I found nothing else outside F1. This change isn't visible in the UI, so I made no previews.

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

propr-dev Bot commented Nov 13, 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 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds opt-in event subscriptions, durable consumption, and event context across automation surfaces. The implementation is well integrated, but needs changes before merge to preserve queued-run recovery and avoid silently broadening repository filters.

✅ Shared execution controls — Event runs use triggerAgentRun; the existing cost gate handles every non-manual trigger, and autonomy remains captured on the run.

✅ Durable receipts — Event-specific idempotency keys and transactional admission protect receipt creation against duplicate delivery and subscription resets.

This review used the supplied code only; no commands or tests were run. Current checks show 34 passed, none failed, and one pending.

Merge blockers

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

F2: 🔴 Cursor resets strand undispatched runs

  • Required behavior: An accepted event run whose enqueue fails must remain recoverable, or reach an explicit terminal state; resetting a subscription must not discard its outstanding dispatch obligation.

  • Evidence: src/agentRunEventTriggers.ts, fireEvent and sweepSubscription; packages/core/src/services/agents/agentDefinitionStore.ts, updateAgentDefinition.

    1. A matching event creates a queued receipt, but enqueueing fails. keepQueuedOnEnqueueFailure: true preserves the receipt, and the sweep leaves its cursor before the event.
    2. Before the next sweep, the owner disables and re-enables the automation, or removes and restores its subscription.
    3. The definition update resets the cursor to the newest event, including the event with the undispatched receipt.
    4. Subsequent sweeps read only events after that cursor. They never reach the existing.state === 'queued' dispatch-recovery branch for this receipt.

    The run remains queued without a job, and also continues counting toward the per-issue loop limit. Idempotency protects receipt uniqueness but does not dispatch it. The supplied scheduler describes stuck-run recovery for running/acting runs; the new consumer's queued recovery depends on revisiting the event that the reset has skipped.

    static trace: Followed the enqueue-failure branch, subscription-reset transaction, cursor query, and existing-receipt dispatch branch. proposed regression: Fail enqueueing, disable/re-enable, restore the queue, and assert the receipt is dispatched or explicitly terminated instead of remaining stranded.

  • Minimum fix: Preserve recovery of accepted, undispatched receipts independently of event discovery, or explicitly transition affected undispatched receipts to a terminal state when resetting the subscription. Maintain the rule that unaccepted historical events are not replayed.

F3: 🔴 Removing a filtered repository broadens subscriptions

  • Required behavior: Saving repository edits must preserve the user's event-filter restriction or require an explicit replacement; it must not silently convert a restricted subscription into an unrestricted one.

  • Evidence: propr-ui/src/components/Agents/agentEditorForm.ts, formToInput; packages/shared/src/automationDefinitions.ts, automationEventTriggerMatches.

    1. An automation includes acme/app and acme/api, with its event trigger restricted to acme/app.
    2. The user removes acme/app from the automation's repositories and saves, leaving acme/api.
    3. formToInput filters out the removed repository and submits eventTriggers[0].repositories: [].
    4. The API accepts that value. automationEventTriggerMatches interprets the empty list as every remaining automation repository, so blocked events in acme/api now start runs.

    The UI therefore enables unattended execution for a repository the user previously excluded. Server scope validation cannot catch this because the resulting unrestricted filter is valid. The added serialization test covers removal when another selected repository survives, but not removal of the last selected repository.

    static trace: Followed form serialization through scope validation and event matching. proposed regression: Remove the sole selected trigger repository while another automation repository remains; verify saving cannot silently enable that remaining repository.

  • Minimum fix: When a previously nonempty filter loses its last repository, require the user to choose a replacement filter or explicitly select all repositories before saving; alternatively disable the event subscription with clear feedback.

Suggestions

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

S2: 🟢 Exercise concurrent first delivery

The concurrent-sweep test replays an event whose receipt already exists. Add a concurrent sweep over a fresh event to exercise competing receipt creation and admission transactions. This improves coverage of the stated concurrency guarantee without establishing another blocker.

Score

The shared execution path and broad surface coverage are strong, and current checks have no failures. Two correctness issues remain in recovery and filter editing.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 46s
  • Tokens: 80,834 (78,911 in / 1,923 out)
  • Cost: $0.78

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 F2 F3 S2

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 2993840

Addressed 1 AI review comment (IDs: 6847642534)

Addressed findings F2, F3

Summary of Changes

I fixed F2 and F3. The new regression tests fail on the previous code and pass now.

F2: Cursor resets strand undispatched runs

A run that was recorded but couldn't be queued no longer depends on its event being read again.

  • Recovery pass. runAgentEventTriggerSweep (src/agentRunEventTriggers.ts) now ends with a step that looks for event runs still queued and queues them again. It uses the run record itself, not the event log or the cursor, so moving the cursor on disable/re-enable or unsubscribe/resubscribe can't drop one.
  • Which runs it picks. It uses a new store query, listUndispatchedEventAgentRuns in agentEventTriggerStore.ts. Runs from a deferred retry are left to that retry's own process. The pass only takes runs unchanged for more than AGENT_EVENT_DISPATCH_RECOVERY_GRACE_MS (5 minutes), and skips any run this sweep already queued.
  • Queueing twice is harmless. The job id is fixed per run and the worker skips runs that are no longer queued. A run stops being picked once the worker takes it.
  • Owners who left. If the owner is no longer a member, nothing is queued, same as for new events.
  • No replay. Skipped events are still never run; only runs recorded before the reset are queued. The sweep result has a new redispatched count.
  • Change to an existing test. The "no subscribers" test now expects 2 database queries instead of 1. The extra one is the check for stranded runs; neither query reads the event table.

F3: Removing a filtered repository broadens subscriptions

  • Save is refused. If the trigger was limited to repositories that have all been removed from the automation, eventTriggerFilterLost catches it. The editor then refuses to save and says why.
  • Editor warning. The Event trigger section shows a notice naming the removed repositories. It has a "React to all of this automation's repositories" button, so choosing all is an explicit step.
  • Backup check. In that case formToInput sends the old filter unchanged instead of []. Any other save path is then rejected by the existing scope check instead of quietly matching every repository.
  • Docs. docs/docs/features/agents.md describes both behaviours.

I also checked the other places that change triggers. The REST/MCP patch path already rejects a repository change that leaves the filter outside the automation's repositories. The CLI only displays triggers, so neither had the same problem.

Tests

  • test/agentRunEventTriggers.test.ts: 17/17 pass. The new tests cover disable/re-enable, unsubscribe/resubscribe, owners who left, and runs the worker already took.
  • agentRunScheduler and agentDefinitionStore: 54/54 pass.
  • UI, propr-ui/src/components/Agents/: 72/72 pass. This includes a new AgentEditor.eventTrigger.test.tsx, which I made a separate file because AgentEditor.test.tsx would have gone over the 400-line lint limit.
  • Typecheck passes for root, core and UI. Zero-warning lint passes on every file I changed.
  • Not run: the full Playwright e2e suite.

I captured the warning and the refused save at desktop and phone width with a temporary Playwright spec, which I've deleted.

Visual preview

Event trigger filter lost: save refused

Event trigger filter lost: save refused

acme/app, the only repository the trigger was limited to, was removed from the automation. The editor warns in the Event trigger section, offers an explicit 'all repositories' choice, and refuses to save instead of widening the trigger to acme/api.

Connect sign-in required. Original retained until 2027-02-11T08:25:00.109Z.

View the full-resolution original in ProPR Connect

Event trigger filter lost on a phone

Event trigger filter lost on a phone

The same warning and refused save at 390px width

Original unavailable: managed storage is unavailable or the upload has expired.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @propr-ultrafix
  • Time: 14m 25s
  • Tokens: 4,825,905 (4,796,723 in / 29,182 out)
  • Cost: $2.12
  • Subscription usage: Fable +1%

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

…vious code and pass now.

I fixed F2 and F3. The new regression tests fail on the previous code and pass now.

## F2: Cursor resets strand undispatched runs
A run that was recorded but couldn't be queued no longer depends on its event being read again.

- **Recovery pass.** `runAgentEventTriggerSweep` (`src/agentRunEventTriggers.ts`) now ends with a step that looks for `event` runs still `queued` and queues them again. It uses the run record itself, not the event log or the cursor, so moving the cursor on disable/re-enable or unsubscribe/resubscribe can't drop one.
- **Which runs it picks.** It uses a new store query, `listUndispatchedEventAgentRuns` in `agentEventTriggerStore.ts`. Runs from a deferred retry are left to that retry's own process. The pass only takes runs unchanged for more than `AGENT_EVENT_DISPATCH_RECOVERY_GRACE_MS` (5 minutes), and skips any run this sweep already queued.
- **Queueing twice is harmless.** The job id is fixed per run and the worker skips runs that are no longer `queued`. A run stops being picked once the worker takes it.
- **Owners who left.** If the owner is no longer a member, nothing is queued, same as for new events.
- **No replay.** Skipped events are still never run; only runs recorded before the reset are queued. The sweep result has a new `redispatched` count.
- **Change to an existing test.** The "no subscribers" test now expects 2 database queries instead of 1. The extra one is the check for stranded runs; neither query reads the event table.

## F3: Removing a filtered repository broadens subscriptions
- **Save is refused.** If the trigger was limited to repositories that have all been removed from the automation, `eventTriggerFilterLost` catches it. The editor then refuses to save and says why.
- **Editor warning.** The Event trigger section shows a notice naming the removed repositories. It has a "React to all of this automation's repositories" button, so choosing all is an explicit step.
- **Backup check.** In that case `formToInput` sends the old filter unchanged instead of `[]`. Any other save path is then rejected by the existing scope check instead of quietly matching every repository.
- **Docs.** `docs/docs/features/agents.md` describes both behaviours.

I also checked the other places that change triggers. The REST/MCP patch path already rejects a repository change that leaves the filter outside the automation's repositories. The CLI only displays triggers, so neither had the same problem.

## Tests
- `test/agentRunEventTriggers.test.ts`: 17/17 pass. The new tests cover disable/re-enable, unsubscribe/resubscribe, owners who left, and runs the worker already took.
- `agentRunScheduler` and `agentDefinitionStore`: 54/54 pass.
- UI, `propr-ui/src/components/Agents/`: 72/72 pass. This includes a new `AgentEditor.eventTrigger.test.tsx`, which I made a separate file because `AgentEditor.test.tsx` would have gone over the 400-line lint limit.
- Typecheck passes for root, core and UI. Zero-warning lint passes on every file I changed.
- **Not run:** the full Playwright e2e suite.

I captured the warning and the refused save at desktop and phone width with a temporary Playwright spec, which I've deleted.

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

propr-dev Bot commented Nov 13, 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 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR implements opt-in blocked-issue triggers across storage, scheduling, prompts, API, UI, and CLI. It needs changes before merge: subscription edits can be bypassed during admission, and recovery can permanently starve eligible runs.

✅ Durable event receipts — Per-definition idempotency keys and persisted cursors support replay without creating duplicate runs.

✅ Shared execution controls — Event runs use the existing trigger primitive, cost gate, captured autonomy, and downstream capability enforcement.

✅ Explicit scope validation — API validation rejects subscriptions outside the definition’s repositories, and the editor prevents silently widening a filter after its repositories disappear.

This review is a static analysis of the supplied code; no commands were run. Current checks show 34 passed, none failed, and one pending.

Merge blockers

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

F4: 🔴 Fence subscription edits during admission

  • Required behavior: Event runs must match the subscription and repository scope in effect when their receipt is accepted.

  • Evidence: src/agentRunEventTriggers.ts, fireEvent; packages/core/src/services/agents/agentEventTriggerStore.ts, holdAgentDefinitionEventCursor and eventCursorResetNeeded.

    1. A sweep reads a definition whose subscription matches an agent_blocked event and enters fireEvent.
    2. While the sweep awaits runtime validation or the cost gate inside context.trigger, the user saves a subscription restricted to dispatch_failed, excluding that event.
    3. This edit preserves the subscribed event type, so eventCursorResetNeeded returns false and the cursor remains unchanged.
    4. Receipt admission checks the cursor, enabled state, and presence of the event type, but never checks the updated filters or definition revision.
    5. The run is inserted and queued using the earlier definition despite the completed exclusion.

    The same sequence applies when removing the event’s repository from the definition while retaining a valid subscription. The cursor transaction does not prevent either case: these edits do not reset the cursor, and the admission check ignores their changed fields. The result is unwanted unattended execution after the user has narrowed its scope.

    static trace: followed definition loading, matching, awaited triggering, definition updates, and transactional admission in the supplied diff.

  • Minimum fix: Fence receipt creation against the definition revision used for matching and execution, with appropriate transactional locking or conditional validation. Refuse and retry with the current definition when that revision changes.

F5: 🔴 Prevent recovery starvation by offboarded owners

  • Required behavior: Accepted event runs whose enqueue failed must remain recoverable even after a subscription reset moves their cursor past the event.

  • Evidence: packages/core/src/services/agents/agentEventTriggerStore.ts, listUndispatchedEventAgentRuns; src/agentRunEventTriggers.ts, redispatchUndispatchedRuns.

    1. During a queue outage, 50 subscribed definitions belonging to one owner each record a queued receipt but fail to enqueue it.
    2. That owner is offboarded. These receipts remain queued with their original timestamps.
    3. Another, still-authorized owner records a newer receipt whose enqueue also fails, then disables and re-enables its definition. The reset moves its cursor past the event, making receipt recovery necessary.
    4. After the grace period and queue recovery, the recovery query selects only the oldest 50 receipts.
    5. Membership checks skip all 50 without changing their eligibility or advancing pagination. Every subsequent sweep selects those same receipts.

    The authorized owner’s run remains queued indefinitely despite a working queue. Event replay cannot rescue it because its cursor was reset. The recovery loop has neither pagination nor a continuation past skipped candidates.

    static trace: followed failed-enqueue persistence, cursor-reset behavior, the oldest-first limited query, and the membership continue in recovery.

  • Minimum fix: Page through recovery candidates beyond skipped owners, using a stable continuation that ensures later eligible receipts are eventually visited, or exclude ineligible receipts before applying the recovery limit.

Suggestions

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

S3: 🟢 Exercise concurrent first delivery

The concurrent-sweep test runs after the event already has a receipt. Add a case where two sweeps encounter a fresh event simultaneously to exercise insertion conflict and dispatch behavior directly. This strengthens coverage; the current idempotency constraint already provides evidence against duplicate receipt creation.

Score

The implementation has substantial coverage and coherent integration, but two localized admission and recovery defects prevent merge readiness. Passing checks do not cover these demonstrated sequences.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 35s
  • Tokens: 85,133 (83,370 in / 1,763 out)
  • Cost: $0.81

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 F5 S3

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit bcec0b9

Addressed 1 AI review comment (IDs: 6848375919)

Addressed findings F4, F5

Summary of Changes

I fixed F4 and F5. test/agentRunEventTriggers.test.ts passes 21/21, including 4 new regression tests. All 4 fail on the previous code. Typecheck and zero-warning lint pass for root and core. The Postgres lock path couldn't be run here because the container has no Postgres; the tests run on SQLite.

F4: an edit made while a run is being admitted is now respected

  • The check now includes the definition's version. holdAgentDefinitionEventCursor (packages/core/src/services/agents/agentEventTriggerStore.ts) takes the revision of the definition the event was matched against. That is also the definition saved into the run. It refuses the run if the stored revision is different. Every user edit bumps the revision, so this covers a narrowed reason filter and a removed repository, which didn't reset the cursor and so slipped past the old check.
  • Lock order. The check now locks the definition row first (FOR SHARE on Postgres), then the cursor row. An edit takes the definition row before it resets cursors, so the two can't deadlock. The shared lock makes an edit wait for a run that is being recorded, but doesn't hold up other runs of the same automation. I checked the SQL Knex generates for Postgres (... limit 1 for share).
  • Refuse, then retry with the saved definition. In src/agentRunEventTriggers.ts, a refused run is handled two ways:
    • If the cursor moved (a reset or another sweep), the sweep stops, as before.
    • If only the definition changed, the sweep reads it again and matches the event again once. A narrowed filter then counts the event as unmatched. An edit that keeps the event in scope runs it with the edited definition.
    • If the definition is edited again during that retry, the cursor stays on the event and the next sweep tries again.
  • New tests: narrowing the reason filter, and removing the event's repository, while the run is being admitted (both start no run); an edit that keeps the event in scope runs with the new revision; an automation edited on every attempt is left for the next sweep.

F5: recovery no longer gets stuck behind an offboarded owner's runs

  • listUndispatchedEventAgentRuns takes an after position (updated_at, id) for paging.
  • redispatchUndispatchedRuns now reads page after page until a page comes back short. Runs of owners who are no longer members are passed over, and later runs from other owners are still reached.
  • New test: with a page size of 2, three stuck runs of an offboarded owner come first; the newer run of a current member, whose cursor was reset past its event, is queued again.

Things to know

  • More enqueue attempts during an outage. Each sweep now tries every stuck event run, not at most 50. If the queue is still down, each of them fails and is counted as failed. The queue's job ids are fixed per run, so a repeat attempt never starts a second run.
  • Docs. I added one sentence to the Event trigger section of docs/docs/features/agents.md: an event that hasn't started a run yet is matched against the automation as saved when its run is recorded.
  • No previews. Nothing in this change is visible in the UI.

Separate observation: a manual run started on the same automation while an event run is being recorded now waits for that short transaction on Postgres. The wait lasts one insert.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 10m 9s
  • Tokens: 2,185,949 (2,166,094 in / 19,855 out)
  • Cost: $1.31

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

…ses 21/21, including 4 new regression tests. All 4 fail on the previous code. Typecheck and zero-warning lint pass for root and core. The Postgres lock path couldn't be run here because the container has no Postgres; the tests run on SQLite.

I fixed F4 and F5. `test/agentRunEventTriggers.test.ts` passes 21/21, including 4 new regression tests. All 4 fail on the previous code. Typecheck and zero-warning lint pass for root and core. The Postgres lock path couldn't be run here because the container has no Postgres; the tests run on SQLite.

**F4: an edit made while a run is being admitted is now respected**
- **The check now includes the definition's version.** `holdAgentDefinitionEventCursor` (`packages/core/src/services/agents/agentEventTriggerStore.ts`) takes the `revision` of the definition the event was matched against. That is also the definition saved into the run. It refuses the run if the stored revision is different. Every user edit bumps the revision, so this covers a narrowed reason filter and a removed repository, which didn't reset the cursor and so slipped past the old check.
- **Lock order.** The check now locks the definition row first (`FOR SHARE` on Postgres), then the cursor row. An edit takes the definition row before it resets cursors, so the two can't deadlock. The shared lock makes an edit wait for a run that is being recorded, but doesn't hold up other runs of the same automation. I checked the SQL Knex generates for Postgres (`... limit 1 for share`).
- **Refuse, then retry with the saved definition.** In `src/agentRunEventTriggers.ts`, a refused run is handled two ways:
  - If the cursor moved (a reset or another sweep), the sweep stops, as before.
  - If only the definition changed, the sweep reads it again and matches the event again once. A narrowed filter then counts the event as unmatched. An edit that keeps the event in scope runs it with the edited definition.
  - If the definition is edited again during that retry, the cursor stays on the event and the next sweep tries again.
- **New tests:** narrowing the reason filter, and removing the event's repository, while the run is being admitted (both start no run); an edit that keeps the event in scope runs with the new revision; an automation edited on every attempt is left for the next sweep.

**F5: recovery no longer gets stuck behind an offboarded owner's runs**
- `listUndispatchedEventAgentRuns` takes an `after` position (`updated_at`, `id`) for paging.
- `redispatchUndispatchedRuns` now reads page after page until a page comes back short. Runs of owners who are no longer members are passed over, and later runs from other owners are still reached.
- **New test:** with a page size of 2, three stuck runs of an offboarded owner come first; the newer run of a current member, whose cursor was reset past its event, is queued again.

**Things to know**
- **More enqueue attempts during an outage.** Each sweep now tries every stuck event run, not at most 50. If the queue is still down, each of them fails and is counted as failed. The queue's job ids are fixed per run, so a repeat attempt never starts a second run.
- **Docs.** I added one sentence to the Event trigger section of `docs/docs/features/agents.md`: an event that hasn't started a run yet is matched against the automation as saved when its run is recorded.
- **No previews.** Nothing in this change is visible in the UI.

**Separate observation:** a manual run started on the same automation while an event run is being recorded now waits for that short transaction on Postgres. The wait lasts one insert.

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

propr-dev Bot commented Nov 13, 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 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds opt-in blocked-issue subscriptions with durable run receipts, event input, and UI/API/CLI presentation. It needs a correctness fix before merge: concurrent event-producing transactions can cause events to be permanently missed.

✅ Admission fencing — Receipt creation checks the definition revision and cursor inside a transaction, protecting against concurrent subscription and scope edits.

✅ Dispatch recovery — Accepted queued runs remain recoverable after subscription resets, with pagination that passes over offboarded owners’ receipts.

✅ Consistent execution policy — Event runs reuse the existing trigger, cost gate, definition snapshot, and capability enforcement.

The supplied current-head status has 34 passed checks, no failures, and one pending check. This review used static analysis only, as requested.

Merge blockers

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

F6: 🔴 Cursor advancement can permanently skip events

  • Required behavior: Subscribed automations must consume matching durable blocked events reliably; concurrent producer transactions must not silently lose events.

  • Evidence: packages/core/src/services/agents/agentEventTriggerStore.ts, listPlanIssueBlockedEventsAfter and advanceAgentDefinitionEventCursor; src/agentRunEventTriggers.ts, sweepSubscription.

    1. On the PostgreSQL path accommodated by the new store’s row-locking implementation, two queue transactions block issues in different plans. Transaction A inserts blocked event ID 101 and pauses before commit; transaction B inserts ID 102 and commits.
    2. While A remains uncommitted, the sweep awaits listPlanIssueBlockedEventsAfter(100, ...). Its query sees committed event 102 but cannot see event 101.
    3. The sweep handles event 102 and durably advances the definition’s cursor to 102.
    4. Transaction A commits. Every subsequent event query requires e.id > 102, so event 101 never creates a run, even though the definition was subscribed and the event matches.

    The producer excerpts explicitly place event insertion inside independently committing queue transactions. Sequence-generated IDs order allocation, not transaction commits. The new definition/cursor locks do not lock those producer transactions or establish a committed event watermark. Run idempotency and queued-run recovery cannot repair this loss because event 101 never received a run receipt.

    static trace: Traced the supplied withBlockedEvents/syncBlockedEvents transaction boundary through the new ID-only event query and cursor advancement. No commands or tests were executed.

  • Minimum fix: Make event consumption safe against out-of-order producer commits. Establish a producer-coordinated committed watermark, or retain durable per-event delivery tracking with reconciliation that discovers late-committing lower IDs. Preserve subscription/reset boundaries and run idempotency; an arbitrary time delay alone does not close this failure.

Suggestions

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

S4: 🟢 Refresh introductory documentation

The guide’s introduction still describes automations as running only on demand or on a schedule, and its schedule section says unscheduled automations display “Manual.” Update these passages to acknowledge event-only automations. This is optional documentation cleanup; the dedicated event section already explains the feature.

Score

The implementation has substantial coverage and thoughtful admission and recovery protections, but the event cursor can permanently lose matching events under concurrent database transactions. Passing checks do not cover that ordering.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 39s
  • Tokens: 87,277 (85,657 in / 1,620 out)
  • Cost: $0.81

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 F6 S4

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit 3489ee4

Addressed 1 AI review comment (IDs: 6849236113)

Addressed finding F6

Summary of Changes

I fixed F6: a blocked event whose write commits after a higher-numbered one is now still delivered instead of being skipped for good. test/agentRunEventTriggers.test.ts passes 23/23, and the 2 new tests fail on the previous code. I also reproduced the race and checked the fix against a real Postgres 18 started in /tmp, but those checks were a throwaway script that isn't in the repo. CI only runs the SQLite tests.

The fix. The sweep now only reads events up to a point where no write still in progress can commit a lower id.

  • Writers (epicQueueBlockedEvents.ts, insertEvent): each one takes a shared Postgres lock before it gets its event id and holds it until commit. Writers don't block each other.
  • The sweep: once per sweep, committedBlockedEventWatermark takes the same lock exclusively. That waits for writers already in progress, then reads the newest event id. Every id at or below it is final, and every later id will be above it.
  • The query: listPlanIssueBlockedEventsAfter now requires that bound (through) and never reads past it. The cursor, the subscription/re-enable reset, run idempotency and the admission check are unchanged.
  • If the lock can't be had within 2 s (a long write is still open), the attempt fails. Every cursor stays where it was and the next sweep tries again. The wait is capped so the sweep can't stall queue writes behind it.
  • SQLite, which every shipped config uses, needs no lock. It allows one writer at a time and that writer commits in id order. So the watermark there is just the newest id, and there's no extra cost for writers.

Postgres results

  • Old query: with the transaction holding id 1 still open and id 2 committed, it returns only [2]. That is the bug.
  • New watermark: while that transaction is open, it times out instead of reading past it. Once it commits, the watermark is 2 and the read returns [1, 2].
  • Deadlock check: one writer was waiting on a row lock held by a second writer, which was queued behind the waiting sweep. Postgres reordered the queue, both writers committed with nothing aborted, and the watermark then covered all their events.

Tests

  • New: an event committed below an id the sweep already saw still runs, and the cursor never moves past it. A watermark that can't be read leaves every cursor in place and is only tried once per sweep.
  • Changed: the existing "reset between reading a batch and admitting it" test now passes an unbounded watermark. Its event is recorded during the query, so the new bound would otherwise filter it out before the reset check it exists to test.
  • Also passing: the blocked-event writer suites (36/36) and the scheduler suite. Typecheck and zero-warning lint pass for root and core on the changed files.

I also added one sentence to docs/docs/features/agents.md saying a late-committing event is still delivered.

Found separately, not changed:


🤖 Implementation Details

  • Model: Claude Opus 5.5 (high)
  • Requested By: @propr-ultrafix
  • Time: 21m 42s
  • Tokens: 4,400,120 (4,363,084 in / 37,036 out)
  • Cost: $2.13
  • Subscription usage: Weekly +1%

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

…her-numbered one is now still delivered instead of being skipped for good. `test/agentRunEventTriggers.test.ts` passes 23/23, and the 2 new tests fail on the previous code. I also reproduced the race and checked the fix against a real Postgres 18 started in `/tmp`, but those checks were a throwaway script that isn't in the repo. CI only runs the SQLite tests.

I fixed F6: a blocked event whose write commits after a higher-numbered one is now still delivered instead of being skipped for good. `test/agentRunEventTriggers.test.ts` passes 23/23, and the 2 new tests fail on the previous code. I also reproduced the race and checked the fix against a real Postgres 18 started in `/tmp`, but those checks were a throwaway script that isn't in the repo. CI only runs the SQLite tests.

**The fix.** The sweep now only reads events up to a point where no write still in progress can commit a lower id.
- **Writers** (`epicQueueBlockedEvents.ts`, `insertEvent`): each one takes a shared Postgres lock before it gets its event id and holds it until commit. Writers don't block each other.
- **The sweep:** once per sweep, `committedBlockedEventWatermark` takes the same lock exclusively. That waits for writers already in progress, then reads the newest event id. Every id at or below it is final, and every later id will be above it.
- **The query:** `listPlanIssueBlockedEventsAfter` now requires that bound (`through`) and never reads past it. The cursor, the subscription/re-enable reset, run idempotency and the admission check are unchanged.
- **If the lock can't be had within 2 s** (a long write is still open), the attempt fails. Every cursor stays where it was and the next sweep tries again. The wait is capped so the sweep can't stall queue writes behind it.
- **SQLite**, which every shipped config uses, needs no lock. It allows one writer at a time and that writer commits in id order. So the watermark there is just the newest id, and there's no extra cost for writers.

**Postgres results**
- **Old query:** with the transaction holding id 1 still open and id 2 committed, it returns only `[2]`. That is the bug.
- **New watermark:** while that transaction is open, it times out instead of reading past it. Once it commits, the watermark is 2 and the read returns `[1, 2]`.
- **Deadlock check:** one writer was waiting on a row lock held by a second writer, which was queued behind the waiting sweep. Postgres reordered the queue, both writers committed with nothing aborted, and the watermark then covered all their events.

**Tests**
- **New:** an event committed below an id the sweep already saw still runs, and the cursor never moves past it. A watermark that can't be read leaves every cursor in place and is only tried once per sweep.
- **Changed:** the existing "reset between reading a batch and admitting it" test now passes an unbounded watermark. Its event is recorded during the query, so the new bound would otherwise filter it out before the reset check it exists to test.
- **Also passing:** the blocked-event writer suites (36/36) and the scheduler suite. Typecheck and zero-warning lint pass for root and core on the changed files.

I also added one sentence to `docs/docs/features/agents.md` saying a late-committing event is still delivered.

**Found separately, not changed:**
- `listEpicQueueBlockedEvents`, the per-execution blocked-event list from #3518, pages by event id the same way. A client paging it during concurrent writes could skip a late-committing event. It predates this PR, so I left it alone.
- An event that gets its id before an automation subscribes or is re-enabled, but commits after, is treated as before the subscription and doesn't run. This is the existing "no backlog" rule.

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

propr-dev Bot commented Nov 13, 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 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR adds opt-in blocked-issue subscriptions across storage, daemon execution, prompts, API, CLI, and UI. It needs a localized concurrency correction before merge.

✅ Durable delivery — Event receipts use definition-scoped idempotency keys, and queued receipts remain recoverable after subscription resets.

✅ Execution policy reuse — Event runs pass through the existing trigger and cost gate, with captured autonomy and fenced event data in both prompts.

✅ Focused coverage — Tests exercise enqueue failures, subscription resets, definition edits during admission, filtering, and loop protection.

The supplied checks show 32 passed, two pending, and no failures. 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.

F7: 🔴 Fence scope validation against concurrent updates

  • Required behavior: A subscribed definition must name its repositories, and every subscription’s repository filter must remain within them. Accepted updates must preserve this invariant.

  • Evidence: packages/api/routes/automationDefinitionRoutes.ts, update and requirePatchedEventTriggerScope; packages/core/src/services/agents/agentDefinitionStore.ts, updateAgentDefinition.

    1. An enabled definition has repositories ['acme/app'] and no subscription. Request A, without the optional expectedRevision, changes its repositories to ['acme/api'].
    2. A validates the proposed scope against the unsubscribed definition, then awaits requireRuntimeValid or verifyRepositories.
    3. During that await, request B subscribes the definition to plan.issue_blocked, filtered to ['acme/app']. B’s update is valid and commits.
    4. A resumes and calls updateAgentDefinition. The store reads the now-current definition and applies A’s repository patch using that revision. Its compare-and-set therefore succeeds, preserving B’s subscription alongside A’s incompatible repositories.
    5. The saved definition now contains a subscription outside its repository scope. Its event runs silently stop matching, although both requests returned success.

    static trace: The route validates one version, but does not pass that version’s revision to the store unless the caller supplied expectedRevision. The store’s revision guard protects its own read/write interval, not the earlier route validation. Runtime event matching prevents out-of-scope execution, but does not prevent this invalid persistent configuration. The same ordering can leave a subscription on a definition whose repositories were cleared.

  • Minimum fix: Pass the route’s validated current.revision as the update’s expected revision when the caller omitted one, or validate the merged subscription scope inside the store against the exact revision being updated. Add a regression covering the concurrent repository-change/subscription sequence.

Suggestions

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

S5: 🟢 Exercise PostgreSQL locking directly

The late-commit test substitutes a watermark, while the suite uses SQLite. A PostgreSQL integration test covering concurrent event writers and the exclusive watermark lock would verify the actual locking implementation and timeout behavior. This is additional confidence, not a separately demonstrated defect.

Score

The implementation has substantial coverage and sound recovery mechanisms, but concurrent API updates can persist a configuration that violates the new subscription contract. The correction appears localized.

Score: 6/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 49s
  • Tokens: 88,078 (86,019 in / 2,059 out)
  • Cost: $0.85

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 F7 S5

🤖 Review by ProPR

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

❌ Failed to apply follow-up changes requested by @propr-ultrafix

An error occurred while processing your request:

Agent execution failed: Failed to authenticate. API Error: 403 Attention Required! | Cloudflare

Comment ID: 0✓
Please check the logs for more details.

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit ff30ea4

Addressed 1 AI review comment (IDs: 6850049276)

Addressed finding F7

Summary of Changes

I fixed F7: an automation update can no longer be saved on top of a version of the definition it didn't check. If another edit lands while the update's checks are running, the update now fails with 409 "reload and retry" instead of saving a subscription outside the repositories.

The fix (packages/api/routes/automationDefinitionRoutes.ts)

  • The update always passes the revision it validated to the store, even when the caller didn't send expectedRevision. The store already writes only if that revision is still current.
  • If the caller sends an expectedRevision that differs from the version the route read, the route returns 409 straight away. Without this, a guessed future revision could match a concurrent edit and slip through the same way.

Other places with the same problem

  • This route is the only code that writes a definition's repositories or event triggers. MCP has no update tool, and creating a definition can't race because the row is new.
  • The other checks in the same update also read the old version: runtime validity, skipping the repository re-check when the list is unchanged, and the extension profile check. The same fix now covers them.
  • Behaviour change: a client that omits expectedRevision now gets 409 if any edit lands during its checks. That includes the system turning off a schedule when its owner leaves. The web UI always sends expectedRevision, so it isn't affected.

Tests (packages/api/test/agentDefinitionRoutes.test.ts)
I added 5 tests, and each race case lets a second update commit while the first one's checks are running:

  • The finding's exact sequence: repositories changed while a subscription is added.
  • Repositories cleared while a subscription is added.
  • The reverse order: subscribing while the repositories change.
  • A caller expectedRevision that is ahead of what the route read.
  • An update without expectedRevision still succeeds when nothing changes meanwhile.

The 4 race tests fail on the previous code: the late update returns 200 and saves an out-of-scope subscription. Now the file passes 32/32, the OpenAPI route coverage and response conformance tests pass 24/24, and typecheck and zero-warning lint pass on both files. The tests run on SQLite only; I didn't run them against Postgres.

Separate from this change: 2 tests in packages/api/test/creatorProjection.test.ts fail, one for plans and one for to-dos. They fail the same way with the previous route code, so this change didn't cause them, and I left them alone.

There are no visual previews because nothing changes on screen.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (xhigh)
  • Requested By: @propr-ultrafix
  • Time: 12m 26s
  • Tokens: 3,260,036 (3,236,765 in / 23,271 out)
  • Cost: $1.56
  • Subscription usage: Weekly +1%, Fable +1%

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

…top of a version of the definition it didn't check. If another edit lands while the update's checks are running, the update now fails with 409 "reload and retry" instead of saving a subscription outside the repositories.

I fixed F7: an automation update can no longer be saved on top of a version of the definition it didn't check. If another edit lands while the update's checks are running, the update now fails with 409 "reload and retry" instead of saving a subscription outside the repositories.

**The fix** (`packages/api/routes/automationDefinitionRoutes.ts`)
- The update always passes the revision it validated to the store, even when the caller didn't send `expectedRevision`. The store already writes only if that revision is still current.
- If the caller sends an `expectedRevision` that differs from the version the route read, the route returns 409 straight away. Without this, a guessed future revision could match a concurrent edit and slip through the same way.

**Other places with the same problem**
- This route is the only code that writes a definition's repositories or event triggers. MCP has no update tool, and creating a definition can't race because the row is new.
- The other checks in the same update also read the old version: runtime validity, skipping the repository re-check when the list is unchanged, and the extension profile check. The same fix now covers them.
- **Behaviour change:** a client that omits `expectedRevision` now gets 409 if any edit lands during its checks. That includes the system turning off a schedule when its owner leaves. The web UI always sends `expectedRevision`, so it isn't affected.

**Tests** (`packages/api/test/agentDefinitionRoutes.test.ts`)
I added 5 tests, and each race case lets a second update commit while the first one's checks are running:
- The finding's exact sequence: repositories changed while a subscription is added.
- Repositories cleared while a subscription is added.
- The reverse order: subscribing while the repositories change.
- A caller `expectedRevision` that is ahead of what the route read.
- An update without `expectedRevision` still succeeds when nothing changes meanwhile.

The 4 race tests fail on the previous code: the late update returns 200 and saves an out-of-scope subscription. Now the file passes 32/32, the OpenAPI route coverage and response conformance tests pass 24/24, and typecheck and zero-warning lint pass on both files. The tests run on SQLite only; I didn't run them against Postgres.

**Separate from this change:** 2 tests in `packages/api/test/creatorProjection.test.ts` fail, one for plans and one for to-dos. They fail the same way with the previous route code, so this change didn't cause them, and I left them alone.

There are no visual previews because nothing changes on screen.

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

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ AI Code Review Complete requested by @propr-ultrafix

Posted 1 review:

View Task Details

integry commented Nov 13, 2026

Copy link
Copy Markdown
Owner

ProPR runs on SQLite only. Remove the PostgreSQL-specific code this PR added: the advisory-lock calls and the non-SQLite branch of the committed-watermark logic in epicQueueBlockedEvents.ts, and anything else that exists only for a database with concurrent writers. SQLite has a single writer that allocates ids and commits under the write lock, so events commit in id order; state that once in a comment where the cursor is advanced and rely on it. Do not add code or tests for other databases. Keep the fixes for races between the sweep and definition updates (F1–F5, F7), which apply to SQLite. In the PR description, note for the reviewer that findings which require concurrent database writers do not apply.

@propr-dev

propr-dev Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ Applied the requested follow-up changes in commit f11b8f9

Summary of Changes

I removed the PostgreSQL-only code this PR added. The event-trigger sweep now relies on SQLite committing events in id order. I couldn't update the PR description myself, though: the edit was refused with Resource not accessible by integration. The note for the reviewer is below so it can be pasted in.

What I removed (all of the F6 fix, which only matters with concurrent writers)

  • epicQueueBlockedEvents.ts: back to how it was before this PR. The advisory-lock calls, committedBlockedEventWatermark and its non-SQLite branch are gone, and so is the lock in insertEvent.
  • agentEventTriggerStore.ts:
    • listPlanIssueBlockedEventsAfter no longer takes or applies an upper bound on event ids.
    • The forShare() row-lock branch in holdAgentDefinitionEventCursor is gone. It ran only on non-SQLite databases. The comments there no longer talk about row locks and deadlocks.
  • src/agentRunEventTriggers.ts: the watermark dependency, the helper that read it once per sweep, and the note about it in the header comment are removed.
  • There is now one comment, where the cursor is advanced: SQLite has a single writer that allocates ids and commits under the write lock, so events commit in id order, and moving past event.id can't skip a lower id.
  • Tests: I removed the two F6 tests (an event committing late, and a watermark that can't be read). The "reset between reading a batch and admitting it" test is back to its original form, and the test helper no longer lets a test pick event ids. No code or tests for other databases were added.
  • Docs: I took out the sentence in docs/docs/features/agents.md about late-committing events.

The fixes for races between the sweep and definition updates are unchanged: F1–F5 (the admission check, cursor compare, revision check and re-enable reset) and F7 (an edit landing during an update's checks returns a 409).

Checks

  • test/agentRunEventTriggers.test.ts passes 21/21; that's 23 minus the two F6 tests.
  • The core blocked-event writer suites (events, notify, head) pass 36/36.
  • Typecheck for root and core passes, and zero-warning lint passes on every file I changed.
  • Nothing here changes the UI, so there are no previews.

Note for the reviewer (for the PR description, under "Closes #3475"):

Note for the reviewer: ProPR runs on SQLite only. SQLite has a single writer that allocates ids and commits under the write lock, so blocked events commit in id order. Findings that need concurrent database writers (for example an event id committing after a higher one, or row-lock ordering between writers) do not apply to this PR. The earlier F6 fix for that case (the Postgres advisory lock and the committed watermark) has been removed. The fixes for races between the sweep and definition updates (F1–F5, F7) stay, because they apply to SQLite.


🤖 Implementation Details

  • Model: Claude Opus 5.5 (medium)
  • Requested By: @integry
  • Time: 7m 57s
  • Tokens: 2,525,587 (2,515,755 in / 9,832 out)
  • Cost: $1.15
  • Subscription usage: Weekly +1%, Fable +2%

Undo Changes • 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
Processing comment ID: 6850571237✓

…-trigger sweep now relies on SQLite committing events in id order. I couldn't update the PR description myself, though: the edit was refused with `Resource not accessible by integration`. The note for the reviewer is below so it can be pasted in.

I removed the PostgreSQL-only code this PR added. The event-trigger sweep now relies on SQLite committing events in id order. I couldn't update the PR description myself, though: the edit was refused with `Resource not accessible by integration`. The note for the reviewer is below so it can be pasted in.

**What I removed (all of the F6 fix, which only matters with concurrent writers)**
- **`epicQueueBlockedEvents.ts`:** back to how it was before this PR. The advisory-lock calls, `committedBlockedEventWatermark` and its non-SQLite branch are gone, and so is the lock in `insertEvent`.
- **`agentEventTriggerStore.ts`:**
  - `listPlanIssueBlockedEventsAfter` no longer takes or applies an upper bound on event ids.
  - The `forShare()` row-lock branch in `holdAgentDefinitionEventCursor` is gone. It ran only on non-SQLite databases. The comments there no longer talk about row locks and deadlocks.
- **`src/agentRunEventTriggers.ts`:** the watermark dependency, the helper that read it once per sweep, and the note about it in the header comment are removed.
- **There is now one comment**, where the cursor is advanced: SQLite has a single writer that allocates ids and commits under the write lock, so events commit in id order, and moving past `event.id` can't skip a lower id.
- **Tests:** I removed the two F6 tests (an event committing late, and a watermark that can't be read). The "reset between reading a batch and admitting it" test is back to its original form, and the test helper no longer lets a test pick event ids. No code or tests for other databases were added.
- **Docs:** I took out the sentence in `docs/docs/features/agents.md` about late-committing events.

The fixes for races between the sweep and definition updates are unchanged: F1–F5 (the admission check, cursor compare, revision check and re-enable reset) and F7 (an edit landing during an update's checks returns a 409).

**Checks**
- `test/agentRunEventTriggers.test.ts` passes 21/21; that's 23 minus the two F6 tests.
- The core blocked-event writer suites (events, notify, head) pass 36/36.
- Typecheck for root and core passes, and zero-warning lint passes on every file I changed.
- Nothing here changes the UI, so there are no previews.

**Note for the reviewer (for the PR description, under "Closes #3475"):**

> **Note for the reviewer:** ProPR runs on SQLite only. SQLite has a single writer that allocates ids and commits under the write lock, so blocked events commit in id order. Findings that need concurrent database writers (for example an event id committing after a higher one, or row-lock ordering between writers) do not apply to this PR. The earlier F6 fix for that case (the Postgres advisory lock and the committed watermark) has been removed. The fixes for races between the sweep and definition updates (F1–F5, F7) stay, because they apply to SQLite.

PR: #3523
Comment by: @integry (ID: 6850571237)
Model: Claude Opus 5.5
@propr-dev

propr-dev Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

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

Overall Evaluation

The PR implements opt-in blocked-issue event triggers across storage, daemon processing, prompts, API, UI, CLI, and documentation. No merge-blocking defect is established by the supplied code. It is ready to merge within the reviewed scope, conditional on the two pending checks completing successfully.

✅ Admission fencing — Run creation checks the definition revision, enabled subscription, and cursor inside the receipt transaction, preventing stale admissions after definition edits or resets.

✅ Durable dispatch recovery — Accepted queued receipts remain recoverable after subscription resets, with pagination that prevents an offboarded owner’s receipts from hiding later runs.

✅ Scoped execution — Subscription validation and matching constrain events to the automation’s repositories; event runs reuse the existing cost gate and captured autonomy.

Review was static; no commands or tests were run. Findings requiring concurrent database writers do not apply to the authorized SQLite-only implementation.

Merge blockers

No merge blockers.

Suggestions

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

S6: 🟢 Test MCP event-list size

Add a boundary test for list_automation_runs with 100 event runs carrying maximum-length blocker reasons. The new triggerEvent payload can contribute over 400 KB before other fields, while the supplied MCP context identifies a 256 KiB result bound. Verify how the shared response layer handles this and consider bounded summaries or smaller pages. This is a follow-up because the supplied context does not establish that layer’s actual oversized-list behavior.

S7: 🟢 Refresh introductory documentation

The guide’s opening description still describes only on-demand and scheduled automations, and its Schedule section says automations without schedules display “Manual.” Update these passages to reflect event triggers and the verified “On blocked issue” label. These are minor documentation inconsistencies.

Score

The implementation has substantial targeted coverage and carefully handles SQLite-relevant admission and recovery races. The supplied current-head status has no failures, with two checks still pending; validation here was static.

Score: 9/10


🤖 Review Details

  • Model: GPT-6 Astra
  • Time: 1m 14s
  • Tokens: 88,871 (87,428 in / 1,443 out)
  • Cost: $0.84

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 S6 S7

🤖 Review by ProPR

@propr-dev propr-dev Bot removed the ultrafix label Nov 13, 2026
@integry
integry merged commit 336eedc into 3470-epic-scheduler-primitives-nrj Nov 13, 2026
50 checks passed
propr-dev Bot pushed a commit that referenced this pull request Nov 13, 2026
…es are merged into the epic branch, in the title and the status block. The progress comment now also lists what is in progress and what is next. All the tests I ran pass. I didn't run the full CI suite.

What the epic shows
- Title (with `prTitleStatus` on): the status emoji is followed by the count, e.g. `🔨 3/5 [Epic] Scheduler primitives`. The shared title helpers recognise and strip the count everywhere, including `[Epic]` detection and the web UI. With the setting off, epic titles are left alone and the status block is still written.
- Status block: the first line reads e.g. `ProPR 🔨 3 of 5 issues merged · #3475 in progress (Ultrafix cycle 4 of 10, last review 6/10) · updated 09:41 UTC`.
  - A sub-PR that is `ready` but unmerged gives `⚠️ … · #3523 (issue #3475) waits to be merged into the epic branch`.
  - With every issue merged it reads `✅ 5 of 5 issues merged · checks: 12 passed`, or `⚠️` with the failed check or the conflict.
- States: they follow your table. An epic shows no review score, and a low score never holds it back. When issues remain but nothing is running and none of your listed causes applies, the epic shows `⚠️` with "nothing in progress". I added that as a fallback.
- New epic PRs: created with `🔨 0/N` and the status block already in the body. An epic PR created on the first sub-PR merge (the usual case) starts at `🔨 1/N` instead, since one issue is already merged. The epic body builder keeps the status block when it rewrites the body.
- Counts: these come from the existing `computeEpicMergeProgress`. That includes excluding sub-PRs that already shipped through an earlier epic PR. I removed the separate count the status facts used to do.

Renames
- The title changes only when the count or the state changes.
- While the queue is about to start the next issue, the epic stays `🔨`, so a merge costs one rename. The test for this confirms exactly one.

Progress comment
- Below "Merged child PRs" it now adds `In progress:` and `Up next:` lines, whatever `prTitleStatus` says.
- "In progress" is left out when empty. "Up next" reads `none` once the last issue is in progress, and both lines go when there is neither. That is how I reconciled "omit empty lines" with your `Up next: none` example.
- It is updated in the same pass as the status block, with no GitHub write when nothing changed.

When the epic gets updated
- A sub-PR into the epic branch opens, closes or is retargeted.
- A sub-PR's own status block or title changes.
- A plan issue changes status, such as starting.
- A sub-PR merges.

Limits to know about
- Reading an epic's status now reads the status of up to 10 of its open sub-PRs. That is extra GitHub calls per epic update, and also for MCP status reads.
- Issue titles in the comment come from the epic body's issue list, so there is no extra GitHub read per issue.
- The status pass only updates an existing progress comment. Creating it is still the job of the first merge, so the two writers can't post it twice.
- The merge path keeps the existing "In progress"/"Up next" lines and then triggers the status pass to refresh them. For a moment after a merge, the merged sub-PR can still be listed as in progress.

Tests and checks
- New suites cover:
  - the epic state table, block wording and title slot (`pullRequestStatusEpic.test.ts`).
  - a fake-GitHub sync run (`pullRequestStatusEpicSync.test.ts`): title, block, comment, no-op writes, one rename per merge, setting off, and the signals.
  - creation with `🔨 0/N` (`epicPRCreationStatus.test.ts`).
- Existing suites gained cases for the slot with a count, `[Epic]` detection behind it, and the comment lines.
- I updated two existing expectations to the new wording (`issues: 1 of 2 merged` became `1 of 2 issues merged`).
- I broke the title change on purpose and confirmed 5 tests fail, then restored it.
- Core and API typecheck clean. Core source lint has zero warnings; four files went over the 400-line limit, so I moved the new code into new modules rather than leave warnings.

Docs are updated in `docs/docs/features/pr-status.md` (new "Epic pull requests" section) and `work-splitting.md`, plus a `CHANGELOG.md` entry. There is no UI change, so I made no visual preview.
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