Skip to content

fix(platform): check a managed dispatch before anything is written - #4995

Merged
yannickmonney merged 1 commit into
mainfrom
fix/dispatch-check-before-apply
Oct 15, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/dispatch-check-before-apply

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Managed configuration writes a project's dispatch last, after the schedules the same declaration may switch off. The platform checked what a dispatch names only when it saved it, so a dispatch it refused at that point left the rest of the declaration applied. The project's agents, the standing roles' open tasks, the labels of its filters and gates, and its schedules were all checked only then. For the Ops fleet this would have meant six automations switched off and no dispatch in their place, had the project lacked the optional-ci label its ci gate names.

What changes

  • Platform: the save's checks are one step, prepareDispatchSave. They cover who may administer the project, an active project, the reviewed hash, a stored document this image can read, and what the document names. POST /api/app/tasks/dispatch/by-project/{projectId}/configuration/check runs that step and writes nothing: no document, audit, pass or hint. It answers {ok: true, changed, hash}, exactly what the save would answer, or {ok: false, issues}. A caller who may not administer the project, or a stale hash, is refused as the save refuses them.
  • CLI: checkResourceChange asks the check for every changed project-dispatch. That happens while planning, and in apply's pass over all resources before the journal and any write. A refused dispatch stops the declaration before anything is written. The refusal names the declared fields (gates.0.labels.0, deduplicated, and only paths shaped like the declaration's). Native text never becomes a diagnostic. An unchanged dispatch is never asked about.
  • TASK-R61 in the tasks spec, the docs' "Manage dispatch as configuration" in EN/DE/FR, a manual reference row, and one sentence in the v0.5.92 notes.

Both halves belong in v0.5.92, the release that introduces the dispatch facet, so no CLI ever meets a platform with the facet but without the check.

Proof

  • Real Postgres, checkFleetDispatch 97/97 locally. The new check refuses the gate's missing label at gates.0.labels.0, the stored dispatch and its audit count stay unchanged, and once the label exists the check answers the hash the save then stores.
  • Unit tests, mutation-checked:
    • Server, dispatch-config.test.ts 12/12. Routing the check through the real save fails 2 of them.
    • CLI, src/lib/config 299/299 and src/lib/deployment 955 (0 fail). Removing the CLI wiring fails 4.
    • The CLI tests cover: refused while planning; at apply, refused with nothing written and no receipt; only declared paths named; an unchanged dispatch never asked.
  • Platform tasks, rest, openapi and guards: 3,006 tests, guards 288/288 (domain-spec 15/15).
  • Typecheck (platform, CLI), type-aware lint, format, lint:manual, lint:links, and the v0.5.92 notes validator all pass.

Managed configuration writes a project's dispatch last, after the
schedules the same declaration may switch off, and the platform checked
what a dispatch names (the project's agents, the standing roles' open
tasks, the labels of its filters and gates, its schedules) only when it
saved it. A dispatch it refused there left the rest applied: a fleet's
old automations switched off and no dispatch started in their place.

The save's checks are now one step, which a new check route runs without
writing anything (no document, audit, pass or hint), answering what the
save would answer or the fields it would refuse. The CLI asks it for
every changed dispatch while planning and in apply's pass before any
write, so a dispatch the platform would refuse stops the declaration
before anything is written. The refusal names the declared fields, such
as gates.0.labels.0, never the platform's words. TASK-R61, with the
docs in English, German and French, the manual reference and a line in
the v0.5.92 notes; both halves ship in v0.5.92 with the endpoint itself.
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 15, 2026
Merged via the queue into main with commit 92f9a86 Oct 15, 2026
@yannickmonney
yannickmonney deleted the fix/dispatch-check-before-apply branch October 15, 2026 07:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant