Repository navigation
Frozen Intent and Guards
Frozen intent is what the human approved for a story. Hashes make a change visible, a hook blocks most changes, and claims and lanes keep parallel agents apart.
A building agent must not quietly widen a story, weaken its tests, or edit another lane's code. Prose asks for that; this page covers what enforces it. Flags are in CLI Plan Tooling.
| What | Recorded in | Set by | Enforced by |
|---|---|---|---|
| Intent |
frozen_sha256 in the story's frontmatter |
freeze --story <id> --via checkpoint|plan |
check, guard hook |
Contract fields (caps, rules, seams, checkpoint, security, frozen_tests, approved_via) |
contract_sha256 in the frontmatter |
the same freeze
|
check, guard hook |
| Who approved the block | approved_via: checkpoint | plan |
freeze --via |
part of the contract hash |
| Where the build started | baseline_commit |
lean-build, once |
guard hook (no rewrite), check --story (a commit behind HEAD) |
Acceptance tests (security: true or irreversible) |
frozen_tests: ['path#sha256', …] |
freeze --story <id> --tests a,b |
check, guard hook |
| Who builds the story | git ref refs/lean/claims/<id>
|
claim --story <id> |
claim, next, check
|
| Which files a lane story may touch |
lanes: in stories.yaml
|
lean-plan |
check --story |
orchestrator (lean-build) implement worker tooling
| |
|-- claim --story E2-1 ---------------------------------> refs/lean/claims/E2-1
| (spec grown, human approves the frozen block)
|-- freeze --story E2-1 --via plan ----------------------> frozen_sha256 = sha256(block), contract_sha256
|-- test worker writes failing tests, orchestrator judges them
|-- freeze --story E2-1 --tests a,b ---------------------> frozen_tests = [path#sha256], contract_sha256 again
|-- baseline_commit = HEAD; status: in-progress
|-- spec path ------------------------->|
| |-- Edit/Write ---> guard hook: allow, or exit 2
|<----------- report, diff -------------|
|-- check --story E2-1 ----------------------------------> hash? tests? size? trespass?
| FAIL: restore from git. Never re-freeze to pass.
| PASS: review, then claim --release
The story file holds the build spec. Its <frozen-after-approval> block is the part the human owns (the template puts Intent, Boundaries and the Edge-Case Matrix inside it):
<frozen-after-approval reason="human-owned intent — change only when the human renegotiates">
## Intent
**Problem:** … **Acceptance:** Given …, when …, then …
</frozen-after-approval>-
freezehashes the block (HTML comments and trailing spaces ignored) and writesfrozen_sha256to the frontmatter. - Edits outside the block do not matter: tasks, notes, status, logs.
-
checkreportsstory/frozen-changedif the block changes or disappears, in any status. Areadyor later story with no hash gets the warningstory/frozen-unhashed. - A small-route story freezes its Intent the same way. Ad-hoc specs use
--file plan/adhoc/<slug>.md.
Some frontmatter fields change what the build must do as much as the block does: a story could drop its frozen tests, lower security, or widen caps without touching the block. freeze therefore also hashes caps, rules, seams, checkpoint, security, frozen_tests and approved_via into contract_sha256 (comments and spacing ignored).
-
checkreportsstory/contract-changedwhen one of them changes, in any status. A frozen story withoutcontract_sha256(frozen by an older LEAN) gets the warningstory/contract-unhashed: runfreezeonce to record it. -
freeze --unlockremoves both hashes;freeze(with or without--tests) writes both again. -
status,route,review_loops,metricsand the logs stay free: the build changes them as it goes.
approved_via says how much of the block a human saw. checkpoint: the human saw the whole block at the build checkpoint. plan: the human approved only the plan stub (its Acceptance), and the orchestrator wrote the rest. In a plan story the orchestrator tags [ASSUMPTION] on every frozen line that says more than the stub, the SPEC, an AD or a human answer. Those lines are frozen against the implementer like the rest, but they are not settled: reviewers may challenge them, and triage judges them on the merits (Review and Triage). This came from an experiment where an unseen line the orchestrator wrote in the block made triage reject a correct finding (Experiment Results).
freeze writes plan unless told --via checkpoint, and keeps the value already recorded when called again without --via.
When a story has security: true or an irreversible step, a test worker writes failing tests from the spec before any code exists (other stories get their tests from the implementer, with the code). The orchestrator judges them, then runs freeze --tests. The implementer makes them pass and never edits them. If it thinks one is wrong, it stops and reports.
check reports story/frozen-test-changed or story/frozen-test-missing for any story not done or retired. A security: true story past ready with no frozen tests gets the warning story/security-untested; lean-loop parks it for a human.
-
claimrunsgit update-refwithcreateonrefs/lean/claims/<id>. The ref points to a blob with the owner and an ISO time. Creation is atomic, so two agents racing for one story cannot both win. - Refs live in the shared git directory. Every worktree of one clone sees them.
- LEAN never pushes, so claims do not cross machines. Teams on separate machines own separate lanes (Parallel Teams).
- A claim is not a status. Status stays in the story file.
-
nextlists claimed stories apart and skips them.checkwarnsclaims/stale(storydoneorretired) andclaims/unknown. - List them with
claim --listorgit for-each-ref refs/lean/claims/.
check --story <id> lists files changed since the story's baseline_commit (tracked and untracked; git diff HEAD when the baseline is empty or NO_VCS). It applies only to epics that declare lanes:.
- Files under the plan folder are ignored.
- A story in a named lane that changes another lane's
modulesgetsdiff/trespass. - Any story outside lane
sharedthat changescontracts_pathorfixtures_pathfromCONTRACTS.mdgetsdiff/trespass: it needs a contract change (<E>-C<n>). - No git, or an unreadable baseline, gives the warning
diff/no-git.
lean-build reverts a trespass before review.
A PreToolUse hook, _lean/hooks/frozen-guard.js, installed by default for Claude Code and Codex (--no-guard-hook skips it). Plain Node, no dependencies.
| Tool | Registered in | Matcher |
|---|---|---|
| Claude Code | .claude/settings.json |
Edit|MultiEdit|Write |
| Codex | .codex/hooks.json |
^apply_patch$ |
The installer merges its entry next to yours and uninstall removes only that entry. Codex runs project hooks only after you trust them once with /hooks.
For each file a tool call would touch, the guard works out the content after the edit. Codex's apply_patch text is parsed and applied in memory first, so adds, updates, deletes and moves are all seen.
It blocks (exit 2, with the reason on stderr for the agent) when:
- the file has a
frozen_sha256and the edit would change the frozen block, drop the block or the hash, or delete or move the file (any status); - the file has a
contract_sha256and the edit would change a contract field or that hash; - the file has a
baseline_commitand the edit would change or remove it; - the file is listed in
frozen_testsof a story whose status isready,in-progressorin-review(any edit).
Everything else passes. A guard crash allows the edit. A patch that cannot apply is left for Codex to reject.
LEAN guard: test/producer.test.js is a frozen acceptance test of plan/epics/E2-export/stories/E2-1-producer.md. Make the code pass it; don't change it. …
-
Shell edits (
sed -i,echo >,git checkout). The hook sees only edit tools.check --storycatches the result afterwards, andlean-buildruns it as its mechanical gate. -
Other tools. OpenCode and Antigravity CLI have no guard hook.
check --storyis the only net there. -
Gaps by design. The guard ignores a block that was never frozen. In
draft, a frozen test edit passes the guard but failscheck. -
Unlocking.
freeze --unlockis a shell command, so the hook cannot stop it. The rule is in the skills: only after the human agrees. -
Who approved. The agent runs
freeze, soapproved_viarecords what the skill says happened; it is not a signature. A hash proves that nothing changed since the lastfreeze, not that a human approved it. For audited work, have a human review the commit that adds the frozen spec (in a pull request, for example).
Off by default. npx lean-method install --git-hook (or answer yes when asked) writes the hook at git rev-parse --git-path hooks/pre-commit. It runs _lean/bin/lean.js check and blocks the commit on errors; warnings do not block. Bypass once with git commit --no-verify.
- It never overwrites a pre-commit hook it did not write (the install reports
git:pre-commit skipped). - Whole-plan
checkincludes every story's frozen hash and test hashes, so a shell edit to frozen intent cannot be committed unnoticed. Trespass needscheck --storyand is not part of it. -
quick-updatekeeps the hook.uninstallremoves it. See CLI Installer.
Intent changed by agreement with the human:
node _lean/bin/lean.js freeze --story E2-1 --unlock # removes frozen_sha256 and contract_sha256
# edit the frozen block (or a contract field) with the human
node _lean/bin/lean.js freeze --story E2-1 --via checkpoint # hash the new block: the human saw itA test judged wrong by the orchestrator (a test that contradicts the spec is a test worker defect):
node _lean/bin/lean.js freeze --story E2-1 --unlock-tests
# fix the test, note it in the Spec Change Log
node _lean/bin/lean.js freeze --story E2-1 --tests test/producer.test.js # list every test again- The implementer never unlocks. It stops and reports.
- After
story/frozen-changedorstory/contract-changed, restore the block or field from the approved version in git. Never re-freeze to makecheckpass. - An unseen
[ASSUMPTION]line (approved_via: plan) that review proves wrong was the orchestrator's mistake: it unlocks, corrects the line, logs it in the Spec Change Log and freezes again with--via plan, without stopping for the human. - A review
intent_gapreverts the code, goes to the human, updates the block, then freezes again (Review and Triage).
-
CLI Plan Tooling: every flag of
freeze,claimandcheck. - lean-build: the step order around freezing and the gate.
- Parallel Teams: lanes, contracts and seams that trespass protects.
- Supported Tools: which tools get the guard hook.
-
Review and Triage: the
intent_gapandbad_specloopbacks.
LEAN 0.10.2 · Repository