Skip to content

fix(pack): plugin bundles carry one rendering per primitive (#3686) - #4693

Merged
Daniel Meppiel (danielmeppiel) merged 40 commits into
mainfrom
danielmeppiel-fix-3686-pack-plugin-renderings
Nov 23, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 40 commits into
mainfrom
danielmeppiel-fix-3686-pack-plugin-renderings

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

apm pack --format plugin for a multi-target producer (for example targets: [claude, copilot]) shipped one primitive in several renderings: agents/rv.agent.md + agents/rv.md, instructions/py.instructions.md + instructions/py.md (+ .mdc with cursor). A Claude consumer of the bundle kept the Copilot rendering, so an applyTo-scoped instruction lost its path scoping and install printed a collision warning.

Now:

  • Pack keeps one rendering per primitive (owner: bundle/plugin_layout.py, PLUGIN_RENDERING_PREFERENCE / duplicate_plugin_renderings, applied per package in bundle/plugin_exporter.py) and prints ONE [i] line that names every dropped rendering. A file's rendering is identified by the target that deployed it (deployed_rendering_extension), so distinct primitives with dotted stems are never paired.
    • Agents and commands keep the Claude plugin rendering (agents/rv.md). Verified empirically on Copilot CLI 1.0.114: a legacy plugin's agents/plain.md loads (--agent probe-plug:plain runs), so Copilot loses nothing.
    • Instructions keep the APM rendering (instructions/py.instructions.md, applyTo) when a copilot install deployed one; without it, every target's rule rendering is kept (for example [claude, cursor] ships py.md and py.mdc). Ruling R1 (STOP rule): no plugin host loads plugin instructions natively (copilot instruction list is empty for instructions/ and rules/ in a legacy plugin), but apm install <bundle> into a Copilot project reads that file as .github/instructions/py.instructions.md; shipping only the Claude paths: rendering would unscope every instruction for Copilot consumers (shown failing on the real CLI before switching to R1).
  • Bundle install (owner: install/local_bundle_paths.py):
    • bundle_rule_format_id selects the rule format, and install/local_bundle_renderings.py converts a packed x.instructions.md through the existing InstructionIntegrator converters (now InstructionIntegrator.convert_rule_content), so a Claude consumer gets .claude/rules/py.md with paths:, exactly as apm install from source renders it. Malformed frontmatter skips that file with a named warning.
    • superseded_bundle_renderings: an older bundle that still carries several renderings deploys the one whose suffix is the target's own extension (Claude keeps py.md, Copilot py.instructions.md, Cursor py.mdc), and one [!] line names every skipped file.
  • services.py LOC budget 1210 -> 1231 (documented in test_architecture_invariants.py, as Render agents from bundles per target (Codex TOML) instead of copying verbatim #3714 did) for the two owner calls in the bundle deploy loop.
  • Owner record bundle-native-layout-lowering and its guard install-deployment-bundle-native-layout now cover rendering selection and rule rendering.

Out of scope: --format apm bundles, new flags, cross-vendor semantics beyond the existing rule converters.

Issue and approved scope

Issue: Fixes #3686

Human scope-approval comment: #3686 (comment) (apm-scope:v1, comment id 7066704425). The instruction rendering follows the escalated ruling R1 under that record's "escalate instead" clause.

Does this PR complete the issue, or what remains? Completes it.

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-LAW-routing.authorized_targets_only -- each consumer target gets its own rendering of a packed primitive (source: issue #3686 scope record)
cell: OP=pack->install SRC=git PRIM=agent+instruction TGT=[claude,copilot]->claude|copilot   owner: bundle/plugin_layout.py + install/local_bundle_paths.py
instrument: today test -> tests/integration/test_pack_bundle_roundtrip_lifecycle.py::test_multi_target_pack_ships_one_rendering_per_primitive (extends the pack round-trip module)
oracles: [I1 (audit --ci), I2 (repeat install byte-stable), I5 (pack writes only generated manifests), I9 (one [i] line, no collision)]  decisive: one stem per primitive in agents/ and instructions/; .claude/rules/py.md has paths and no applyTo; .github/instructions/py.instructions.md keeps applyTo
failing-before: pytest <node> on HEAD 11f8f585 -> AssertionError: assert ['rv', 'rv'] == ['rv']
passing-after: pytest <node> -> passed
guard+mutation: install-deployment-bundle-native-layout (extended; existing MutationCase)     ledger: 3686
hints executed: none printed

Commands (local, via the host guard):

  • pytest tests/integration/test_pack_bundle_roundtrip_lifecycle.py tests/unit/install/test_install_local_bundle.py tests/unit/test_plugin_exporter_logic.py -> 149 passed
  • Neighbours (tests/unit/install, tests/unit/bundle, plugin exporter / packer / instruction integrator units, local-bundle and pack integration modules, ledger, owner-rule mutation for this guard) -> all passed except tests/unit/install/test_unix_install_ownership.py / test_install_safety.py cases that hit subprocess.TimeoutExpired (15 s) at host load ~30; a different subset fails on each run, and those installer scripts are untouched here.
  • Lint mirror: ruff 0.15.12 check + format --check, pylint R0801, scripts/lint-auth-signals.sh, check_complexity_ratchet.py --base-ref origin/main, tests.quality.taxonomy --changed, scripts/lint_architecture_boundaries.py --root ., 2100-line guard -> 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
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

apm-spec-waiver: plugin bundle rendering selection and local-bundle rule conversion; OpenAPM v0.1 specifies no plugin bundle layout or local bundle install, so no new normative surface.

apm-spec-waiver: plugin bundle rendering selection and local-bundle rule conversion; OpenAPM v0.1 specifies no plugin bundle layout or local bundle install, so no new normative surface.

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

Filename-based deduplication silently drops distinct agents and misses duplicate instructions, while rule selection discards native Cursor rules and leaves incompatible scoping metadata.

2 open issues
What changed in this PR

This PR addresses #3686 by deduplicating plugin-bundle renderings and routing packed APM instructions through existing target converters, extending the bundle-rendering approach used for agents in #3714.

Changes:

  • Centralizes rendering preferences and reports dropped files during plugin packing.
  • Selects target-native renderings from older bundles and converts packed APM instructions during installation.
  • Adds regression coverage, architecture checks, and documentation.
File Description
tests/​unit/​install/​test_install_local_bundle.py Tests rendering selection and rule-format routing.
tests/​unit/​install/​test_architecture_invariants.py Adjusts the install-services size budget.
tests/​integration/​test_pack_bundle_roundtrip_lifecycle.py Adds multi-target pack/install regression coverage.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​3686.json Records the bug and regression tests.
src/​apm_cli/​integration/​instruction_integrator.py Exposes shared rule-content conversion.
src/​apm_cli/​install/​services.py Integrates rendering selection and rule conversion.
src/​apm_cli/​install/​local_bundle_rules.py Converts bundled instructions and warns on invalid YAML.
src/​apm_cli/​install/​local_bundle_paths.py Selects target renderings and instruction formats.
src/​apm_cli/​bundle/​plugin_layout.py Defines rendering identities and preferences.
src/​apm_cli/​bundle/​plugin_exporter.py Filters duplicate renderings and reports omissions.
scripts/​architecture_linter/​checks/​marketplace_package_and_registration.py Checks routing through shared rendering owners.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Updates pack and bundle-install guidance.
docs/​src/​content/​docs/​reference/​cli/​pack.md Documents rendering selection and conversion.
changelog.d/​4693.changed.md Adds a user-facing changelog entry.
.apm/​architecture/​owners/​install-deployment.json Expands rendering ownership definitions.

Review effort: Balanced

Comment thread src/apm_cli/bundle/plugin_layout.py Resolved
Comment thread src/apm_cli/bundle/plugin_layout.py Resolved
…s without the APM rendering

Review: dotted stems (rv.md + rv.agent.md from one Claude install) are no
longer paired, review.agent.instructions.md pairs with its Claude rule, a
[claude, cursor] producer keeps py.md and py.mdc, and bundle install names
every file it skips for another rendering of the same target file.

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

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

# Conflicts:
#	docs/src/content/docs/reference/cli/pack.md
#	src/apm_cli/install/local_bundle_paths.py
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json

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

Two critical defects can turn scoped Claude rules unconditional and silently drop distinct commands, while malformed-frontmatter handling lacks regression coverage.

3 open issues
2 resolved since last review

Review effort: Balanced

Comment thread src/apm_cli/bundle/plugin_exporter.py Resolved
A [copilot, gemini] producer exports .github/prompts/review.prompt.md as
commands/review.md; report .md as its rendering extension so it pairs with
commands/review.toml and the bundle keeps one rendering.

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

- A Claude rule packed as instructions/py.instructions.md keeps its paths:
  (InstructionIntegrator.is_native_rule), instead of a second conversion
  that dropped the scoping.
- Regressions: a Claude command and a renamed Copilot prompt with a dotted
  stem stay distinct; a malformed packed instruction is named, skipped and
  unclaimed while its sibling installs.

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

# Conflicts:
#	docs/src/content/docs/reference/cli/pack.md
#	src/apm_cli/install/local_bundle_paths.py
#	tests/lifecycle/generator/rules.py
#	tests/quality/lifecycle_obligations.json

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

Bundle rule conversion bypasses decoded-frontmatter security checks, allowing blocked bidirectional characters to be deployed, while superseded files are omitted from skipped counts.

2 open issues
3 resolved since last review

Review effort: Balanced

Comment thread src/apm_cli/install/services.py Resolved
…ked rules

- Distinct native agents rv.md and rv.agent.md from a Claude install both
  deploy: bundle install strips the extension the packing install gave a
  dependency file (bundle lockfile deployed_files), not the longest suffix.
- Packed rules pass InstructionIntegrator.decoded_frontmatter_blocked (the
  decoded-frontmatter hidden-character preflight, force policy kept) before
  native passthrough or conversion; the AC36 guard follows the scan owner.
- Superseded renderings count in the install summary's skipped total.

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

The switch from approved Claude renderings to APM renderings lacks an R1 ruling in the fetched comments, requiring maintainer confirmation of the scope change and native-host compatibility evidence.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

main's revert left the module at 2101 lines; fold the skills filter into
the loop header (no behavior change).

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

Instruction rendering identity is derived incorrectly for identity-copied Grok Build files, causing doubled Copilot filename suffixes and mixed-target collisions instead of deduplication.

1 open issue

Review effort: Balanced

Comment thread src/apm_cli/bundle/plugin_layout.py Resolved
…d install

Instruction targets without a rule transform (Copilot, Grok Build) copy an
APM instruction verbatim under its source name, whatever extension the
mapping declares. plugin_layout.deployed_file_extension owns that policy;
pack rendering identity and bundle install lowering both use it, so a
[grok-build, copilot] producer dedupes the two renderings, pack.renderings
records .instructions.md, and consumers install py.instructions.md.

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.

🔵 Needs a closer look

Human assessment is needed because target-specific path handling assigns different identities to the same nested agent, causing Claude bundle consumers to install both renderings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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

Valid YAML with mixed-type mapping keys can trigger an uncaught TypeError in the frontmatter scanner, aborting bundle installation and preventing valid sibling files from installing.

1 open issue

Review effort: Balanced

)

Valid YAML such as extra: {1: numeric, note: text} makes the decoded
frontmatter preflight raise TypeError and aborts the bundle install
instead of installing the file and its sibling.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The decoded-frontmatter preflight serialized metadata with sorted keys,
so valid YAML with a numeric key raised TypeError and aborted the
bundle install. The scanner now renders every key as text, keeping
keys that render alike as separate entries so no value escapes the
scan.

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

YAML sets bypass recursive frontmatter checks, allowing decoded Unicode override characters to evade bundle-rule preflight detection.

1 open issue
1 resolved since last review

Review effort: Balanced

…3686)

A decoded override character inside a !!set member reaches the scan
only as an ASCII escape, so the packed rule installs.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The decoded-frontmatter preflight left set members and other non-JSON
values to str(), whose repr escapes a hidden override character, so the
scan never saw it. Set members now become list items and other values
and non-string keys become their decoded text.

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.

🔵 Needs a closer look

Human assessment is needed because a numeric frontmatter key can trigger an uncaught TypeError that aborts bundle installation rather than allowing valid sibling instructions to install.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 6c0d166 into main Nov 23, 2026
75 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-fix-3686-pack-plugin-renderings branch November 23, 2026 13:55
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 --format plugin for a multi-target producer ships one primitive in several renderings, and a Claude consumer keeps the wrong one

2 participants