Repository navigation
Skip unapproved project hooks via declaration-digest trust store - #282
Open
raymondginger2018-sudo wants to merge 1 commit into
Open
raymondginger2018-sudo wants to merge 1 commit into
raymondginger2018-sudo wants to merge 1 commit into
Conversation
Borrowed from ZCode's rule: a project's hooks.json is workspace-supplied code. declaration_digest(workspace) hashes only canonical declaration fields (event, matcher, command, timeout, priority, type) so cosmetic edits keep approval while semantic changes rotate the digest. HookTrustStore is an atomic JSON store; a corrupt file degrades to empty. discover_hooks/HooksEngine.discover accept trust_store= keyword — when None (default) discovery is exactly the old behavior; when given, project sources are skipped with a warning until their digest is approved.
This branch has not been deployed
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.
Summary
Treats a project's
hooks.jsonas workspace-supplied code: project hook declarations are gated behind an explicit, content-addressed approval (borrowed from ZCode's trust rule). Discovery defaults are unchanged — the gate activates only when a caller passes atrust_store.Changes
core/harness/hooks/trust.py:declaration_digest(workspace, *, home=None, paths=None)— sha256 over canonical declaration fields only (event, matcher, command, timeout, priority, type): cosmetic edits keep approval, semantic changes rotate the digest. User-level config never feeds the digest.HookTrustStore— atomic JSON store; a corrupt file degrades to empty (treated as "nothing approved"), never crashes.core/harness/hooks/discovery.py:discover_hooks(..., *, trust_store=None)— when given and the workspace digest is not approved, project hook sources are skipped with a warning (user-level hooks unaffected).core/harness/hooks/engine.py:HooksEngine.discover(..., trust_store=None)passthrough.core/harness/hooks/__init__.py: export the new trust surface.tests/test_hook_declaration_trust.py(10 tests: digest canonicalization, digest rotation on semantic change, store approve/revoke/corruption, engine opt-in default, and an end-to-enddiscover_hooksgate test).Tests
tests/test_hook_declaration_trust.py— 10 passedtests/test_hooks.py— failure set identical to upstream baseline (32 baseline reds; zero new failures vs pristine checkout)pre-commit run --all-files(ruff 0.15.21) — passedNotes