Skip to main content

Module tree_lint

Module tree_lint 

Source
Expand description

Tree gates at commit time: run beside the commit’s checks, never decide it, stamp the tree when they prove it (ADR-0024).

The commit’s verdict is untouched: it comes from the checks it always came from. A tree gate adds at most greengate.treeLintSlack after those finish, and a pass is recorded as the token tree:<name> in the commit’s gate stamp (gate_stamp::record), which post-commit binds to both the commit and its tree. The push reads the tree’s note, so a reword keeps the proof.

No stamp, and the gates do not even start, when the tree they would lint is not exactly the commit’s tree:

  • tracked files had unstaged edits (captured BEFORE the staged-only hold parks them — after, the working tree always looks clean);
  • untracked, non-ignored files exist;
  • ignored files exist outside the allow-list (snapshotPrepareOutputs, plus tool caches by default) — a gitignored generated module can make a linter pass here and fail in CI;
  • a merge, rebase, cherry-pick or revert is in progress.

Structs§

SideCar
Tree gates in flight.

Constants§

DEFAULT_OUTPUTS
Ignored paths that are tool caches or dependency trees CI recreates, and never a module a linter could import in place of a committed one.
OUTPUTS
REHEARSAL_TIMEOUT
SLACK
TOGGLE
WAIT

Functions§

allowed
Whether an ignored entry (as git ls-files -o -i --directory prints it: directories end in /) is covered by an allow-list pattern.
argv
The argv a gate runs: its command through sh -c, as a CI run: line runs through a shell, with {cache} expanded to cache_flags.
await_verdict
tree_verdict, waiting — at most greengate.treeLintWait counted from started (the start of pre-push), as ONE deadline for every gate — for a rehearsal running on the tree of one of tips to stamp its tree gates. Independent of greengate.rehearsalWait: it neither uses nor extends it.
enabled
Whether tree gates run here. On by default where attestation is on: a stamp nobody signs is paid for and never used.
finish
Wait at most greengate.treeLintSlack for the gates still running, cancel the rest, and return the stamp tokens of the gates that proved the tree. stampable is false when the commit is blocked or a check rewrote files: then nothing is waited for and nothing is stamped. Cold gates go to the background warm-up.
fit_line
prefix + body + suffix, with body cut (and an ellipsis added) so the whole line fits 80 columns. The body carries a tool’s own summary line, whose length nothing bounds.
flush_evidence
Write this run’s tree-gate evidence against tree’s gate note, and clear it. Best-effort, like every evidence writer.
guard
Why this commit’s tree cannot be proven, or None when it can. Runs BEFORE the staged-only hold: only then can unstaged edits be seen.
note_withheld
Every gate withheld for the same reason (the guard fired).
outputs
The allow-list: the defaults plus snapshotPrepareOutputs.
prepare_guard
Whether a snapshot is still exactly its tree once snapshotPrepare (and snapshotCarry) ran: tracked content unchanged, nothing untracked, and nothing ignored outside the allow-list. Prepare runs arbitrary commands, so this is what keeps it from forging the tree a stamp names.
rehearse
The rehearsal’s half (ADR-0024): prove gates on the snapshot of tree, uncached (every snapshot sits at a new path) and bounded by greengate.treeLintRehearsalTimeout, and stamp the TREE. Runs before the rehearsal’s test gates, so a push waiting on lint does not wait on tests.
start
Start one thread per gate against the working tree, which the staged-only hold has made the commit’s tree. EVERYTHING a gate needs to decide runs in its own thread, so none of it delays the commit’s checks: the version probe (bounded and cancellable — a wrapper may reach the network), the skew check, the namespace, the warm and fit tests, the lock, the run. cover_ms is how long this commit’s own declared checks are expected to run. Returns None when nothing starts.
tree_verdict
Which declared tree gates every pushed tip’s TREE proves, as note gate ids (tree-<name>), and which it does not, by name. A tip whose tree git cannot name proves nothing.
warm
amont warm — fill every cold tree gate’s cache in its current namespace: a full run with {cache}, then the completion marker. Old namespaces are deleted first, under the gate’s lock. A gate whose lock is held is left to whoever holds it. Exit 0 whatever the lint found: a warm-up proves nothing, it only makes the next commit’s run cheap.