SwarmOps
ReferenceCommandsswarmops check run

Page kind: Reference

swarmops check run#

Describes stable at 47a431aa, ; latest release v0.13.0what changedLast changed View as Markdown

Run the checks of one stage of a clean workspace, or of a directory with --dir.

Runs the checks of STAGE (default before-land) that .swarmops/checks.toml names, or the one check default of .swarmops/workspaces.json's check.argv, or only the NAMEs given (each of the stage), one at a time, each after the checks it needs (needs) and otherwise in name order: each with no shell and no stdin, in its own process group, under its timeout_s, in its dir. A named check brings the checks it needs, and a need that is no check of the stage refuses the run (E_CHECK_FILE). Every selected check runs, whatever an earlier one did, except a check whose need did not pass: it is skipped (and says which need), unless it says always. One envelope names each outcome: passed, failed, timed_out, not_started, cancelled, not_run or skipped. A run where any check did not pass is E_CHECK_FAILED, its details.run the whole result. A check gets the SWARMOPS_CHECK_* variables, HOME, LANG, LC_ALL, LC_CTYPE, LOGNAME, PATH, TMPDIR, TZ and USER of your environment, and the variables --pass names; nothing else (the check default keeps your whole environment). Its output goes to a log with a time on every line, which check log reads. Once it has ended, the findings it wrote as JSON lines to SWARMOPS_CHECK_REPORT, and those of the JUnit and SARIF reports its definition declares that this run wrote, come with its outcome, at most 10,000 a run, the rest counted; they change no outcome.

The workspace form (--ws, --ws-path, else the workspace around the working directory) needs a clean workspace: no edits, not rebasing, not stale. It reads the check file from the store at the changeset the files stand for, holds the workspace's lock while the checks run, and never writes the store; its runs are kept in .swarmws/check-runs/. --dir DIR runs the checks of the files below DIR as they are, opens no store, and says vouched: its runs are kept below SWARMOPS_CHECK_RUNS_DIR, else the state directory's swarmops/check-runs; the newest 20 of each are kept. SIGINT, SIGTERM and SIGHUP kill the running check's process group and end the run. No identity.

A check that names a group (group in its table: name, scope host, wait_s) takes the group's lock on this host before it starts, waits for another run's hold on it up to wait_s seconds (default 900, at most 86,400; 0 tries once), and holds it until the check has ended and its process group is gone: the check's processes hold it too, so a runner that is killed leaves the group held while the check lives. The lock is the file NAME.lock in DIR, DIR being --group-locks, else SWARMOPS_CHECK_GROUP_LOCKS_DIR (absolute; a directory the host's operator makes, never a default, so that accounts share one); a run with a check that names a group and no such directory is E_INVALID_ARG (group_locks_dir) before anything starts. A check whose wait ran out is not_started with the reason group: no process and no log, and the run goes on with the next check. A check whose dir is missing waits for nothing. In a workspace the wait is inside the workspace's lock, which a signal ends.

--shadow runs every check as it would be run and makes a plan of the change first, as check plan does, so that misses can be counted before a plan is ever honoured: nothing is skipped because of it, and no outcome and no exit status changes. Each check's result and run line say what the plan said of it (plan, plan_reason), the answer's would_skip names the checks the plan would have skipped in run order and misses those of them that failed, timed out, or could not start for their program or their directory; a held group, a full disk, a stop and a failed need are no misses. A workspace plans the change its chain makes and its edits; --dir DIR takes the changed paths from --changed PATH and --changed-from FILE (- is stdin; --nul for NUL-separated entries), which need --shadow, and with none given the plan is widened and every check is run. A plan that cannot be made, or a file of paths that cannot be read, stops no check: it is in the answer's plan_error and on stderr, and every check is run (plan_reason widened). A plan that knows the changed paths writes them, sorted, to the file changed in the run's directory, and each check's SWARMOPS_CHECK_CHANGED names it; otherwise the variable is empty and a check takes the whole tree as changed.

Each check the run reaches appends one run line, a JSON object of diagnostics (its name, run, stage, tree, wait, duration, outcome and, on Linux, sampled peak memory), to run-lines.jsonl in the directory --run-lines names, else SWARMOPS_CHECK_RUN_LINES_DIR, else beside the runs kept; nothing decides from it, and a line that cannot be written is a warning on stderr.

