Repository navigation
fix(uninstall): keep surviving bundles' skills: selection (#3760) - #3784
Daniel Meppiel (danielmeppiel) merged 15 commits into
Conversation
…ner (#3760) apm uninstall re-integrated surviving packages without their skills: selection, so every skill of a surviving bundle was redeployed and left unrecorded in the lockfile. Add effective_dependency_selection() in install/package_resolution.py as the single owner of the effective deploy selection and route install preflight, install deploy, audit replay and uninstall re-integration through it. skill_subset is now a required keyword of integrate_package_primitives and prepare_package_deployment. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]>
Add the install-deployment-effective-selection architecture guard: every integrate_package_primitives, prepare_package_deployment and DeployableSourcePlan.create call passes skill_subset (and any dep_target_subset) from effective_dependency_selection, with allowlisted hooks-only and plan-derived sites, and skill_subset stays a required keyword. Register the dependency-selection owner, add its MutationCase and mutation-break cases, update the audit-replay guard and its tests to the owner call, pass skill_subset explicitly in direct test callers, add a TypeError unit test and the uninstall L7 lifecycle test (project and -g), and document the uninstall rebuild selection. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The shared conformance fixture omits the now-required skill_subset argument, causing all four cases to raise TypeError before reaching their admission assertions.
1 open issue
What changed in this PR
This PR addresses #3760 by preserving surviving dependencies' skills: selections when uninstall rebuilds integrations in project and global scope. It centralizes deployment selection across install, audit replay, and uninstall; cleanup of previously leaked skills and diamond-edge selection merging remain out of scope.
Changes:
- Introduces a shared dependency-selection owner and makes
skill_subsetan explicit, required deployment argument. - Adds architecture guards, mutation tests, and project/global lifecycle regression coverage.
- Updates existing test callers, uninstall documentation, and release notes.
| File | Description |
|---|---|
tests/unit/integration/test_hook_target_selection.py |
Supplies explicit skill selection. |
tests/unit/integration/test_hook_configured_routing.py |
Updates the deployment helper's arguments. |
tests/unit/integration/test_dep_target_intersection.py |
Updates target-intersection test callers. |
tests/unit/integration/test_data_driven_dispatch.py |
Updates the dispatch helper's arguments. |
tests/unit/integration/test_cursor_hook_native_contract.py |
Updates Cursor hook deployment callers. |
tests/unit/integration/test_command_integrator.py |
Updates command integration callers. |
tests/unit/integration/test_canvas_integrator.py |
Updates canvas integration callers. |
tests/unit/install/test_skill_subset_deploy_parity.py |
Tests the selection owner and required keyword. |
tests/unit/install/test_skill_completion_receipt.py |
Updates completion-receipt callers. |
tests/unit/install/test_services.py |
Updates service test callers. |
tests/unit/install/test_services_rendering.py |
Updates rendering test callers. |
tests/unit/install/test_services_phase3.py |
Updates service branch test callers. |
tests/unit/install/test_services_hook_scope.py |
Updates hook-scope test callers. |
tests/unit/install/test_services_branches.py |
Updates service branch test callers. |
tests/unit/install/test_agent_symlink_diagnostics.py |
Updates the diagnostic test's deployment call. |
tests/unit/install/test_agent_plugin_deployment_boundary.py |
Updates the plugin-boundary deployment call. |
tests/integration/test_uninstall_skill_selection_lifecycle.py |
Adds project/global survivor-selection regression tests. |
tests/integration/test_plugin_bin_trust_posture.py |
Updates plugin trust test callers. |
tests/integration/test_install_services_phase3w5.py |
Updates service integration callers. |
tests/integration/test_install_services_orchestration.py |
Updates orchestration test callers. |
tests/integration/test_hook_integrator_copilot_casing_e2e.py |
Updates the hook integration helper. |
tests/integration/test_hook_configured_routing_e2e.py |
Updates the routing test helper. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds selection-owner bypass mutations. |
tests/integration/test_architecture_intent_guards.py |
Requires audit replay to use the selection owner. |
tests/integration/test_architecture_install_compound_mutations.py |
Aligns audit mutations with owner-based selection. |
src/apm_cli/integration/hook_reintegration.py |
Explains the hooks-only selection exception. |
src/apm_cli/install/template.py |
Routes preflight and deployment through the owner. |
src/apm_cli/install/services.py |
Requires skill selection and routes local content through the owner. |
src/apm_cli/install/package_resolution.py |
Defines the shared effective-selection owner. |
src/apm_cli/install/drift.py |
Uses the owner for locked-selection replay. |
src/apm_cli/install/deployment_plan.py |
Makes skill_subset required. |
src/apm_cli/commands/uninstall/engine.py |
Preserves survivor selection during reintegration. |
scripts/architecture_linter/checks/install_frozen_and_audit.py |
Updates the audit-replay guard. |
scripts/architecture_linter/checks/install_effective_selection.py |
Adds selection ownership and required-keyword checks. |
scripts/architecture_linter/checks/install_deployment_analyzers.py |
Registers the selection guard. |
docs/src/content/docs/reference/cli/uninstall.md |
Documents survivor skill-selection preservation. |
CHANGELOG.md |
Records the fix and legacy cleanup guidance. |
.apm/architecture/owners/install-deployment.json |
Registers dependency-selection ownership. |
Review effort: Balanced
…ve-selection rule (#3760) apm-spec-waiver: test-only call-site update for the required skill_subset argument; no spec behavior change Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 3 | 0 | The owner and the required-keyword design are sound for deploy calls. The guard still misses target selection, aliased call names and the lockfile's recorded subset. |
| Test Coverage Expert | 0 | 2 | 0 | Every Done-when item is trapped, including a pre-fix-failing real-binary regression test. That test is not in the PR-time lifecycle job, and the target half of uninstall selection is untested. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Test Coverage Expert] Mark
tests/integration/test_uninstall_skill_selection_lifecycle.pyaslifecycle_smoke(andintegration). Today a revert of the [BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760 fix would surface only in the merge queue. - [Python Architect] Route
LockfileBuilder._attach_skill_subset_overridethrougheffective_dependency_selection, and keepeffective_deploy_skill_subsetinside the owner module. Otherwise the recorded selection and the deployed selection come from two call sites, and they will drift once [BUG] Transitive skill_bundle deduplication silently discards skill subsets when two parents declare different subsets of the same repo #3735 changes selection. - [Test Coverage Expert] Add a project-scope survivor case with
targets: [claude].engine.py:1199now takestarget_subsetfrom the owner, but nothing asserts it. - [Python Architect] Make the owner the only target-selection authority. Route the hook reconcile through it and guard
resolve_effective_package_targetswith a MutationCase, or narrow the registry text. As it stands, the registry claims more than the guard enforces. - [Python Architect] Resolve aliased imports when the guard matches deploy calls, and add an alias-bypass MutationCase. No alias exists today, so this is the lowest priority.
Recommendation
The bug fix is correct, inside the stated scope, and proven by a real-binary regression test that failed before the fix. Fold the lifecycle_smoke marker in this PR. Close the lockfile single-owner and target-selection gaps before PR-3 (#3786) builds diamond-merge selection on this owner.
Full per-persona findings
Python Architect
- [recommended] The owner entry claims target selection, but nothing enforces it, and the uninstall hook reconcile still reads
dep_ref.target_subsetdirectly (src/apm_cli/integration/hook_integrator.py:1981). Thedependency-selectionregistry entry claims target selection for uninstall survivor re-integration. The guard checks only deploy-call keywords, so changingengine.py:1199back todep_ref.target_subsetwould still pass, andreconcile_after_removalis a second target authority.
Suggested: Passeffective_dependency_selection(dep_ref).target_subsetin the hook reconcile. Then addresolve_effective_package_targetsto the guarded calls with a MutationCase, or narrow the registry text. - [recommended] The guard finds deploy calls by bare name, so an aliased import or a
cls.createcall escapes it (scripts/architecture_linter/checks/install_effective_selection.py:74). The required keyword catches an omitted selection at runtime, but not a call that passes a locally computed subset through an alias.
Suggested: Collect ImportFrom aliases per module and treat the aliased names as deploy names. Add an alias-bypass MutationCase. - [recommended] The lockfile phase records the skill subset by calling
effective_deploy_skill_subsetdirectly instead of the owner (src/apm_cli/install/phases/lockfile.py:401). Audit replay deploys the locked selection that this builder writes, so "audit --ci agrees" depends on two call sites making the same decision.
Suggested: Compute the selection witheffective_dependency_selection(locked_dep, self.ctx).skill_subsetand restricteffective_deploy_skill_subsetto the owner module.
Test Coverage Expert
- [recommended] The [BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760 regression test is not marked
lifecycle_smoke, so a revert of the fix is first caught in the merge queue, not at PR time (tests/integration/test_uninstall_skill_selection_lifecycle.py:19). The required job selects-m 'lifecycle_smoke and not lifecycle_merge_group'.
Proof (passed):tests/integration/test_uninstall_skill_selection_lifecycle.py-- proves: after an unrelated uninstall, only the selected alpha skill remains, recorded in the lock, at project and user scope. It failed 2/2 on pre-fix src. [portability-by-manifest,governed-by-policy] - [recommended] Uninstall survivor targeting reads the target subset from the owner, but no test checks that a survivor's
targets:narrowing holds after uninstall (src/apm_cli/commands/uninstall/engine.py:1199).
Proof (missing at):tests/integration/test_uninstall_skill_selection_lifecycle.py-- proves: an unrelated uninstall does not widen a survivor beyond the targets the consumer narrowed it to. [portability-by-manifest,multi-harness-support,governed-by-policy]
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
Panel follow-ups on #3784. The lockfile builder recorded the skill subset by calling effective_deploy_skill_subset itself, and uninstall hook reconcile plus the explicit-target preflight read dep_ref.target_subset directly, so the owner covered less than its registry entry claimed. All three now take the selection from effective_dependency_selection. The install-deployment-effective-selection guard now also checks every resolve_effective_package_targets call, keeps effective_deploy_skill_subset internal to the owner module, and resolves aliased imports of the deploy functions; four new bypass mutations prove each case. The #3760 lifecycle test is now lifecycle_smoke (runs in the PR-time lifecycle job) and gains a survivor targets: narrowing case. apm-spec-waiver: install deploy-selection routing with no OpenAPM requirement change Co-authored-by: Copilot App <[email protected]>
Traps the lockfile builder's route through effective_dependency_selection: it records the persisted plus CLI --skill union for skill bundles only. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…real lock entries (#3763) Align the pairing owner with #3786's explicit-empty rule: an edge whose skills: or targets: is explicitly empty contributes no skill-target pairs, and a node whose every edge is empty keeps the empty flat selection (NodeSelection.lock_selection reconciles audit and uninstall). effective_dependency_selection only treats a decoded SkillTargetSelection as a pairing, and the #3784 lockfile overlay test uses LockedDependency. Co-authored-by: Copilot App <[email protected]>
#3793 guarded the post-uninstall legacy-root assertion with an xfail until #3760 landed. With the effective-selection owner in place the survivor keeps only its selected skill, so the conditional would only mask a future U1 regression. Co-authored-by: Copilot App <[email protected]>
The U1 x --legacy-skill-paths assertion in the #3793 lifecycle module only runs in the merge queue. Add a cheap local-path case to the lifecycle_smoke module so a survivor-selection regression on the legacy layout fails on every PR. Fails on pre-fix src (all 4 skills re-integrated), passes at head. Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 1 | 0 | All three prior findings are folded. #3793 adds no deploy path that skips the owner. Still open: a deploy call that omits dep_target_subset would pass the guard. |
| Test Coverage Expert | 0 | 1 | 0 | Both prior gaps are trapped and the new mutations are meaningful. The legacy U1 trap ran only in the merge queue; it is now folded into the PR-time module. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [Python Architect] After merge, make
dep_target_subseta required keyword on the deploy functions and have the guard flag its omission. Target selection currently relies on the uninstall survivor call pre-narrowing through the owner; requiring the argument turns a future omission into a TypeError, as forskill_subset.
Folded in this run
- (copilot) Spec conformance
codex_admissionfixture passesskill_subset=None-- resolved in aab5460. - (panel)
lifecycle_smokemarker; survivortargets:e2e case; lockfile record and target resolution through the owner; alias-aware guard -- resolved in f95fc6c, 9f754fd. - (panel/captain) PR-time legacy-layout U1 trap, and the fix(skills): rebuild recorded skills in the layout the install used (#3773) #3793
#3760xfail conditional removed -- resolved in 3285f7b, b775711.
Deferred (out-of-scope follow-ups)
- (panel) Required
dep_target_subsetkeyword plus guard -- scope boundary: the approved scope makes only the skill selection a required argument; targets already route through the owner at every site.
Regression-trap evidence (mutation-break gate)
test_uninstall_skill_selection_lifecycle.pyL7 (project,-g) and the legacy case -- on pre-fix src these FAILED (all skills re-integrated).- The survivor targets case -- with the engine's owner target subset replaced by
None, it FAILED. test_lockfile_records_the_selection_the_owner_deploys-- with the owner call'sctxdropped, it FAILED.- Bypass params
aliased-deploy-call,uninstall-local-target-subset,hook-reconcile-local-target-subsetandlockfile-records-outside-owner-- each FAILED with its guard check disabled.
Lint contract
At 1a4dc9b: uvx [email protected] check and format --check silent; pylint R0801 10.00/10; scripts/lint-auth-signals.sh clean; bash scripts/lint-architecture-boundaries.sh exit 0.
CI
All checks green at 1a4dc9b: CI, Merge Gate, Spec conformance, CodeQL, NOTICE Drift. One CI fix iteration: the Windows Compatibility Gate failed in the unrelated test_audit_workspace_identity_lifecycle.py[git] because gh auth token timed out on the runner (infra); the rerun was green.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3784 | 1a4dc9b | ship_with_followups | 2 | 7 | 1 | 2 | green | MERGEABLE | BLOCKED | pending required review |
Full per-persona findings
Python Architect
- [recommended]
dep_target_subsetis still optional on the deploy functions, so a call that omits it passes the guard (scripts/architecture_linter/checks/install_effective_selection.py). All callers are correct today. The uninstall survivor call omits it but pre-narrows its targets through the owner atengine.py:1210.
Suggested: Make it a required keyword-only argument, add it to the guard's required-keyword check, and passselection.target_subsetin the uninstall survivor call. Deferred as a scope boundary; see above.
Test Coverage Expert
- [recommended] The now-unconditional U1 x legacy-layout assertion only runs in the merge queue (
tests/integration/test_legacy_skill_layout_lifecycle.py:134).
Folded in b775711 astest_uninstall_unrelated_package_keeps_legacy_layout_skill_selectionin thelifecycle_smokemodule.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
) Co-authored-by: Copilot App <[email protected]>
Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]>
#3735) (#3786) * fix(uninstall): route every deploy through one effective-selection owner (#3760) apm uninstall re-integrated surviving packages without their skills: selection, so every skill of a surviving bundle was redeployed and left unrecorded in the lockfile. Add effective_dependency_selection() in install/package_resolution.py as the single owner of the effective deploy selection and route install preflight, install deploy, audit replay and uninstall re-integration through it. skill_subset is now a required keyword of integrate_package_primitives and prepare_package_deployment. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * fix(install): guard the effective deploy-selection owner (#3760) Add the install-deployment-effective-selection architecture guard: every integrate_package_primitives, prepare_package_deployment and DeployableSourcePlan.create call passes skill_subset (and any dep_target_subset) from effective_dependency_selection, with allowlisted hooks-only and plan-derived sites, and skill_subset stays a required keyword. Register the dependency-selection owner, add its MutationCase and mutation-break cases, update the audit-replay guard and its tests to the owner call, pass skill_subset explicitly in direct test callers, add a TypeError unit test and the uninstall L7 lifecycle test (project and -g), and document the uninstall rebuild selection. apm-spec-waiver: deploy-time skill selection routing fix; no OpenAPM spec requirement covers uninstall re-integration selection Co-authored-by: Copilot App <[email protected]> * docs(changelog): uninstall keeps skills: selection (#3784) Co-authored-by: Copilot App <[email protected]> * fix(deps): merge diamond skill and target selections through one owner (#3735) WIP: selection-merge owner, resolver edge accumulator, uninstall shrink, audit via the owner, frozen selection reason, static guard. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): real-binary diamond selection lifecycle (#3735) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): fold RT4 selection-merge lifecycle suite; deterministic parent ties; docs (#3735) resolved_by ties among equal-depth parents break by lowest parent key, so manifest order no longer changes apm.lock.yaml bytes. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * docs(changelog): selection merge entry (#3786) apm-spec-waiver: lockfile skill_subset/target_subset meaning clarified in lockfile-spec.md only; the normative requirement is deferred to #3763 per approved decision D7. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(audit): declared-selection wording in subset replay lifecycle (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(deps): keep download annotations on merged references; trim resolve phase (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(deps): trap audit target_subset, marketplace keys and dev edges (#3786) Addresses panel follow-ups FU1-FU3 (test-coverage-expert): the audit target_subset mismatch branch, the marketplace declaration mapping in declared_node_selections, and a devDependencies edge contributing its selection, each proven by a mutation that breaks it. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test: pass skill_subset in spec conformance callers; register effective-selection rule (#3760) apm-spec-waiver: test-only call-site update for the required skill_subset argument; no spec behavior change Co-authored-by: Copilot App <[email protected]> * fix(install): route lockfile record and target resolution via owner Panel follow-ups on #3784. The lockfile builder recorded the skill subset by calling effective_deploy_skill_subset itself, and uninstall hook reconcile plus the explicit-target preflight read dep_ref.target_subset directly, so the owner covered less than its registry entry claimed. All three now take the selection from effective_dependency_selection. The install-deployment-effective-selection guard now also checks every resolve_effective_package_targets call, keeps effective_deploy_skill_subset internal to the owner module, and resolves aliased imports of the deploy functions; four new bypass mutations prove each case. The #3760 lifecycle test is now lifecycle_smoke (runs in the PR-time lifecycle job) and gains a survivor targets: narrowing case. apm-spec-waiver: install deploy-selection routing with no OpenAPM requirement change Co-authored-by: Copilot App <[email protected]> * test(install): lockfile records the owner's deployed selection (#3784) Traps the lockfile builder's route through effective_dependency_selection: it records the persisted plus CLI --skill union for skill bundles only. Co-authored-by: Copilot App <[email protected]> * fix(deps): merge replaced, aliased and marketplace diamonds; audit fails closed (#3786) Addresses the four Copilot inline findings: - replace: diamonds now lock and reload the merged selection (the binding original carries the union; lock evidence re-merges every request); - audit treats an incomplete declaration walk as unverified unless an unrestricted edge absorbs the unread declarations; - the reachability walk reads an aliased node where the lock materialized it; - marketplace declarations map to their locked entry at every depth. Each fold is proven by a mutation that breaks its new test. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * fix(deps): expand same-repo path children of fetched packages in the walk (#3786) The declared-selection walk loaded package manifests without their origin, so a fetched package's same-repository path: child stayed a consumer-local path, never reached its locked node, and audit reported it unverified (test_mcp_dev_dependency_lifecycle). Mark the origin as install and DeclaredTransportIndex do. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * test(skills): make the U1 x legacy layout assert unconditional (#3784) #3793 guarded the post-uninstall legacy-root assertion with an xfail until #3760 landed. With the effective-selection owner in place the survivor keeps only its selected skill, so the conditional would only mask a future U1 regression. Co-authored-by: Copilot App <[email protected]> * test(uninstall): PR-time U1 trap for the legacy skill layout (#3784) The U1 x --legacy-skill-paths assertion in the #3793 lifecycle module only runs in the merge queue. Add a cheap local-path case to the lifecycle_smoke module so a survivor-selection regression on the legacy layout fails on every PR. Fails on pre-fix src (all 4 skills re-integrated), passes at head. Co-authored-by: Copilot App <[email protected]> * test(deps): replaced diamond locks and audits its union end to end (#3786) Addresses delta panel follow-ups: an integration trap installs a replace: diamond whose parents select different skills and audits the locked union; the unit trap now round-trips the lock; the resolver keeps an explicitly empty merged selection as the replacement path does. Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> * Merge main (dfb6a83) into #3784; slot CHANGELOG bullet Co-authored-by: Copilot App <[email protected]> * test: follow #3790 rename in the preflight target mutation anchor (#3784) Co-authored-by: Copilot App <[email protected]> * docs(changelog): drop duplicate #3784 bullet after main merge (#3786) Co-authored-by: azevedo-luis <[email protected]> Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]> Co-authored-by: azevedo-luis <[email protected]>
…real lock entries (#3763) Align the pairing owner with #3786's explicit-empty rule: an edge whose skills: or targets: is explicitly empty contributes no skill-target pairs, and a node whose every edge is empty keeps the empty flat selection (NodeSelection.lock_selection reconciles audit and uninstall). effective_dependency_selection only treats a decoded SkillTargetSelection as a pairing, and the #3784 lockfile overlay test uses LockedDependency. Co-authored-by: Copilot App <[email protected]>
…real lock entries (#3763) Align the pairing owner with #3786's explicit-empty rule: an edge whose skills: or targets: is explicitly empty contributes no skill-target pairs, and a node whose every edge is empty keeps the empty flat selection (NodeSelection.lock_selection reconciles audit and uninstall). effective_dependency_selection only treats a decoded SkillTargetSelection as a pairing, and the #3784 lockfile overlay test uses LockedDependency. Co-authored-by: Copilot App <[email protected]>
…-rs-018) (#3769) * feat(spec): req-rs-018 exact per-edge subset pairing owner (#3763) Add the OpenAPM req-rs-018 subset-merge requirement (new Section 7.4.1): multi-edge skills x targets selections merge by exact per-edge pairing, all absorbs per edge and axis, order independence, lock recording via the canonical optional subset_pairings field, consistency and frozen replay. Appendix C/D, enumerations, counts (139: 134 MUST) and the requirements manifest are updated; CONFORMANCE regenerated. Add the pure pairing algebra to the selection owner (models/dependency/subsets.py): SkillTargetSelection, merge_edge_pairings, and the lock record codec, with hypothesis property tests and req-rs-018 conformance tests. Partial: #3763 Co-authored-by: Copilot App <[email protected]> * docs(changelog): note proposed req-rs-018 (#3769) Co-authored-by: Copilot App <[email protected]> * docs(spec): fold spec-guardian round-1 findings into req-rs-018 (#3769) Pin the canonical subset_pairings ordering comparison, scope the determinism claim to data structures, exclude req-ext-001 vendor keys from pairing elements, clarify the wildcard element and the 'any edge' quantifier, add the Section 11.2 disclosure pointer and the Section 10.11 lockfile-tampering mapping, and type target_subset and subset_pairings in the distinct proposed lockfile-v0.1.60.schema.json (earlier schema bytes unchanged). Co-authored-by: Copilot App <[email protected]> * fix(subsets): reject non-canonical axes; scope order identity to selection fields (#3769) Address Copilot review: direct SkillTargetSelection construction now rejects empty, blank or padded axes that would change meaning after a lock round trip, and req-rs-018 clause 3 scopes the identity requirement to skill_subset, target_subset and subset_pairings rather than the whole entry (depth may legitimately change). Co-authored-by: Copilot App <[email protected]> * feat(deps): deploy diamond skills x targets with exact per-edge pairing (#3763) Each skill a declaration selects now reaches only that declaration's targets (OpenAPM req-rs-018) instead of the 0.36.1 skills x targets cross-product. The selection-merge owner (models/dependency/subsets.py) computes NodeSelection through merge_edge_pairings; the resolver carries the exact pairing on DependencyReference.subset_pairings; the lockfile records it as the optional canonical subset_pairings field only when the flat product would over-select (so product lockfiles stay byte-identical) and decodes it only through SkillTargetSelection.from_lock_fields. effective_dependency_selection hands skill_pairing to every integrate_package_primitives call (install, audit replay, uninstall survivors, local content) and the skill integrator narrows each skills root to the skills paired with its targets. Uninstall shrink, audit skill-subset-consistency and a new pre-deploy InstallService.enforce_frozen_selections compare through the owner, so a 0.36.x cross-product lock fails --frozen with a named reason before anything deploys. The selection-merge guard now requires the pairing on every deploy call and site; a parametrized mutation test proves it. Fixes #3763 Co-authored-by: Copilot App <[email protected]> * fix(lockfile): replay replaced sources with the locked pairing (#3763) Fold python-architect review: a replacement-bound lock entry now replays the locked skill_subset, target_subset and subset_pairings instead of the rule's original edge, and a CLI --skill overlay that widens a product selection clears any stale subset_pairings. Co-authored-by: Copilot App <[email protected]> * test(deps): port pairing lifecycle scenarios to the selection-merge suite (#3763) PR-3 replaced its diamond lifecycle file with test_skill_selection_merge_lifecycle.py; carry the exact-pairing scenarios there (both declaration orders with byte-identical locks, absorb on one harness only, cross-product lock refused by --frozen and audit before deploy, uninstall shrink) and drop the resurrected file. Co-authored-by: Copilot App <[email protected]> * docs(changelog): place the pairing entry under Changed (#3769) Co-authored-by: Copilot App <[email protected]> * chore(conformance): regenerate CONFORMANCE for req-rs-018 codec and frozen tests (#3769) Co-authored-by: Copilot App <[email protected]> * test(deps): pin shared skills-root union and --skill overlay on pairings (#3763) Fold test-coverage panel findings: copilot and cursor share .agents/skills, so the per-root filter must take the union of their paired skills; and a --skill overlay on a non-product pairing must widen every selected target identically in deploy and in the lockfile. Co-authored-by: Copilot App <[email protected]> * docs(changelog): merge pairing entry into the Changed section (#3769) Co-authored-by: Copilot App <[email protected]> * test(install): expect the skill_pairing field on EffectiveDependencySelection (#3763) Co-authored-by: Copilot App <[email protected]> * fix(subsets): explicitly empty edges pair nothing; lock overlay uses real lock entries (#3763) Align the pairing owner with #3786's explicit-empty rule: an edge whose skills: or targets: is explicitly empty contributes no skill-target pairs, and a node whose every edge is empty keeps the empty flat selection (NodeSelection.lock_selection reconciles audit and uninstall). effective_dependency_selection only treats a decoded SkillTargetSelection as a pairing, and the #3784 lockfile overlay test uses LockedDependency. Co-authored-by: Copilot App <[email protected]> * docs(changelog): re-place the pairing entry after rebasing on #3786 (#3769) Co-authored-by: Copilot App <[email protected]> * fix(lockfile): fold CI findings on the pairing replay (#3769) Replacement replay keeps the binding's merged flat selection (#3786 re-merges request evidence) and only carries the exact pairing; the replay pairing helper reads subset_pairings directly so the lock consumer contract covers the new field; services.py stays within its LOC budget. Co-authored-by: Copilot App <[email protected]> * docs(changelog): keep the pairing entry under Unreleased after v0.36.1 (#3769) Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
apm uninstall <unrelated-pkg>re-integrated every surviving dependency without itsskills:selection, so a bundle pinned toskills: [alpha]got all of its skills redeployed. The extra skill directories were not recorded inapm.lock.yamlandapm audit --cistill passed. Project and-gscope were both affected.Root cause: four call sites computed the effective deploy selection on their own. Install preflight and install deploy used the CLI
--skilloverlay, audit replay used the locked ref, and uninstall survivor re-integration computed nothing and fell back to theskill_subset=Nonedefault ("deploy all").Fix (one owner, every caller routed through it, plus a static guard):
effective_dependency_selection(dep_ref, ctx=None) -> EffectiveDependencySelection(skill_subset, target_subset)insrc/apm_cli/install/package_resolution.py.dep_ref=Noneis first-party project content (no selection). The CLI--skilloverlay delegates to the existing pureeffective_deploy_skill_subset.install/template.py), audit replay (install/drift.py), uninstall survivor target authorization and re-integration (commands/uninstall/engine.py) and local content (install/services.py) all call the owner.skill_subsetis now a required keyword inintegrate_package_primitivesandprepare_package_deployment, so leaving it out raisesTypeErrorinstead of deploying everything.hook_reintegrationkeeps an explicitNonewith a comment, because it builds a hooks-only plan.install-deployment-effective-selection: everyintegrate_package_primitives(,prepare_package_deployment(andDeployableSourcePlan.create(call must passskill_subset=(and anydep_target_subset=) from the owner. The only exceptions are allowlisted forwarders, the hooks-onlyNonesite and the plan-derived skill-adoption site. The guard also requires the keyword to stay required and the owner to be defined exactly once.dependency-selectionentry in.apm/architecture/owners/install-deployment.json, plus a sortedMutationCaseand four mutation-break cases. The existing audit-replay guard and its tests now require the owner call.The diamond-edge selection merge (#3735, PR-3) can extend this owner. Skills leaked by earlier versions are out of scope: APM cannot tell they are its own, so users should delete stray skill directories by hand.
Issue and approved scope
Issue: Fixes #3760
Human scope-approval comment: #3760 (comment)
This PR completes the issue. Out of scope per the record: removing skills leaked by earlier versions, and merging selections across diamond edges (#3735).
Type of change
Testing
Validation evidence (local,
.venveditable install,APM_BINARY_PATH=$PWD/.venv/bin/apm):pytest tests/integration/test_uninstall_skill_selection_lifecycle.py -p no:xdiston v0.36.0 code (2769573 plus the test only){'alpha','beta','delta','gamma'} != {'alpha'}after uninstall)pytest tests/unit/install/test_skill_subset_deploy_parity.py -p no:xdist(owner and TypeError tests)pytestover the 39 non-architecture test files that call the deploy functions, drift replay or uninstall re-integration (-m "not requires_apm_binary")pytest tests/integration/test_architecture_install_compound_mutations.py tests/integration/test_architecture_intent_guards.py tests/integration/test_architecture_skill_preflight.pypytest tests/integration/test_architecture_owner_rule_mutations.py -k "deploy_selection or install-deployment-effective-selection"pytest tests/integration/test_architecture_owner_rule_mutations.py -k "effective_selection or deploy_selection or audit_replay or coverage or surgical or before_mutation or registry"python scripts/lint_architecture_boundaries.py --root .uvx [email protected] checkandformat --check(CI paths)pylint R0801(CI paths)bash scripts/lint-auth-signals.shSpec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.