Skip to content

fix(install): route the local-bundle approval hint through the remediation catalog - #4506

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
bug-sweep/p4436
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
bug-sweep/p4436

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

One remedy, one message (steward condition). A parked local-bundle executable (hooks, MCP, LSP) now prints the remediation catalog's apm approve command, the same command apm approve --pending prints (#4490). The manifest entry follows as the equivalent grant:

To approve this exact local bundle's hooks, run:
    apm approve '<key>'
then rerun 'apm install <bundle-path>'. The same grant as this entry in apm.yml:
executables:
  allow:
    "<key>":
      hooks: true
  • core/remediation.py: new entry local-bundle-executables-unapproved (W4 drift-trust block): command apm approve {key}, promise "approve this exact local bundle's {exec_type}", then "rerun '{install}'". At user scope the command is apm approve -g '<key>' (security.trust.approve_command) and the reinstall is apm install -g <bundle-path>.
  • security/executables.py local_bundle_approval_hint renders from that entry.
  • Installed-CLI test test_local_bundle_approval_hint_is_the_catalog_remedy_and_runs: parks a bundle hook, asserts the exact catalog text, RUNS the printed apm approve '<key>', reinstalls, then asserts the hook is registered, the lock matches disk (I1) and audit --ci passes.

Fold order: #4490 -> #4506. apm approve <key> for content-bound bundle keys exists only once #4490 (#4437) is in. Standalone CI of this PR on main is therefore expected to be red on that test node; train CI is the gate.

Fold patch (integrator: apply when folding this PR, after #4490, on top of #4283)

#4283's test_bundle_hooks_park_then_register_like_a_source_install (#4216) still asserts the old wording. This patch pins the NEW exact catalog wording and runs the printed apm approve command (no alternation). git apply --check is clean on #4490 @ e20abf8 and on train/0.37-final-2 @ b7bd508:

diff --git a/tests/integration/test_local_bundle_hooks_lifecycle.py b/tests/integration/test_local_bundle_hooks_lifecycle.py
index 0405921f87..78012f591f 100644
--- a/tests/integration/test_local_bundle_hooks_lifecycle.py
+++ b/tests/integration/test_local_bundle_hooks_lifecycle.py
@@ -217,18 +217,16 @@ def test_bundle_hooks_park_then_register_like_a_source_install(
     assert "not approved for this exact bundle content" in text, text
     assert _hook_entries(consumer) == {"PreToolUse": ["Write"]}
 
-    # Apply the printed remedy as printed: the apm.yml executables.allow snippet,
-    # then reinstall ('apm approve <key>' writes the same entry, #4437).
+    # Run the printed catalog remedy (#4436): 'apm approve <key>', then the reinstall.
     printed = re.search(
-        r"add to apm\.yml: executables: allow: \"([^\"]+)\": (\w+): true Then rerun the install",
+        r"To approve this exact local bundle's hooks, run: apm approve '([^']+)' "
+        r"then rerun 'apm install <bundle-path>'\. The same grant as this entry in apm\.yml:",
         text,
     )
     assert printed is not None, text
     printed_key = re.sub(r"\s+", "", printed.group(1))
     assert printed_key == new_key, (printed_key, new_key)
-    manifest = load_yaml(consumer / "apm.yml")
-    manifest["executables"]["allow"][printed_key] = {printed.group(2): True}
-    dump_yaml(manifest, consumer / "apm.yml")
+    world.apm(consumer, "approve", printed_key)
     world.apm(consumer, "install", str(unapproved), "--no-policy")
     assert _hook_entries(consumer) == {"PreToolUse": ["Write", "Bash"]}
     assert _run_hook(world, consumer, "Bash") == "v2\n"

Issue and approved scope

Issue: Fixes #4436 (scope record: #4436 (comment))

Human scope-approval comment: #4436 (comment)

Does this PR complete the issue, or what remains? It completes #4436.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Run through the host test guard:

  • First revision (manifest-edit remedy): pytest tests/unit/core/test_remediation_block_proofs.py tests/unit/core/test_remediation_w4_drift_trust_catalog.py tests/unit/core/test_remediation_catalog_commands.py tests/integration/test_remediation_advice_lifecycle.py::test_local_bundle_approval_hint_is_the_catalog_remedy_and_runs -> 470 passed.
  • Current revision (approve-led): not run locally (no host slot granted); the executed-remedy node needs fix(approve): accept the content-bound local-bundle key install prints (#4437) #4490, so train CI is the gate. The catalog entry was checked in process against the block-test invariants; ruff is clean.
  • pytest tests/quality/test_lifecycle_bug_ledger.py -> 2 passed.
  • ruff check and format (0.15.12) -> clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md:
    user-visible effect first, 25 words or fewer, ending with (#PR);
    breaking changes only under upgrade notes; no Highlights; see
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

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

…ation catalog

The parked local-bundle executable hint keeps the exact key snippet and
renders its next step from the catalog entry local-bundle-executables-unapproved:
add the key under executables.allow, then run 'apm install <bundle-path>'
('-g' at user scope). An installed-CLI test runs the printed remedy.

Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 20:39

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 change alters user-visible wording outside the approved refactor scope, and the lifecycle test corrupts valid bundle paths when constructing the install command.

2 open issues
What changed in this PR

This PR centralizes the approval next step for parked local-bundle executables in APM's remediation catalog, addressing #4436 while retaining the exact approval-key snippet.

Changes:

  • Adds a catalog entry and uses it for project- and user-scope approval hints.
  • Adds a lifecycle proof that applies the printed approval and reinstalls the bundle.
  • Records the regression coverage and user-visible change.
File Description
tests/​unit/​core/​test_remediation_w4_drift_trust_catalog.py Delegates the new entry's execution proof to the lifecycle test.
tests/​integration/​test_remediation_advice_lifecycle.py Tests the catalog hint, approval, reinstall, and audit.
tests/​fixtures/​lifecycle_bug_ledger.json Links #4436 to its regression test.
src/​apm_cli/​security/​executables.py Renders approval advice through the catalog with scope-specific commands.
src/​apm_cli/​core/​remediation.py Defines the local-bundle approval remediation entry.
CHANGELOG.md Documents the updated approval advice.

Review effort: Balanced

Comment thread src/apm_cli/security/executables.py Outdated
f' "{approval_key}":\n'
f" {exec_type}: true\n"
"Then rerun the install."
f" {exec_type}: true\n" + remedy.bind(exec_type=exec_type, manifest=target).sentence()
manifest = load_yaml(consumer / "apm.yml")
manifest["executables"] = {"allow": {key: {"hooks": True}}}
dump_yaml(manifest, consumer / "apm.yml")
command = shlex.split(remedy.command.replace("<bundle-path>", str(bundle)))
…apm approve command

One remedy, one message: a parked local-bundle executable prints the
catalog entry local-bundle-executables-unapproved, 'apm approve <key>'
('-g' at user scope), then the reinstall, with the executables.allow entry
as the same grant. The executed-remedy test runs the printed approve
command and reinstalls; it needs apm approve for content-bound keys (#4490).

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
…tests follow #4506's catalog hint (L1)

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 49abe00 into main Nov 21, 2026
41 of 44 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the bug-sweep/p4436 branch November 21, 2026 05:24
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.

Route the local-bundle approval hint through the remediation catalog

2 participants