Repository navigation
Scope hook obligations to the slice's changed files (#137) - #143
Merged
Merged
Conversation
Hook checks (pre-commit, lefthook) checked the whole tree, so a violation that already existed outside a slice blocked every slice. Verify now builds the argv from the slice's changes against its baseline commit: deleted paths are left out, renamed files pass under their new name, and each path is one argv element run through the broker. Husky has no file-list mode and keeps the whole-tree check, which its description now says. Obligations carry an optional `hook` field; older slices keep the whole-tree command. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hook obligations (pre-commit, lefthook) checked the whole tree, so a violation that already existed outside a slice's files blocked every slice.
What changes
runtime/plan/hooks.mjs: each hook system can say how to run on a list of files (pre-commit run --files <paths>,lefthook run pre-commit --file=<path>…). Husky has none. A path starting with-is passed as./-…to pre-commit, so it cannot read as an option.runtime/plan/obligations.mjs: hook obligations carryhook: <system>, and the description says whether it runs on the slice's changed files or on the whole tree (husky).runtime/verify/verify.mjs: at verify time the argv is built fromchangedPaths(worktree, baseline_commit), leaving out deleted paths (--no-renames, so a renamed file shows up under its new name). It still runs throughbrokerExec(sandbox, no network). Each path is one argv element and nothing goes through a shell. If no paths are left (a slice that only deletes), the obligation passes with a built-in record and the tool is not run.schemas/proof-obligation.schema.json: optionalhookfield (enumnull | pre-commit | husky | lefthook), so the change is backward compatible. Slices planned before this have nohookfield and keep the whole-tree command.docs/security-model.mdand CHANGELOG (Unreleased).Scenario → test
tests/integration/hook-scope.test.mjs› scenario 1tests/integration/hook-scope.test.mjs› scenario 2tests/integration/hook-scope.test.mjs› scenario 3tests/integration/hook-scope.test.mjs› scenario 4tests/unit/plan/hook-obligations.test.mjs› "pre-commit and lefthook are scoped to the changed files; husky keeps the whole tree and says so (#137)"tests/unit/plan/hook-obligations.test.mjs› "a missing tool makes the obligation a person's to confirm, and husky is unaffected" (existing, unchanged)The integration tests use a fake
pre-commitonPATH. It covers*.mjsand fails on any file containingVIOLATION; with--all-filesit would fail on the untouchedsrc/legacy.mjs.Checks
npm test: 3670 tests, 3654 pass, 9 skipped, 7 fail. All 7 failures are intests/unit/daemon/remote.test.mjs(CA signature digest algorithm too weak). That file generates TLS certificates with the local LibreSSL 3.3.6, and the failures are unrelated to this change.Closes #137
🤖 Generated with Claude Code