Skip to content

fix(approve): correct the remediation after apm deny - #3979

Closed
Daniel Meppiel (danielmeppiel) wants to merge 2 commits into
mainfrom
danielmeppiel/fix-3957-deny-remediation
Closed

Daniel Meppiel (danielmeppiel) wants to merge 2 commits into
mainfrom
danielmeppiel/fix-3957-deny-remediation

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

Fixes the remediation users get after apm deny. Before this PR it was wrong on every surface:

  1. --frozen wording. A denied server the lock still admits now fails with admitted in apm.lock.yaml but the executables gate now parks it (denied); see 'apm policy explain <pkg>' .... Before, it said "no longer declared in apm.yml", and with feat(security): portable, content-pinned approval for dependency executables (#3902) #3918 it said "not approved". A lock-only name that carries gate omission evidence now prints is now left out (<reason>), never "no longer declared".
  2. apm approve after a deny. Naming a package lifts its deny in the store being written (Cleared deny for <pkg>), the mirror of apm deny dropping the matching allow. --all and --recommended skip denied packages instead of lifting them. If a deny in another layer (--user or org) still blocks the package, approve exits 1, names that layer, and says how to lift it. It never prints "Approved" without effect.
  3. --user outside a project. apm deny --user and apm approve --user no longer fail with "No apm.yml found". Outside a project they read the packages apm install -g installed (APM_HOME) and write only $APM_HOME/config.json.

Docs for approve, deny, install, baseline-checks and the apm-usage skill are updated.

Issue and approved scope

Issue: Fixes #3957

Human scope-approval comment: the newest (superseding) apm-scope:v1 record on #3957 (Review contact: Daniel Meppiel (@danielmeppiel)).

Does this PR complete the issue, or what remains? It completes all three parts. Deny semantics are otherwise unchanged.

Type of change

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

Testing

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

Validation evidence:

  • New tests/integration/test_deny_remediation_lifecycle.py has three tests, one per scope part.
    • test_frozen_names_the_gate_and_approve_lifts_a_project_deny passed locally.
    • The other two timed out at 120 s while the shared host's load average was around 170. CI is the authority for them.
    • The red-team repro scripts showed the same behaviour by hand: user deny followed by project approve exits 1 with still denied (user-deny) ... apm approve --user ./pkgs/tools, and deny --user outside a project exits 0 and writes config.json.
  • On main, all three parts reproduce: frozen fails with the wrong text, approve prints "Approved" with exit 0 and no effect, and deny --user fails with "No apm.yml found".
  • pytest tests/unit/commands/test_approve_deny.py tests/unit/integration/test_mcp_config_view.py tests/unit/integration/test_frozen_mcp_evidence.py tests/spec_conformance/test_portable_mcp_approval_reqs.py tests/unit/security -n 8: 400 passed.
  • ruff check / ruff format --check (ruff 0.15.12, as pinned in uv.lock): clean.

Changelog

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

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

- install --frozen names the executables gate for a denied server instead
  of 'no longer declared' or 'not approved'.
- apm approve <pkg> lifts a deny in the store it writes, --all and
  --recommended skip denied packages, and a deny in another layer makes
  approve exit 1 naming that layer instead of reporting success.
- apm deny --user and apm approve --user work outside a project and read
  the packages apm install -g installed.

Closes #3957

apm-spec-waiver: CLI remediation wording and approve/deny store handling; no OpenAPM-observable manifest, lockfile or resolution behaviour changes.

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

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

Deny detection and key matching can incorrectly skip approvals or remove another artifact’s deny, while outside-project recovery hints recommend an install command that fails.

3 open issues
What changed in this PR

This PR addresses #3957 by correcting deny-related remediation across executable approvals, frozen installs, and user-scoped commands.

Changes:

  • Distinguishes denied MCP servers from missing declarations in frozen-install diagnostics.
  • Adds same-store deny clearing for named approvals, bulk-skip handling, and reporting of remaining denies.
  • Enables --user approval and denial outside projects, with lifecycle tests and updated documentation.
File Description
tests/​integration/​test_deny_remediation_lifecycle.py Adds lifecycle coverage for the three remediation flows.
src/​apm_cli/​integration/​mcp_config_view.py Adds deny-specific consent diagnostics.
src/​apm_cli/​install/​service.py Uses omission evidence in frozen-install messages.
src/​apm_cli/​commands/​approve.py Updates deny clearing, bulk approval, and outside-project handling.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Updates command guidance for the revised behavior.
docs/​src/​content/​docs/​reference/​cli/​install.md Documents denied-server frozen diagnostics.
docs/​src/​content/​docs/​reference/​cli/​deny.md Documents user scope and lifting denies.
docs/​src/​content/​docs/​reference/​cli/​approve.md Explains approval after denial and outside-project support.
docs/​src/​content/​docs/​reference/​baseline-checks.md Documents deny-specific audit diagnostics.
CHANGELOG.md Records the user-visible remediation changes.

Review effort: Balanced

Comment on lines +61 to +64
if user_scope:
from ..core.scope import InstallScope, get_manifest_path

return get_manifest_path(InstallScope.USER)
Comment on lines +746 to +747
denied = _same_store_denies(deny, decl)
if denied and bulk:
Comment on lines +811 to +812
keys = {decl.package_key, _identity(decl)}
return [key for key in deny if key in keys or _strip_version(key) in keys]
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

PR #3979 fixes what apm tells you to do after apm deny: the frozen message, approving a denied package, and --user outside a project. Before merge, approve must match deny keys the same way the gate does, so the hint cannot loop.

panel-mode=full; personas=python-architect,test-coverage-expert,devx-ux-expert,doc-writer,supply-chain-security-expert,cli-logging-expert,apm-ceo

cc Daniel Meppiel (@danielmeppiel) -- a fresh advisory pass is ready for your review.

The PR covers all three parts of the #3957 scope. The frozen and consent wording now names the executables gate. A named approve lifts a deny in the same store and exits 1 when another layer still denies the package. apm deny --user and apm approve --user now work outside a project. The supply-chain-security-expert found no bypass: bulk approves never lift a deny, globs and org denies are never touched, and denies in other layers fail closed. The one real defect was flagged by 4 of 6 personas. _same_store_denies matches deny keys only by exact text or with the version stripped. The gate (_map_denies) matches through canonical_exec_identity, which ignores case for GitHub/ADO, URL and host spellings, and ports. For package_key acme/tools, the deny keys https://github.com/acme/tools, Acme/Tools and github.com/acme/tools gave cleared=[] while the gate still denied. The tool then prints the same apm approve command the user just ran. That breaks scope item (2). The fix is one shared matcher next to _map_denies in security/executables.py, used by both the gate and approve.

On atomic vs. latent grant: keep the write, report it honestly, exit 1. A project allow written to apm.yml takes effect for every teammate who lacks the approver's personal user deny, and a --user allow takes effect in other projects. Refusing to write would make one layer's deny veto approvals in other layers, a deny-semantics change that is out of scope. So say "recorded, still denied here" and end the output on the error line.

The lookalike concern is in scope because this PR introduces the deny pop: lift a deny only when the argument matches a lockfile-derived identity. Approving a denied package that is not installed currently warns and exits 0, which is "without effect"; exit 1 and name the deny. Unit-tier tests are in scope. Out of scope, to track separately: moving all deny remediation wording into trust.py, CurrentMcpConfigView.omission_reason, CommandLogger migration, and org-deny visibility for --user outside a project.

Dissent. python-architect wants still-denied packages checked before any write; devx-ux, cli-logging and doc-writer want the write kept and reported honestly, and supply-chain accepts the latent grant. The CEO sides with keeping the write. All personas agree the deny-key matcher must be fixed; only python-architect rated it blocking, and that rating is accepted because the hint loop breaks scope item (2).

Aligned with: Secure by default: no bypass found; requiring a lockfile-identity match before lifting a deny closes the lookalike risk. Governed by policy: the gate and approve must share one deny-key matcher. Portable by manifest: --user reads and writes only APM_HOME outside a project. Pragmatic as npm: every printed fix command must work when run.

Panel summary

Persona B R N Takeaway
Python Architect 1 2 2 Good fix, but _same_store_denies forks the deny-key matching that _map_denies owns, and that can loop the remediation.
Test Coverage Expert 0 2 2 All 3 scope parts have lifecycle tests; gaps: spelling-variant denies loop, --recommended/org hint untested, no unit tier.
Devx Ux Expert 0 3 2 Printed fix commands can loop or do nothing (deny spelling mismatch, uninstalled packages); exit 1 hides that the store was written.
Doc Writer 0 2 1 Stale claims are gone; approve.md omits the project-deny layer and that exit 1 still writes the store.
Supply Chain Security Expert 0 2 1 No bypass found; lifting a deny should require an exact lockfile identity and match spellings like the gate.
Cli Logging Expert 0 2 3 Messages are clear and ASCII; a still-denied approve hides its write and ends on a green line; frozen wording inconsistent.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 5 follow-ups

  1. [Python Architect] (blocking-severity) Replace the exact/strip_version check in _same_store_denies with a shared matcher next to _map_denies in security/executables.py using canonical_exec_identity; skip glob and content-bound keys; add a mixed-case, URL-spelled deny regression test. -- Four personas found it; approve otherwise prints the command the user just ran, breaking scope item (2).
  2. [Test Coverage Expert] Add CliRunner unit tests: deny spelling variants lifted, --recommended/--all skip denied, org deny exits 1 naming the org layer, --user hint wording, the package_name lookalike case, and a still-denied approve that records and exits 1. -- Unit-tier evidence is missing on a governed-by-policy surface.
  3. [Supply Chain Security Expert] Lift a same-store deny only when the argument matches a lockfile-derived identity; for a package_name-only match keep the deny and print apm approve <identity>. -- A lookalike package must not choose which deny is lifted.
  4. [Devx Ux Expert] Make the still-denied path honest: "Recorded approval in ; is still denied () here: ", count recorded vs still denied, print [x] lines last, exit 1; document all three layers. -- An unexplained apm.yml diff after exit 1 is the real UX failure.
  5. [Devx Ux Expert] A named package that is not installed but matches a same-store deny: exit 1, name the deny, say to install first. -- Today it warns and exits 0, which is "without effect".

Architecture

classDiagram
    direction LR
    class approve_py {
      <<CommandModule>>
      +approve_cmd()
      +deny_cmd()
      -_find_manifest(user_scope) Path
      -_record_and_save(..., bulk)
      -_same_store_denies(deny, decl) list
      -_still_denied(manifest, decls) list
      -_lift_deny_hint(layer, identity) str
    }
    class executables_py {
      <<CanonicalOwner>>
      +resolve_exec_decision(ctx, key, type) ExecDecision
      +canonical_exec_identity(key) str
      -_map_denies(map, key, type) bool
      -_strip_version(key) str
    }
    class trust_py {
      <<CanonicalOwner>>
      +package_type_verdicts() dict
      +REASON_DENIED
    }
    class CurrentMcpConfigView {
      +omissions dict
      +consent_problems() dict
    }
    class InstallService {
      -_frozen_mcp_reasons() list
    }
    approve_py ..> executables_py : deny matching
    approve_py ..> trust_py : _verdicts
    trust_py ..> executables_py : resolve_exec_decision
    CurrentMcpConfigView ..> trust_py : REASON_DENIED
    InstallService ..> CurrentMcpConfigView : omissions
    class approve_py:::touched
    class CurrentMcpConfigView:::touched
    class InstallService:::touched
    classDef touched fill:#fff3b0,stroke:#d47600
Loading
flowchart TD
    A["apm approve [--user] pkg / --all / --recommended"] --> B["_find_manifest(user_scope)"]
    B -->|cwd apm.yml| C["project apm.yml"]
    B -->|missing and --user| D["APM_HOME/apm.yml"]
    C --> E["_load_store allow, deny"]
    D --> E
    E --> F["_record_and_save(..., bulk)"]
    F --> G{"_same_store_denies"}
    G -->|denied and bulk| H["Skipped: denied"]
    G -->|named| I["_record_declaration + pop same-store deny"]
    I --> L["_save_store"]
    L --> M["_still_denied via trust ctx"]
    M -->|TRUST_DENIED| O["still denied (layer): hint; exit 1"]
    M -->|admitted| P["Approved; exit 0"]
    T["apm install --frozen"] --> Y["consent_problems: gate now parks it (denied)"]
Loading

Recommendation

The core fix is right and has no security regression. Before merge, fold the shared canonical deny-key matcher (the blocking item), the unit-tier tests, the lockfile-identity requirement for lifting a deny, the honest "recorded but still denied" output and docs, and exit 1 for a denied package that is not installed. All of these are within #3957's scope. Track the trust.py wording consolidation, CommandLogger migration and --user org-deny visibility separately.


Full per-persona findings

Python Architect

  • [blocking] _same_store_denies adds a second deny-key matcher that disagrees with _map_denies/canonical_exec_identity, so a deny can survive apm approve and the hint loops at src/apm_cli/commands/approve.py:807
  • [recommended] The still-denied check runs after _save_store, so exit 1 still leaves a persisted allow and a lifted same-store deny at src/apm_cli/commands/approve.py:769
  • [recommended] Deny remediation text is spread over several sites; route it through one helper in security/trust.py at src/apm_cli/commands/approve.py:834
  • [nit] install/service.py inspects raw omission evidence instead of asking CurrentMcpConfigView at src/apm_cli/install/service.py:647
  • [nit] _still_denied keeps only layers[0] and filters successes with id() plus zip at src/apm_cli/commands/approve.py:815

Cli Logging Expert

  • [recommended] Still-denied approve prints [x] before [+] and the Updated line; silent about the write when all are still denied at src/apm_cli/commands/approve.py:774
  • [recommended] Frozen 'now left out ()' shows a raw reason token and no fix at src/apm_cli/install/service.py:651
  • [nit] Skipped-denied line fits _rich_warning better than _rich_info at src/apm_cli/commands/approve.py:748
  • [nit] Org-layer hint reads awkwardly at src/apm_cli/commands/approve.py:841
  • [nit] New lines bypass CommandLogger at src/apm_cli/commands/approve.py:771

Devx Ux Expert

  • [recommended] Still-denied hint can loop: approve only clears exact-spelling denies at src/apm_cli/commands/approve.py:807
  • [recommended] apm approve cannot lift a deny on a not-installed package: warns and exits 0 at src/apm_cli/commands/approve.py:531
  • [recommended] Exit 1 hides that the store was changed at src/apm_cli/commands/approve.py:775
  • [nit] Org-deny hint lacks a command at src/apm_cli/commands/approve.py:834
  • [nit] Bulk approve exits 0 with no summary when everything skipped

Supply Chain Security Expert

  • [recommended] A named approve can lift a deny for a package matched only by the name in its own apm.yml at src/apm_cli/commands/approve.py:745
  • [recommended] _same_store_denies matching is narrower than the gate; some denies can never be lifted (fails closed) at src/apm_cli/commands/approve.py:807
  • [nit] --user outside a project probably cannot see an org deny in _still_denied at src/apm_cli/commands/approve.py:272

Doc Writer

  • [recommended] approve.md omits the project-deny layer and that the approval is saved before exit 1 at docs/src/content/docs/reference/cli/approve.md:156
  • [recommended] "Naming a package lifts its deny" fails for differently spelled deny keys at src/apm_cli/commands/approve.py:807
  • [nit] CHANGELOG line does not name the commands --user applies to at CHANGELOG.md:45

Test Coverage Expert

  • [recommended] No test for deny keys stored under URL, host-qualified, or different-case spellings at src/apm_cli/commands/approve.py:807
    Proof (missing at): tests/unit/commands/test_approve_deny.py
  • [recommended] No test for the --recommended skip, the org-deny hint, or --user hint wording at src/apm_cli/commands/approve.py:747
    Proof (missing at): tests/unit/commands/test_approve_deny.py
  • [nit] No test for the service.py 'now left out ()' branch at src/apm_cli/install/service.py:651
  • [nit] Approval-saved-on-exit-1 and replace: original_identity deny survival are not asserted at tests/integration/test_deny_remediation_lifecycle.py:85

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Superseded by #3988 (the #3983 umbrella, 0.37 owner hardening). This branch's fix and tests were harvested into #3988, which routes the change through its canonical owner with a closed-world guard. Closing in favour of #3988.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 19, 2026
* fix(lockfile): stamp the running APM on every substantive lock write (#3962)

Harvested from #3977.

Co-authored-by: Copilot App <[email protected]>

* fix(bundle): warn when a bundle's lockfile was written by a newer APM (#3963)

Harvested from #3978.

Co-authored-by: Copilot App <[email protected]>

* fix(marketplace): origin-check every marketplace resolution entry point (#3959)

Harvested from #3976; the positional install reads the lock lazily.

Co-authored-by: Copilot App <[email protected]>

* fix(install): preview object-form marketplace dependencies in --dry-run (#3960)

Harvested from #3973.

Co-authored-by: Copilot App <[email protected]>

* fix(prune): keep object-form marketplace dependencies (#3960)

Harvested from #3974.

Co-authored-by: Copilot App <[email protected]>

* fix(install): retire a local bundle's MCP servers when a reinstall drops them (#3956)

Harvested from #3975.

Co-authored-by: Copilot App <[email protected]>

* fix(update,audit): honour the current executables decision after apm deny (#3958)

Harvested from #3981.

Co-authored-by: Copilot App <[email protected]>

* fix(approve): correct the remediation after apm deny; approve clears a same-store deny (#3957)

Harvested from #3979.

Co-authored-by: Copilot App <[email protected]>

* fix(approve): match package names exactly and refuse ambiguous names

A partial name could grant or deny execution for another package.

Co-authored-by: Copilot App <[email protected]>

* fix(pack): never ship APM-managed root .mcp.json servers (#3966)

Harvested from #3971.

Co-authored-by: Copilot App <[email protected]>

* fix(install): the trust owner reads the scope manifest, so -g honours executables: (#3954)

exec_trust_context_for_project takes the manifest file instead of deriving
apm.yml from a caller-chosen root; -g resolves APM_HOME/apm.yml through
core.scope.get_manifest_path. A closed-world guard registers every caller.
Supersedes #3969 and keeps its lifecycle test.

Co-authored-by: Copilot App <[email protected]>

* fix(deps): deps update and lock --update revalidate marketplaces (#3961)

Every caller of the shared install entry now runs inside a registered
catalog-freshness envelope; the guard is closed-world.

Co-authored-by: Copilot App <[email protected]>

* fix(lifecycle): lifecycle test --execute fires through the script gate

APM_NO_SCRIPTS, org executables.deny_all and project script trust now apply;
LifecycleScriptRunner is built only by build_runner_from_context, guarded
closed-world by the new lifecycle-script-firing-gate owner.

Co-authored-by: Copilot App <[email protected]>

* test(approve): exact and unambiguous approve/deny matching

Co-authored-by: Copilot App <[email protected]>

* fix(pack): root .mcp.json reads exclude APM-managed servers by default (#3966)

The only opt-out is a dependency's own authored .mcp.json; a closed-world
guard refuses any other.

Co-authored-by: Copilot App <[email protected]>

* test(architecture): a bundle reinstall must reconcile its owned MCP servers (#3956)

Co-authored-by: Copilot App <[email protected]>

* test(architecture): guard object-form lock-row mapping and exact approve matching

Co-authored-by: Copilot App <[email protected]>

* fix(update): read packages as replay does; skip the policy fetch when the gate was never on (#3958)

Harvested from #3981 (b4cface, cb015e6); the trust read uses the scope manifest.

Co-authored-by: Copilot App <[email protected]>

* fix(install): -g MCP admission reads trust from APM_HOME/apm.yml (#3954)

Harvested from #3969 (5c2cab2).

Co-authored-by: Copilot App <[email protected]>

* fix(targets): apm targets honours targets: in apm.yml (#3792)

Reads the manifest restriction through the same owner install uses.

Co-authored-by: Copilot App <[email protected]>

* fix(cli): user-facing text names current keys, targets and marketplaces

- compile's no-output hint names targets:, not the deprecated target:
- pack's mismatch hint no longer suggests the deprecated pack --target
- skip messages name executables.allow instead of allowExecutables
- origin and freshness errors say marketplace, not catalog
- generated apm.yml headers and unknown-target errors stop listing vscode
- config docs show default_client: copilot

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): 0.37 owner hardening entries; ruff fixes

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* docs(changelog): reference #3988

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(update): converge the mixed-type reconcile; pin probe boundaries

Harvested from #3981 (6cd7b3a, delta panel fold). Only a denied row
with mixed per-type verdicts reconciles, so common partial approvals keep
the no-change short-circuit; the probe catches only unreadable-package
errors instead of every exception. Tests pin when the probe fetches
policy, mixed detection on a two-type package, and every unavailable
policy outcome. Test calls pass the scope manifest path, per #3988's
trust-owner signature.

Refs #3958

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>

* test: align tests with the 0.37 contracts this PR introduces

CI on 913336a was red on tests that encoded the pre-#3983 contracts:
- lifecycle test --execute now fires through the script gate, so the
  firing test trusts the project first and the old bypass trap now
  asserts untrusted scripts are withheld (mutation-break: restoring an
  ungated LifecycleScriptRunner fails it);
- codex native admission names executables.allow, not allowExecutables;
- a real LockFile.write stamps the running CLI (#3962), so the heal
  eligibility fixture pins the stamp it means to write;
- pack no longer ships servers apm install renders from apm.yml (#3966),
  so the bundle MCP retire test authors its server in .mcp.json.

Addresses merge-worker CI triage on #3988.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(uninstall): origin-check marketplace rows from the batch index

require_locked_catalog_origin rescanned lockfile.dependencies for every
package, breaking the uninstall single-traversal guarantee. The batch
index now also keys rows case-insensitively, and the registry fallback
checks each matched row through require_locked_row_origin before any
catalog I/O. Adds a rebound-alias regression test (mutation-break:
dropping the check lets the catalog be reached) and moves the origin
entry-point guard and its mutation case to the new call.

Refs #3959

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(pack): warn when root .mcp.json servers APM manages are left out

A Claude plugin silently lost the MCP servers apm install renders from
apm.yml. Pack now names them and the remedy; the CHANGELOG moves the
#3966 line to upgrade notes with that migration, pack.md and apm-usage
say the same, and the unrelated #3931 line this PR dropped is restored.

Addresses panel follow-ups (supply-chain, doc-writer) on #3988.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix: fold Copilot review on trust and origin owners

- install x@alias reads a legacy apm.lock for the origin check, through
  the read-only lockfile resolver, so a rebound alias fails closed before
  migration (Copilot on commands/install.py:220);
- the update probe reuses POLICY_RESOLUTION_FAILURE_OUTCOMES, so an
  incomplete policy chain also forces the guarded install path
  (Copilot on commands/update.py:148);
- apm approve clears a same-store deny stored under any spelling the
  deny ladder matches (URL, host, case), via canonical_exec_identity
  (Copilot on commands/approve.py:817).

Each fix has a regression test proven by mutation-break.

Refs #3957, #3958, #3959

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* fix(targets): singular target: all lists the install set as active

restriction() folds singular `target: all` to None (auto-detect), but
install expands it to the stable install set, so apm targets showed every
target inactive. Expand it through target_catalog.expand_all("install").
Regression test proven by mutation-break.

Addresses Copilot on commands/targets.py:32.

Refs #3792

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* perf: share one marketplace index across dry-run and prune lookups

locked_marketplace_row and locked_marketplace_form were called per
declaration without an index, so LockFile.get_dependency rebuilt the
marketplace index each time (O(M*N)). Both callers now build it once,
as the reachability walk already does.

Addresses Copilot on install/dry_run_plan.py:33 and install/orphans.py:46.

Refs #3960

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

* test(architecture): track the shared marketplace index in mutation cases

The object-form mutation cases match the exact call text, which now
passes the shared marketplace index.

Co-authored-by: Copilot App <[email protected]>

* fix(pack): ship apm.yml MCP declarations; only root claims hide root entries

Red team qa-prA-5 and qa-prA-6 on #3988, both regressions against main:

- A Claude bundle and plugin.json dropped the producer's own apm.yml MCP
  servers: they were read only from the rendered root .mcp.json, which pack
  now withholds. collect_mcp_servers projects the root manifest's
  self-defined declarations from apm.yml values (never the rendered copy),
  through the existing credential stripping, so output is byte-identical
  before and after apm install. The pack warning remains only for
  APM-managed servers apm.yml does not define (a dependency's).
- apm_managed_mcp_names unioned lock claims from every runtime, so a
  Cursor-only claim on `docs` hid an authored root `docs` from Claude and
  Codex. Only claims whose runtime writes root .mcp.json count, read
  through the factory (ClientFactory.project_destination_is_root_mcp_json,
  side-effect free); unknown runtimes and unplaced aggregate names stay
  managed (conservative).

The new unit tests fail on e9d6c9d and pass here; the bundle-retire
lifecycle test is back to its apm.yml declaration; test_pack_mcp_ownership
asserts byte identity, no header or secret values and no reference to the
rendered file; the pack guard requires both owner rules, with a standalone
mutation test. CHANGELOG, pack.md and apm-usage updated.

apm-spec-waiver: consistency fixes route callers through existing owners; no new or changed normative requirement

Co-authored-by: Copilot App <[email protected]>

---------

Co-authored-by: danielmeppiel <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Takeshi Masukawa (takeaship) pushed a commit to takeaship/apm that referenced this pull request Nov 20, 2026
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.

[BUG] Wrong remediation after apm deny: --frozen says "no longer declared" and approve reports success without effect

2 participants