Skip to content

Record Factory Commits proofs

Factory Commits is an open convention for recording in git how each change was produced and verified. A proof says which work unit a change belongs to, which checks ran on the exact tree and whether they passed. It uses git trailers, git notes and in-toto statements. HAR is one producer. Any tool that follows the spec can write or verify the same proofs.

Since HAR 2.0, when git factory is installed, every har env verify --full becomes a factory-run statement about the verified tree, and the commit of that tree gets the statement as a note in refs/notes/factory. The note stays local until you push it.

Each commit is reported at one level:

Level Name The commit has…
L0 Linked a Work-Unit or Factory-Run trailer
L1 Recorded a note with a valid statement for its exact tree, verdict pass
L2 Signed L1, signed by a trusted signer
L3 Gated L2, plus a statement from a trusted merge gate

HAR writes unsigned statements, so HAR-produced commits reach L1. L2 and L3 need a signer and a merge gate, defined in the spec.

A signature means accountability: it proves the statement was not changed and who vouches for it, not that the stages ran.

Every statement says how far to trust the environment that produced it, in environment.trust:

  • self-reported: the agent could have altered the run or the statement.
  • independent: neither the run nor its signing key was within the agent’s reach.

HAR runs verification as the developer, with the agent on the same machine and no sandbox, so it always writes self-reported, in CI too. Read a HAR proof as “this checkout says these stages passed on this exact tree”, not as an independent attestation. The spec lists these limits, and optional mitigations, in §11 Limitations.

HAR builds the predicate. The git-factory executable does everything else: the statement, the envelope, notes, trailers and verification. HAR installs it: har env launch and har hooks install put @osfactory/factory-proof@0.4.0 in ~/.har/factory-proof, and replace a different version there. They install it only when the repository sets HAR_FACTORY_PROOF to notes or notes+trailers. A git-factory already on your machine (on PATH, or an older copy in ~/.har/factory-proof) never turns proofs on and never makes HAR install or upgrade one.

HAR needs factory-proof 0.2.0 or newer, 0.3.0 for carried proofs, and 0.4.0 for har proof sync. 0.2.0 renamed the trust values, and older and newer versions reject each other’s statements, so HAR treats an older git-factory as missing. har hooks status shows the version HAR found.

HAR uses, in order: HAR_FACTORY_PROOF_BIN, the copy in ~/.har/factory-proof, then git-factory on PATH. If HAR_FACTORY_PROOF_BIN is not executable, HAR treats git-factory as missing and does not fall back. To install an unreleased build, set HAR_FACTORY_PROOF_PACKAGE to any spec npm accepts (a .tgz, a directory); HAR_FACTORY_PROOF_HOME moves the install.

The mode is set per repository in .har/harness.env:

Terminal window
HAR_FACTORY_PROOF=notes # off | notes | notes+trailers (unset: off)

Proofs are off by default. They are on only when this line says notes or notes+trailers. har onboard and har env maintain explain the modes, ask, and write the line (--proofs off|notes|notes+trailers answers without asking).

HAR reads the mode from the main checkout’s .har/harness.env, also inside slot worktrees. Set it there once: verify, the commit hooks and har hooks status in every slot use the same mode, even when a worktree’s own copy of harness.env lacks the line. The stage list and the .har/stages.json digest in a slot’s proof come from the slot’s own tree instead, so the proof describes the configuration that tree carries (the main checkout’s copy is used only when the slot has no .har/stages.json).

  • Unset (the default) is off, whatever is installed on the machine. The launch banner says git factory: skipped (proofs not enabled; enable with HAR_FACTORY_PROOF=notes in .har/harness.env).
  • off turns proofs off: no attestation, no note, and nothing installed. har hooks install removes the proof setup HAR added under an earlier mode (see Turn proofs off).
  • notes writes a note for each commit of a verified tree. har hooks install also runs git factory setup, which adds a fetch refspec that brings the remote’s notes into the tracking ref refs/notes/remotes/<remote>/factory (never over your own refs/notes/factory), and sets notes.rewriteRef so notes survive rebase and amend. When git-factory is missing, HAR prints a one-line hint.
  • notes+trailers does the same, and adds a commit-msg hook that writes Factory-Run and Factory-Attestation trailers on commits of a verified tree, plus a Work-Unit trailer when the verify ran in a slot bound to a work unit (see Bind a work unit). Factory-Run names the run and its verification trace: Factory-Run: <run-id>; trace=<trace-id>. Trailers rewrite commit messages, so they are never on by default.

The post-commit hook writes the notes, so install, or re-install, the commit hooks:

Terminal window
har hooks install

Re-run har hooks install after changing the mode. har hooks uninstall removes the hooks and the git config git factory setup added.

Terminal window
har proof disable

This sets HAR_FACTORY_PROOF=off in .har/harness.env (commit that change) and removes what HAR added for proofs, printing each item:

  • the notes fetch refspec of each remote (+refs/notes/factory:refs/notes/remotes/<remote>/factory, or an older one into refs/notes/factory);
  • notes.rewriteRef for refs/notes/factory;
  • the commit-msg trailer hook: HAR’s worker, and HAR’s block in the commit-msg git runs or in husky’s .husky/commit-msg (the rest of that file is kept).