Metadata
Group
checks
Since
0.13.0
Mutates
yes
Identity required
no
MCP tool
check_run
Envelope op
check_run
Exit codes
01

Syntax#

Syntax
swarmops check run [OPTIONS] [NAME]...

Required arguments#

None.

Optional arguments#

The command also takes the global options.

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>.

Run the checks of the files below DIR on this host, as they are.

Syntax: --stage <STAGE>. Default: before-land.

The stage whose checks to run. 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: --pass <NAME>....

A variable of your environment the checks also get; repeatable.

Syntax: --run-lines <DIR>.

Append the run lines to run-lines.jsonl in DIR, not beside the runs.

Syntax: --group-locks <DIR>.

Take the locks of the checks' groups in DIR, which the host's operator makes.

Syntax: --shadow.

Run every check as usual and record beside each what a plan of the change says.

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.

Syntax: <NAME>.

Only these checks, each of the stage.

Examples#

Shell
HOME=[tmp]/home LANG=C LC_ALL=C LC_CTYPE=C LOGNAME=agent PATH=/usr/bin:/bin SWARMOPS_CHECK_RUNS_DIR=[tmp]/runs TMPDIR=[tmp] TZ=UTC USER=agent swarmops check run --dir [tmp]/tree found ok
Output
{ "ok": true, "op": "check_run", "api": 1, "result": { "vouched": true, "run": "[run2]", "stage": "before-land",
Show 70 more lines "file": ".swarmops/checks.toml", "version": 1, "dir": "[tmp]/runs/[dir_key]/[run2]", "inherited_env": [ "HOME", "LANG", "LC_ALL", "LC_CTYPE", "LOGNAME", "PATH", "TMPDIR", "TZ", "USER" ], "inherited_all": false, "cancelled": false, "failed": [], "duration_ms": "[duration_ms]", "checks": [ { "name": "found", "outcome": "passed", "definition_digest": "[id2]", "timeout_s": 900, "duration_ms": "[duration_ms]", "exit_code": 0, "log": "[tmp]/runs/[dir_key]/[run2]/logs/found.log", "findings": [ { "level": "error", "title": "unused import", "path": "src/lib.rs", "line": 3, "end_line": 4, "message": "remove it", "report": 0 }, { "level": "notice", "title": "no tests changed", "report": 0 } ], "findings_total": 2, "reports": [ { "format": "findings", "path": "[tmp]/runs/[dir_key]/[run2]/checks/found/report.jsonl", "state": "read", "findings": 2 } ] }, { "name": "ok", "outcome": "passed", "definition_digest": "[id3]", "timeout_s": 900, "duration_ms": "[duration_ms]", "exit_code": 0, "log": "[tmp]/runs/[dir_key]/[run2]/logs/ok.log" } ] }, "meta": { "elapsed_ms": "[elapsed_ms]", "resolved": {}, "auth": "trust" } }

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 run runs the checks of one stage that a tree's .swarmops/checks.toml names, one at a time, and answers one envelope naming every check's outcome. It is how this repository's maintainers and agents start the gate before a push: so check run --dir . --stage before-land. The gate guides: the directory form is vouched for by the caller alone, and nothing records its answer yet.

Two forms#

  • In a workspace, check run [NAME…] with --ws NAME, --ws-path DIR, or the workspace around the working directory. The workspace must be clean: no edits on disk (E_WS_DIRTY, with the first 20 paths), not rebasing (E_UNRESOLVED_CONFLICTS), its base still on its target (E_WS_STALE). Its lock is taken (E_WS_LOCKED after a 5 s wait, retryable) and held until the run ends, so no ws command moves the files under a running check: a check that runs one gets E_WS_LOCKED. The check file is read from the store at the changeset the files stand for, never from the files on disk, and the result names that changeset and its root tree, the tree every check ran on; vouched is false. The store is only read: no writer lock is taken, and a check may write to the store itself. The runs are kept in the workspace's .swarmws/check-runs/.
  • In a directory, check run [NAME…] --dir DIR: the checks of the files below DIR on this host, as they are, read as check list --dir reads them. It opens no store, so --repo, SWARMOPS_REPO and --as are not used, and the envelope has no meta.repo. The result says vouched: true and names no tree. The runs are kept below SWARMOPS_CHECK_RUNS_DIR (an absolute directory), else below the state directory's swarmops/check-runs ($XDG_STATE_HOME, ~/.local/state or ~/Library/Application Support), in a directory keyed by DIR's canonical path, whose file dir names it. Nothing is written into DIR. Two runs of one directory at once are not kept apart.

What runs#

The checks whose stages hold --stage (default before-land), or of them only the NAMEs given and, transitively, the checks they need, each run once, each after the checks it needs and otherwise in name order (of the checks whose needs have all run, the first by name runs next; a file without needs runs in name order). A name the file does not define is E_INVALID_ARG with details.reason: check; a name not of the stage, details.reason: stage with the check's stages; a stage with no check, or a tree with no check file and no check.argv, no_checks: nothing runs then, so a gate that would run nothing fails. A file that does not read is E_CHECK_FILE, as check list gives it. So is a file that reads but whose needs a run cannot satisfy: a need of a selected check that the file does not define, or that is not of the stage run, refuses the run before anything starts, with details.reason: need, details.check and details.need, details.stage, details.key (check.<name>.needs) and details.line (the check's table); the first check by name is named, with its first such need. check lint lists every such fault of a file without running it. A check not selected is not judged.

Each check runs its argv with no shell and no stdin, in its dir below the root, in a process group of its own, for at most its timeout_s; past it, the whole group is killed. However the check ends, its group is killed once its output ends, or a second after it exits if a process it left still holds the output: nothing it left running in its group outlives it. A check that fails does not stop the run: every selected check runs, except one that needs a check that did not pass (below). Outcomes:

OutcomeWhen
passedIt exited 0.
failedIt exited with another code (exit_code), or a signal the runner did not send ended it (signal), or its log could not be written whole (a full disk, say): then message says why, whatever it exited with.
timed_outIt ran past timeout_s; its process group was killed.
not_startedIts dir is not a directory here (not_started: dir, as a sparse workspace may lack it), its program did not start (not_started: program, with the host's message), its log or its own directory could not be made (not_started: log, with the host's message), or its group stayed held for the whole of its wait (not_started: group, with no log; see exclusive groups below).
cancelledA signal stopped the run while it ran; its process group was killed.
not_runThe run was stopped before it started: no process, no log.
skippedA check it needs did not pass (or was skipped itself), and it does not say always: it was not started, so it has no process, no log and no run line; need names the first by name of the needs that did not pass.

Only passed passes: a skipped check did not pass, so it is in failed, and the run is E_CHECK_FAILED; it does not set cancelled. Every check passed: the result, exit 0. Otherwise E_CHECK_FAILED, exit 1, whose message names each check that did not pass and why, with the count of its findings when it has any (check failed (exit 101, 2 findings)), whose details.run is the whole result below, and whose hint names, for the first, where its findings are (details.run.checks[<i>].findings) when it has any, then check log: that check's, or, when two or more checks did not pass, check log --failed --run RUN, which reads the logs of all of them. A check that did not pass carries the last 8 KiB of each of its streams (stdout_tail, stderr_tail); one that passed does not.

Findings#

A check reports findings by writing them to its report file, the path SWARMOPS_CHECK_REPORT names (in its own directory of the run, never in the tree; not made, so a check that has nothing to report writes nothing). Once the check has ended and its process group is gone, the file is read, and its findings come with its outcome: findings, findings_total and, in reports, the file as it was read. It is read for passed, failed and timed_out; not for cancelled, whose file a stop left partial. Findings change no outcome: a check that exits 0 passes whatever it reports, and one that fails with none still fails.

The file is UTF-8, one JSON object a line, each line ended by \n (a \r before it is dropped, and the last line needs none):

JSON
{"level":"error","title":"unused variable `x`","path":"crates/app/src/lib.rs","line":12,"end_line":14,"message":"remove it, or start its name with _"}
KeyTypeRequiredRule
levelstringyeserror, warning or notice.
titlestringyesNot empty once trimmed. One line: a line break in it becomes a space. Cut to 200 bytes at a character's end, with ….
messagestringnoCut to 4 KiB at a character's end, with …; line breaks kept. Left out when empty.
pathstringnoA repository path from the tree's root (the directory, in the directory form): no leading /, no . or .., at most 4 KiB.
lineintegerno1 to 2^32; only with path.
end_lineintegernoFrom line to 2^32; only with line.

