Verification and commit gate
Quick and full verification
Section titled “Quick and full verification”har env verify 1har env verify 1 --fullhar env verify 1 --full --json # structured result onlyQuick verification should be fast enough for iteration. Full verification is the
repository’s completion contract. The exact commands are adapted in
.har/stages.json; typical full checks include unit tests, lint, readiness, browser
E2E, and project-specific stages.
har env verify streams progress to stderr. It does not dump the per-step JSON
contract afterward — that duplicated CI logs and agent context. Scripts that
need the object can pass --json. Passing steps omit output; failed steps
include a truncated excerpt.
HAR records CLI and MCP verification as run JSON and records the exact Git tree state for full verification. A later source edit invalidates that validation.
Every har env verify is a new factory run: its own run id, its own stage logs
in .har/artifacts/<factory-run-id>/ and its own verification trace, even when the
tree was verified before. A failed verify followed by a passing one of the same tree
(for example after a factory line gate) is two runs,
and both reach Mission Control and every other receiver. The validation record of a
tree points at its latest run: that is the verify the commit gate checks, and
the run a commit of that tree binds to, in its proof and trailers.
Install the commit gate
Section titled “Install the commit gate”Init and maintain now offer to install the gate according to the user’s onboarding preferences. Configure that default once:
har preferences configureInstall or inspect it directly at any time:
har hooks installhar hooks statusHAR installs repository-level pre-commit and post-commit hooks that cover its worktrees:
- pre-commit hashes the staged change batch and compares it with successful full validation;
- post-commit associates the new commit SHA with that validation.
The gate is intentionally based on content, not timestamps or branch names.
Husky and other managed hooks (core.hooksPath)
Section titled “Husky and other managed hooks (core.hooksPath)”When core.hooksPath is set, git runs hooks only from that directory, not
.git/hooks. Husky sets it: v9 to .husky/_, a relative path that each worktree
resolves against its own root and that husky generates on install, so it may not
exist yet. HAR does not write into such a directory unless you ask it to.
har hooks install always installs the workers (har-pre-commit, har-post-commit
and, for notes+trailers, har-commit-msg) in <git-common-dir>/hooks, which every
worktree shares, and always runs the Factory Commits proof setup. Under a managed
core.hooksPath it then reports which hooks are not active and prints the block
for each one; it does not fail.
With husky, let HAR add the blocks to husky’s tracked hooks:
har hooks install --managed # appends a HAR block to .husky/pre-commit, post-commit (and commit-msg)git add .husky && git commit -m "chore: run the har commit gate from husky"Each block calls "$(git rev-parse --git-common-dir)/hooks/har-<hook>" only when
that worker exists, so the same tracked files work in every worktree and do nothing
in a clone without HAR. Re-running is idempotent; har hooks uninstall removes the
blocks (commit that change too). har hooks status names the file each hook runs
from, and says when core.hooksPath keeps the gate from running.
For another hook manager, add the printed blocks to its pre-commit, post-commit
and, with notes+trailers, commit-msg hooks. --force writes into the
core.hooksPath directory itself, which a manager like husky regenerates.
The workers re-enter the har that installed them and fall back to har on
PATH, then node_modules/.bin/har, when that one is gone (for example after a
Node version manager moves it). If none is found they skip with a notice and
never block the commit.
Configure policy
Section titled “Configure policy”In .har/stages.json:
{ "commitGate": { "enabled": true, "mode": "block", "scope": "worktrees" }}mode can be block or warn. scope can be worktrees or all; the default
worktree scope enforces agent sessions while warning in ordinary checkouts.
"enabled": false turns the gate off.
har onboard and har env maintain ask for the gate (off, warn or block)
when nobody chose it yet, and record the answer with "recordedBy": "onboard" or
"maintain". From then on har env maintain never changes the gate, and never
reinstalls hooks you removed, unless you pass --commit-gate off|warn|block. A gate
set to "enabled": false by hand counts as chosen too.
Correct sequence
Section titled “Correct sequence”har env verify 1 --fullgit add -Agit commit -m "fix: explain the validated change"Stage everything that was verified. A partially staged tree is a different batch and should not pass the gate. Never bypass hooks to force an agent commit; run the required validation against the intended state.
Factory Commits proofs
Section titled “Factory Commits proofs”Setup, levels, pushing notes and squash merges are covered in Record Factory Commits proofs. In short:
HAR can record its validations as Factory Commits
proofs in git. HAR builds a factory-run predicate from each full validation.
The git-factory executable (HAR_FACTORY_PROOF_BIN, else the copy HAR installs in
~/.har/factory-proof, else PATH) builds the
statement and writes notes, trailers and verification. The mode is set per
repository in the main checkout’s .har/harness.env (slot worktrees use it too):
HAR_FACTORY_PROOF=notes # off | notes | notes+trailers (unset: off)- Unset (the default) or
off: no proofs. Nothing is attested, noted or installed, even when agit-factoryis on the machine.har hooks installremoves the proof setup an earlier mode added (fetch refspec,notes.rewriteRef, the trailercommit-msghook) and keeps the notes;har proof disablesetsoffand does the same. notes:- every
har env verify --fullattests the validated tree, stored next to the validation record; - post-commit adds that attestation to
refs/notes/factoryon the new commit; when HEAD already has the verified tree (re-verify after a rebase or amend), verify adds it to HEAD’s note itself; har hooks installrunsgit factory setup(a fetch refspec into the tracking refrefs/notes/remotes/<remote>/factory,notes.rewriteRef), andhar hooks uninstallundoes it. Publish notes withhar proof sync.
- every
notes+trailers: everything innotes, plus a managed commit-msg hook that addsFactory-RunandFactory-Attestationtrailers for a verified tree, and aWork-Unittrailer when the slot was bound to a work unit (--work-idat launch, orhar env work-bind). Re-runhar hooks installafter changing the mode.
A proof names a work unit and an attempt only when the slot is bound to one. A full verify that writes a proof with no work unit says so in one line; see Bind a work unit.
Proofs never block verify or a commit. When git-factory fails, or is missing
under an explicit mode, HAR prints one line and carries on. Predicates never contain absolute paths,
prompts, or work-unit titles or URLs.
Under notes or notes+trailers, HAR installs factory-proof 0.4.0 in
~/.har/factory-proof on har env launch and har hooks install, needs 0.2.0 or newer, and treats an older git-factory as
missing; har hooks status shows what it found.
Every HAR proof has environment.trust: self-reported, in CI too: the agent runs as
the developer, so a proof records what this checkout reports, not an independent
attestation. See Trust.
Inspect and verify proofs with har proof show [rev] and
har proof verify [rev|A..B] [--min-level L0|L1|L2|L3] [--allowed-signers <file>] [--json].
MCP agents use har_proof_show and har_proof_verify. Both pass git factory
output and exit codes through. The minimum level defaults to L1 for one commit and
for a range.
Completion
Section titled “Completion”har env complete 1 reuses the last passing full validation whose tree hash
matches the current worktree, then tears the slot down and keeps the session
branch. Verify-before-done already recorded that proof — complete does not
re-run the suite by default.
If the tree changed after that verify (or there is no matching passing full validation), complete refuses and tells you to re-run:
har env complete 1 --verify--verify is the previous default: full verification, record validation, then
teardown. Use har env teardown 1 for cleanup without claiming completion.
--skip-verify is a deprecated no-op; skip is already the default.