It never touches refs/notes/factory or any note. Setting HAR_FACTORY_PROOF=off, or removing the line, and re-running har hooks install (or har env maintain, when it reinstalls the hooks) does the same; har hooks status lists what is left until then. Going from notes+trailers to notes removes only the trailer hook.

With husky or another manager that sets core.hooksPath, har hooks install still runs git factory setup, but the hooks that write proofs (post-commit, and commit-msg for trailers) are not active until the managed hooks call HAR’s workers. Run har hooks install --managed for husky, or add the printed blocks; see Husky and other managed hooks. har hooks status shows the mode and whether it comes from harness.env or the default (off).

  1. har env verify 1 --full records the validation as usual. HAR then builds a factory-run predicate from it (stage ids, statuses, durations, verdict, and the work unit and attempt when the slot is bound to one) and calls git factory attest. The attestation is stored next to the validation record, in .har/validations/<tree>.attestation.json.
  2. You commit the verified tree. With notes+trailers, the commit-msg hook adds the trailers first.
  3. The post-commit hook adds the attestation to the new commit’s note in refs/notes/factory.

If HEAD already has the verified tree when the full verify passes, HAR adds the attestation to HEAD’s note right away and prints har: factory note sha256:… added to HEAD <sha>. This happens when you re-verify after a rebase or an amend: the rewritten commits have no proof, and no commit follows to run the post-commit hook. HAR only notes HEAD, not older commits in the branch. If HEAD’s note already holds a passing attestation for that tree, HAR leaves it alone, so repeated verifies (for example har env complete --verify) do not grow the note. A working tree that differs from HEAD gets no note until you commit it.

If you send telemetry to a backend, the same verify also emits a verification trace whose factory.run.id and factory.git.tree match the proof’s run id and tree.

Each verify is its own factory run, with its own run id, stage logs and trace. Verify the same tree twice and you get two runs: a failed verify stays on record next to the passing one that followed it. The commit binds the tree’s latest verify, so the note, the Factory-Run and Factory-Attestation trailers and the proof’s run.id name the run that passed. Re-verifying a tree that is already committed starts a new run too, but leaves the commit’s note alone when it already holds a passing proof for that tree.

Only a passing full validation of the exact committed tree gets a note or trailers. Commit a different tree, or commit after a failed verify, and nothing is added.

A proof names a work unit, and the attempt that worked on it, only when the slot is bound to a work unit. A slot launched without --work-id and never bound writes proofs with no workUnit in the predicate, and with notes+trailers its commits get no Work-Unit trailer. The proof is still valid, and a commit of the tree still reaches L1.

Bind at launch:

Terminal window
har env launch 1 --work-id widget-123 --work-source github \
--work-url https://github.com/acme/widget/issues/123

Or bind a slot that is already running (from its work dir, or pass the slot id):

Terminal window
har env work-bind 1 --work-id widget-123 --work-source github

Each binding starts an attempt, and the attempt id goes into the predicate next to the work unit:

"workUnit": { "id": "widget-123", "source": "github", "attemptId": "a09efc28-e0d4-499d-b971-33199910a125" }

The binding applies to the next verify, not to proofs already written: after har env work-bind, re-run har env verify 1 --full before you commit. With notes+trailers, the commit then carries a Work-Unit trailer, written <source>:<id> (or <id> alone when the unit has no source):

feat: add saved filters
Work-Unit: github:widget-123
Factory-Run: c10994f4-c61c-482a-9e97-81909b92674c; trace=bd351a96de9020245482cb7e5eab946c
Factory-Attestation: sha256:539c4170b4fcf72bdbf4d158c9e15a31df16bbddaa7b3f9e219d77793343d8dc

The trailer carries the work unit only. The attempt is in the attestation, in the note.

HAR says when a proof will be unattributed. A full verify that writes a proof with no work unit prints one line:

har: proof has no work unit — bind one with `har env work-bind 1 --work-id <id>`, then re-run `har env verify 1 --full`

Under notes+trailers, har env launch without --work-id also says that the slot’s commits will carry no Work-Unit trailer. MCP agents get the verify line as proofHint from har_run_verification.

Terminal window
har proof show # note and trailers on HEAD
har proof show <rev> --json
har proof verify # HEAD, must reach L1
har proof verify main..HEAD # every commit in a range, each must reach L1
har proof verify --min-level L2 --allowed-signers .github/allowed_signers

Both commands pass git factory show and git factory verify through. --json prints git factory’s JSON as is. Exit codes come from git factory: 0 ok, 1 verification failed (a commit below --min-level, or problems found), 2 usage or environment error, including a missing git-factory. HAR always passes --min-level, L1 unless you choose another level, for one commit and for a range alike. A range with one unproven commit fails. (git factory verify on its own applies no minimum to a range.) The lowest level you can pass is L0.

