Repository navigation
Description
Problem
The blocked event from the previous issue reaches people. The RFC in #3385 asks for more: an automation or goal should be able to react (start Ultrafix, create a replacement task, escalate) instead of the queue simply stopping. Automations can only be started manually, on a schedule, or through the API, MCP and CLI; there is no event trigger.
Goal
An automation definition can subscribe to "an epic queue issue became blocked" and is run once per event with the event as its input.
Acceptance criteria
- A new automation trigger type for events exists, with one event to start with: plan issue blocked. A definition opts in explicitly and can limit the trigger to repositories and to blocker reason kinds. No shipped definition subscribes by default.
- Each blocked event starts at most one run per subscribed definition, also across restarts and repeated deliveries. Events that arrive while the definition is disabled or paused are not run later.
- The run receives the event as structured input: repository, plan, execution, issue number, reason kind and text, and links to the plan and the issue.
- The run is unattended and obeys everything a scheduled run obeys: the definition's autonomy level (dry run, preview with approval, auto), its capabilities and grants, cost gates and budget caps. An event never widens what a definition may do.
- Loop protection: a run started by a blocked event whose own actions cause another blocker on the same issue does not trigger itself without bound. Bound it per issue and say so in the docs.
- The trigger is visible wherever triggers are shown or validated: the definition contract (
get_automation_definition_contract), the definition editor, the run list (which event started a run), CLI and docs. - Existing triggers are unchanged, and an instance with no subscribed definition does no extra work when an issue is blocked.
- Tests cover: one run per event per definition, no run for a non-matching repository or reason kind, no duplicate run after a restart or repeated delivery, autonomy and cost gates applied, the loop bound, and no behaviour change without subscribers.
Out of scope
- A template that implements a recovery policy; a short documented example definition is enough.
- Other event types, and goals subscribing to plan events (goals and plans are not linked today).
Implementation
Key files: packages/shared/src/automationDefinitions.ts (AUTOMATION_RUN_TRIGGERS = ['manual', 'schedule', 'api', 'mcp', 'cli'], isUnattendedTrigger), packages/core/src/services/agents/agentRunTrigger.ts (triggerAgentRun, TriggerAgentRunInput, enqueueAgentRunPhase: the single trigger primitive), src/agentRunScheduler.ts (how scheduled runs are claimed and deduplicated), packages/api/routes/automationDefinitionRoutes.ts, packages/api/mcp/toolsAutomations.ts, src/jobs/processAgentRunJob.ts, the blocked-event record and its writer from the previous issue, the definition editor in propr-ui/src/components/Agents/, docs/docs/features/agents.md.
Consume events from the durable record with a cursor per definition, in the worker, rather than calling the trigger from inside the queue write: the queue transaction must not depend on automation code, and the cursor gives restart safety and at-most-once runs. Verify with the standard commands; add the tool/contract changes to docs/mcp.md and keep packages/api/test/mcpObservableSurface.test.ts passing.
Activity
propr-dev commentedon Nov 13, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53475/claude-opus-5-5-let-an-automation-run-whe-20261113-0621-rud3470-epic-scheduler-primitives-nrjissue-3475-20261113-0621-claude-opus-5-5-rud🔍 Track Task Execution
feat(ai): I removed the PostgreSQL-only code this PR added. The event…
feat(ai): I fixed the Shard 4/4 failure. It was a test-ordering probl…
I've implemented #3531. Open epic PRs now show how many of their issu…