Skip to content

fix(bundle): align local bundle and pack gate coverage - #4645

Merged
Daniel Meppiel (danielmeppiel) merged 14 commits into
mainfrom
danielmeppiel-bundle-pack-gate-coverage
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 14 commits into
mainfrom
danielmeppiel-bundle-pack-gate-coverage

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

This PR makes local bundle install and apm pack honour the same gates as install from a git dependency.

  • Canvas in local bundles. install/local_bundle_canvas.py (gate_bundle_canvas) now owns the canvas feature flag and the executables gate for local bundles.
    • When canvas is not admitted (no approval, or the bundle is denied), install retires the extensions the bundle deployed earlier, and edited files are kept.
    • The pending approval record and apm approve <bundle> now list canvas when the bundle ships it.
  • Org dependencies.deny for local bundle install. The bundle's own name is checked as _local/<name>, and so is every package in its embedded lockfile.
    • The check goes through the existing admit_bundle -> run_policy_preflight -> _check_dependency_denylist path.
    • A denied bundle exits 1 with nothing written.
    • Bundled packages are checked against deny only; allow, require and pins still judge the project's own declarations.
  • apm pack refuses content from a denied dependency. bundle/pack_policy.py runs before any format is packed, so it covers --dry-run, --archive and every format. It applies the same refusal that install, update and lock use: Pack blocked by org policy: <pkg>, exit 1, nothing packed.
  • Pack warning matches bundle contents. Dependency hook or MCP config is reported as "not packed" only when the bundle does not carry it. Attested hook files still ship, and unattested bytes never ship.

Docs: reference/cli/install.md, reference/cli/pack.md, reference/policy-schema.md, apm-usage/governance.md.

Issue and approved scope

Issue: none; scope set by the maintainers. Maintainer ruling: the org dependency deny applies to local bundles, and pack refuses denied content.

Human scope-approval comment: approved by the maintainers.

Does this PR complete the issue, or what remains? It completes the local bundle and pack gate alignment.

Type of change

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

Testing

  • Tested locally

  • All existing tests pass

  • Added tests for new functionality (if applicable)

  • tests/integration/test_local_bundle_canvas_gate_lifecycle.py covers:

    • gate off, then deploy
    • gate on, then retire
    • approve --pending lists canvas
    • approve, then redeploy
    • deny, then retire
    • audit --ci
  • tests/integration/test_org_dependency_deny_bundle_pack_lifecycle.py covers a denied local bundle install and pack under org deny. It fails on main and passes here.

  • Unit tests cover the bundle policy subjects, dependency identity case and pack warning.

  • tests/lifecycle/security/test_policy_outcomes.py changes 8 cells: the p-exec bundle under a policy that denies p-exec now expects the refusal.

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.
  • 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 -- applies the existing executables gate and org dependency policy to the local bundle and pack paths; no new contract.

apm-spec-waiver: applies the existing executables gate and org dependency deny to local bundle install and pack; no new contract.

…s not carry

A dependency's hooks file that apm.lock.yaml attests (deployed_files and
its hash) packs into hooks/, yet pack still warned that the dependency's
hook config was not attested and would not be packed. The warning now
names only config no packed file carries: hook config when no attested
hooks file packs (for example a shared settings merge, or a format that
drops hooks), and MCP config, which install never attests. Unattested
cache bytes still never ship.

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

apm install <bundle> now checks the bundle's package name (as
_local/<name>, so **/<name> matches) and every package its embedded
apm.lock.yaml records against dependencies.deny through the shared
install policy preflight, and refuses a denied bundle before any file is
written, with the same violation line and policy hint as a denied git
dependency. These packages meet the deny list only.

apm pack (including --dry-run and --archive) runs the same preflight
before packing: the project's declared dependencies as install judges
them, and every locked package against dependencies.deny. A refused
package fails the pack with "Pack blocked by org policy: <pkg>" and exit
1; nothing is packed.

The bundle admission owner registers bundle_policy_subjects and the pack
entry point, and its guard now requires both routes.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 16:26
apm-spec-waiver: applies the existing executables gate and org dependency deny to local bundle install and pack; no new contract.

