Expand description
The record that turns “a declaration exists” into “the check ran”.
Moving a gate entry to commit time (docs/checks.md, “Moving a gate entry
earlier”) makes the push gate skip a script because a pre-commit
declaration covers it. A declaration is a promise on paper: a commit made
with --no-verify, from a libgit2 client that runs no hooks, or on a
machine without amont was never judged by it — and until this module
existed, push time had no way to tell those commits from checked ones.
Three hooks share one record:
- pre-commit (
record) writes a one-shot marker into$GIT_DIRnaming the gate scripts that actually ran, bound to the tree the commit is about to write (git write-tree— during pre-commit the index IS the commit’s content;staged_onlyparks only the working tree). - post-commit (
bind_to_head) consumes the marker and, when the marker’s tree matchesHEAD^{tree}, stamps the commit in a notes ref.--no-verifyskips pre-commit but NOT post-commit, so an unchecked commit arrives here with no marker and gets no stamp — which is the entire point. The tree comparison makes an aborted commit’s leftover marker harmless, and a retried commit of the SAME tree correctly stamped: the check really did run on exactly that content. - pre-push (
stamps_for) reads the stamps back and suppresses a gate script only for pushes whose relevant commits all carry it. - pre-push, on the way out (
stamp_push) writes the push-time gates that PASSED onto each pushed tip — andamont run pre-push, which drives the same dispatcher, writes the same stamp forHEAD. The next push of that tree finds the stamp and skips the gate. That is what lets the suite run BEFORE git opens its connection: a rehearsal stamps, the push verifies. And a push that passed the gate but died on the wire — a remote that dropped the idle session while the suite ran — retries in seconds instead of minutes. Push-time tokens are full ids (pre-push-run-tests-js), commit-time ones are script names (test); the two share a note and never collide.
Every failure mode points the same direction: no marker, a mismatched tree, a missing note, a rewritten hash — all mean “no stamp”, and no stamp means the push gate RUNS. Nothing here can let an unchecked commit through; it can only cost a redundant gate run.
§The second half of the note: what a run COST, and how it ENDED
The token line above answers one question — may this gate be skipped for this content — and it is deliberately a set, with no history in it. A stamp says a gate passed; it cannot say a gate has been passing in four seconds since the day its test runner stopped finding any tests.
So the note carries optional extra lines, one per RUN:
greengate-gate-v1 pre-push-cargo-test
run 1726900000 pre-push-cargo-test pass 412391
run 1726903600 pre-push-audit-js fail 903Additive on purpose, and in the only direction that is safe: every reader
that existed before these lines did reads body.lines().next() and is
unaffected, and an amont old enough to rewrite the note without them loses
history — never a verdict. The run lines are EVIDENCE, read by
crate::gate_evidence; nothing in this module’s skip decisions consults
them, so a corrupted or forged one cannot make a check be skipped.
One more kind of line, and the one exception to that rule (ADR-0013):
deferred cargo-testA commit-time gate the busy policy deferred to CI. Pre-push reads it
(deferred_for) so the gate’s push twin defers too instead of running
the suite with the remote’s connection held open. It can only ever move a
gate to CI — it is never a token, never stamps, never attests — so a
forged line makes CI run more, never less. Kept apart from the run
history, whose [MAX_RUNS] trim must not forget it.
The note’s key is the tree, which makes the record a per-FINGERPRINT one for free: two runs of one gate against one tree are two lines in one note, and if they disagree the gate is flaky on content that did not change.
Why a notes ref and not config: notes are keyed by commit, garbage-collect
with unreachable commits (an greengate.checked.<hash> config key would
outlive every rebase forever), stay local (notes refs are not pushed by
default), and stay out of git log (only refs/notes/commits displays by
default). amont uninstall deletes the ref; see uninstall_repo_hooks.
Structs§
- Note
- A parsed note body: the skip tokens, and the runs recorded against this key.
- Run
- One run of one gate: when, which, how it ended, how long it took.
Enums§
- Completion
- How a gate completed without passing (ADR-0018). The kind is part of the record, so each answers only for as long as it should.
- RunOutcome
- How a single run of one gate ended.
Constants§
- CLUSTER_
FULL_ REF - CLUSTER_
REF - Where CLUSTER passes are recorded (ADR-0016): the same note format, keyed
by the judged tree, holding tokens of
gate_identity::cluster_token. Nevergreengate-gate(ADR-0015): a local token here would let the laptop sign a pass it never ran. - DONE_
FULL_ REF - DONE_
REF - Where a gate that COMPLETED without passing is recorded (ADR-0018): a
warn-severity failure, or a gate that could not run. The same note format,
keyed by the tree, holding
gate_identitytokens. Nevergreengate-gate: a completion is not a pass, and nothing reads this ref to attest or to skip a gate in an inline push. Only the refusing push (greengate.pushGates refuse) and land’s own push read it, so that what a rehearsal or land’s pre-stage already ran is not refused as “not run”. - FORMAT
- First token of the marker file and of every note body. Versioned like
staged_only::FORMAT: a future amont that changes the shape bumps this, and an old record is ignored rather than misread. - INPUTS_
FULL_ REF - INPUTS_
REF - The second ref: stamps keyed by a gate’s declared-input fingerprint
(
.github/greensummit-inputs, seecrate::attest_inputs) instead of by the whole tree. A gate whose inputs a repository declares is reused on any tree where those inputs are byte-identical — the closing plan commit changes the tree and none of them. Every key there is an oid that is not an object, as in attest’s own inputs ref, sogit notes pruneon it would drop everything: never run it, and never merge the ref withcat_sort_uniq. - NOTES_
FULL_ REF - The same ref, fully qualified — what
git update-ref -dneeds. A literal, not derived from [WRITE]; a test holds it equal torefs/notes/{NOTES_REF}. - NOTES_
REF - The notes ref, spelled the way
git notes --refwants it. - PROVENANCE
- The reserved first word of a provenance line: where a token came from (platform, observed imageID, Job UID). Never a token, never a run, and every reader of tokens drops it.
Functions§
- bind_
to_ head - post-commit: consume the marker; stamp HEAD when the tree still matches.
- commit_
stamps_ enabled - Does this repository reuse a gate’s verdict across commit attempts of one tree?
- deferred_
for - Which of
commitscarry a deferral ofgateon their tree’s note (or their own). Read only to defer a push twin, never to skip one: a commit in this set still has no stamp. - deferred_
on - The commit-time gates the busy policy deferred on
tree, by script name. Whatamont stampsreports asdeferred; never a token. - done_
on_ every - Did the gate behind
tokencomplete without passing on the tree of every one ofcommits, by a record that still answers underseverity? An unreadable tree or note is “no”, the direction that refuses rather than skips. - forget
- uninstall: forget everything this module ever wrote here.
- forget_
in - The same, for a repository this process is not standing in.
- is_
provenance - Is
lineaPROVENANCEline? Every token reader asks, so a line that says where a pass came from can never be read as the pass itself. - push_
stamps_ enabled - Does this repository reuse push-time stamps?
- record
- pre-commit: record that
scriptsran clean against the tree the commit will carry. - record_
deferred - pre-commit: record on
tree(the staged tree, which is the commit’s) that the busy policy deferredgates, by their commit-time script names. Best-effort and silent: a lost line runs the push twin, the safe way. - record_
done - Record on
treethat the gates behindtokenscompleted there without passing, ashow(ADR-0018). Merged into the note; anUnavailableorDeferredrecord replaces the one of its kind before it for the same gate, so a tree’s note does not grow by a word per run. The error names the tree, for the caller to say: a record that was not written costs a refused push. - record_
runs - Record what a gate run COST and how it ENDED, against the content it ran on.
- stamp_
push - pre-push, after every block gate passed: record that
gatespassed againsttree, the content ofcommit— MERGING with whatever the note already says, because a commit-time stamp (test) may already sit there andnotes add -fwould otherwise erase it. - stamp_
tree - Add
tokensto the gate note ontree— how a rehearsal records tree gates it proved in its snapshot of exactly that tree. Merged, never rendered from the tokens alone, so evidence already on the note survives. - stamps_
for - pre-push: which of
commitscarry a stamp, and for which scripts. - tree_
tokens - The stamp tokens on
tree(a tree object id). Tree gates are read here and only here (ADR-0024):tree:<name>on the pushed tree proves the gate on exactly that content, whichever commit carried it. - vouched_
for_ staged_ tree - pre-commit, before a gate runs: the scripts a previous run already vouched for against the tree this commit is about to seal.