Repository navigation
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
- In a project with the executables gate on, run
apm install <pkg-with-hook>andapm install <pkg-with-canvas>, thenapm approveboth packages and runapm install. This deploys.github/hooks/<pkg>-session.jsonand.github/extensions/<pkg>/extension.mjs. - Edit both files. For example, change the hook command from
echo p-exectoecho my-own-hookand append a comment line toextension.mjs. - Optional:
apm audit --ciexits 1 and reportsdrift detected: 1 file(s): .github/hooks/<pkg>-session.json. - Run
apm install. It exits 0 and prints1 hook(s) integratedand1 canvas extension(s) integrated. - 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.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
[-][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[/+]danielmeppiel commentedon Nov 21, 2026
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)
danielmeppiel commentedon Nov 21, 2026
Moved from 0.38.0 to 0.38.1 in the 0.38 release cut (2026-11-21). Scope and acceptance are unchanged.
18 remaining items
docs: install keeps edited managed files; add I7-X2 regular-file cont…
Merge main (b8a12c2) into train 5; regenerate
test: patch run_replay where prepare_ci_audit_replay looks it up (#4626…
test: restore drift.run_replay patches; ci_checks looks run_replay up…
test(lifecycle): T-6b ownership scenario suite -- user bytes survive …
test: stub keeps_edited_output on the Kiro hook mock integrator (#4626)
fix(lsp): a target's own keep is re-judged, never withheld, when anot…
Merge pull request #4678 from microsoft/danielmeppiel-fix-4626-overwr…
Merge origin/main into danielmeppiel-p1-4570-audit-allowlist-remedy
fix(install): keep edited hook, canvas and LSP outputs like any manag…
refactor: keep file-length budgets; edit_kind lives with the overwrit…
fix(lsp): keep OpenCode's entry when a socket upgrade is held (micros…