Skip to content

fix(pack): omit a gate-parked canvas dependency instead of refusing with a looping remedy (#4714) - #4729

Merged
Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-fix-4714-pack-parked-canvas
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 8 commits into
mainfrom
danielmeppiel-fix-4714-pack-parked-canvas

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

When the executables gate parks a git dependency's canvas extension (unapproved, apm deny, or approval revoked after deploy), apm pack (including --dry-run) used to exit 1. The error said "the lockfile records no deployed files ... stale or partial install. Run 'apm install' ...". Running apm install changed nothing, because the gate still parked the canvas, so the remedy looped.

  • Owner. bundle/plugin_exporter.py _cache_would_contribute_primitives decides whether a dependency with no deployed_files is a provenance gap. Both exporters share it through export_common. A new helper, _gate_parked_types, reads the lock row's exec_status (gated_pending_approval or denied) and exec_allowed_types. A canvas the lock records as withheld is not a provenance gap, so pack omits it, just as it already omits parked hooks and LSP servers. A canvas the lock records as deployed but with no files is still refused as a stale install (negative control in the owner table test).
  • One [!] line per parked canvas, with a remedy that works. _warn_parked_executables prints, for example: [!] dependency lifecycle/o-canvas: canvas extension(s) not packed (not approved in executables.allow). Run 'apm approve lifecycle/o-canvas' to approve its canvas extensions, then run 'apm install' to deploy them. For a deny it points to apm policy explain <pkg>. The wording comes from the same owner install uses: executable_skip_reason in install/exec_gate.py now delegates to a pure withheld_executable_reason.
  • Docs: reference/cli/pack.md and apm-guide commands.md.

Out of scope, as proposed: approval semantics and the pack format.

Issue and approved scope

Issue: Fixes #4714

Human scope-approval comment: pending. The P4 lead proposed the scope ("pack succeeds and packs only what install deployed; one [!] line naming the parked canvas with a remedy that works; every printed hint executed; out of scope: approval semantics and pack format") and asked Intake for the apm-scope:v1 record on #4714. This PR will follow that record if it differs.

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

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)
promise: P-INV-I4 -- pack never ships an executable the gate withheld, and a parked one never blocks packing what was deployed; P-INV-I8 -- every printed hint reaches its stated outcome
cell: OP=pack SRC=git PRIM=canvas SCOPE=project GATE={unapproved-exec, denied-executable, revoked-after-deploy}
owner: bundle/plugin_exporter.py _cache_would_contribute_primitives / _gate_parked_types; remedy wording install/exec_gate.py withheld_executable_reason
instrument: target scenario -> tests/lifecycle/scenarios/test_pack_parked_executables.py::test_pack_omits_a_parked_canvas_and_its_hint_restores_it[*] (new: no pack-gate scenario existed; the T1 generated cells are credited by the M-GATE pack spine in #4700, so this module credits none)
oracles: exit 0, canvas files absent from the pack listing, exactly one [!] line naming the parked canvas, I1-I9 per step
failing-before: all 3 rows -> "R: 'pack --dry-run' exited 1, expected [0] ... Run 'apm install' to record provenance"
passing-after: 3 passed
hints executed: unapproved -> 'apm approve' then 'apm install' -> canvas deployed and packed; denied / revoked -> 'apm policy explain', then the 'apm approve' it names, then 'apm install' -> canvas deployed and packed
ledger: tests/fixtures/lifecycle_bug_ledger/bugs/4714.json

Commands run locally, on main merged at d6484f1 (#4645 and #4713 included):

  • The three cells, the owner table in tests/unit/bundle/test_plugin_exporter_canvas.py, the exporter/packer unit tests and 59 pack, bundle and canvas integration modules: 1101 passed, 3 skipped.
  • tests/unit/install and tests/unit/core: passed, apart from failures unrelated to this change (installer-script timeouts under host load, and an ADO auth test that reaches the network).
  • Lint mirror: [email protected] check and format --check, pylint R0801, lint-auth-signals.sh, the complexity ratchet, taxonomy --changed, the assertion-quality ratchet, the architecture linter, the 2100-line guard and tests.lifecycle.generator --check. All clean.

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: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 10:14
apm-spec-waiver: pack omits a gate-parked canvas; no OpenAPM v0.1 req covers executable gating of packed dependency content

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

The remediation warnings can target the wrong dependency, misreport canvas trust status, and recommend commands that cause agent-plugin packaging to fail.

3 open issues
What changed in this PR

This PR addresses #4714 by letting apm pack omit gate-parked canvas dependencies instead of refusing with an ineffective apm install remedy. It preserves provenance checks for content expected to have been deployed.

Changes:

  • Recognizes withheld canvas content and adds shared warnings to both plugin exporters.
  • Reuses install’s remediation wording for pack warnings.
  • Adds regression coverage, a bug-ledger entry, documentation, and a changelog fragment.
File Description
tests/​unit/​bundle/​test_plugin_exporter_canvas.py Tests parked-canvas detection, warnings, and stale-install controls.
tests/​lifecycle/​scenarios/​test_pack_parked_executables.py Exercises three gate states and follows printed remedies.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​4714.json Records the bug and regression tests.
src/​apm_cli/​install/​exec_gate.py Extracts shared withholding-reason wording.
src/​apm_cli/​bundle/​plugin_exporter.py Omits parked canvas from provenance-gap detection and emits warnings.
src/​apm_cli/​bundle/​export_common.py Exposes the shared warning helper.
src/​apm_cli/​bundle/​agent_plugin_exporter.py Adds parked-executable warnings to Agent Plugin export.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Documents canvas omission and remediation.
docs/​src/​content/​docs/​reference/​cli/​pack.md Explains packing behavior for gate-parked canvas.
changelog.d/​4729.fixed.md Adds the user-visible fix entry.

Review effort: Balanced

Comment thread src/apm_cli/bundle/plugin_exporter.py Resolved
Comment thread src/apm_cli/bundle/plugin_exporter.py Resolved
…ixed rows, and names the carrying format (#4714 review)

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.

🔵 Needs a closer look

Canvas handling grants an exemption for nondeployable files and omits the experimental-flag enablement step from approval guidance, suppressing provenance refusals or causing a repeating failure.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Require a deployable bundle before exempting a parked canvas

src/​apm_cli/​bundle/​plugin_exporter.py:927

A package with unapproved hooks and .apm/extensions/demo/icon.txt, but no extension.mjs, is treated as having a parked canvas here even though install discovers no canvas bundle. This suppresses the provenance-gap refusal and prints a canvas approval remedy that cannot deploy those files. Use CanvasIntegrator.find_canvas_bundles() to confirm a deployable bundle before granting the exemption or emitting the warning.

Medium severity Enable the canvas feature before suggesting approval and installation

src/​apm_cli/​bundle/​plugin_exporter.py:949

With the experimental canvas flag disabled, the printed approve/install commands cannot deploy the canvas because its integrator returns immediately. Approval changes the lock status to deployed, so the next pack loses this exemption and again fails with the looping provenance remedy. Include apm experimental enable canvas before the approval/install steps when the flag is disabled, and cover that hint sequence in a regression test.

3 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit b6cfc7f into main Nov 22, 2026
50 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-4714-pack-parked-canvas branch November 22, 2026 16:27
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
…_reasons.py (exec_gate.py 1007 -> 945 LOC)

Main 387ae90 failed test_no_install_module_exceeds_loc_budget after
#4724 and #4729 both grew exec_gate.py. executable_skip_reason and
withheld_executable_reason (the wording install and pack print for a
parked executable) move to their own module under the
executable-trust-context owner; callers import it directly. No budget raise.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
…ells are required

Union of the denied-dependency refusals (compile from main, mcp-install from the T-1 car). #4729 fixed #4714, so KNOWN_PACK is empty and G1|pack|canvas|{unapproved-exec,denied-executable,revoked-after-deploy}|project earn receipts.

Co-authored-by: Copilot App <[email protected]>
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] apm pack fails on a project whose canvas dependency the executable gate parks, and its "apm install" remedy loops

2 participants