Skip to content

fix(exec): omit the project-only policy explain hint for -g hook and canvas denies (#4296) - #4297

Closed
Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
mainfrom
danielmeppiel-scope-aware-deny-hints-4296
Closed

Daniel Meppiel (danielmeppiel) wants to merge 3 commits into
mainfrom
danielmeppiel-scope-aware-deny-hints-4296

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

apm policy explain resolves only the current project's apm.yml, so it cannot explain a user-scope (apm install -g) installation: outside a project it fails with "No apm.yml found", and inside one it explains the wrong package set. At user scope, the deny line for a hook or canvas extension now stops at the deny (<pkg>: hooks skipped (denied).) instead of pointing to that command. Project-scope wording is unchanged.

File Change
src/apm_cli/install/exec_gate.py explain_hint_applies(ctx) (false at InstallScope.USER); executable_skip_reason(..., explain_hint=); log_hooks_skip passes it.
src/apm_cli/install/target_warnings.py log_canvas_skip passes it.
tests/integration/test_bin_canvas_deny_diagnostics_lifecycle.py Installed-CLI test at -g, parametrized over canvas (copilot) and hooks (claude): approve via the user manifest, install, apm deny --user, reinstall; asserts the exact line <pkg>: <kind> skipped (denied)., no policy explain, no apm approve hint, deployed files removed.
CHANGELOG.md One Fixed line.

Out of scope (remaining in #4296): a user-scope mode for apm policy explain itself, after which the hint can return at -g.

Issue and approved scope

Refs #4296

Human scope-approval comment: #4296 (comment)

Does this PR complete the issue, or what remains? Partial: the hints are scope-aware; the user-scope policy explain mode remains.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally (after merging main): APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest -n 2 tests/integration/test_bin_canvas_deny_diagnostics_lifecycle.py tests/integration/test_pinned_hook_policy_deny_lifecycle.py tests/integration/test_executables_deny_retires_hooks_lifecycle.py: 23 passed. Without the src/ change, both new -g cases fail.
  • All existing tests pass (CI)
  • Added tests for new functionality (if applicable)

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

apm-spec-waiver: diagnostic wording at user scope only; no OpenAPM-observable behaviour change

  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

…canvas denies (#4296)

'apm policy explain' resolves only the current project, so at user scope the
deny line for a hook or canvas extension stops at the deny.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The integration test can modify a developer’s real Claude settings, while user-scope denials still show misleading project-only guidance and approval prompts.

3 open issues
What changed in this PR

This PR makes APM's hook and canvas deny diagnostics scope-aware, omitting the project-only apm policy explain hint during user-scope (-g) installs. It addresses the diagnostic portion of #4296; user-scope support for the explain command remains deferred.

Changes:

  • Add a shared scope check while preserving project-scope wording.
  • Add installed-CLI coverage for user-scope hook and canvas denial, reinstall, and cleanup.
  • Record the diagnostic correction in the changelog.
File Description
tests/​integration/​test_bin_canvas_deny_diagnostics_lifecycle.py Add user-scope denial and deployment-cleanup coverage.
src/​apm_cli/​install/​target_warnings.py Apply scope-aware hint handling to canvas skips.
src/​apm_cli/​install/​exec_gate.py Add the shared scope check and apply it to hook skips.
CHANGELOG.md Document the user-scope diagnostic correction.

Review effort: Balanced

root = isolated.home / deploy_root
root.mkdir(parents=True, exist_ok=True)
env = {**isolated.subprocess_env(), "COLUMNS": "1000"}
env.pop("COPILOT_HOME", None)
Comment on lines +630 to +631
reason = executable_skip_reason(
ctx, package_name, label, EXEC_TYPE_HOOKS, "hooks", explain_hint=explain_hint_applies(ctx)
_pkg_label,
EXEC_TYPE_CANVAS,
"canvas extension(s)",
explain_hint=explain_hint_applies(ctx),
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Superseded by #4275, which shipped the scope-aware deny hint. #4498 pins the behaviour. Closing; thank you.

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.

2 participants