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 --directoryprints it: directories end in/) is covered by an allow-list pattern. - argv
- The argv a gate runs: its command through
sh -c, as a CIrun:line runs through a shell, with{cache}expanded tocache_flags. - await_
verdict tree_verdict, waiting — at mostgreengate.treeLintWaitcounted fromstarted(the start of pre-push), as ONE deadline for every gate — for a rehearsal running on the tree of one oftipsto stamp its tree gates. Independent ofgreengate.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.treeLintSlackfor the gates still running, cancel the rest, and return the stamp tokens of the gates that proved the tree.stampableis 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, withbodycut (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
Nonewhen 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(andsnapshotCarry) 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
gateson the snapshot oftree, uncached (every snapshot sits at a new path) and bounded bygreengate.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_msis how long this commit’s own declared checks are expected to run. ReturnsNonewhen 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.