Skip to content

fix(pack): use the apm.yml version in the bundled plugin.json - #3408

Merged
Daniel Meppiel (danielmeppiel) merged 7 commits into
microsoft:mainfrom
abhishekacharya200:fix/pack-plugin-version-stale
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 7 commits into
microsoft:mainfrom
abhishekacharya200:fix/pack-plugin-version-stale

Conversation

@abhishekacharya200

Copy link
Copy Markdown
Contributor

Fixes #3351.

Problem

apm pack names the bundle directory from the apm.yml version but takes the manifest from a disk-first read of an existing plugin.json. After a version bump, the two disagree:

build/demo-pkg-1.0.3/plugin.json -> {"name": "demo-pkg", "version": "1.0.2"}

So the artifact's own identity contradicts its directory name, and whatever consumes that plugin.json (host, registry, marketplace) keeps seeing the previous release.

Reproduced on main with a project whose apm.yml declares 1.0.3 and whose .claude-plugin/plugin.json still declares 1.0.2; before this change the packed manifest kept 1.0.2.

Fix

export_plugin_bundle now reconciles the manifest version to the apm.yml version and warns when the authored value differed, naming both versions so the author can fix the source file instead of re-bumping on every pack. Every other authored field is preserved as before (find_or_synthesize_plugin_json is still disk-first), and the input dict is not mutated.

This matches the existing rule already documented on build_plugin_manifest: apm.yml is the source of truth for the generated manifest.

Note on scope: apm pack does not write the ecosystem manifests at the repository root (.claude-plugin/plugin.json, .github/plugin/plugin.json) — those are produced by the build orchestrator — so this change does not rewrite source files. It makes the bundle it emits internally consistent.

Tests

  • New TestReconcilePluginJsonVersion covering: stale authored version reconciled, matching version untouched and silent, missing version filled, input not mutated, and an end-to-end pack asserting build/demo-pkg-1.0.3/plugin.json declares 1.0.3.
  • test_uses_existing_plugin_json asserted the old contract (authored 2.0.0 preserved inside a test-pkg-1.0.0 bundle). Updated to the new contract with the reason documented in the test docstring; the authored name assertion is unchanged.

Verification

  • tests/unit/test_plugin_exporter.py: 111 passed, 5 skipped.
  • tests/unit/bundle tests/unit/test_packer.py tests/unit/test_plugin_exporter.py: 274 passed, 5 failed — the same 5 symlink/case-sensitivity tests fail identically on main in this Windows checkout (no symlink privilege).
  • tests/integration/test_remaining_modules_coverage.py: 154 passed.
  • ruff check and ruff format --check clean on both touched Python files.
  • tests/spec_conformance could not be used as a signal here: it fails on Windows symlink privileges and then stalls past a 4-minute bound in this environment, unrelated to the change.

A stale authored plugin.json made `apm pack` produce a self-contradicting
bundle: the directory came from the apm.yml version (build/<pkg>-1.0.3)
while the manifest inside still declared the previous release's version.
Reconcile the manifest version to apm.yml, warn when the authored value
diverged, and preserve every other authored field.

Closes microsoft#3351

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.

🟢 Approval recommended

No active review issues remain for the change aligning bundled manifest versions with apm.yml.

No open issues 🎉

What changed in this PR

Fixes the bundled-manifest version mismatch reported in #3351 by making apm.yml authoritative for the version emitted by apm pack. Authored source manifests remain unchanged.

Changes:

  • Reconciles the bundled plugin.json version and warns when it differs, preserving other authored fields.
  • Adds regression coverage for stale, matching, and missing versions, input immutability, and bundle-directory consistency.
  • Records the fix in the changelog.
File Description
tests/​unit/​test_plugin_exporter.py Adds reconciliation tests and updates the expected bundled-version contract.
src/​apm_cli/​bundle/​plugin_exporter.py Reconciles the manifest version during export and warns on mismatches.
CHANGELOG.md Documents the corrected bundle version behavior under Unreleased.

Review effort: Balanced

@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

