Skip to content

fix(platform): a delegated start honours its dispatch's gates and source label filter #5547

In review

Description

@yannickmonney

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.labels in packages/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:

  1. Gates on the dispatch's own board. A pool agent's run calls task_start_agent for another agent on a task that a held gate governs. Example: the gate holds every task labelled repo:ops while a live configuration sequence runs. The start goes ahead and the started agent works through the hold.
  2. 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_agent step. lockAgentForStart admits the agent through agentReachesProject, 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 with whenStale: 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's labels filter (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, with gate: <key>, the way paused and blocked already answer. A task.start_agent step then answers started: 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

  • startDelegatedAgentRun refuses 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 answers held with 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 declares whenStale: hold, and a gate with labels governs only tasks that carry one of them.
  • On a served board, a task that the source's labels filter does not select is refused with AGENT_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_agent answers started: false, reason: "held", gate. Its output type in configs/platform/system/connectors/task/connector.yml and WorkflowAgentStart say so.
  • Native task_start_agent describes held in 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 (the task.start_agent answers table) and docs/*/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), through startDelegatedAgentRun:
    • 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.
  • Manual: a box in the tasks suite, or a row in reference/automation.md that names the spec.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readysecurityservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions