Skip to content

assay mark --out <file> [--cross-file]

Writes the mark of the project, its state now, to a file, so that a later assay gate --scope changed --since <file> judges what changed since. It judges nothing.

assay mark --out <file> [--cross-file] [--color auto|always|never]

Take a mark by hand before a piece of work. The agent plugin takes one itself at session start, with --cross-file.

Option Effect
--out <file> Required. The file to write the mark to, by a path absolute or relative to the project root. The directories above it are created.
--cross-file Also run the cross-file and the project-file checks on the whole project, and keep the results that stand now in the mark.
--color auto|always|never The form of what is written for a person, as for every command.
assay mark --out .dart_tool/assay/mark.json # by hand, before a piece of work
assay mark --out .dart_tool/assay/mark.json --cross-file # also keep the cross-file results that stand now

A mark, then the gate on the change since it:

assay mark --out .dart_tool/assay/mark.json --cross-file # before the work
# ... edit, commit or not ...
assay gate --scope changed --since .dart_tool/assay/mark.json
assay gate --scope changed --base origin/main # in CI: the change since a commit

On success, one line on standard output: Wrote the mark of the project to `<file>`: followed by commit <sha>, no commit yet or no git repository, and with --cross-file how many whole-project results stand.

The mark is written whatever the configuration says, since it records the options files as they are. A configuration in error is told on standard error in one line and fails nothing; under it --cross-file finds no result, as no check runs. A baseline that cannot be read is told on standard error too, and the mark is written all the same.

Part What it is
The commit The commit checked out, or that there was none yet. Outside a repository, or where git cannot be run or ignores the project’s directory: that the project was in no repository.
The ignored Dart files The Dart files git ignores that assay’s engine would judge, so that a file hidden from git after the mark still counts as changed. In a repository only.
The ignored shipped files The files the app ships that secret_in_shipped_file reads and git ignores (a .env of a declared directory, for example; no image, no font, none larger than 1 MB), each with a digest of its content. One written or created after the mark counts as changed, although git does not name it. In a repository only.
The baseline The text of the baseline file; or that there was none; or that it could not be read.
The options files The text of the root options file and of every file it includes, each by its address; for a file that was not there, that there was none.
The cross-file results With --cross-file only: the fingerprints of the results of the cross-file and the project-file checks that stand now, found by one pass over the whole project. Without the flag the mark holds none, which is not the same as an empty set.

A session of the agent plugin keeps the same parts, taken by the same code.

One JSON object, written atomically: the whole text goes to a file beside the target, then is renamed into place.

The format is assay’s own: keep the file and hand its path back to assay; read nothing in it. It names itself (format: "assay-mark") and has a version (schema, now 2); a mark of another version is not read. A part that a later release adds keeps the version: an earlier release ignores the part, and a mark without it holds none of it. So a mark of an earlier release holds no ignored shipped files, and then no ignored file counts as changed. For the curious, it also holds the version of assay that wrote it, takenAt, repository, and the parts under parts.

Code When
0 The mark was written.
2 Usage error: no --out, an empty one, or an argument.
3 Could not run: git knows the project but does not say which files it ignores, or the file cannot be written.

Two options of gate --scope changed say what “changed” means without a session of an agent: --since <mark file> and --base <commit>. The verdict, the reports and the JSON result are those of any gate --scope changed. The full report is .dart_tool/assay/reports/gate-changed.txt.

--since <mark file> --base <commit>
Changed files What git says differs from the mark’s commit, committed since or not; untracked files git does not ignore; Dart files hidden by an ignore file after the mark; and ignored shipped files whose digest differs from the mark’s, or that the mark does not hold. What git says differs from the commit (any name git resolves: HEAD~1, a branch, a full SHA). No file git ignores counts.
New suppressions Against the files at the mark’s commit. Against the files at the commit.
Baseline before The mark’s baseline, so an uncommitted baseline present at the mark is not growth. The baseline file at the commit.
Configuration before The mark’s options files. The options files at the commit.
Cross-file results that stood Those of mark --cross-file. The message leaves them out; the full report and the result list them. Without them, none stood. None stood.

The path of the mark file is absolute or relative to the project root. In a pull request job, pass --base the merge-base, not the target branch: see The pull request job.

Usage errors (exit code 2):

  • --since and --base together; either without --scope changed.
  • A mark file that is missing, is not a mark, or is of another version of the format.
  • A mark taken where git had nothing to say about the project, without --changes: git cannot say what changed since, so a list of changes is needed (below).
  • --base where git has nothing to say about the project, or with a name git resolves to no commit.

Where the mark was taken in a repository and git has nothing to say about the project now, the gate could not run (exit code 3).

The agent plugin passes --since, and --changes where needed, itself. A usage error there is told to the person as a gate that could not run, and the agent is not held.

In a project in no repository, git cannot say what changed since the mark. Whatever keeps its own record of what it changed, such as the agent plugin’s ledger, writes a list of changes and hands it over:

assay mark --out .dart_tool/assay/mark.json --cross-file # before the work, outside git
assay gate --scope changed --since .dart_tool/assay/mark.json --changes .dart_tool/assay/changes.json

The list is one JSON object; both keys may be left out:

{
"changed": [
{"path": "lib/a.dart", "before": {"text": "int a() => 1;\n"}},
{"path": "lib/b.dart", "before": {"file": "/tmp/before/b.dart"}},
{"path": "lib/c.dart", "before": {"absent": true}},
{"path": "lib/d.dart", "before": {"unknown": true}}
],
"deleted": ["lib/e.dart"]
}
  • Paths are relative to the project root, with forward slashes. Each is named once in the whole list, after normalising (lib/./a.dart is lib/a.dart).
  • before is exactly one of:
    • {"text": …}: the text the file held;
    • {"file": …}: the text of another file, by a path absolute or relative to the project root, read as UTF-8 when the gate starts, so a large text need not sit in the JSON;
    • {"absent": true}: the file did not exist, so no suppression in it stood before;
    • {"unknown": true}: what it held is not known, so every suppression in it counts as new (over-reported, never under-reported).
  • What is on disk now decides. A listed changed file that is gone counts as deleted. A file listed as deleted that exists again counts as changed, with its before-state unknown. A file the list does not name is not changed.
  • The baseline and the configuration before, and the cross-file results that stood, come from the mark, as with --since alone.
  • The result JSON is that of any gate --scope changed, with no separate repositories. The console says the change is “from the list of changes at <file>, since the mark at <mark>, as the project is in no git repository”.
  • The list’s path, like the mark’s, is absolute or relative to the project root.

Usage errors (exit code 2), each with a message that names the list’s path and says what is wrong:

  • --changes without --since, or with --base.
  • --changes where git answers for the project, or with a mark taken in a repository.
  • A list that cannot be read, is not JSON or is not an object; a key other than changed and deleted; an entry of changed that is not exactly {path, before}; a before of no known kind; an entry of deleted that is not a string; a path outside the project (.., absolute, empty, or with a backslash); a path named twice.
  • A before.file that cannot be read.
assay gate --scope changed --since <mark> [--changes <file>] --reporter json:<file> [--full-report <path>]

This writes everything a caller, such as the agent plugin or a CI script, needs to say what the gate found by itself. The schema is lib/schema/assay_result_3.schema.json in assay_cli. Beside the fields every result has, these matter to a caller:

Field What it is
config.packagesNotFetched The configuration is in error because the presets’ package cannot be resolved. Tell the person to fetch the packages, not to correct the configuration.
files[].notJudgedBecause Why a file is not judged: compile_error, and each of assay’s own codes compileErrors names for it (file_is_not_utf8, file_cannot_be_read, file_could_not_be_judged, rule_failed, cross_file_pass_failed). Empty for a judged file.
violations[].inBaseline The fingerprint is in the baseline, also where the baseline does not apply: a blocking violation in a changed file still blocks (“in the baseline; blocks because its file was changed”).
violations[].inMark Gate only: the result stood at the start of the change. Only a result of a cross-file or a project-file check can be. A caller leaves those out of its message.
change Gate only. null in the project judgement and where it cannot be said what the change holds (git does not name its files). Otherwise from (where the files came from, in words), files[{path, sha256}] (every changed file of any kind but those under .dart_tool/; sha256 is null for a file that could not be read), deleted and separateRepositories.
newSuppressions[] Gate only: file, line, column, scope, codes, justified, identity. identity survives moved code, so use it to tell each suppression once.
newCoverageIgnores[] Gate only: the coverage-ignore comments the change added: file, line, column, kind (line, start, end, file), identity. They fail nothing; the agent plugin blocks the turn end on them. summary.newCoverageIgnores counts them in every result, 0 outside the gate.
baselineGrowth Gate only: entries[{fingerprint, rule, file, addedIn}] and the records[{seq, at, added}] they belong to.
crossFilePass Gate only: ran; not_run (no check on, the configuration in error, or no file the checks read in the change); failed (the pass threw, so there is no cross-file result).
conditions[] Gate only: each gate condition the configuration writes, with metric (coverage or duplication; a later version may add others), on (new_lines, overall), least for a floor or most for a ceiling, value (the share measured, one decimal, or null), status (passed, failed, not_judged) and why for one not judged. A failed one adds gate_condition to failedBecause.
coverage Gate only, with --coverage: the line coverage by the report, as metrics.coverage holds it, with the new coverable and covered lines of each changed file.
duplication Gate only, with --duplication where duplicated_code ran: the duplicated code of the files it reads, and on a change of their new lines.
notes[], warnings[] Gate only: what the console says below the report and on standard error, as plain text. A warning changes no verdict.
report.path The full report: under .dart_tool/assay/reports/, or where --full-report <path> put it (absolute or relative to the project root; named relative to the root inside the project, absolute outside).

The agent plugin builds two more things from the result:

  • The state of a change, to release an agent that stopped in the same failing state: a digest of change.files and change.deleted with failedBecause, config.errors, the compile errors of the changed files that are not judged, the blocking violations that are no cross-file result (fingerprint, rule, file, range) and baselineGrowth.entries (fingerprint, addedIn). With change null, or any sha256 null, there is no state, and the caller blocks.
  • What was said, so each thing is told once: the keys are the violation’s fingerprint, suppression:<identity>, configuration:<key>:<before as JSON>:<after as JSON>, and compile_error:<file>:<code>:<message> for a compile error in a file outside the change.

Exit codes with a result. Exit 2 with a result is a configuration error (failedBecause holds configuration_error); exit 2 without one is a usage error. Could not run (exit 3) is no result: standard error says why (a second engine that could not start or ended late, git that does not say what changed, a full report or a baseline file that could not be written). In the last two cases a JSON file named by --reporter json:<file> may still have been written; the exit code wins.

The Next: row of the console report repeats --since, --base and --changes as they were given.