Skip to content

Reinstalling a local bundle after the lockfile is lost leaves MCP lock state that audit --ci and install --frozen reject #4634

Closed

Description

Reporting and investigating a bug need no permission. Before implementing a
substantive fix for inclusion in APM, obtain human scope approval and a review
contact on this issue. Trivial documentation corrections have standing
preapproval. See Contributing.

For vulnerabilities, use SECURITY.md
instead of a public issue. Remove credentials and other sensitive data from logs.

Describe the bug
Suppose a project deployed a local plugin bundle that ships an MCP server, and apm.lock.yaml is then lost (for example, a fresh checkout without it). Reinstalling the same bundle exits 0, but it leaves lock state that both gates reject. apm audit --ci fails config-consistency with p-exec-mcp: in lockfile but not in manifest (declared by bundle:p-exec). apm install --frozen exits 1 with MCP server 'p-exec-mcp' is no longer declared in apm.yml. A successful install should leave a state that --frozen and audit --ci accept. The same bundle flow with the lock in place stays clean.

To Reproduce

  1. apm install ./bundles/p-exec-1.0.0.zip. The bundle ships a hook and a stdio MCP server, p-exec-mcp.
  2. Pin the bundle as the output says (executables: allow: "p-exec#1.0.0@sha256:<digest>": {hooks: true, mcp: true, bin: true}), then apm install ./bundles/p-exec-1.0.0.zip again. This deploys .github/hooks/p-exec-hooks.json and the p-exec-mcp entry in .mcp.json.
  3. rm apm.lock.yaml.
  4. apm install ./bundles/p-exec-1.0.0.zip exits 0. It prints Skipping .github/hooks/p-exec-hooks.json -- local file exists (not managed by APM) and All servers up to date.
  5. apm audit --ci exits 1 (config-consistency). apm install --frozen exits 1.
  6. apm install (the printed remediation) makes audit --ci clean. Running step 4 again breaks it again.

Expected behavior
After step 4, the lock records the bundle's MCP server the same way a first bundle install does, so audit --ci and install --frozen both pass. Otherwise the install should fail, or tell the user what to run.

Environment (please complete the following information):

  • OS: macOS (lifecycle test world, engine driver)
  • Python Version: 3.12
  • APM Version: main (0.38 development)

Logs

=== apm audit --ci -> 1
| [x] | config-consistency | 1 MCP config inconsistenc(ies) -- repeat 'apm install' with the intended selection ('--only apm' for skills-only) to reconcile |
  config-consistency details:
    - p-exec-mcp: in lockfile but not in manifest (declared by bundle:p-exec)
=== apm install --frozen -> 1
- MCP server 'p-exec-mcp' is no longer declared in apm.yml
[x] --frozen: apm.lock.yaml is out of sync with apm.yml.

Additional context
Strict known cell to flip when this is fixed: tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_local_bundle_never_replaces_the_users_hook[present-provenance-unknown] (law R on the audit --ci / install --frozen pair after the reinstall, tracking this issue). Then regenerate with python -m tests.lifecycle.generator so its pair moves from known-failing to required.

Found by the T-6b ownership scenario suite: cell pair|SRC=local-bundle|DEPLOYED=present-provenance-unknown, law P-INV-I3 / P-LAW-outcome.status_matches_state (a successful install leaves a state the gates accept). Epic #4565.

Activity

  1. added
    bug
    on Nov 21, 2026
  2. danielmeppiel commented on Nov 21, 2026

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: Bug fix, no new surface and no new lockfile fields. Reinstalling a local plugin bundle (apm install <bundle>) when apm.lock.yaml is absent records the bundle's MCP servers exactly as a first bundle install does, with bundle:<name> provenance (BUNDLE_MCP_OWNER_PREFIX in src/apm_cli/integration/mcp_config_view.py), so apm audit --ci (config-consistency) and apm install --frozen accept the result. The fix lives in the local-bundle install path (src/apm_cli/install/local_bundle_handler.py together with the MCP recording in src/apm_cli/install/mcp/integration.py) and reuses the existing first-install recording; no second provenance rule.
    Done when: The lifecycle case behind tests/lifecycle/scenarios/test_ownership_siblings.py::test_a_local_bundle_never_replaces_the_users_hook[present-provenance-unknown] passes its audit and frozen checks on the real binary: after the lock is removed and the same bundle is reinstalled, apm audit --ci and apm install --frozen both exit 0, and a repeat reinstall stays clean. Controls: the same flow with the lock in place stays clean; a first bundle install records the same lock rows as before (byte-identical); the hook file APM no longer has provenance for is still skipped, not taken over. A bug-ledger row and one Fixed line in CHANGELOG.md.
    Out of scope: Re-adopting or overwriting files whose provenance is unknown (hooks or others; see #4626); bundle format or pack changes; new flags.
    Review contact: Daniel Meppiel (@danielmeppiel)

  3. added
    status/accepted
    type/bug
    area/mcp-config
    pillar/consume
    on Nov 21, 2026
  4. modified the milestones: 0.38.0, on Nov 21, 2026
  5. danielmeppiel commented on Nov 21, 2026

    @danielmeppiel
    CollaboratorAuthor

    Moved from 0.38.0 to 0.38.1 in the 0.38 release cut (2026-11-21). Scope and acceptance are unchanged.

  6. modified the milestones: , 0.38.0 on Nov 21, 2026
  7. danielmeppiel commented on Nov 21, 2026

    @danielmeppiel
    CollaboratorAuthor

    Moved to 0.38.0: maintainer direction is that found bugs and in-flight accepted work ship in 0.38.

  8. added a commit that references this issue on Nov 22, 2026
    0f1b88e
  9. added 2 commits that reference this issue on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mcp-configbugpillar/consumestatus/acceptedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions