Skip to content

[BUG] apm uninstall deletes an instruction a local bundle still owns and exits 0 after "1 package failed" #4703

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.

Describe the bug
A local bundle and a path dependency deploy the same instruction file. After apm uninstall of the path dependency:

  • The instruction file is deleted from disk, even though the lockfile still records it as deployed and owned by the local bundle (active_owner: local-bundle). The lock now records a deployed file that does not exist (I1).
  • The command prints [x] 1 package failed: Materialization copilot||project|.github/instructions/f-doc.instructions.md has no ownership metadata, then [*] Uninstall complete, and exits 0. An error line with a success exit breaks the exit contract (I8).

To Reproduce

  1. Create a package f-doc with apm.yml (name: f-doc, version: 1.0.0, dependencies: {apm: []}) and .apm/instructions/f-doc.instructions.md (frontmatter applyTo: '**').
  2. Pack it: apm pack --archive -o out gives out/f-doc-1.0.0.zip.
  3. Add a skill to the same package source (.apm/skills/f-doc/SKILL.md).
  4. In a consumer project with targets: [copilot] and dependencies: {apm: []}:
    • apm install out/f-doc-1.0.0.zip deploys .github/instructions/f-doc.instructions.md (local bundle).
    • apm install <path to f-doc> deploys the skill and the same instruction path.
    • apm uninstall <path to f-doc> exits 0. Its output:
      [+] Cleaned up 1 integrated instruction
        [x] 1 package failed:
          +- Materialization copilot||project|.github/instructions/f-doc.instructions.md has no ownership metadata
      [*] Uninstall complete: removed 1 package
      
  5. .github/instructions/ is now empty, but apm.lock.yaml still lists .github/instructions/f-doc.instructions.md under local_deployed_files and as a deployment with active_owner: local-bundle.

Expected behavior

  • uninstall keeps a file that another owner (here the local bundle) still holds, and the lock stays equal to disk.
  • If uninstall cannot complete a package, it exits non-zero and leaves state consistent, as it already does when the bundle also ships the skill: "Uninstall could not remove tracked target files ... Resolve or remove the listed files, then retry uninstall", exit 1.

Environment (please complete the following information):

  • OS: macOS
  • Python Version: 3.12
  • APM Version: 0.37.0 (main 488a4b1)

Logs
See the output in step 4.

Additional context

Activity

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

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: apm uninstall keeps a deployed file that another owner, such as a local bundle, still holds, so the lockfile stays equal to disk (lifecycle law I1). When uninstall cannot complete a package it exits non-zero and leaves state consistent, the same way it already refuses when the bundle also ships the skill, instead of printing a package failure and exiting 0 (lifecycle law I8). Uninstall never deletes more than before.
    Done when: The T-6c file-routing cell pair|OP=uninstall|FILEROUTE=deployed (strict cell uninstall-keeps-a-bundle-owned-instruction) is flipped to required in the same PR and passes: the shared instruction stays on disk, the lockfile matches disk, and any reported package failure exits non-zero. It fails before the fix and passes after it, a bug-ledger row and a CHANGELOG line are added, and CI is green.
    Out of scope: Changes to ownership precedence between owners; uninstall of files no other owner holds; lockfile format.
    Review contact: Daniel Meppiel (@danielmeppiel)

  3. added
    status/accepted
    on Nov 21, 2026
  4. 3 remaining items

  5. moved this from Todo to In Progress in APM Roadmapon Nov 23, 2026
  6. moved this from In Progress to Done in APM Roadmapon Nov 23, 2026
  7. added a commit that references this issue on Nov 23, 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

    status/acceptedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions