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 unrecorded files at a withheld package's hook path - #4767
TL;DR. When the executables gate withholds a package's hooks (a deny, or no approval), a file sitting at one of that package's own hook destinations that apm.lock.yaml does not record is now named: apm install keeps it and warns with the path, and apm audit --ci fails hook-approval-pins naming the path. Nothing is deleted: without a lock record, APM cannot prove it wrote the file.
Problem (WHY)
A package-namespaced hook file (for example .github/hooks/<pkg>-<name>.json) can exist without a lock record, for example after a checkout restores it without apm.lock.yaml.
If that package's hooks are withheld, install said only that hooks were skipped and audit --ci passed, so nobody was told the file was there.
Approach and implementation
File
Change
integration/copilot_hook_paths.py (new)
Single owner of the Copilot hook file name (copilot_hook_target), used by HookIntegrator; copilot_hook_destinations() computes the files a package would deploy through the read-only shared source selector, without writing.
install/withheld_hooks.py (new)
withheld_hook_files() (one package), locked_withheld_hook_files() (every locked package, judged by current_exec_decision, the install gate's own verdict, on its effective targets via resolve_effective_package_targets), announce_withheld_hook_files() (install warning via kept_file_message). Paths that cannot be computed fail closed: audit fails naming the package, install warns.
install/services.py
After the hooks-skipped warning and target reconcile, install announces such files. Exit code unchanged.
policy/ci_checks.py
hook-approval-pins also fails on these files (path, lock key, denied / not approved). The check list and count are unchanged.
New withheld-hook-file-unrecorded: delete each named file you did not write yourself, then run apm audit --ci.
Scope: per-file hook destinations (the Copilot hooks directory). Merge-based hook targets are a separate follow-up. No deletion, by design.
Trade-offs
Report, never delete. Equal bytes are not proof of ownership; deleting could remove a user's own file.
Folded into hook-approval-pins rather than a new check, so audit output and check counts stay stable.
Issue and approved scope
Issue: none; scope set by the maintainers. Design accepted by the program lead.
Human scope-approval comment: approved by the maintainers.
Does this PR complete the issue? Yes for detection and announcement; retirement stays out of scope by design.
Type of change
Bug fix
New feature
Documentation
Maintenance / refactor
Testing
Tested locally
All existing tests pass (targeted neighbours)
Added tests for new functionality
tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_withheld_hook_a_checkout_brings_back_is_kept_announced_and_detected (installed CLI, lifecycle kit with I1-I9 oracles):
install, approve, deny, install (hook retired); the file comes back without a lock; install keeps it and says Kept <path>: ...; audit --ci exits 1 naming the path; the printed remedy (delete the file, run apm audit --ci) passes.
Owner tests tests/unit/install/test_withheld_hooks.py: a package with legacy per-target hook file names is still checked; a dependency restricted away from Copilot is not reported; uncomputable hook paths fail closed. Each fails on the previous behaviour (3 failed, 2 passed) and passes now (5 passed).
Failing-before (src at main, test kept): R: 'audit --ci' exited 0, expected [1] / All 15 check(s) passed.
Install a package with a hook for target copilot, approve, install; apm deny <pkg>; install (the hook is removed).
Put the hook file back, delete apm.lock.yaml, run apm install: it warns Kept .github/hooks/<pkg>-<name>.json: ... and keeps the file.
apm audit --ci exits 1 naming the path; delete the file 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.
When the executables gate withholds a package's hooks (a deny, or no
approval), a file at one of that package's own hook destinations that
apm.lock.yaml does not record is now named: apm install keeps it and
warns, and apm audit --ci fails the hook-approval-pins check naming the
path. Nothing is deleted, since no lock record proves APM wrote it.
apm-spec-waiver: audit and install diagnostics for executable hook files; 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
Unresolved audit issues can miss restored denied hooks, recommend deleting files outside a dependency’s allowed targets, and cause quadratic lockfile-parsing overhead.
This PR extends APM's executable-gate diagnostics to identify unrecorded files at a withheld package's Copilot hook destinations without deleting files whose ownership cannot be proven.
Changes:
Shares hook destination naming between deployment and read-only inspection.
Adds install warnings and failures under the existing hook-approval-pins audit check.
Adds remediation guidance, documentation, and lifecycle regression coverage.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Audit can recommend deleting a symlink’s referent and falsely flag hook destinations because its target filtering and approval checks diverge from install.
Report the hook symlink path instead of its referent
src/apm_cli/install/exec_gate.py:1028
For an unrecorded hook symlink, portable_relpath() reports the referent instead of the hook destination, including an absolute path when the referent is outside the project. Following the printed deletion remedy can then delete that file while leaving the hook symlink behind, so audit still fails. Preserve the lexical hook destination for the ownership lookup and diagnostics so the remedy names the link itself.
Use per-hook approval when auditing announced destinations
src/apm_cli/install/exec_gate.py:1073
With two hook sources and only one valid pin, this treats the entire package as withheld and fails audit for an unrecorded file at the approved hook's destination. Install's check_executable_approval() admits that hook and skips the new announcement branch, so audit incorrectly labels the path as unapproved and advises deleting it. Use the same hook-approval verdict as install rather than inferring package-wide rejection from the aggregate executable status.
…d when unknown
- Destinations come from the read-only shared hook source selector, so a
package whose hook routing install refuses is still checked.
- Each package is checked only on the targets install deploys it to
(resolve_effective_package_targets with its persisted selection).
- A hook path that cannot be computed fails audit --ci naming the package,
and install warns.
- The detection moves to install/withheld_hooks.py (exec_gate.py stays at
its size); audit resolves the trust context once.
Co-authored-by: Copilot App <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Active issues allow permission errors to silently skip unchecked packages and symlink resolution to misidentify hook paths, potentially directing deletion at the referent instead of the link.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Unreadable hook directories can let unrecorded hooks bypass approval checks, while unsafe parent symlinks and misleading remediation advice risk external-file deletion or leave errors unresolved.
…; unreadable hook sources fail closed
- A hook destination whose parent directory resolves outside the project
is reported as unchecked (inspect manually), never as a file to delete.
- A hook source directory that exists but cannot be listed yields an
unchecked row instead of reading as no hooks.
- Unchecked rows carry their own remediation; deletion advice only names
actual files.
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 because a supported external COPILOT_HOME configuration can break both install and audit, with path-containment and symlink-safety implications.
#4767)
The withheld-hook checkout row already proves the pair: with the deny
recorded and no lock, install keeps the user's file at the hook path and
says so, and audit --ci fails naming it. Baseline 527 -> 526.
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. When the executables gate withholds a package's hooks (a deny, or no approval), a file sitting at one of that package's own hook destinations that
apm.lock.yamldoes not record is now named:apm installkeeps it and warns with the path, andapm audit --cifailshook-approval-pinsnaming the path. Nothing is deleted: without a lock record, APM cannot prove it wrote the file.Problem (WHY)
.github/hooks/<pkg>-<name>.json) can exist without a lock record, for example after a checkout restores it withoutapm.lock.yaml.audit --cipassed, so nobody was told the file was there.Approach and implementation
integration/copilot_hook_paths.py(new)copilot_hook_target), used byHookIntegrator;copilot_hook_destinations()computes the files a package would deploy through the read-only shared source selector, without writing.install/withheld_hooks.py(new)withheld_hook_files()(one package),locked_withheld_hook_files()(every locked package, judged bycurrent_exec_decision, the install gate's own verdict, on its effective targets viaresolve_effective_package_targets),announce_withheld_hook_files()(install warning viakept_file_message). Paths that cannot be computed fail closed: audit fails naming the package, install warns.install/services.pypolicy/ci_checks.pyhook-approval-pinsalso fails on these files (path, lock key, denied / not approved). The check list and count are unchanged.reference/baseline-checks.md(hook-approval-pins),apm-usage/governance.md.core/remediation.pywithheld-hook-file-unrecorded: delete each named file you did not write yourself, then runapm audit --ci.Scope: per-file hook destinations (the Copilot hooks directory). Merge-based hook targets are a separate follow-up. No deletion, by design.
Trade-offs
hook-approval-pinsrather than a new check, so audit output and check counts stay stable.Issue and approved scope
Issue: none; scope set by the maintainers. Design accepted by the program lead.
Human scope-approval comment: approved by the maintainers.
Does this PR complete the issue? Yes for detection and announcement; retirement stays out of scope by design.
Type of change
Testing
tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_withheld_hook_a_checkout_brings_back_is_kept_announced_and_detected(installed CLI, lifecycle kit with I1-I9 oracles):install, approve, deny, install (hook retired); the file comes back without a lock;
installkeeps it and saysKept <path>: ...;audit --ciexits 1 naming the path; the printed remedy (delete the file, runapm audit --ci) passes.Owner tests
tests/unit/install/test_withheld_hooks.py: a package with legacy per-target hook file names is still checked; a dependency restricted away from Copilot is not reported; uncomputable hook paths fail closed. Each fails on the previous behaviour (3 failed, 2 passed) and passes now (5 passed).R: 'audit --ci' exited 0, expected [1]/All 15 check(s) passed.1 passed.Validation commands and results
How to test
copilot, approve, install;apm deny <pkg>; install (the hook is removed).apm.lock.yaml, runapm install: it warnsKept .github/hooks/<pkg>-<name>.json: ...and keeps the file.apm audit --ciexits 1 naming the path; delete the file 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]