Wards
A ward is a guardrail magus runs against a resolved op - after a target's operation is fully assembled but before it executes. The ward inspects the op's argv and rejects it when the command contradicts the op's declared kind, so a misconfigured op fails immediately with a coded, actionable diagnostic instead of misbehaving at run time.
Wards share the MGSxxxx diagnostic rail with the rest of magus's diagnostics and
error codes: each ward raises a typed error with a stable
code, a plain-language explanation, and a suggested fix.
Kind coherence
magus ops carry a kind - a service op is a long-running process magus supervises in the foreground; a command op runs to completion. A ward fires when the argv lies about that kind:
- A service op that detaches (MGS5002) -
docker run -d, a--detachflag, and friends fork the process away from magus, so foreground supervision, readiness, and stop all stop working. Drop the detach flag, or make it a command op if detaching is what you want. - A command op that never exits (MGS5003) - a watcher
like
tsc --watchin a run-to-completion op hangs the run. Make it a service op, or drop the watch flag.
Both are mirror images of the same bug: the argv and the kind disagree. Catching it at resolution time turns a confusing hang or a lost log into a one-line fix.
See Services for the full rationale, and Operations for how op kinds fit the work hierarchy.
Where wards fit
Wards are one family in magus's diagnostics. The complete catalog, grouped by area, lives under the diagnostic codes:
- magusfile - authoring and configuration problems.
- race - concurrency and ordering hazards.
- sandbox - filesystem and exec isolation violations.
- services - service-op problems, including the kind-coherence wards above.