Skip to content

Scope hook obligations to the slice's changed files (#137) - #143

Merged
QuintinBotes merged 3 commits into
mainfrom
goal/137-scope-hook-obligations
Nov 26, 2026
Merged

QuintinBotes merged 3 commits into
mainfrom
goal/137-scope-hook-obligations

Conversation

@QuintinBotes

Copy link
Copy Markdown
Owner

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 carry hook: <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 from changedPaths(worktree, baseline_commit), leaving out deleted paths (--no-renames, so a renamed file shows up under its new name). It still runs through brokerExec (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: optional hook field (enum null | pre-commit | husky | lefthook), so the change is backward compatible. Slices planned before this have no hook field and keep the whole-tree command.
  • Docs: docs/security-model.md and CHANGELOG (Unreleased).

Scenario → test

# Scenario Test
1 Pre-existing violation in an untouched file → passes tests/integration/hook-scope.test.mjs › scenario 1
2 Slice changes a violating file → fails, output names it tests/integration/hook-scope.test.mjs › scenario 2
3 No covered files changed → passes without a whole-tree run (and a deletion-only slice does not run the tool) tests/integration/hook-scope.test.mjs › scenario 3
4 Deleted paths not passed, renamed paths passed under new name tests/integration/hook-scope.test.mjs › scenario 4
5 Tool without a file-list mode keeps whole-tree and says so tests/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)"
6 Missing tool still left for a person to confirm 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-commit on PATH. It covers *.mjs and fails on any file containing VIOLATION; with --all-files it would fail on the untouched src/legacy.mjs.

Checks

npm test: 3670 tests, 3654 pass, 9 skipped, 7 fail. All 7 failures are in tests/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

Quintin Botes and others added 3 commits November 26, 2026 20:39
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>
@QuintinBotes
QuintinBotes merged commit 20067ee into main Nov 26, 2026
12 checks passed
@QuintinBotes
QuintinBotes deleted the goal/137-scope-hook-obligations branch November 26, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scope hook obligations to the slice's changed files

1 participant