Skip to content

[BUG] apm install silently overwrites user edits to deployed hook, canvas and LSP files #4626

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
When a user edits a hook file, a canvas extension or an LSP server entry that APM deployed, a plain apm install replaces the edited file with the package's content. It prints no warning. A deployed skill is handled differently: apm install keeps the edited file and prints [!] Kept .agents/skills/<name>/SKILL.md: it was modified since APM deployed it .... apm audit --ci and apm install --frozen both report the edited hook as hash drift, so the edit is detected and then discarded on the next install.

To Reproduce

  1. In a project with the executables gate on, run apm install <pkg-with-hook> and apm install <pkg-with-canvas>, then apm approve both packages and run apm install. This deploys .github/hooks/<pkg>-session.json and .github/extensions/<pkg>/extension.mjs.
  2. Edit both files. For example, change the hook command from echo p-exec to echo my-own-hook and append a comment line to extension.mjs.
  3. Optional: apm audit --ci exits 1 and reports drift detected: 1 file(s): .github/hooks/<pkg>-session.json.
  4. Run apm install. It exits 0 and prints 1 hook(s) integrated and 1 canvas extension(s) integrated.
  5. Both edits are gone, and no line names the overwritten files.

Expected behavior
Edited executable files should follow the same ownership rule as skills. Either keep the user's bytes and report them (as Kept ... modified since APM deployed it does), or refuse with a remediation such as move aside, apm install --force or apm export-patch. Only --force should replace user edits silently. If restoring approved bytes is intended for executables, the install should say which files it overwrote.

Environment (please complete the following information):

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

Logs

=== apm install -> 0
[i] Targets: copilot  (source: apm.yml)
  |-- 1 canvas extension(s) integrated -> .github/extensions/
  |-- 1 hook(s) integrated -> .github/hooks/
  |   sessionStart: runs echo p-exec (session.json)
[*] Installed 2 APM dependencies in 0.6s.

After the install, the hook again runs echo p-exec and the canvas comment is gone.

Additional context
The same happens to an edited LSP server entry in .github/lsp.json: apm install restores APM's entry.

Strict known cell to flip when this is fixed: tests/lifecycle/scenarios/test_ownership_siblings.py::test_edited_executable_files_are_kept (law I1 via I1-X2, tracking #4626); then regenerate with python -m tests.lifecycle.generator so its pairs move from known-failing to required.

Found by the T-6b ownership scenario suite: cells pair|PRIM=hook|DEPLOYED=edited and pair|PRIM=canvas|DEPLOYED=edited, law P-LAW-ownership.preserve_unowned (oracle I1-X2: APM must keep the bytes a user wrote). Epic #4565.

Activity

  1. added
    type/bug
    on Nov 21, 2026
  2. changed the title [-][BUG] apm install silently overwrites user edits to deployed hook and canvas files[/-] [+][BUG] apm install silently overwrites user edits to deployed hook, canvas and LSP files[/+] on Nov 21, 2026
  3. added
    status/needs-design
    area/hooks
    pillar/govern
    on Nov 21, 2026
  4. danielmeppiel commented on Nov 21, 2026

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: apm install, at project and user scope, never rewrites a deployed hook file or copied hook script, a canvas extension file, or an APM-managed LSP server entry unless deployment evidence proves APM wrote the current bytes (matching receipt, legacy ownership or locked render), the same overwrite gate other kinds use. Identical or proven-unedited outputs update silently. A proven edit with nothing new to deploy is kept with one [!] Kept line naming it and its remedies, and the install exits 0. A proven edit that blocks an update, or an unproven mismatch, is kept, named and the install exits 1. A canvas bundle with any kept member is left whole. LSP entries are judged per server against the entry APM rendered, preserving unrelated keys. A kept edit is never recorded as APM's baseline. --force still overwrites.
    Done when: New required installed-CLI lifecycle cells (T-6b pair|PRIM=hook|DEPLOYED=edited, pair|PRIM=canvas|DEPLOYED=edited, plus an edited LSP entry) fail before the fix and pass after it. They cover an edited copied script, a two-member canvas with one member edited, unrelated LSP keys, a blocked update, an unproven mismatch, and a silent update of unedited outputs. They assert the user's bytes, the Kept line, the exit code and that the kept outputs' prior lock claims are unchanged. A bug-ledger row and a CHANGELOG line are added, docs are updated, and CI is green.
    Out of scope: Backup copies; three-way merge; hook entries merged into shared host settings files; MCP and bin executables; changes to approval semantics.
    Review contact: Daniel Meppiel (@danielmeppiel)

  5. added
    status/accepted
    and removed
    status/needs-design
    on Nov 21, 2026
  6. modified the milestones: 0.38.0, on Nov 21, 2026
  7. 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.

  8. modified the milestones: , 0.38.0 on Nov 21, 2026
  9. 18 remaining items

  10. added a commit that references this issue on Nov 23, 2026
  11. moved this from In Progress to Done in APM Roadmapon Nov 23, 2026
  12. added a commit that references this issue on Nov 23, 2026
    5a1b49a
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/hookspillar/governstatus/acceptedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions