Repository navigation
feat(hooks): stage consent-aware Claude standalone inline hooks - #3332
Draft
Daniel Meppiel (danielmeppiel) wants to merge 1 commit into
Draft
Daniel Meppiel (danielmeppiel) wants to merge 1 commit into
Daniel Meppiel (danielmeppiel) wants to merge 1 commit into
Conversation
Route selected standalone hooks through package consent and shared resource owners. Withhold whole denied primitives and replay current consent without mutating the workspace. Native certification, public sibling composition and remaining acceptance evidence remain explicit draft gates for #3227. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: d9a7aa47-b6e4-4956-9ba9-4467b9d2a9fe
Collaborator
Author
|
Status: parked as a draft (maintainer decision, 2026-11-12). This builds on the same Claude native groundwork as #3290, which is being revived first. Once #3290 lands, this will be rebased onto it and completed against #3227's accepted scope, including the native Claude check for commands, skills and agents at project and user scope. Posted with AI assistance on behalf of Daniel Meppiel (@danielmeppiel). |
This was referenced Nov 12, 2026
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.
fix(hooks): stage consent-aware Claude standalone inline hooks
Description
TL;DR
This held draft adds APM-side consent, whole-primitive withholding, resource relocation and read-only replay for selected Claude commands, skills and non-plugin agents with structured inline hooks. It reuses package/type consent rather than creating a new grant store or promoting scoped hooks into global settings. Installed-CLI witnesses pass, but this does not complete #3227 or certify any native Claude version.
Warning
Not ready to merge. Native command/skill/agent x project/user certification is absent, native trust/probe permission remains withheld, public sibling composition and additional acceptance work remain below. No native client or hook was invoked.
Problem (WHY)
These are observed failures, not inferred native-runtime claims. The accepted scope explicitly says "withhold the whole affected hook-bearing primitive rather than silently remove protective hooks". The evidence follows Agent Skills' "Refine with real execution": retain failures as well as successful reruns.
Approach (WHAT)
This keeps the fragile admission sequence explicit rather than adding a second authority: "Be prescriptive".
Implementation (HOW)
src/apm_cli/install/deployable_source_plan.py,deployment_plan.pysrc/apm_cli/integration/inline_hooks.pysrc/apm_cli/integration/hook_source_selection.py,hook_integrator.py,hook_bundle.pyinline_for(target), strict required-resource checks and edited-resource protection. Default global-hook behavior remains separate.src/apm_cli/install/exec_gate.py,template.py,src/apm_cli/security/executables.py_local; user scope reads its real manifest.src/apm_cli/commands/approve.pysrc/apm_cli/install/services.py,src/apm_cli/integration/command_integrator.py,agent_integrator.py,skill_integrator.py,skill_preflight.pysrc/apm_cli/install/context.py,phases/cleanup.py,src/apm_cli/integration/cleanup.pysrc/apm_cli/install/drift.py,src/apm_cli/policy/ci_checks.py,src/apm_cli/commands/audit.py.apm/architecture/owners/install-deployment.json,scripts/architecture_linter/checks/install_inline_hooks.py,install_deployment_analyzers.py,tests/integration/test_architecture_owner_rule_mutations.pytests/integration/test_inline_hook_consent_lifecycle.py,tests/unit/integration/test_inline_hooks.py,tests/integration/test_executables_gate_integration.pydocs/src/content/docs/producer/author-primitives/{hooks-and-commands,skills}.md,docs/src/content/docs/reference/cli/{approve,audit}.mdpackages/apm-guide/.apm/skills/apm-usage/{commands,governance,package-authoring}.mdSource anchors: selected-source owner and native-only selector.
Diagrams
Dashed nodes show the inline-specific path; deployment and scratch replay consume the same selected sources and effective consent.
flowchart LR subgraph Selection[Selection] A[DeployableSourcePlan.create] B[read_inline_hook_document] A --> B end subgraph Consent[Existing package consent] C{check_executable_approval} B --> C end subgraph Projection[Claude projection] D["for_target: withhold whole primitive"] E[select_hook_sources and bundle copier] F["Command, Skill and Agent integrators"] C -->|Pending or denied| D C -->|Allowed or gate disabled| E E --> F end subgraph Audit[Read-only replay] G["run_replay: selected sources and current consent"] H[diff_scratch_against_project] G --> H end D --> H F --> H classDef new stroke-dasharray: 5 5; class B,D,E,F,G new;Trade-offs
evals/) from skill bundles at install time #3215 author subtraction/provenance and Hook files cannot be limited to a target: Copilot events leak into Claude settings #3226 native placement validation must be composed from their actual public carriers. This draft exposes the shared resource seam without claiming that integration is complete.Benefits
Issue and approved scope
Issue: Related to #3227.
Human scope-approval comment: #3227 (comment); explanatory record: #3227 (comment). Separate current-session execution delegation authorized implementation. The trusted helper returned
record-present,authorizes_implementation:false; that evidence was not treated as permission.This PR does not complete the issue. Preserve Roger Siegenthaler (@siegenthalerroger)'s original investigation attribution; no implementation claim or assignment is attributed to them.
Remaining acceptance gates:
evals/) from skill bundles at install time #3215 descriptor provenance, author-subtracted declaration inventory and retained-source validation ordering, including surviving inline projection.placement=settings|skill|agentvalidation; commands use skill placement, agents do not accept skill-onlyonce. Remove temporary validation vocabulary.Type of change
Testing
Validation
Exact head:
5e30371ba77305382201645a6c14b90f51593891, based on actual public main3b9a8503e0bf5978253f769f823bb84340edfc4a. Local checks below are not a claim of green GitHub CI, full-suite completion or native certification.Exact commands and observed results
Every test/quality command below ran inside the campaign admission wrapper:
python3 /Users/danielmeppiel/.copilot/session-state/f79e464c-180e-4be3-9056-0773aa679a1a/files/campaign-em/run-heavy.py --lane 3227 --timeout 1800 -- env PATH="$PWD/.venv/bin:$PATH" APM_BINARY_PATH="$PWD/.venv/bin/apm" bash /Users/danielmeppiel/.copilot/session-state/d9a7aa47-b6e4-4956-9ba9-4467b9d2a9fe/files/qualify-inline.sh— exit 0. Owned Python 3.12.10, CLI shebang and editable import belong to this checkout.uv run --frozen --extra dev ruff check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pyAll checks passed!uv run --frozen --extra dev ruff format --check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py2088 files already formatteduv run --frozen --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pyYour code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)bash scripts/lint-auth-signals.sh[+] auth-signal lint cleanYAML, portable-path and 2100-line CI mirrors passedbash scripts/lint-architecture-boundaries.sh.venv/bin/python -m pytest -q tests/integration/test_inline_hook_consent_lifecycle.py tests/unit/integration/test_inline_hooks.py tests/integration/test_executables_gate_integration.py tests/unit/install/test_security_scan_scope.py 'tests/integration/test_architecture_owner_rule_mutations.py::test_owner_rule_catches_its_guard_mutation[install-deployment-inline-hooks]' tests/integration/test_architecture_owner_rule_mutations.py::test_owner_rules_report_nothing_before_mutation tests/integration/test_architecture_owner_rule_mutations.py::test_matrix_covers_every_registry_guard_exactly_once --basetemp=/Users/danielmeppiel/.copilot/session-state/d9a7aa47-b6e4-4956-9ba9-4467b9d2a9fe/files/pytest-inline-publish --tb=short156 passed in 117.69s (0:01:57)node --test docs/scripts/check-links.test.mjsgit diff --exit-codeFinal owner-named diagram separately passed:
python3 /Users/danielmeppiel/.copilot/session-state/f79e464c-180e-4be3-9056-0773aa679a1a/files/campaign-em/run-heavy.py --lane 3227 --timeout 1800 -- mmdc -i /Users/danielmeppiel/.copilot/session-state/d9a7aa47-b6e4-4956-9ba9-4467b9d2a9fe/files/inline-hook-flow.mmd -o /Users/danielmeppiel/.copilot/session-state/d9a7aa47-b6e4-4956-9ba9-4467b9d2a9fe/files/inline-hook-flow.svg --quiet— exit 0.Failure history retained: initial three forbidden-deployment witnesses; two withholding-audit failures; one user-path replay failure; earlier
609 passed, 89 failedarchitecture run (duplicate owner registration, misplaced target-specific routing and upstream ambiguous mutation); targeted13 passed, 3 failed(first-party fixture layout plus two genuine approval-inventory failures). A prepublication guard also caught 2101 lines in HookIntegrator; its existing docstring was shortened. These were corrected/composed and the bounded exact-head run above passed. This does not assert that the original full mutation run or the full ordinary suite was rerun green.Scenario Evidence
Paths below are in
tests/integration/test_inline_hook_consent_lifecycle.pyunless otherwise stated.test_denied_inline_hook_withholds_whole_primitive(regression-trap for #3227)test_approved_inline_hook_preserves_native_definitiontest_inline_hook_approval_revocation_and_readonly_audittest_invalid_inline_definition_fails_before_activationtest_inline_withholding_does_not_change_other_targettest_edited_inline_primitive_is_not_silently_revoked,test_inline_resource_edits_block_reinstallation_without_overwritetest_first_party_inline_hooks_do_not_need_dependency_approval,test_approval_inventory_uses_actual_selected_inline_sourcestests/unit/integration/test_inline_hooks.pyHow to test
Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
Pending, not N/A. Existing executable admission, deny precedence and selected-source promises (
req-sc-009,req-sc-011,req-sc-015) are affected. Whole-primitive semantics and scoped native support require the normal specification/conformance treatment before this held draft can land. No spec waiver is claimed.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com