MCP agents use har_proof_show and har_proof_verify.

Git does not push or fetch notes by default. Use har proof sync rather than pushing refs/notes/factory yourself:

Terminal window
har proof sync # fetch the remote's notes, merge them into yours, push
har proof sync --no-push # fetch and merge only
har proof sync upstream # another remote (default: origin)
har proof sync --json # git factory sync's JSON output

har proof sync runs git factory sync with the git-factory HAR manages (factory-proof 0.4.0 or newer), so you do not need factory-proof on your PATH. It needs proofs enabled: with HAR_FACTORY_PROOF unset or off it says so, exits 1 and installs nothing. If you installed factory-proof yourself, git factory sync does the same thing.

To push notes after every session, record it once in .har/harness.env (har onboard and har env maintain ask, or har env maintain --proofs-push):

Terminal window
HAR_FACTORY_PROOF_PUSH=on # har env complete runs har proof sync (unset or off: notes stay local)

With it, a successful har env complete runs har proof sync; a failed sync is a warning and the session still completes. Anyone with access to the repository can read pushed notes, teammates and CI see them only after their own sync, and hosts do not show notes in their web UI.

sync fetches the remote’s notes into the tracking ref refs/notes/remotes/<remote>/factory, merges them into your refs/notes/factory and pushes the result without force. The merge keeps the notes already on the remote: when both sides annotate the same commit, it combines the two notes into one (every attestation from both, de-duplicated by digest). If the remote moved while it ran, it starts over. It is safe to run again, and it never deletes or rewinds refs/notes/factory, locally or on the remote. If either side’s note is not a valid note document, it stops before changing anything and names the commit.

A plain git fetch brings the remote’s notes into the tracking ref only, so it no longer touches your local notes. Verifiers read refs/notes/factory alone: in a fresh clone, run har proof sync --no-push before har proof verify. git factory verify and show name that command when a commit’s note is only in the tracking ref.

Do not git push origin refs/notes/factory by hand: when the remote already has notes, the push is rejected. Older factory-proof versions configured a forced +refs/notes/factory:refs/notes/factory refspec, so a fetch replaced your local, unpushed notes with the remote’s. Re-run har hooks install (or git factory setup) after upgrading: it replaces that refspec with the tracking one.

On shared branches the spec recommends that only the merge gate pushes notes.

A statement names a git tree, not a commit. Squash, rebase and amend often keep the tree, so the proof still applies. But the note stays on the commit it was attached to, and a squash creates a new commit:

  • If the branch was up to date with its base, the squash commit has the verified tree. A gate (or you, with git factory note add <commit> --attestation <file>) can copy the attestation onto it.
  • If the base moved, the merged tree differs from everything verified, and the proof does not apply. Re-verify the merged tree.

To keep merged commits provable, require branches to be up to date before merging, or use a merge queue. The merge gate extension describes the full L3 flow.

A rebase onto a base that moved gives every rebased commit a new tree, so each one loses its proof, even when the change is the same. By default this is final: the rebased tree was never run, and har proof verify reports it below L1. Re-verify it.

For stacks of pull requests that is one full verify per pull request after each sync. When the change itself did not change, you can carry the proof instead:

Terminal window
har proof carry <old-head> --base origin/main # onto HEAD
har proof carry <old-head> <new-head> --base lower-pr --old-base <old-lower-head>
har proof verify --accept-carried # L1 (carried from <old-head>)

har proof carry wraps git factory carry. It compares the change of the old commit against its base with the change of the rebased commit against its base, using git patch-id. When they match, and the old commit has a passing proof, it writes a carried proof to the local note on the rebased commit. It refuses when the change differs, for example after a conflict resolution. A proof carried a second time still points at the original run.

A carried proof is a separate claim, not a run:

  • har proof verify ignores it unless you pass --accept-carried. Your CI decides whether to accept it.
  • It never counts above L1, even when the original proof was signed.
  • The verify output names the original commit (carriedFrom), so reviewers can tell it from a run on this tree.

It proves only that the change is the same as one that passed. The change together with the new base was never run. Carried proofs need git-factory 0.3.0 or newer. See the carried proof extension. MCP agents use har_proof_carry, and acceptCarried on har_proof_verify.

History is permanent and often public. A HAR proof contains:

  • the repository URL, with credentials stripped;
  • the tree hash, the HAR validation id and its start and end times;
  • when the slot is bound to a work unit: the work unit id and tracker (for example github), and the attempt id;
  • the verify policy (har-verify-full), a hash of .har/stages.json, and each stage’s id, kind, status and duration;
  • the HAR version and whether it ran locally or in CI.

It never contains prompts, agent output, stage logs, file contents, absolute paths, or work unit titles or URLs.

Proofs never block verify, a commit or a launch. When git-factory fails, HAR prints one line and carries on. A missing git-factory also gets one line when you set the mode explicitly, and none under the default. The commit is made without a note, and the validation is recorded as usual. Install git-factory and re-run har env verify --full before your next commit to get a proof for it.

See also Verification & commit gate.