A line of spaces and tabs alone is skipped. Any other line that is not a finding (not JSON, not an object, a key not in the table, a missing level or title, a value of the wrong type or outside its rule, more than 64 KiB, bytes that are not UTF-8) is skipped and counted in the report's invalid_lines, and the report's message names the first one and why (line 3: unknown key "lvl"). A file past 64 MiB is read to that bound, its last partial line left out, and its report says cut. A report file that is a symbolic link, a FIFO or anything but a regular file is refused with fault: not_a_file, and nothing behind it is read; one that cannot be read is refused with fault: io. A report that is not read is never the run's error.

A run returns at most 10,000 findings and 4 MiB of their text (titles, groups, messages and paths together), in run order: the checks in the order they ran, each check's in the order its report gave them. From the finding that would pass either bound on, no finding of the run is returned, but every one is counted: in its check's findings_total, its report's findings, and the run's findings_omitted. The 10,001st finding of a run is counted and not returned. Each finding's report is the index of its report in its check's reports.

Reports a check declares#

A check may also declare, with its reports key in .swarmops/checks.toml (check list), the JUnit and SARIF files its tools leave in its tree. After the check (for passed, failed and timed_out, as the report file), each is looked for at its path below the check's dir, in declared order, after the report file, and read into findings:

FormatA finding forLevelTitleGroupMessagePath and lines
juniteach testcase with a failure or error childerrorits nameits classname, else the nearest testsuite's namethe first failure's message and text, then the end of the case's system-err, within 4 KiBits file and line attributes, when it has them
sarifeach result whose kind is fail or not givenerror, warning, note and none as error, warning, notice, notice; no level is warningits ruleId, else its message's first lineits run's tool.driver.namemessage.text, within 4 KiBits first location: artifactLocation.uri (a relative reference, percent-decoded, or a file: URI below the check's directory) and region's startLine and endLine

A path is the report's, relative to the check's dir, joined to it to make a repository path from the tree's root; one that is not a repository path then (absolute, .., another directory) is left out, and the finding kept. A JUnit report's reports entry counts its cases (tests), those that failed (failed, each a finding) and those skipped (skipped), as read, never as the suites' own attributes say; a SARIF report's counts its results, of every kind.

Only a report this run wrote is read. Each declared path is looked at just before the check starts, nothing read; after it, a report whose file is the same and unchanged (device, inode, size, modification and status change times), or whose modification time is more than a second before the check's start (a copy that kept an old time, say), is stale, and not read. check run writes nothing in the tree it checks: a stale report is left where it is.

A report is opened from the check's directory one component at a time, never through a symbolic link: a link anywhere below that directory, a directory, a FIFO or anything but a regular file is refused with fault: not_a_file, and what it names is never read. Each report's state:

StateWhen
readRead: its findings, and its counts.
missingNot there after the check.
staleThere, but not written by this run.
refusedThere, and not read as its format: fault and a one-line message say why.
FaultWhen
too_largePast 64 MiB: nothing of it is read.
not_a_fileA symbolic link at any component, a directory, a FIFO or another kind of entry.
not_textNot UTF-8: a UTF-16 byte order mark, or an XML declaration of another encoding, included.
syntaxNot XML or not JSON, cut short, or an entity reference other than XML's five.
doctypeAn XML document type declaration, which could define entities: refused before anything is read.
too_deepXML elements, or JSON arrays and objects, nested past 64.
shapeWell formed, but not the format: an XML root other than testsuites or testsuite; a SARIF log not of version 2.1.0, without runs, or with a value of the wrong type.
ioIt could not be read: the host's words in message.

Nothing in a report is run, opened or followed: its paths are strings. Each report is read whole, one at a time, at most 64 MiB of it, and of its findings at most as many as the run can still return are kept. The JUnit and SARIF mappings may read more of a report in a later release; the report file's format is the one this release fixes.

Exclusive groups#

A check that names a group ({ name, scope = "host", wait_s } in its table) runs only while no other check of that group runs on this host. Before the check starts, check run takes the group's lock; it holds it until the check has ended, its process group is gone and its run line is appended, and then lets it go, so a lock is never held while nothing of the run runs. The lock is the kernel's advisory lock (flock) on the file <name>.lock in a directory the operator names: --group-locks DIR, else the absolute directory SWARMOPS_CHECK_GROUP_LOCKS_DIR names. The directory has no default and the run never makes it, so that every account that is given the same directory shares one lock per group: a default below one account's state directory would let two accounts each hold "the host's" group at once. The run makes a lock file that is missing, with mode 0644 whatever its umask, never writes to it, and opens it to read, without following a link; a lock file that is no regular file, or cannot be opened or made, is E_IO with details.path. Because the lock is the file's, a flock(1) on the same file excludes with it.

Both are checked before any check starts, and only when a selected check names a group: a run with none named, a directory that is not absolute, or one that is no directory, is E_INVALID_ARG with details.reason: group_locks_dir, details.group the first group that needs it, and a hint naming the flag and the variable. Checks that name no group ask for neither.

The wait comes after the check's needs have been judged (a check that will be skipped waits for nothing) and before its reports are looked at, so that a report another run wrote while this one waited is not read as this run's. It is one try of the lock; while another holds it, a pause of 250 ms and another try, at most wait_s times 4 pauses. The bound is counted in pauses and not read from a clock. A stop (a signal) is looked at before each pause: the run ends there, this check and the later ones not_run, no line. A check whose directory is missing waits for nothing: it is not_started: dir at once.

  • Taken: the check runs; its result, its log's start line and its run line say the group and group_wait_ms, the pauses waited times 250. The check's wait_ms includes that wait.
  • Bound over: the check is not_started with the reason group, a message such as "the group heavy stayed held for 3600 s", group_wait_ms the whole bound and no log; the run goes on with the next check and ends E_CHECK_FAILED.

An order among waiters is not promised: a waiter blocked in flock(1) is served before one that polls. In the workspace form the wait is inside the workspace's lock, which is held for the check's run anyway, up to 24 hours: every other change to that workspace is E_WS_LOCKED while it lasts, and so is an MCP call that waits; the bound is not lowered there, and a signal ends the wait.

The check's processes hold the lock too. The check, and whatever it starts, inherit an open descriptor on the lock file that shares the runner's open file description, so a runner that is killed (SIGKILL, out of memory) leaves the group held for as long as any process that inherited the descriptor lives, as exec 9<heavy.lock; flock 9; just bench does. While the runner lives, it lets the lock go itself once the check's group is killed and its line appended, whoever still has the descriptor open: a process the check left behind on purpose does not hold the group. The check sees one more open descriptor, whose number is not promised.

Shadow selection#

--shadow runs every check of the stage as a run without it does, and records what a plan of the change would have done to each, so that the plan's misses can be counted before one is ever honoured. Nothing is skipped because of a plan: no outcome, no exit status and no check that starts changes. Without --shadow check run makes no plan and its answer, its record and its lines carry none of the keys below.

The plan is made once, after the checks are selected and before the first starts, as check plan makes it for the same change and stage: in the workspace form for the change the workspace's chain makes and the edits in its files (under the workspace's lock, which the planner does not take); in the directory form for the changed paths --changed PATH (repeatable) and --changed-from FILE (- is standard input; --nul for NUL-separated entries) give, which are refused without --shadow (E_INVALID_ARG, details.reason: shadow). A directory form with none given has no list of paths, so its plan is widened and every check is run, widened.

