Skip to main content

Module gate_stamp

Module gate_stamp 

Source
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:

  1. pre-commit (record) writes a one-shot marker into $GIT_DIR naming 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_only parks only the working tree).
  2. post-commit (bind_to_head) consumes the marker and, when the marker’s tree matches HEAD^{tree}, stamps the commit in a notes ref. --no-verify skips 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.
  3. pre-push (stamps_for) reads the stamps back and suppresses a gate script only for pushes whose relevant commits all carry it.

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.

Why a notes ref and not config: notes are keyed by commit, garbage-collect with unreachable commits (an amont.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.

Constants§

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.
NOTES_FULL_REF
The same ref, fully qualified — what git update-ref -d needs.
NOTES_REF
The notes ref, spelled the way git notes --ref wants it.

Functions§

bind_to_head
post-commit: consume the marker; stamp HEAD when the tree still matches.
forget
uninstall: forget everything this module ever wrote here.
record
pre-commit: record that scripts ran clean against the tree the commit will carry.
stamps_for
pre-push: which of commits carry a stamp, and for which scripts.