Co-authored-by: Copilot App <[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

Malformed lockfiles can bypass dependency admission, and canvas retirement can follow directory symlinks to delete files outside the project.

5 open issues
What changed in this PR

This PR extends APM’s existing policy and executable gates to local bundle installation and packing, bringing those paths closer to Git dependency installation.

Changes:

  • Checks local bundle identities and embedded dependencies against org deny policy, and adds policy preflight before packing.
  • Adds canvas approval reporting and retirement for local bundles.
  • Refines unpacked-config warnings and updates regression tests, architecture guards, and documentation.
File Description
tests/​unit/​test_plugin_exporter.py Tests warnings against packed hook and MCP content.
tests/​unit/​policy/​test_dependency_identity_case.py Tests bundled dependency subjects and remedies.
tests/​unit/​install/​test_bundle_policy_subjects.py Tests bundle identities and embedded lockfile handling.
tests/​quality/​lifecycle_obligations.json Updates a source evidence line reference.
tests/​lifecycle/​security/​test_policy_outcomes.py Expects policy refusal for denied local bundles.
tests/​lifecycle/​generator/​rules.py Updates the corresponding evidence line reference.
tests/​integration/​test_org_dependency_deny_bundle_pack_lifecycle.py Covers bundle and pack refusal without output writes.
tests/​integration/​test_local_bundle_canvas_gate_lifecycle.py Covers canvas approval, deployment, and retirement.
tests/​integration/​test_architecture_owner_rule_mutations.py Tests policy and canvas routing guards.
src/​apm_cli/​policy/​policy_checks.py Includes bundled packages in dependency deny checks.
src/​apm_cli/​policy/​install_preflight.py Forwards bundled dependency subjects.
src/​apm_cli/​install/​services.py Delegates canvas gating to the new helper.
src/​apm_cli/​install/​local_bundle_handler.py Supplies policy subjects and records canvas approval types.
src/​apm_cli/​install/​local_bundle_canvas.py Implements local bundle canvas gating and retirement.
src/​apm_cli/​install/​bundle_admission.py Collects bundle and embedded dependency identities.
src/​apm_cli/​bundle/​plugin_exporter.py Makes config warnings reflect packed hook files.
src/​apm_cli/​bundle/​packer.py Runs policy preflight before format dispatch.
src/​apm_cli/​bundle/​pack_policy.py Implements pack dependency-policy preflight.
src/​apm_cli/​bundle/​export_common.py Exposes the shared config-warning helper.
src/​apm_cli/​bundle/​agent_plugin_exporter.py Reuses the shared config-warning helper.
scripts/​architecture_linter/​checks/​marketplace_pack_plugin_manifests.py Updates the permitted MCP inspection helper.
scripts/​architecture_linter/​checks/​install_trust_integrity.py Guards bundle identity and pack policy routing.
scripts/​architecture_linter/​checks/​install_lsp_plugin.py Guards canvas approval routing.
scripts/​architecture_linter/​checks/​install_entry_and_commit.py Recognizes pack policy as an authorized preflight caller.
packages/​apm-guide/​.apm/​skills/​apm-usage/​governance.md Documents bundle and pack deny enforcement.
docs/​src/​content/​docs/​reference/​policy-schema.md Explains bundle policy identities and coverage.
docs/​src/​content/​docs/​reference/​cli/​pack.md Documents policy refusal and refined config warnings.
docs/​src/​content/​docs/​reference/​cli/​install.md Documents local bundle deny checks.
changelog.d/​4645.fixed.md Summarizes the user-visible gate changes.
.apm/​architecture/​owners/​install-deployment.json Expands ownership records for policy and canvas handling.

Review effort: Balanced

Comment thread src/apm_cli/install/bundle_admission.py Resolved
Comment thread src/apm_cli/bundle/pack_policy.py Resolved
Comment thread src/apm_cli/bundle/pack_policy.py Resolved
…read; observable test outcomes

A bundle apm.lock.yaml that exists but cannot be parsed made the org
dependency check judge the bundle as recording no packages. It now
refuses the install and asks for a repack; a bundle without a lockfile
is still accepted.

The new pack-warning and bundle-subject tests assert on printed output
or the refusal, and the guard mutation test reads the source it mutates,
so the assertion-quality ratchet holds.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.38.0 milestone Nov 21, 2026
… per bundle

A local bundle's canvas extensions were retired only when that same
bundle was reinstalled, and that retirement matched rows by extension
path, so a blocked bundle could remove another bundle's extension.

An install that deploys a bundle's extensions now records them with the
bundle's slug and approval key beside its hooks record (hook_ownership).
The scope re-check that install, update and prune run for bundle hooks
also retires canvas extensions current executables trust no longer
admits (gate on, deny, org layer), and apm audit --ci's local-bundle
check reports them. Retirement touches only the recorded bundle's rows;
an edited file is kept, and a row without a recorded hash keeps its file,
row and record. The hook-trust guard now requires these routes.

Co-authored-by: Copilot App <[email protected]>
apm pack ran the full install preflight (allow list, require, pins) but
only when the lockfile held a package. It now checks the declared
dependencies and every locked package against dependencies.deny alone,
whatever the lock holds, through the shared preflight (DenyOnlySubjects).
A bundle that records a denied package is refused on local install.
Re-anchors the lifecycle rule citation the preflight move shifted.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 21, 2026
…r bundle

Committed lock rows and bundle records are now acted on only when they
name a path inside the target's canvas or hooks root, with no '.'/'..'
segment and no linked component, resolving inside the project
(contained_bundle_path). This covers bundle canvas retirement, per-file
hook files and copied hook scripts; a symlinked extension directory is
never followed.

Canvas retirement is per bundle: it touches only the retired bundle's
rows, never a file another bundle's record still lists, and the record
keeps what was not retired. A reinstall retires the extensions the new
bundle content no longer ships (renamed, removed, or no canvas at all).
The lockfile is read for canvas only when a canvas record or root
exists. The hook-trust guard requires the containment routes.

Co-authored-by: Copilot App <[email protected]>
Under enforcement: warn the org deny findings were collected by a
discarded logger, so pack shipped the dependency without a word. They
now become pack warnings: printed, and listed in --json warnings.

The unpack policy test packs its producer bundle outside org policy,
since pack itself now refuses the denied dependency.

Co-authored-by: Copilot App <[email protected]>
Moves the declared executable types helper beside the other local bundle
path helpers; no behaviour change.

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 4b436d5 into main Nov 22, 2026
96 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-bundle-pack-gate-coverage branch November 22, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants