You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(audit): name merged hook config entries matching a withheld package's hook - #4798
TL;DR. This extends #4767 to targets that merge hooks into one shared config file: .claude/settings.json, .cursor/hooks.json, .codex/hooks.json and the other merge targets. When the executables gate withholds a package's hooks (denied or unapproved), an entry in that file that renders exactly as the package's own hook, and that no ownership record attributes to another source, is now named. apm install keeps it and warns; apm audit --ci fails hook-approval-pins naming the file and the event. Nothing is removed.
Note
Dependency order: none. Builds on #4767 (merged); main is merged in.
Fixes#4821: apm audit --ci reports a blocking org policy outcome once again. The withheld-hook scan defers to the policy-outcome route on PolicyViolationError instead of failing hook-approval-pins (and drift) with the same cause. P|audit-ci|empty/block is now a lifecycle_smoke row that forbids the repeated cause; it fails without the fix (output lacks /(policy.fetch_failure_default=block)/, output has /hook-approval-pins\W+Blocked by org policy/).
Approach and implementation
File
Change
install/withheld_merged_hooks.py (new)
withheld_merged_hook_entries() renders the package's entries per merge target through the integrator's own read-only steps (shared source selector, _rewrite_hooks_data, the per-target native converters and legacy shapes). It re-applies sidecar ownership, then names entries that match and are unattributed or attributed to that package (canonical marker or an unambiguous legacy alias). A config reached through a symlink, an unreadable or malformed config, or an unreadable hook source fails closed as unchecked.
install/withheld_hooks.py
Audit and install fold the merged rows in; an unreadable decision counts as unchecked for any scanned target.
policy/ci_checks.py
Entry rows get their own message and remedy, separate from file rows and unchecked rows.
core/remediation.py
withheld-hook-entry-unrecorded: remove each named hook entry you did not add yourself, then run apm audit --ci.
With target claude, install a package with a hook, then deny it; put its entry back into .claude/settings.json with no apm-hooks.json and no lock record.
Run apm install: it warns Kept hook entry .claude/settings.json: SessionStart: ....
Run apm audit --ci: it exits 1 naming the file and event. Remove the entry and it passes.
Changelog
One fragment per section, changelog.d/<pr>.<section>.md, holding
one line: user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes only under upgrade notes; no Highlights; no
new lines under ## [Unreleased]. See changelog.d/README.md and .github/instructions/changelog.instructions.md.
…ge's hook
For targets that merge hooks into one config file (Claude settings.json,
Cursor and Codex hooks.json, and the other merge targets), an entry that
renders exactly as a withheld package's own hook and that no ownership
record attributes to another source is now named: apm install keeps it
and warns, apm audit --ci fails hook-approval-pins naming the file and
event. Nothing is removed. An unreadable merged config fails closed.
apm-spec-waiver: audit and install diagnostics for executable hook entries; no OpenAPM-observable contract changes.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The scan can miss legacy withheld hooks, abort on null hook configurations, and recommend removing entries from external symlink targets, while duplicated rendering logic risks inconsistent audit results.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Malformed hook configurations can incorrectly pass approval checks, and invalid ownership metadata can trigger uncaught TypeErrors instead of unchecked-path diagnostics.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Two critical gaps let malformed null hook containers bypass approval checks and unreadable merged-hook directories leave matching entries without entry or unchecked-path warnings.
An explicitly null hook container, such as {"hooks": null}, is treated as if the container were absent. The scan consequently returns no entries instead of an unchecked-path row, allowing hook-approval-pins to pass this malformed config. Distinguish a missing key from a present null value so the existing object validation rejects the latter.
Check merged hook directory readability before source selection
For a merged-only install, an unreadable hooks/ or .apm/hooks/ directory can produce an empty descriptor selection, so an existing matching entry is silently left without either the entry warning or the unchecked-path warning. The audit caller checks directory readability first, but announce_withheld_hook_files() only gets that check for Copilot targets. Run the shared _require_readable_hook_dirs() check before selecting merged sources so this install path also reports the unreadable source as unchecked.
… bare leaf marker is unchecked
An entry a marker attributes to the withheld package is its receipted
deployment: install retires it and exec-status-current reports it, so
hook-approval-pins no longer fails first and hides that verdict
(test_frozen_stale_exec_status_lifecycle). A bare leaf marker the lock
cannot resolve to this package is reported as ambiguous, never skipped.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical finding remains: restoring the merged config and ownership sidecar after the lock records denied leaves this package’s hook unreported while exec-status-current still passes, requiring a reporting fix and regression coverage.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because empty source markers can leave denied-package hooks unreported, while inaccessible configuration paths can abort scans instead of producing diagnostic warnings.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unresolved hook-scan defects can silently miss denied hooks, let malformed metadata bypass audit checks, and abort scans for supported external user-config roots.
…l user roots and unreadable sources handled
- A blank _apm_source is treated as unattributed, never as another owner.
- An explicit null hook container is malformed (unchecked), not absent.
- A user-scope config root outside $HOME (CLAUDE_CONFIG_DIR, CODEX_HOME)
is scanned instead of aborting the scan.
- The install-side render checks hook source readability, as audit does.
Co-authored-by: Copilot App <[email protected]>
…ok-approval-pins (#4821)
The withheld-hook scan resolves the executables trust context for any
package that declares executables. Under fetch_failure_default=block the
resulting PolicyViolationError failed hook-approval-pins, which made the
audit skip its policy-outcome route and repeat the cause under drift. The
scan now defers to that route, which reports the block and fails.
P|audit-ci|empty/block becomes a lifecycle_smoke row that forbids the
repeated cause.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical policy-provider mismatch can let an already-denied package escape restored-hook detection when a valid --policy override succeeds despite unavailable auto-discovery.
The withheld-hook scan classified its own auto-discovered policy, so an
explicit --policy or a --no-cache split could defer a block the audit's
policy route never reports. hook-approval-pins now takes the audit's
policy_fetch and classifies it exactly as _route_ci_policy_outcome does:
it defers only when that route blocks, and otherwise judges with the
route's policy (trust built by exec_gate.trust_context_for_policy, a
registered trust caller). Without an audit discovery a policy block
fails closed.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to weigh an unpublished finding that deployed-hook checks can reject valid policy overrides or report blocking causes through the wrong route.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to weigh omitted findings involving ignored policy overrides, suppressed policy-outcome reporting, and false hook-check failures for packages without applicable hooks.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The pin scan still auto-discovers policy before using the shared audit provider, potentially rejecting valid --policy overrides or suppressing policy-outcome reporting for deployed-hook packages.
A withheld package's hook entry put back in .claude/settings.json is kept,
announced and fails audit --ci; a blank marker attributes nothing; a
non-string marker or symlinked config fails the audit closed; the user's own
hook is not named.
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (51e2e65, main f53aa79). Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- strict known cells for an MCP entry of a runtime no longer targeted (#4784)
and a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Ledger regenerated (baseline 3, known-failing 1, required 2419).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (2e8592d, main acb0423). Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- strict known cells for an MCP entry of a runtime no longer targeted (#4784)
and a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Ledger regenerated (baseline 3, known-failing 1, required 2419).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (2e8592d) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Ledger regenerated (baseline 3, known-failing 1, required 2419).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (699e837) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Review folds: I5 admits the compile record only as a regular file and its
newly created ancestor directories; run/preview, content-types, plugin-root
hook, lane C fresh twin and source-machine bundle identity oracles tightened.
Ledger regenerated (baseline 3, known-failing 1, required 2419).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (699e837) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Review folds: I5 admits the compile record only as a regular file and its
newly created ancestor directories; run/preview, content-types, plugin-root
hook, lane C fresh twin, source-machine bundle identity, self_defined warn and
hook bundle update oracles tightened. U-USER-SCOPE-ORG-POLICY removes explicit
user-scope cells only: the four scope-free T1 bin x denied-dependency cells are
required, witnessed by the project matrix refusals.
Ledger regenerated (baseline 3, known-failing 1, required 2423).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (699e837) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Review folds: I5 admits the compile record only as a regular file and its
newly created ancestor directories; run/preview, content-types, plugin-root
hook, lane C fresh twin, source-machine bundle identity, self_defined warn and
hook bundle update oracles tightened; the self_defined warn row is a real
warn-mode policy now and is strict known on #5070. U-USER-SCOPE-ORG-POLICY removes explicit
user-scope cells only: the four scope-free T1 bin x denied-dependency cells are
required, witnessed by the project matrix refusals.
Ledger regenerated (baseline 3, known-failing 1, required 2423).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (699e837) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Review folds: I5 admits the compile record only as a regular file and its
newly created ancestor directories; run/preview, content-types, plugin-root
hook, lane C fresh twin, source-machine bundle identity, self_defined warn and
hook bundle update oracles tightened; the self_defined warn row is a real
warn-mode policy now and is strict known on #5070; the #4826 refusal row checks rollback. U-USER-SCOPE-ORG-POLICY removes explicit
user-scope cells only: the four scope-free T1 bin x denied-dependency cells are
required, witnessed by the project matrix refusals.
Ledger regenerated (baseline 3, known-failing 1, required 2423).
Co-authored-by: Copilot App <[email protected]>
…C, v0.38 sweep)
Stacked on corpus train 6 (699e837) and merged with main fc1866b. Cars:
- policy promise rows in test_policy_promises.py with a control each (scripts
deny, self_defined, max_depth, require_resolution, source_attribution,
unmanaged_files, fail_on_drift, pinned constraint, explicit includes,
transitive MCP trust, content types); the #4826 install refusal is required
now that #4853 fixed it on main.
- an MCP entry of a runtime no longer targeted (#4784) takes main's required
row (its fix landed); a strict known cell for a codex hook copy that cannot read its plugin's skill (#2824).
- lane C incremental deploy differential (kit from #4849).
- v0.38.0 sweep: compile dependency-policy run and preview (#4734), a converged
install writes nothing (#4790), hook bundle approval pin (#4688), a registry
URL on a local host (#4521).
- burndown: a denied local bundle is refused unwritten (#4646), present-
provenance-unknown x denied-executable (#4767), audit --ci judges locked
content with apm_modules gone, merged-hook entry detection end to end (#4798).
Review folds: I5 admits the compile record only as a regular file and its
newly created ancestor directories; run/preview, content-types, plugin-root
hook, lane C fresh twin, source-machine bundle identity, self_defined warn and
hook bundle update oracles tightened; the self_defined warn row is a real
warn-mode policy now and is strict known on #5070; the #4826 refusal row checks rollback; no-write stamps add the POSIX change time. U-USER-SCOPE-ORG-POLICY removes explicit
user-scope cells only: the four scope-free T1 bin x denied-dependency cells are
required, witnessed by the project matrix refusals.
Ledger regenerated (baseline 3, known-failing 1, required 2423).
Co-authored-by: Copilot App <[email protected]>
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
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.
Description
TL;DR. This extends #4767 to targets that merge hooks into one shared config file:
.claude/settings.json,.cursor/hooks.json,.codex/hooks.jsonand the other merge targets. When the executables gate withholds a package's hooks (denied or unapproved), an entry in that file that renders exactly as the package's own hook, and that no ownership record attributes to another source, is now named.apm installkeeps it and warns;apm audit --cifailshook-approval-pinsnaming the file and the event. Nothing is removed.Note
Dependency order: none. Builds on #4767 (merged); main is merged in.
Fixes #4821:
apm audit --cireports a blocking org policy outcome once again. The withheld-hook scan defers to the policy-outcome route onPolicyViolationErrorinstead of failinghook-approval-pins(and drift) with the same cause.P|audit-ci|empty/blockis now alifecycle_smokerow that forbids the repeated cause; it fails without the fix (output lacks /(policy.fetch_failure_default=block)/,output has /hook-approval-pins\W+Blocked by org policy/).Approach and implementation
install/withheld_merged_hooks.py(new)withheld_merged_hook_entries()renders the package's entries per merge target through the integrator's own read-only steps (shared source selector,_rewrite_hooks_data, the per-target native converters and legacy shapes). It re-applies sidecar ownership, then names entries that match and are unattributed or attributed to that package (canonical marker or an unambiguous legacy alias). A config reached through a symlink, an unreadable or malformed config, or an unreadable hook source fails closed as unchecked.install/withheld_hooks.pypolicy/ci_checks.pycore/remediation.pywithheld-hook-entry-unrecorded: remove each named hook entry you did not add yourself, then runapm audit --ci.reference/baseline-checks.md,apm-usage/governance.md.Trade-offs
Issue and approved scope
Issue: none; scope set by the maintainers. Follow-up to #4767.
Human scope-approval comment: approved by the maintainers.
Does this PR complete the issue? Yes for merged-config targets.
Type of change
Testing
tests/unit/install/test_withheld_merged_hooks.pydeploys with the realHookIntegratorand covers:locked_withheld_hook_files) names the entry.Red-first: with detection disabled, 6 failed and 1 passed; with it, all pass.
Validation commands and results
How to test
claude, install a package with a hook, then deny it; put its entry back into.claude/settings.jsonwith noapm-hooks.jsonand no lock record.apm install: it warnsKept hook entry .claude/settings.json: SessionStart: ....apm audit --ci: it exits 1 naming the file and event. Remove the entry and it passes.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedCo-authored-by: Copilot [email protected]