Thank you for contributing this fix. APM starts with an issue, not an implementation (https://github.com/microsoft/apm/blob/main/CONTRIBUTING.md). Please ask a maintainer to review and accept the scope in #3351 before implementation proceeds, including whether this should update only the packed plugin.json or also the source manifests described in the issue. This PR is labelled status/deferred until then. Current review requests include Daniel Meppiel (@danielmeppiel) and Sergio Sisternes (@sergio-sisternes-epam).


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

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added status/deferred Not invited for implementation now; no release commitment. triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented. labels Nov 3, 2026
Folds the microsoft#3351 scope gaps into microsoft#3408. The approved scope requires every
plugin.json in the bundle output to carry the apm.yml version regardless
of a previous build, a regression test on POSIX and Windows, and updated
docs and CHANGELOG. The warning now names the authored manifest path so
the author knows which file to fix (it is never rewritten), and an
authored manifest without a version is filled silently since nothing
contradicts apm.yml. The parametrized regression test seeds a stale
build/<pkg>-1.0.2 and a stale .claude-plugin/plugin.json, asserts both
bundled manifests (root and the hooks native copy) say 1.0.3, keeps
authored and old-build bytes unchanged, and is marked windows_compat so
the PR-time Windows gate runs it. CHANGELOG entry moves into the
existing Unreleased Fixed section and cites (microsoft#3408).

Addresses Step 0.P plan gaps G1-G6 (scope record issuecomment-6824141350).

Co-authored-by: abhishekacharya200 <[email protected]>
Co-authored-by: Copilot App <[email protected]>
When apm.yml declares target:, apm pack writes the source ecosystem
manifest and preserves an existing one without --force, so a version bump
yields both the existing skip warning and the new bundle-version warning
for the same file. The reference now names --force as the regeneration
path and links the Overwrite and dry-run section, keeping the page
consistent with itself.

Addresses panel doc-writer finding on docs/src/content/docs/reference/cli/pack.md:168.

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

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

Community bug fix: apm pack now writes the apm.yml version into every bundled plugin.json, so a stale authored manifest or an earlier build no longer ships the wrong version.

panel-mode=lean; personas=devx-ux-expert,test-coverage-expert,doc-writer(adhoc: approved scope requires docs + CHANGELOG),apm-ceo

cc Abhishek Acharya (@abhishekacharya200) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three panelists converged. DevX UX confirms the warning is actionable and ASCII, apm.yml as the canonical version matches npm/cargo expectations, and never editing source manifests is the right build-tool contract. Test coverage confirms every item in the #3351 scope record has a targeted test with mutation-break confirmation: the stale-build case, root and native .claude-plugin/plugin.json copies, the windows_compat marker for the Windows gate, unchanged authored and old-build bytes, and the warning content. The doc-writer's one finding (point users whose manifest apm pack generated from target: to --force) was folded in 6ef3607.

The contributor's original commit is preserved; maintainer folds carry Co-authored-by credit. Nothing outside the approved scope was added.

Aligned with: portable by manifest (apm.yml is the single version source for the bundle); pragmatic as npm (surface fixable drift at build time without rewriting source); OSS community driven (contributor work preserved and credited).

Panel summary

Persona B R N Takeaway
DevX UX Expert 0 0 0 Warning wording is actionable and ASCII; apm.yml-is-canonical model matches npm/cargo; source never edited; ship.
Test Coverage Expert 0 0 0 All five scope items have targeted tests with mutation-break confirmation; ship.
Doc Writer 0 1 0 Docs and CHANGELOG match the code; one gap (no --force pointer for generated manifests), now folded.

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

Recommendation

Three panelists unanimous, zero open findings after the doc fold, every scope item test-covered, CI green on the merged head. Ready for maintainer review; no follow-ups to track.

Folded in this run

  • (scope gap) Regression test seeds a stale build/<pkg>-1.0.2/ and a stale .claude-plugin/plugin.json, asserts the new bundle says 1.0.3, and checks authored and old-build bytes are unchanged -- resolved in 3e0a296.
  • (scope gap) Regression test marked windows_compat, so the PR-time Windows Compatibility Gate runs it (POSIX and Windows) -- resolved in 3e0a296.
  • (scope gap) Hooks case asserts the native .claude-plugin/plugin.json copy in the bundle also carries the apm.yml version -- resolved in 3e0a296.
  • (scope gap) Docs updated: reference/cli/pack.md, producer/pack-a-bundle.md -- resolved in 3e0a296.
  • (scope gap) CHANGELOG bullet moved into the existing Unreleased Fixed section, citing (fix(pack): use the apm.yml version in the bundled plugin.json #3408) with contributor credit -- resolved in 3e0a296.
  • (scope gap) Warning names the authored manifest path; an authored manifest without a version is filled silently -- resolved in 3e0a296.
  • (panel: doc-writer) pack.md points users with a target:-generated manifest to --force -- resolved in 6ef3607.

Copilot signals reviewed

  • Overview review 5682298404 -- NOT-LEGIT (nothing actionable): approval recommended with zero inline items; second fetch found no new comments.

Regression-trap evidence (mutation-break gate)

  • tests/unit/test_plugin_exporter.py::TestReconcilePluginJsonVersion::test_stale_build_and_manifest_pack_with_apm_yml_version -- deleted the _reconcile_plugin_json_version assignment in export_plugin_bundle; the test (and test_uses_existing_plugin_json) FAILED as expected; guard restored.

Lint contract

On b35eac0 (merged with current main): ruff check and format --check silent, pylint R0801 clean, lint-auth-signals.sh clean, lint-architecture-boundaries.sh exit 0.

CI

23 checks pass, 3 skipping, 0 failing at b35eac0 (Build & Test, Lifecycle Smoke, Windows Compatibility Gate, Spec conformance, Merge Gate, CodeQL); license/cla pass (after 0 CI fix iterations).

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3408 b35eac0 ship_now 1 7 0 2 green MERGEABLE BLOCKED pending required review

Convergence

1 outer iteration; 2 Copilot rounds. Final panel stance: ship_now. Closes #3351 via the existing Fixes #3351 in the PR body. Ready for maintainer review.

This panel is advisory. It does not block merge.


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

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Lane L: main merged for landing

  • Pre-merge head: b35eac0200ec6337409dd52daeed8b3d57cef2b2
  • Merged origin/main c2c2e0d72c8e8c88f143099c73f40720b6529a4e (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: 69af6b2ccbc860a4ae7d85f2818937630178b14a
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Integrate copilot runtime #2 of 18, so queued PRs no longer collide at the section head while landing serially.
  • Lint: ruff check + ruff format --check silent at the new head; CI green at the new head.
  • Owner-touch report regenerated at the new head; every recorded functional test was re-run at that exact head and passed (one process at a time, no xdist).
  • Push: git push https://github.com/abhishekacharya200/apm.git HEAD:refs/heads/fix/pack-plugin-version-stale (plain push, no force).

This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel).

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 7b50e18 into microsoft:main Nov 12, 2026
26 checks passed
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of eight main commits (#3408, #2231, #2602, #3640, #3611,
#3645, #3602, #3646); no lockfile or autopilot package conflicts and
apm audit --ci passes with no drift.

Co-authored-by: sergio-sisternes-epam <[email protected]>
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

status/deferred Not invited for implementation now; no release commitment. triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] apm pack produces incorrect plugin.json version if an older build already exists

4 participants