A plan never stops a run. A plan that cannot be made (a target that does not resolve, a file that reads at one tree and not at the other) and a --changed-from file that cannot be read are recorded and the checks run: every check gets plan: run, plan_reason: widened; the answer gets plan_error with the error's code and one line of its message; stderr gets one line, warning: shadow plan: …. Only the errors check run has without --shadow, and the two argument errors above, refuse a run before it starts.

What is recorded:

  • Each check of the result has plan (run or not_applicable) and plan_reason (the plan's reason, as check plan words it).
  • The answer has shadow: true, would_skip (the checks the plan marked not_applicable, in run order, whatever became of them: a check skipped or not_run is among them), misses (those of them that showed the plan wrong) and plan_error, each omitted when empty or false. They are in details.run of an E_CHECK_FAILED too.
  • Each run line has shadow: true, plan and plan_reason, and, for every line of a check that did not start, shadow or not, not_started, the reason's word.
  • The run's directory has changed when the plan knows the changed paths: one path a line, \n ended, sorted bytewise, written once before the first check, which every check's SWARMOPS_CHECK_CHANGED names. When it does not (the list is unknown, unreadable or truncated, or the plan failed) there is no file and the variable is empty.

A miss. A check the plan marked not_applicable counts as:

It endedCounted as
passeda would-be skip
failed, timed_outa would-be skip and a miss
not_started, reason program or dira would-be skip and a miss
not_started, reason group, log or one this build does not knowa would-be skip
cancelleda would-be skip
skipped, not_runa would-be skip in the answer; no line

A held host lock, a full disk, a stop and a need that failed say nothing about whether the plan was right, so none counts as a miss. A plan word other than not_applicable is neither. A sparse workspace that lacks a check's directory counts a miss it did not earn: the count that matters is that of the gate's own runs, which are not sparse. check runs --selection counts the same on the lines.

Signals#

SIGINT, SIGTERM and SIGHUP stop the run: the running check's process group is killed, that check is cancelled, the checks after it are not_run, and the answer is E_CHECK_FAILED with details.run.cancelled: true. A signal once the last check has exited stops nothing but what that check left in its group: the run ends as its checks did. A second signal changes nothing. A process that left its check's group, and a check left running when swarmops itself is killed with SIGKILL, are not stopped.

The environment#

A check of .swarmops/checks.toml gets these variables, and of the caller's environment only HOME, LANG, LC_ALL, LC_CTYPE, LOGNAME, PATH, TMPDIR, TZ and USER, each when it is set, and each --pass NAME that is set; nothing else. inherited_env lists the names given, never their values.

VariableValue
SWARMOPS_CHECK_NAMEThe check's name.
SWARMOPS_CHECK_STAGEThe stage run.
SWARMOPS_CHECK_TREEThe tree's 64 hex digits in a workspace; empty in the directory form.
SWARMOPS_CHECK_ATTEMPT1.
SWARMOPS_CHECK_RUNThe run's id.
SWARMOPS_CHECK_REPORTThe path of the check's report file of findings, JSON lines, not made; read after the check ends (see "Findings").
SWARMOPS_CHECK_OUTPUTSA path for the check's outputs, not made; nothing reads it yet (M31-6).
SWARMOPS_CHECK_SUMMARYA path for the check's summary, not made; nothing reads it yet (M31-18).
SWARMOPS_CHECK_ARTIFACTSA directory for the check's artifacts, made empty; nothing reads it yet (M36-3).
SWARMOPS_CHECK_CHANGEDIn a shadow run (see Shadow selection) whose plan knows the changed paths, the path of the run's changed file: one path a line, sorted bytewise; otherwise empty, and a check takes the whole tree as changed. A run without --shadow makes no plan, so the variable is empty.
SWARMOPS_WSThe workspace's name, in the workspace form.

A --pass name is 1 to 128 bytes of [A-Za-z_][A-Za-z0-9_]*, not a SWARMOPS_CHECK_ name nor SWARMOPS_WS, at most 64 of them; another is E_INVALID_ARG with details.reason: pass. The one check default of .swarmops/workspaces.json keeps the caller's whole environment, as ws land --check gives it, with these variables set over it; inherited_all says so.

The run and its logs#

A run's dir holds run.json (its state, running then ended, and the result, the checks' findings in it once they have ended), lock (held while it runs), logs/<check>.log and checks/<check>/, the paths the environment names. Each directory a run makes, the runs root and a directory's key directory among them, is its owner's alone (mode 0700), as a workspace's .swarmws/ is: a log holds whatever its check printed, secrets among them.

Each log holds both streams, a time on every line, and the sections a check opens; check log reads one, and its page has the format. The newest 20 runs of a directory or a workspace are kept, and a run whose lock is held, or cannot be tried, is never removed. A run of --dir also removes the runs of each other directory that is gone (the dir file below their key names a path that is not there), unless one of them is running: the runs root does not grow with every throwaway directory checked. Nothing there is synced: the logs and records are diagnostics, which nothing decides from. A log that cannot be written is its check's outcome, and the run goes on; only a record that cannot be written makes the run E_IO, with the outcomes so far in details.run and a hint naming the run's directory.

duration_ms is the run's, from its first check's start to its last's end, and each check's its own; neither is a measured figure of any check.

Run lines#

Each check a run reaches appends one run line to a diagnostics file on the host that ran it: one JSON object a line, at most 4 KiB, ended by \n. A check that ended passed, failed, timed_out, cancelled or not_started leaves one, the check default of .swarmops/workspaces.json as any other; a check the run never reached (not_run) or skipped (skipped) leaves none. The line is appended once the check's process group is gone and its findings are read, before the next check starts, so a runner that dies in a run has left the lines of the checks that ended. A run of three checks adds three lines.

KeyTypePresentMeaning
atintegeralwaysWhen the check started (for not_started: when it was tried), in Unix milliseconds on the host that ran it: the started_at_ms of its log's start line.
runstringalwaysThe run's id.
checkstringalwaysThe check's name.
attemptintegeralways1, as SWARMOPS_CHECK_ATTEMPT.
stagestringalwaysThe stage run.
treestringin a workspaceThe tree's 64 hex digits; the directory form knows no tree.
vouchedboolalwaystrue in the directory form.
workspacestringin a workspaceThe workspace's name.
definition_digeststringalwaysAs check list gives it (provisional).
wait_msintegeralwaysThe milliseconds from the run's start to the check's start: with one check at a time, the time the checks before it took, and the wait for its group.
groupstringwhen the check names oneThe group's name.
group_wait_msintegerwith groupThe milliseconds it waited for the group: a whole number of 250 ms pauses; 0 when the group was free.
duration_msintegeralwaysThe check's, as in the result; 0 for not_started.
outcomestringalwaysAs in the result; never not_run or skipped.
not_startedstringfor a check that did not startThe reason's word: dir, program, log, group, or one a later release adds.
shadowboolin a shadow runtrue.
planstringin a shadow runWhat the plan said: run, not_applicable, or a word a later release adds.
plan_reasonstringwith planThe plan's reason: a word of check plan's, or one a later release adds.
exit_codeintegerwhen it exited
findingsintegerwhen not 0The check's findings_total.
labelsarray of stringswhen not emptyThe runner labels the check requires: none yet.
peak_rss_kibintegeron Linux, when a sample saw the checkSee below.
run_dirstringwhen at most 1,024 bytesThe run's directory, absolute: where its run.json and logs are while the host keeps the run.

swarmops schema CheckRunLine prints the type. A later release adds keys; none is removed or changes its meaning, and a reader ignores a key it does not know.

Where they go. To run-lines.jsonl in:

  1. the directory --run-lines DIR names (relative to the working directory);
  2. else the directory SWARMOPS_CHECK_RUN_LINES_DIR names, which must be absolute: another value is E_INVALID_ARG with details.reason: run_lines_dir, before anything runs;
  3. else the form's own place: the workspace's .swarmws/check-runs/, or the directory's key directory below the runs root, beside its kept runs.

A named directory that is not there is made, one level, its owner's alone (mode 0700); one that is there is used as it is and never changed, so that an operator may share it between accounts with the mode it chooses. The runs kept (the newest 20) are removed without the lines; the lines beside a directory's runs go with them when that directory is gone.

Rotation. The append that takes run-lines.jsonl past 64 MiB renames it to run-lines.1.jsonl, replacing the one older file, under run-lines.lock; the next line starts a new file. At most 128 MiB of lines are kept in a directory.

Diagnostics. The file is not synced, and nothing decides from it: no gate, no land, no answer of check run. A line that cannot be appended (the directory not writable, the disk full, something there that is no directory) writes warning: run lines: … to stderr, once a run, and nothing more is tried in that run: every outcome, the envelope, the exit code and run.json are what they would have been.

Peak memory. peak_rss_kib is a sample, on Linux: once 100 ms after the check starts and then once a second, the resident memory (VmRSS) of every process in the check's process group is summed from /proc, and the largest sum is kept. It is not the kernel's high-water mark: a spike between two samples is missed, pages two of the group's processes share are counted for each, and a process that left the check's group is not counted. A check over within 100 ms has none, and neither has a check on a host that is not Linux. The cost of a sample, one pass over /proc, is not measured.

