Repository navigation
Description
Problem
A project's dispatch has two fences on the work it starts:
- Gates (
dispatch-gates.ts, TASK-R51). A signal from outside holds the ready work a gate governs, for example a CI queue that is full, a live configuration sequence, or a freeze. - A source's label filter (
projectDispatchSourceSchema.labelsinpackages/shared/src/schemas/project-dispatch.ts, TASK-R71). A source board gives up only the work its filter selects.
Only the dispatch pass (dispatch-pass.ts) judges either fence. The delegated start, startDelegatedAgentRun in services/platform/backend/domains/tasks/delegated-start.ts, judges neither. It is the one admission behind another agent's task_start_agent and an automation's task.start_agent step. So a start that does not come from the pass gets past both fences:
- Gates on the dispatch's own board. A pool agent's run calls
task_start_agentfor another agent on a task that a held gate governs. Example: the gate holds every task labelledrepo:opswhile a live configuration sequence runs. The start goes ahead and the started agent works through the hold. - Gates and the label filter on a served board. An automation bound to a source project names an agent of the serving dispatch in a
task.start_agentstep.lockAgentForStartadmits the agent throughagentReachesProject, which reaches per project and ignores labels. The step can then start that agent on a source task that the filter excludes, or that a held gate governs.
A person's own Start is out of scope: gates have never held it, and it stays that way.
Why
Operators put gates and label filters in place to keep agents away from work at given moments: a freeze, a live configuration lock, a private repository that only labelled tasks may touch. While a steered or misled agent run (prompt injection from an intake), or a misconfigured schedule, can start an agent past those fences, they are advice and not fences. The texts on the ops side currently have to say so.
Design
Option A from the follow-up: the delegated start honours the reaching dispatch. Option B, a per-agent allow-list of which agents a run may start, is a new configuration surface with its own schema, migration and editor. Option A reuses the two fences that already exist and that operators already declare, so it is the change taken here.
The reaching dispatch of a delegated start is the dispatch of the started agent's own project, as stored. Its gates bind whether the dispatch is switched on or off: a gate is declared data, and a held freeze must also stop agents' own starts while the fleet is switched off. A switched-off dispatch serves no board, so its source filters never come into play.
- The task is on that dispatch's own board. A gate of that dispatch that governs the task (by label, or every task when the gate names none) and holds now (
judgeGate: a report, or staleness withwhenStale: hold) refuses the start. - The task is on a board the dispatch serves (the agent reaches it through
sources). The same gate rule applies. In addition, a task that fails that source'slabelsfilter (include/exclude, matched by name on that board, as the pass does) is refused. - Standing-role tasks of that dispatch are never held by a gate (TASK-R51 already says so for the pass) and are never filtered.
- Starts that are unchanged: a dispatch's own starts (
via.kind === 'dispatch', already judged by the pass), a person's Start, and the start of an agent whose project has no dispatch, or one this version cannot read.
How each fence answers:
- A held gate is transient. The start answers a new non-throwing outcome,
held, withgate: <key>, the waypausedandblockedalready answer. Atask.start_agentstep then answersstarted: false, reason: "held", gate. A schedule does not count it as a failure, so a freeze never pauses an automation. - A failed label filter is a standing refusal:
AGENT_START_FORBIDDEN(403), saying the serving dispatch does not take this task from its board.
Acceptance criteria
-
startDelegatedAgentRunrefuses an agent's or an automation's start on a task that a held gate of the started agent's dispatch governs, on its own board and on a served board. It answersheldwith the gate's key, writes nothing (no assignment, no run, no card move), and the per-task hourly budget is not charged. - The gate rule is
judgeGate/gateGoverns, shared with the pass and not copied: a stale gate holds only when it declareswhenStale: hold, and a gate with labels governs only tasks that carry one of them. - On a served board, a task that the source's
labelsfilter does not select is refused withAGENT_START_FORBIDDEN, and nothing is written. - A standing-role task of the dispatch is neither held nor filtered.
- Unchanged: the dispatch pass's own starts, a person's Start, and agents of a project with no dispatch.
- The automation step
task.start_agentanswersstarted: false, reason: "held", gate. Its output type inconfigs/platform/system/connectors/task/connector.ymlandWorkflowAgentStartsay so. - Native
task_start_agentdescribesheldin its tool text and its outcome sentence (workspace_tools_bridge.ts,workspace_domain_tools.ts). - A tasks-spec rule card (
services/platform/backend/domains/tasks/spec.md) holds the behaviour, and a test names it. The "Not yet" note on cross-project dispatch is corrected. - The docs (EN/DE/FR) name the new answer:
docs/*/platform/automations/triggers.md(thetask.start_agentanswers table) anddocs/*/platform/projects/task-automation.md(what an agent's start checks). The API contract bump follows the 3.25.0 precedent for a native-tool answer.
Tests
- Unit, on the pure decision. A held gate refuses with its key. An open, stale-open or label-mismatched gate admits. A gate that names no labels governs every task. A source's include and exclude filters admit and refuse. A role task is exempt. A non-reaching or switched-off dispatch admits.
- Integration (
backend:integration, real Postgres), throughstartDelegatedAgentRun:- an agent's start on its own board while a gate that governs the task holds →
held, no run and no assignment; the gate reports open → the same start goes ahead; - an automation's start of a dispatch agent on a served board's task without the source's label →
AGENT_START_FORBIDDEN; - with the label and a held gate →
held; - a standing-role task under a held gate → starts.
- an agent's start on its own board while a gate that governs the task holds →
- Manual: a box in the tasks suite, or a row in
reference/automation.mdthat names the spec.
Activity
fix(platform): hold automatic retries behind the dispatch's fences
fix(platform): keep a gate-held retry armed and close two fence gaps