Page kind: Reference
swarmops check plan#
Say which checks a change needs, and why: a change in the store, a workspace or a directory.
Each check of the tree the change lands comes with one state, run or not_applicable, and the one reason, the first rule that holds: its definition or its stages are not those of the check of the same name in the target's file (definition_changed), the plan could not tell (widened; so is a need that is no check of the file or of the stage asked), it declares no inputs and a path changed (whole_tree), a changed path is one of its inputs (input_changed), or none is (no_input_changed); a check that none of these runs, and that a check that runs needs, runs too (needed, with needed_by). Nothing is run. HEAD plans landing the changeset HEAD onto --target (default main) as land --dry-run plans it, with --base and --key as land takes them: the tree it lands, the paths it changes, and the checks of that tree's .swarmops/checks.toml, read as check list reads them; a change that is already on the target, or whose --key landed, has no changed path. Without HEAD, the workspace (--ws, --ws-path, else the one around the working directory) plans its chain onto its target and adds the edits in its files, read as ws status reads them: nothing is written and no store lock is taken, and an answer with edits says vouched, since no changeset holds them. --dir DIR plans the files below DIR on this host and opens no store: give the changed paths with --changed PATH, repeatable, and --changed-from FILE (- is stdin), one path a line, or with --nul separated by NUL as git diff --name-only -z writes them; both together are one list, and the answer says vouched.
A plan fails closed: what it cannot read or tell makes the checks run, never skip. With no list of changed paths, an entry that is no repository path, a list cut at 16 MiB or past 100,000 paths, more than 1,000 changed paths in a land check, a change that conflicts, a check file that both the change and the target changed, or a sparse workspace's edits off its prefixes, every check runs (widened) and widened_by says why. A check whose definition is not the target's runs whatever its inputs say, so a change that narrows its own inputs cannot skip itself; a target whose file does not read, and a directory with a changed check file, change every definition. removed names the checks the target's file defines that the tree planned for does not: a deleted check, a renamed check's old name, a check moved out of the stage. A file that does not read is E_CHECK_FILE, never an empty plan. --stage keeps the checks of one stage, --check only the named ones, each of the stage, and the checks they need. It exits 0 whatever the plan says. Reads only: no identity, no store lock.
- Group
checks- Since
0.14.0- Mutates
- no
- Identity required
- no
- MCP tool
check_plan- Envelope op
check_plan- Exit codes
- 012
Syntax#
swarmops check plan [OPTIONS] [HEAD]Required arguments#
None.
Optional arguments#
The command also takes the global options.
Syntax: <HEAD>.
The changeset to plan landing: the change's head. Without it, the workspace or --dir.
Syntax: --ws <NAME>.
The workspace, by its name in the store's registry (default: the one around the working directory).
Syntax: --ws-path <DIR>.
The workspace's directory.
Syntax: --dir <DIR>.
Plan the files below DIR on this host, with the changed paths you give.
Syntax: --base <REV>.
Where the change starts: a first-parent ancestor of HEAD (default: the merge base of HEAD and the target's head, along first parents).
Syntax: --target <REF>.
The ref the change would land on: main (the default), a release ref such as release/1.0, and in a FORMAT 2 store a branch (feature/x).
Syntax: --key <KEY>.
The change's land key, as land --key: a change the target holds a land of with it is replayed, and needs no check.
Syntax: --stage <STAGE>.
Only the checks of this stage. Values: before-land: Before a change lands: the gate; after-land: After a change has landed; scheduled: On a schedule; release: Before a release is cut; manual: Only when someone asks for it; deploy: Before a deployment.
Syntax: --check <NAME>....
Only this check, which must be of the stage; repeatable.
Syntax: --changed <PATH>....
A changed path; repeatable. With --dir. List both the old and the new name of a renamed path (git diff --name-only --no-renames does): a check that reads the old name would otherwise be not applicable.
Syntax: --changed-from <FILE>.
A file of changed paths, one a line; - is stdin. With --dir.
Syntax: --nul.
The entries of --changed-from are separated by NUL, not by a newline.
Examples#
swarmops --repo [tmp]/store check plan [doc]Show 48 more lines
"target":Exit code 0. Recorded by the CLI tests. A name in square brackets, such as [tmp] or [c1], stands for what differs from run to run: the test's temporary directory, an id, a time.
No recorded example yet.
Details#
check plan says which of a tree's checks a change needs, and why. Each check comes back as run
or not_applicable, with the one reason that decided it. It runs nothing, takes no identity and
no store lock, and writes nothing to a store. It exits 0 whatever the plan says: a plan informs.
A step of a workflow that cannot read the answer treats any non-zero exit as "run".
Three forms#
- A change in the store,
check plan HEAD [--base REV] [--target REF] [--key KEY]: the plan of landingHEADonto the target (mainby default), made by the callland --dry-runmakes (land_check):ontois the target's head it was made on,outcomewhat the landing would come to,treethe root tree it would make, and the changed paths those it would change. With--key, a change the target holds a land of isreplayed. A change already on the target isnothing_to_land. Neither has a changed path, so no check is needed. A head or base not found, or a base that is no ancestor of the head, is the store's error, not a plan. - A workspace,
check plan [--ws NAME | --ws-path DIR], or the workspace around the working directory: the plan of its chain onto its target, with the edits in its files added to the changed paths. It reads the workspace asws statusdoes and leaves it as it was: the workspace must not be rebasing or stale, and its files must stand for its head, ascheck runasks; its index file is not written, and no store lock is taken. As every read of a workspace does, it finishes a materialisation a crash left, under the workspace's own lock, and its scan makes and removes a temporary file in.swarmws/. With edits the answer isvouched: trueand has notree, since no changeset holds them; without, it is the store form's answer for the head. - A directory,
check plan --dir DIR: the files belowDIRon this host, with the changed paths you give. It opens no store, and the answer isvouched: true.
The three forms answer the same type. The store form reads the check file of the tree the
landing makes, as check list reads it, and the directory form reads DIR's own. Where a form has
the target's check file to compare with, a check whose definition changed runs (below).
The changed paths of the directory form#
--changed PATH, repeatable, and --changed-from FILE (- is standard input) give the changed
paths; both together are one list, sorted, each path once. In a file, entries are separated by a
newline, or with --nul by NUL, as git diff --name-only -z writes them; a last empty entry is
dropped, and a list given and empty means nothing changed. At most 16 MiB of a file are read, and
at most 100,000 paths. A file that is not there, or is no regular file, is E_INVALID_ARG with
details.reason changed_from. A path is a repository path: /-separated, relative, with no
empty, . or .. component and no control character. With neither flag the changes are not
known.
A rename is two changed paths, the old name (gone) and the new one. List both: a list that
holds only the new name can make a check whose input moved away read not_applicable, since
nothing it reads is among the paths. git diff --name-only --no-renames writes both.
The rules#
The first rule that holds decides each check:
| Rule | State | Reason |
|---|---|---|
| The check's definition, or its stages, are not those of the check of its name in the target's file | run | definition_changed |
The plan is widened (below), or a check it needs is no check of the file, or not of the stage asked | run | widened |
The check declares no inputs, and a path changed | run | whole_tree |
The check declares no inputs, and no path changed | not_applicable | no_input_changed |
A changed path matches one of the check's inputs | run | input_changed |
| No changed path matches | not_applicable | no_input_changed |
Then, whatever the rule: a check that is not_applicable and that a check that runs needs, directly
or through the checks between, is run, with the reason needed and needed_by the first by name
of the checks that run and need it directly. Nothing waits for a result that will not come: a
check run for what it declares finds the checks it needs in the plan, run for it. A need that
is no check of the file, or not of the stage asked, is no error in a plan: the check that names
it is run, widened, and the need is not listed. check run refuses the same file, as
E_CHECK_FILE with reason need.
A plan never resolves a pattern against the tree: it matches each changed path against the
patterns, which are read as check list gives them. An added, modified, deleted
or merged path matches alike. Each check comes with its definition digest and its stages, as
check list gives them. --stage keeps the checks of one stage, and leaves out the others
rather than marking them; --check NAME, repeatable, keeps the named checks, each of the stage,
and the checks they need, transitively, as check run selects them.
A name the file does not define is E_INVALID_ARG with details.reason check, one not of the
stage stage. checks is empty only when the file defines no check, or none of the stage.
A definition that changed#
A plan compares each check with the one the target's file defines under its name, at the target's
head (onto). The check runs, definition_changed, whatever its inputs say, when the target's
file defines no check of that name, when the digest of its definition differs (which covers the
command, the directory, the timeout, the reports and the inputs), or when its stages differ: with
--stage, the stage asked is not among the target's stages for that check, and without it the two
stage sets are not equal. So a change that narrows a check's own inputs, so that nothing it
changes matches them, still runs that check, a check moved into the stage runs there, and a
renamed check runs under its new name. When the target's file does not read, every check is a
changed definition.
removed lists, sorted, the checks the target's file defines (of the stage asked) that the tree
planned for does not: a deleted check, a renamed check's old name, a check moved out of the stage.
A deleted check has none left to widen, so the list is what says it is gone. Where a file is read
from a changeset though its landed bytes are not known (a merged or conflicting change, a list of
paths cut), removed can name a check the target added since the change's base: it over-reports,
never under-reports, and the same change rebased onto the target gives the exact list.
The files are those of the tree the landing makes, each from where it comes from: the check file,
the legacy file and .swarmops itself are read from the target when the change does not list them,
from the head when it adds or modifies them, as absent when it deletes them. A head behind the
target that changes only workspaces.json is planned with the target's check file, and a head and
the same head rebased onto the target, landing one tree, get one plan. A check file that both the
change and the target changed merges into bytes no changeset holds: the head's file is read, and
the plan is widened (definitions_merged). In the workspace form an edited definition file is read from the
workspace's directory, unless the target changed it since the workspace's base, which would
merge: then it is widened the same way, as is an edit of .swarmops itself. In the directory
form there is no target tree, so a changed path of .swarmops, .swarmops/checks.toml or
.swarmops/workspaces.json makes every check definition_changed.
Failing closed#
What a plan cannot read or tell makes the checks run, never skip, and the plan says why in
widened_by. When several apply it names the first of this order.
widened_by | When |
|---|---|
conflict | The change conflicts with the target: nothing says what it would land. |
definitions_merged | A check file the change and the target both changed would merge into bytes no changeset holds, or the same holds of a workspace's edit of it. |
changes_unknown | The directory form was given no changed paths. |
changes_truncated | The land check lists more than 1,000 paths (the check file is then read from the target for a path before the last one it lists, and from the head after it), the plan reads more than 100,000, or a file of paths is cut at 16 MiB. |
path_unreadable | An entry is no repository path, holds a control character, is not UTF-8, or, in a list of lines, starts with a quote, as git quotes a path it cannot print: use -z. The entry is left out of the list. |
edits_outside | A sparse workspace holds edits off its prefixes, which no path names. |
A widened plan can differ from the plan of the same tree that is not widened, and then it names
every check run.
A file that does not read is an error and never an empty plan: the check file of the tree is
E_CHECK_FILE, a head or target not found is the store's error, and a --dir that is no
directory is E_INVALID_ARG with details.reason dir. checks is [] only when the file
defines no check of the stage.
The MCP tool#
swarmops mcp serves the store form as the tool check_plan, whose arguments are CheckPlanReq
(head, base, target, idempotency_key, stage, checks) and whose result is the
command's. There is no workspace or directory form there.
Return information#
result is a CheckPlanResp (swarmops schema CheckPlanResp prints its JSON Schema).
| Field | Type | Required | Description |
|---|---|---|---|
changed | integer or null | no | How many changed paths the plan read. Omitted when they are not known. |
checks | array of CheckPlanCheckOut | yes | The checks, sorted by name, bytewise; empty when the file defines none (of stage). |
file | string or null | no | The file the checks came from, as check list names it. Omitted when the tree holds no check file. |
head | string or null | no | The change's head, a full id. Omitted for a directory. |
onto | string or null | no | The target's head the plan was made on, a full id: a land with expect_target set to it lands the tree planned for, or nothing. Omitted for a directory. |
outcome | ItemOutcome or null | no | What landing the change would come to, as land_check says it. Omitted for a directory. |
removed | array of string | no | The checks the target's file defines (of stage) that the tree planned for does not: a deleted check, a renamed check's old name, a check moved out of the stage. Sorted by name. Omitted when there are none. |
stage | CheckStage or null | no | The stage asked for: checks holds only the checks of it. Omitted when every check is planned. |
target | string or null | no | The ref the change would land on. Omitted for a directory. |
tree | string or null | no | The root tree the plan is for: 64 hex digits. Omitted for a directory, for a workspace holding edits, and for a change that conflicts. |
version | integer or null | no | The check file's version, 1. Omitted unless file is .swarmops/checks.toml. |
vouched | boolean | yes | Whether only the caller stands behind what the plan read: true for a directory the caller named, and for a workspace holding edits that no changeset records; false for a change in the store, whose files are those of tree. |
widened_by | CheckPlanWidened or null | no | Why the whole plan widened every check to run, when it could not tell what changed or what the files at the target are. When several causes apply, the first of conflict, definitions_merged, changes_unknown, changes_truncated, path_unreadable and edits_outside. Omitted when the plan was not widened as a whole. |
workspace | string or null | no | The workspace the plan is of, in the workspace form. |
Envelope op: check_plan.
Exit codes:
0: Success.1: The operation failed.2: The request or the command line is malformed.
Errors#
- E_INVALID_ARG (exit 2): A malformed argument or request, including a command-line usage error.
- E_CHECK_FILE (exit 1): A check file does not read, or cannot work:
.swarmops/checks.toml(or, in a tree without one,.swarmops/workspaces.json) is too large, not text, not a file, not TOML (JSON), not version 1, holds a key, a name or a value version 1 does not take, has checks that need one another in a circle (details.cycle), or is one whose need a run cannot satisfy (details.check,details.need,details.stage):details.file,details.reason,details.vouched, anddetails.lineanddetails.keywhen known.
Any command that opens a store may also fail with a store error, such as E_NOT_A_REPO, E_IO or E_STORE_CORRUPT; a command line the grammar refuses is E_INVALID_ARG (exit 2).