Commit 3fbb624
fix(hooks): scope merged-hook wipe to resolved targets, not all KNOWN_TARGETS (#2252)
* fix(hooks): scope merged-hook wipe to resolved targets, not all KNOWN_TARGETS
HookIntegrator.sync_integration() wiped package-owned merged-hook entries
across every supported harness (.claude/settings.json, .cursor/hooks.json,
.gemini/settings.json, .kiro/hooks/), while the uninstall/prune rebuild
paths that follow it only repopulate the project's currently-declared
targets: list. Narrowing targets: silently dropped a still-installed
sibling package's hooks (and its apm-hooks.json ownership sidecar) in the
now-undeclared target, with no rebuild to restore them.
HookIntegrator remains the single canonical owner of this decision:
- sync_integration() now decouples the file-deletion prefix guard (kept
as the union of KNOWN_TARGETS + caller targets, never narrower than
before -- a safety floor) from a new merge_source variable that scopes
the merged-hook JSON cleanup loop to the caller-supplied targets,
falling back to all KNOWN_TARGETS only when targets is None.
- reconcile_after_removal() now passes targets=targets into its internal
sync_integration() call (previously omitted).
- uninstall/engine.py's _sync_integrations_after_uninstall() now passes
targets=_resolved_targets (previously omitted).
Both apm uninstall and apm prune delegate to the same HookIntegrator
methods with the same resolved-target semantics the rebuild step uses --
no caller-specific cleanup logic.
Adds tests/integration/test_hook_wipe_target_scope_e2e.py: 8 hermetic
CLI-driven tests parametrized across both callers (uninstall, prune)
covering the narrowing repro with sibling + manual-entry preservation,
a negative twin (in-scope wipe still works), idempotency, zero-write
abort before the destructive wipe on resolve failure, and a mutation-
break proof that the scoped-targets behavior is load-bearing. Confirmed
RED (2/8 fail, reproducing #2250 for both callers) with the fix
reverted, GREEN (8/8) restored.
closes #2250
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8f0f6bce-c30a-4694-934e-53ebec71d384
* chore: trigger spec-conformance re-run with waiver
apm-spec-waiver: restores the reconcile-and-preserve hook contract already documented in prune.md/manage-dependencies.md; corrects an implementation bug against an existing promise, no new normative behavior added
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 8f0f6bce-c30a-4694-934e-53ebec71d384
---------
Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>1 parent 49bfdc6 commit 3fbb624
4 files changed
Lines changed: 527 additions & 30 deletions
File tree
- src/apm_cli
- commands/uninstall
- integration
- tests/integration
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
23 | 29 | | |
24 | 30 | | |
25 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
635 | 635 | | |
636 | 636 | | |
637 | 637 | | |
638 | | - | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
639 | 645 | | |
640 | 646 | | |
641 | 647 | | |
642 | 648 | | |
| 649 | + | |
643 | 650 | | |
644 | 651 | | |
645 | 652 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1877 | 1877 | | |
1878 | 1878 | | |
1879 | 1879 | | |
1880 | | - | |
1881 | | - | |
1882 | | - | |
1883 | | - | |
1884 | | - | |
| 1880 | + | |
| 1881 | + | |
1885 | 1882 | | |
1886 | 1883 | | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
1887 | 1890 | | |
1888 | 1891 | | |
1889 | 1892 | | |
1890 | 1893 | | |
1891 | 1894 | | |
1892 | | - | |
1893 | | - | |
1894 | | - | |
1895 | | - | |
1896 | | - | |
1897 | | - | |
1898 | | - | |
1899 | | - | |
1900 | | - | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
| 1903 | + | |
| 1904 | + | |
| 1905 | + | |
1901 | 1906 | | |
1902 | 1907 | | |
1903 | 1908 | | |
| |||
1929 | 1934 | | |
1930 | 1935 | | |
1931 | 1936 | | |
1932 | | - | |
1933 | | - | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
1934 | 1941 | | |
1935 | 1942 | | |
1936 | 1943 | | |
| |||
1977 | 1984 | | |
1978 | 1985 | | |
1979 | 1986 | | |
1980 | | - | |
1981 | | - | |
1982 | | - | |
1983 | | - | |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
1984 | 1997 | | |
1985 | 1998 | | |
1986 | 1999 | | |
| |||
2000 | 2013 | | |
2001 | 2014 | | |
2002 | 2015 | | |
2003 | | - | |
2004 | | - | |
2005 | | - | |
2006 | | - | |
2007 | | - | |
2008 | | - | |
2009 | | - | |
2010 | | - | |
2011 | | - | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
2012 | 2021 | | |
2013 | 2022 | | |
2014 | 2023 | | |
| |||
0 commit comments