recursive-lock to lock a phase artifact once it has passed audit. Use verify-locks to confirm that all locked artifacts in a run still match their stored hashes.
recursive-lock
recursive-lock finalizes a phase artifact by writing three fields into it:
Status: LOCKED— marks the artifact as immutableLockedAt— records the UTC timestamp of the lockLockHash— a SHA-256 hash of the artifact content (excluding theLockHashline itself)
Why use the script
TheLockHash must be computed from normalized content (CRLF-normalized, LockHash line stripped) using a specific algorithm. If you write the lock fields by hand, the hash will almost certainly be wrong, and verify-locks will report the artifact as tampered.
Usage
<run-id> with your run directory name and --phase / -Phase with the filename of the artifact you want to lock (for example, 01-as-is.md, 02-to-be-plan.md).
Pre-lock validation
Before writing lock fields, the script runs the same checks aslint-recursive-run. If any lint failures are found, the lock is aborted and the failures are printed. Fix the artifact, then run recursive-lock again.
verify-locks
verify-locks iterates over all artifacts in a run that carry a LockHash field and recomputes the hash from the current file content. Any artifact whose recomputed hash does not match the stored hash is reported as potentially tampered or corrupted.
What it checks
- Every artifact with
Status: LOCKEDhas aLockHashfield - The recomputed SHA-256 hash of each locked artifact matches its stored
LockHash LockedAtis present and parseable
Usage
When to run
Runverify-locks in the following situations:
- Before merging — confirm that no locked artifact was edited after locking
- After any artifact edit — if you needed to correct a locked artifact using an addendum, verify that the lock fields are still intact on the original artifact
- As a CI hygiene check — add
verify-locksto your CI pipeline to catch accidental edits to locked history
Recursive Mode does not rewrite locked history. If you need to correct a locked phase, add an addendum artifact and reconcile it in the downstream phase — do not edit the locked file directly.
verify-locks reports a hash mismatch on a file I didn't touch
verify-locks reports a hash mismatch on a file I didn't touch
Hash mismatches can result from line-ending normalization by your editor, Git, or OS tools. The lock hash is computed from LF-normalized content, so any tool that converts line endings can silently invalidate a hash. Check your Git
core.autocrlf and editor settings.I need to correct a mistake in a locked artifact
I need to correct a mistake in a locked artifact
Do not edit the locked file. Instead, create an addendum artifact in the run directory and explicitly reconcile the correction in the next downstream phase. Record the addendum in the
Inputs section of any phase that depends on the corrected information.