Repository navigation
[3475 by Claude Opus 5.5] Let an automation run when an epic queue issue becomes blocked - #3523
Conversation
… 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.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Fence admission against subscription resets
SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Test concurrent initial deliveryThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 4c1b32e
Summary of ChangesF1 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
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 (
Typecheck (root and core) and zero-warning lint pass on the changed source files. These suites still pass: I found nothing else outside F1. This change isn't visible in the UI, so I made no previews. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 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
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 ✅ 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 blockersEvery finding below was introduced by this PR and must be resolved before merging. F2: 🔴 Cursor resets strand undispatched runs
F3: 🔴 Removing a filtered repository broadens subscriptions
SuggestionsThese are optional follow-ups and are not sent to S2: 🟢 Exercise concurrent first deliveryThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 2993840
Summary of ChangesI fixed F2 and F3. The new regression tests fail on the previous code and pass now. F2: Cursor resets strand undispatched runsA run that was recorded but couldn't be queued no longer depends on its event being read again.
F3: Removing a filtered repository broadens subscriptions
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
I captured the warning and the refused save at desktop and phone width with a temporary Playwright spec, which I've deleted. Visual previewEvent trigger filter lost: save refusedacme/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 phoneThe same warning and refused save at 390px width Original unavailable: managed storage is unavailable or the upload has expired. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 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
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 blockersEvery finding below was introduced by this PR and must be resolved before merging. F4: 🔴 Fence subscription edits during admission
F5: 🔴 Prevent recovery starvation by offboarded owners
SuggestionsThese are optional follow-ups and are not sent to S3: 🟢 Exercise concurrent first deliveryThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit bcec0b9
Summary of ChangesI fixed F4 and F5. F4: an edit made while a run is being admitted is now respected
F5: recovery no longer gets stuck behind an offboarded owner's runs
Things to know
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
💡 ProPR Slash Commands
🤖 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
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 blockersEvery finding below was introduced by this PR and must be resolved before merging. F6: 🔴 Cursor advancement can permanently skip events
SuggestionsThese are optional follow-ups and are not sent to S4: 🟢 Refresh introductory documentationThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 3489ee4
Summary of ChangesI fixed F6: a blocked event whose write commits after a higher-numbered one is now still delivered instead of being skipped for good. The fix. The sweep now only reads events up to a point where no write still in progress can commit a lower id.
Postgres results
Tests
I also added one sentence to Found separately, not changed:
🤖 Implementation Details
💡 ProPR Slash Commands
🤖 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
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 blockersEvery finding below was introduced by this PR and must be resolved before merging. F7: 🔴 Fence scope validation against concurrent updates
SuggestionsThese are optional follow-ups and are not sent to S5: 🟢 Exercise PostgreSQL locking directlyThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
❌ Failed to apply follow-up changes requested by @propr-ultrafix An error occurred while processing your request: Comment ID: 0✓ |
|
✅ Applied the requested follow-up changes in commit ff30ea4
Summary of ChangesI 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 (
Other places with the same problem
Tests (
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 There are no visual previews because nothing changes on screen. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 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
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
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 |
|
✅ Applied the requested follow-up changes in commit f11b8f9 Summary of ChangesI 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 What I removed (all of the F6 fix, which only matters with concurrent writers)
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
Note for the reviewer (for the PR description, under "Closes #3475"):
🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…-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
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe 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 blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S6: 🟢 Test MCP event-list sizeAdd a boundary test for S7: 🟢 Refresh introductory documentationThe 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. ScoreThe 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
Copy and edit to choose records from this review: 🤖 Review by ProPR |
…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.


AI Implementation Summary
Closes #3475
Branch:
3475/claude-opus-5-5-let-an-automation-run-whe-20261113-0621-rudCommits: ✅ 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
eventTriggersfield. The only event isplan.issue_blocked, and it can be limited to some repositories and some blocker reasons. No existing or shipped definition subscribes.src/agentRunEventTriggers.ts) reads the blocked-event log with a cursor per definition. The queue transaction never calls automation code.event, and go throughtriggerAgentRun. So the definition's autonomy mode, capabilities, grants, cost gate and spend caps all apply.Where it shows up
get_automation_definition_contractnow listseventas a run trigger and theeventTriggersrules.eventTriggerson definitions andtriggerEventon runs.propr automation showlists the event triggers, and run output includes the event.docs/docs/features/agents.md, plusdocs/mcp.mdand the CHANGELOG.A new migration adds
event_triggersto definitions,trigger_eventandtrigger_subjectto runs, and a cursor table.Tests
test/agentRunEventTriggers.test.tscovers each case the issue lists:mcpAgentRuns.mcpObservableSurface: passes, but only withPROPR_DOCS_DIR=docsset. Without it, it fails on a missing docs bundle in this container, which has nothing to do with this change.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:
f53a0ff2-47bb-48df-a5ff-66f54ca9124dLog files stored at:
/usr/src/app/logs/executions/issue-3475-2026-11-13T07-11-23-282Z-conversation.json/usr/src/app/logs/executions/issue-3475-2026-11-13T07-11-23-282Z-output.txtLatest Conversation Messages
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
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
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
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
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