The MCP tool#

swarmops mcp serves the workspace form as the tool check_run, whose arguments are CheckRunReq (workspace, stage, checks), and whose result carries each check's findings as the command's does: there is no directory form there, and no --pass, since the server's environment is not the agent's to hand out; a check gets the fixed list of the server's variables. A call holds the server until the run ends, each check bounded by its timeout. The directory of the group locks is the one the server's SWARMOPS_CHECK_GROUP_LOCKS_DIR names (there is no --group-locks), and a run with a check that names a group and no such directory is E_INVALID_ARG; a check that waits for its group holds the call, and the workspace's lock, for up to its wait_s. SIGINT, SIGTERM or SIGHUP to the server stops the run as it stops check run: the call is answered, and then the server exits. A check that did not pass makes the call's result an error, E_CHECK_FAILED, with every outcome in details.run. Its checks leave run lines as the command's do: in the directory the server's SWARMOPS_CHECK_RUN_LINES_DIR names, else in the workspace's .swarmws/check-runs/.

Return information#

result is a CheckRunResp (swarmops schema CheckRunResp prints its JSON Schema).

FieldTypeRequiredDescription
cancelledbooleanyesWhether a signal stopped the run before its checks ended: the check running then is cancelled, those after it not_run. A signal once the last check has exited stops nothing: the run ends as its checks did. A check skipped for a need that did not pass does not set it.
changesetstring or nullnoThe changeset the workspace's files stood for. Omitted in the directory form.
checksarray of CheckRunOutyesOne per selected check, in the order they ran: each after the checks it needs, and otherwise by name.
dirstringyesThe run's directory on the host it ran on, absolute: run.json, the logs and each check's own directory.
duration_msintegeryesThe run's milliseconds, from its first check's start to its last's end.
failedarray of stringyesThe checks that did not pass, in run order; empty when every one passed. A skipped check did not pass.
filestringyesThe file the checks came from: .swarmops/checks.toml, or .swarmops/workspaces.json for the one check default.
findings_omittedintegernoThe findings of the run that were counted and not returned: past the run's bound of 10,000 findings and 4 MiB of their text, every later finding is counted in its check's findings_total and here, and none is returned. Omitted when 0.
inherited_allbooleanyesWhether the checks got the caller's whole environment: only the check default of .swarmops/workspaces.json, which keeps what ws land --check gives it.
inherited_envarray of stringyesThe names of the caller's variables the checks got besides the pinned ones, sorted; no values. Empty when inherited_all.
missesarray of stringnoThose of would_skip that showed the plan wrong: a check that failed or timed_out, or did not start because its program or its directory is missing. A held group, a log that could not be written, a stop and a need that failed are none. Omitted when none.
plan_errorCheckPlanErrorOut or nullnoWhy a shadow run's plan could not be made: the error's code and one line. Every check then ran, run with the reason widened. Omitted when the plan was made.
runstringyesThe run's id: a UUID v7, so that runs sort by their start.
shadowbooleannoWhether the run was in shadow mode (check run --shadow): every check ran, and each records what the plan said of it. Omitted when false.
stageCheckStageyesThe stage run.
treestring or nullnoThat changeset's root tree, 64 hex digits: the tree every check ran on. Omitted in the directory form, which knows no tree.
versioninteger or nullnoThe check file's version, 1. Omitted unless file is .swarmops/checks.toml.
vouchedbooleanyesWhether only the caller stands behind the files the checks ran on: true in the directory form (check run --dir), which no gate accepts; false in a workspace, whose files were checked against tree first.
workspacestring or nullnoThe workspace's name. Omitted in the directory form.
would_skiparray of stringnoIn a shadow run, the checks the plan marked not_applicable, in run order, whatever became of them (a check skipped or not_run among them). Omitted when none.

Envelope op: check_run.

Exit codes:

  • 0: Success.
  • 1: The operation failed.

Errors#

  • E_CHECK_FAILED (exit 1): A check failed or ran past its time: ws land --check's or the bootstrap of ws create (details.stage: check or bootstrap; exit_code, timed_out, the tails of its output, log, changeset; nothing was landed), or one or more of check run's (details.run: the run's whole result, every check's outcome and each check's findings, or cancelled after a signal).

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).

See also#

On this page