Skip to content

fix(deps): merge diamond skill and target selections through one owner (#3735) - #3786

Merged
Daniel Meppiel (danielmeppiel) merged 35 commits into
mainfrom
danielmeppiel-t4-3735-selection-merge
Nov 18, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 35 commits into
mainfrom
danielmeppiel-t4-3735-selection-merge

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

When two packages you depend on declare the same skill bundle with different
skills: (or targets:), APM kept only the first declaration it met and
silently dropped the other. Which one won depended on manifest order. A parent
that wanted the whole bundle was starved by a sibling that narrowed it.

This PR adds one owner for "which selection does a dependency node carry when
several edges declare it" and routes every reader through it.

User scenario, before vs after:

Scenario Before (0.36.0) After
pkg-a selects [alpha, beta], pkg-b selects [gamma, delta] of one bundle Only one parent's skills deployed; which one depends on manifest order All four deployed and locked as the sorted union; byte-identical apm.lock.yaml in any order
pkg-a selects [alpha], pkg-b takes the whole bundle Only alpha Whole bundle (an unrestricted declaration absorbs)
pkg-a targets: [claude], pkg-b targets: [copilot] Only one harness populated Both harnesses; target_subset: [claude, copilot]
apm uninstall pkg-a Union kept forever Narrows to pkg-b's selection; alpha/beta removed and unrecorded; then apm uninstall pkg-b cleans the bundle
apm audit --ci Checked direct deps only, by strict equality Recomputes the expected selection for every locked dep from the declared graph; unreadable evidence is "unverified", never a pass
apm install --frozen with a 0.36.0 lock that recorded one parent Silently replayed the bug Exits nonzero: selection for <dep> changed: ... run 'apm install' and commit apm.lock.yaml
A parent's skills: matches no skill (#3204) Hidden whenever another parent won Fails, naming the declaring parent chain; prior files and lock bytes preserved
Two parents alias the bundle differently Silent first-wins Shallowest declaration wins, with a warning naming both aliases

How it is fixed:

  • Owner models/dependency/subsets.py: frozen EdgeSelection(parent_chain, skill_subset, target_subset, alias, allow_insecure, mode) and NodeSelection(skill_subset, target_subset, contributors); merge_edge_selections(edges) -> NodeSelection (per-field sorted union, None absorbs; commutative, associative, idempotent) and union_selection_names(*subsets). contributors keeps every per-edge record for diagnostics and is never persisted. SelectionMode = Literal["include"] is the typed hook for [FEATURE] Exclude individual skills of a dependency #3203 exclude-mode (merging another mode raises SelectionMergeError).
  • Resolver deps/apm_resolver.py: _record_edge_selection at every edge-discovery site before any dedup (root prod, root dev before the prod-wins skip, Phase C before the queued_keys test); _apply_edge_selections after the walk sets each node's merged selection and selection_contributors. Identity keys are unchanged. allow_insecure is AND over edges; transport hints stay first-wins. resolved_by stays nearest-first, with equal-depth ties broken by lowest parent key (captain decision), so manifest order no longer changes lock bytes.
  • Effective selection ([BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760, PR-2): effective_deploy_skill_subset delegates to union_selection_names.
  • [BUG] skills: selection that matches nothing removes all of the dependency's skills and exits 0 #3204 per edge: preflight_skill_selection checks each contributing edge, so a union never hides a parent's selection that matches nothing; the error names the parent chain.
  • Uninstall deps/reachability.py: the walk records edges before its visited dedup and expands git: parent / same-repo path: declarations as install does; declared_node_selections merges them via the owner. _shrink_surviving_selections applies the result; an incomplete walk keeps the locked union.
  • Audit _check_skill_subset_consistency uses declared_node_selections for every locked dependency.
  • Frozen InstallService._enforce_frozen_no_rewrite names each dependency whose selection changed.
  • Static guard install-deployment-selection-merge (owner dependency-selection-merge in install-deployment.json) + MutationCase.

Issue and approved scope

Issue: Fixes #3735

Refs #3763 (0.37: exact per-edge skills x targets pairing and the normative spec requirement)

Human scope-approval comment: #3735 (comment)

Does this PR complete the issue, or what remains? It completes #3735 as
scoped. Exact per-edge pairing and a normative OpenAPM requirement remain in
#3763 (0.37). Stacked on #3784 (fixes #3760, effective-selection owner): merge
#3784 first; this branch rebases onto main after it lands.

Co-authored with Luis Azevedo (@azevedo-luis), whose design comment on #3735 matches this
implementation (union, unrestricted absorbs, no identity key change, one owner,
resolved_by unchanged).

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence at head bccd2da1ab (local, macOS; one test process at a time):

Command Result
APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm pytest -p no:xdist tests/integration/test_skill_selection_merge_lifecycle.py (17 real-binary scenarios: L1-L6, L8-L12, D4 alias, dev edge) passed; 15 of 16 original scenarios fail on the pre-fix source
Exact-head functional set (unit + test_skill_selection_merge_lifecycle, test_uninstall_skill_selection_lifecycle, test_mcp_dev_dependency_lifecycle, test_dependency_replacement_lifecycle) 874 passed
Sweep of the ~90 integration files that run audit --ci 788 passed; the only failures need a packaged native binary or xdist worker_id (environmental)
Mutation-break for every new trap (see the terminal advisory comment) each fails with its guard removed
uvx [email protected] check / format --check; pylint R0801; lint-auth-signals.sh; lint-architecture-boundaries.sh; file-length, YAML I/O, relative_to guards clean
CI (gh pr checks 3786) 23 pass, 3 skipping, 0 fail

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

The lockfile field meaning is clarified in lockfile-spec.md only (approved
D7); the normative requirement is deferred to #3763.

…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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.36.1 milestone Nov 17, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
#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]>
…arent 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]>
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]>
…ve phase (#3786)

Co-authored-by: azevedo-luis <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Diamond skill+target selection merges through one owner with deterministic union, fail-closed audit, and 16-scenario lifecycle coverage -- the merge-diamond contract lands.

panel-mode=lean; personas=python-architect,test-coverage-expert,performance-expert,apm-ceo

All three panelists converge on a clean ship. python-architect confirms the architecture is layered correctly: merge_edge_selections is the sole selection authority enforced by a static guard, the post-pass preserves identity keys via _with_node_selection, the nearest-parent tie-break is deterministic (equal-depth ties by lowest parent key yield byte-identical locks across manifest orders), and the audit path fails closed on unreadable evidence. The 16-scenario integration suite plus hypothesis property tests give strong confidence that the merge algebra is correct.

The test-coverage-expert surfaced two missing-test gaps on the governed-by-policy audit surface: the target_subset mismatch branch in _check_skill_subset_consistency has no coverage at any tier, and the marketplace ref-to-locked-key mapping in declared_node_selections (which feeds both audit and uninstall shrink) is untested. Neither is blocking -- the audit code is structurally correct and the lifecycle scenarios exercise the happy paths -- but both are regression-trap gaps worth closing.

The performance-expert's two observations (a second reachability walk in uninstall, audit cost growing to O(N) manifest reads) are correct but benign at current scale. The O(N) audit growth is an intentional trade for transitive verification.

Aligned with: Governed by policy -- audit now checks all locked deps transitively and fails closed on unreadable evidence. Portable by manifest -- byte-identical locks regardless of declaration order. Secure by default -- allow_insecure ANDs over edges and #3204 is enforced per edge naming the declaring parent chain. Pragmatic as npm -- diamond merges just work with a deterministic union.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 merge_edge_selections sole selection authority with static guard; post-pass preserves identity keys; tie-break deterministic; reachability mirrors install expansion; audit fail-closed. Ship.
Test Coverage Expert 0 3 0 16 lifecycle scenarios cover the core contract; gaps: audit target_subset branch, marketplace key mapping in declared_node_selections, dev-edge at integration tier.
Performance Expert 0 2 0 No O(n^2) patterns; two linear-cost notes: uninstall runs two reachability walks, audit skill-subset check grew from O(direct) to O(N) reads.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 5 follow-ups

  1. [Test Coverage Expert] Add test coverage for the audit target_subset mismatch branch in _check_skill_subset_consistency. -- outcome:missing on a governed-by-policy surface; one case tampering target_subset closes it cheaply.
  2. [Test Coverage Expert] Add a unit test for the declared_node_selections marketplace ref-to-locked-key mapping. -- It feeds both uninstall shrink and audit; a wrong key would give false audit mismatches or a wrong shrink for marketplace deps.
  3. [Test Coverage Expert] Consider integration-tier coverage for a dev edge contributing its selection before prod wins. -- The unit test covers the call site; the install-pipeline tier floor is integration.
  4. [Performance Expert] Consolidate the two sequential reachability walks in uninstall. -- Linear redundancy; the orphan walk and shrink walk read the same manifests.
  5. [Performance Expert] Track audit O(N) manifest reads for future shared-walk consolidation. -- Correct trade today; revisit as lockfiles grow.

Recommendation

Merge after the effective-selection base (#3784). The architecture is clean, the algebra is correct, and the lifecycle suite plus property tests cover the core contract. Close the two audit-surface test gaps (target_subset branch, marketplace key mapping) as follow-ups or in-PR. Performance observations are benign at current scale.


Full per-persona findings

Python Architect

No findings.

Test Coverage Expert

  • [recommended] Audit target_subset mismatch branch in _check_skill_subset_consistency has zero test coverage at any tier. at src/apm_cli/policy/ci_checks.py
    New branch lock_targets != expected_targets; L12 and the unit tests only tamper skill_subset.
    Suggested: Extend the unit consistency test or add an L12 case tampering target_subset.
    Proof (missing at): tests/integration/test_skill_selection_merge_lifecycle.py -- proves: a lockfile target_subset that disagrees with the declared merge fails apm audit --ci. [governed-by-policy,multi-harness-support]
  • [recommended] declared_node_selections marketplace ref-to-locked-key mapping (locked_form) has zero test coverage. at src/apm_cli/deps/reachability.py
    The mapping feeds uninstall shrink and audit; the lifecycle world only uses git deps.
    Suggested: Unit test with a marketplace-style manifest ref and its locked entry.
    Proof (missing at): tests/unit/test_skill_subset_persistence.py -- proves: audit looks up a marketplace dependency's expected selection under its locked key. [governed-by-policy,secure-by-default]
  • [recommended] Dev-edge selection before prod-wins has unit coverage but no integration-tier test. at src/apm_cli/deps/apm_resolver.py
    The install-pipeline tier floor is integration-with-fixtures.
    Proof (passed): tests/unit/deps/test_apm_resolver_selection_merge.py::test_dev_edge_still_contributes_before_prod_wins -- proves: a devDependency's selection merges into the node while the prod edge wins is_dev. [portability-by-manifest,devx]

Performance Expert

  • [recommended] Uninstall performs two sequential reachability walks where one would suffice. at src/apm_cli/commands/uninstall/engine.py
    The orphan walk (only when candidates exist) and the shrink walk read the same manifests; linear redundancy.
    Suggested: Thread the first walk's edge_selections into the shrink.
  • [recommended] Audit skill-subset check cost grew from O(direct_deps) to O(N) apm.yml reads. at src/apm_cli/policy/ci_checks.py
    Correct trade for transitive verification; new per-CI I/O proportional to lockfile size.
    Suggested: No change now; future: share one walk across audit checks.

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Incomplete declaration evidence can incorrectly pass CI checks, while lost merged selections and unresolved dependency lookups can deploy incorrect subsets and prevent uninstall from removing obsolete selections.

4 open issues
What changed in this PR

This PR addresses #3735 by centralizing how APM merges skill and target selections when multiple parents declare the same dependency. It also includes the shared deployment-selection work from #3784 for consistent install, audit, and uninstall behavior.

Changes:

  • Merge incoming selections as sorted unions, with unrestricted declarations selecting everything, and validate each parent's skill selection.
  • Recompute surviving selections during uninstall, verify declared unions during audit, and diagnose selection changes during frozen installs.
  • Add architecture guards, lifecycle coverage, reusable fixtures, and documentation. Exact per-target skill pairing remains deferred to #3763.
File Description
tests/​utils/​skill_selection_world.py Adds isolated dependency-graph fixtures and observation helpers.
tests/​unit/​test_skill_subset_persistence.py Tests transitive unions and incomplete audit evidence.
tests/​unit/​scripts/​test_architecture_runner.py Registers the selection-merge guard in the expected inventory.
tests/​unit/​policy/​test_ci_skill_subset_replay.py Updates expected audit diagnostic wording.
tests/​unit/​models/​test_dependency_selection_merge.py Tests merge algebra, aliases, and transport consent.
tests/​unit/​integration/​test_hook_target_selection.py Supplies the required skill-selection argument.
tests/​unit/​integration/​test_hook_configured_routing.py Supplies explicit unrestricted skill selection.
tests/​unit/​integration/​test_dep_target_intersection.py Updates deployment calls for required selection.
tests/​unit/​integration/​test_data_driven_dispatch.py Updates the dispatch helper's selection argument.
tests/​unit/​integration/​test_cursor_hook_native_contract.py Updates hook deployment calls for required selection.
tests/​unit/​integration/​test_command_integrator.py Updates command integration calls for required selection.
tests/​unit/​integration/​test_canvas_integrator.py Updates canvas integration calls for required selection.
tests/​unit/​install/​test_skill_subset_deploy_parity.py Tests the effective-selection owner and required keyword.
tests/​unit/​install/​test_skill_completion_receipt.py Supplies selection in completion-receipt scenarios.
tests/​unit/​install/​test_services.py Updates service calls for required selection.
tests/​unit/​install/​test_services_rendering.py Updates rendering scenarios for required selection.
tests/​unit/​install/​test_services_phase3.py Updates deployment scenarios for required selection.
tests/​unit/​install/​test_services_hook_scope.py Supplies selection in hook-scope scenarios.
tests/​unit/​install/​test_services_branches.py Updates service branch scenarios for required selection.
tests/​unit/​install/​test_agent_symlink_diagnostics.py Supplies selection in the symlink diagnostic scenario.
tests/​unit/​install/​test_agent_plugin_deployment_boundary.py Supplies selection in the plugin-boundary scenario.
tests/​unit/​deps/​test_apm_resolver_selection_merge.py Tests resolver unions, ordering, aliases, and annotations.
tests/​integration/​test_uninstall_skill_selection_lifecycle.py Tests survivor selections in project and user scopes.
tests/​integration/​test_skill_selection_merge_lifecycle.py Adds diamond install, audit, uninstall, update, and frozen scenarios.
tests/​integration/​test_plugin_bin_trust_posture.py Updates executable-trust scenarios for required selection.
tests/​integration/​test_install_services_phase3w5.py Updates service scenarios for required selection.
tests/​integration/​test_install_services_orchestration.py Updates orchestration scenarios for required selection.
tests/​integration/​test_hook_integrator_copilot_casing_e2e.py Supplies selection in the hook integration helper.
tests/​integration/​test_hook_configured_routing_e2e.py Supplies selection in routing lifecycle scenarios.
tests/​integration/​test_audit_skill_subset_replay.py Updates expected subset-mismatch wording.
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 Updates replay mutations for owner-based selection.
src/​apm_cli/​policy/​ci_checks.py Compares locked selections against the declared graph.
src/​apm_cli/​models/​dependency/​subsets.py Defines edge records and canonical selection merging.
src/​apm_cli/​models/​dependency/​reference.py Adds diagnostic-only selection contributors.
src/​apm_cli/​integration/​skill_preflight.py Validates every contributing edge's skill selection.
src/​apm_cli/​integration/​skill_integrator.py Adds declaring-parent context to selection errors.
src/​apm_cli/​integration/​hook_reintegration.py Adds a comment explaining unrestricted hooks-only plans.
src/​apm_cli/​install/​template.py Routes preflight and deployment through the selection owner.
src/​apm_cli/​install/​services.py Requires skill selection and routes first-party selection through the owner.
src/​apm_cli/​install/​service.py Reports frozen-install selection mismatches.
src/​apm_cli/​install/​phases/​resolve.py Emits resolver warnings.
src/​apm_cli/​install/​package_resolution.py Defines the shared effective deployment-selection owner.
src/​apm_cli/​install/​drift.py Uses the selection owner during audit replay.
src/​apm_cli/​install/​deployment_plan.py Makes skill selection a required keyword.
src/​apm_cli/​deps/​reachability.py Collects declaring edges and recomputes node selections.
src/​apm_cli/​deps/​dependency_graph.py Adds resolver warning storage.
src/​apm_cli/​deps/​apm_resolver.py Records edges before deduplication and applies merged selections.
src/​apm_cli/​commands/​uninstall/​engine.py Recomputes survivor selections and uses them during reintegration.
src/​apm_cli/​commands/​uninstall/​cli.py Schedules changed survivors for cleanup and redeployment.
scripts/​architecture_linter/​checks/​install_selection_merge.py Guards edge recording and canonical merge ownership.
scripts/​architecture_linter/​checks/​install_frozen_and_audit.py Updates the audit guard for owner-based selection.
scripts/​architecture_linter/​checks/​install_effective_selection.py Guards required selection arguments and owner routing.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Registers both selection guards.
packages/​apm-guide/​.apm/​skills/​apm-usage/​dependencies.md Documents shared-dependency selection behavior.
docs/​src/​content/​docs/​reference/​package-types.md Explains skill-bundle union semantics.
docs/​src/​content/​docs/​reference/​manifest-schema.md Documents merged selections and alias precedence.
docs/​src/​content/​docs/​reference/​lockfile-spec.md Clarifies locked union fields and audit checks.
docs/​src/​content/​docs/​reference/​cli/​uninstall.md Documents selection-preserving survivor rebuilds.
CHANGELOG.md Records lifecycle fixes and lockfile migration guidance.
.apm/​architecture/​owners/​install-deployment.json Registers deployment-selection and merge ownership.

Review effort: Balanced

Comment thread src/apm_cli/deps/apm_resolver.py Resolved
Comment thread src/apm_cli/policy/ci_checks.py Resolved
Comment thread src/apm_cli/deps/reachability.py Resolved
Comment thread src/apm_cli/deps/reachability.py Resolved
…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]>
…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]>
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
…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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 17, 2026
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]>
…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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_now

Delta folds lock the replacement-diamond and audit-selection contracts with mutation-broken traps; the PR is green, mergeable and Copilot-drained.

panel-mode=delta; personas=python-architect,test-coverage-expert,performance-expert,apm-ceo

All three delta panelists converged. python-architect asked for a lock round-trip assertion on replaced diamonds and matching empty-selection handling in the resolver; test-coverage-expert asked for an integration-tier trap that drives a replaced diamond with divergent parent skills through install, lock and audit --ci. Both landed in bccd2da and are mutation-broken. performance-expert found only O(1) per-node work and one O(n) index per walk.

Since the previous panel, the PR also folded FU1-FU3 and all four Copilot inline findings, and fixed a regression CI's lifecycle smoke caught: the declaration walk did not mark fetched packages' origin, so same-repository path: children never reached their locked node and audit reported them unverified.

Aligned with: Portable by manifest -- a replaced diamond locks and reloads the same merged selection on any machine. Secure by default -- audit reports a selection as unverified whenever the walk is incomplete, unless an unrestricted declaration absorbs. Governed by policy -- the integration trap proves audit --ci holds across the replacement path.

Panel summary

Persona B R N Takeaway
Python Architect 0 1 0 Replacement re-merge correct; binding mutation safe; audit fail-closed and walk mapping sound. Round-trip assertion requested (folded).
Test Coverage Expert 0 1 0 Each fold has a mutation-broken trap; integration-tier replaced-diamond trap requested (folded).
Performance Expert 0 0 0 O(1) per node plus one O(n) index per walk; no regressions.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 2 follow-ups

  1. [Performance Expert] Consolidate the orphan walk and the selection-shrink walk in apm uninstall. -- Deferred: widening the orphan walk's candidate set changes the Formalize a spec requirement for uninstall reachability preservation (req-lk-0XX) #2270 orphan-preservation evidence contract; track as its own issue.
  2. [Performance Expert] Track audit's O(N) manifest reads for a walk shared across audit checks. -- Tracking note only.

Recommendation

Every delta finding is folded and mutation-broken; FU1-FU3 and the four Copilot findings are resolved; CI is green and the owner-touch gate verifies. Merge after #3784 (its head is already merged into this branch).

Folded in this run

  • (panel FU1) Trap for the audit target_subset mismatch branch -- 89456c2.
  • (panel FU2) Trap for the marketplace declaration mapping -- 89456c2.
  • (panel FU3) Lifecycle trap for a devDependencies edge contributing its selection -- 89456c2.
  • (copilot) replace: diamonds lock and reload the merged selection -- b256a6f.
  • (copilot) Audit fails closed on an incomplete walk unless an unrestricted edge absorbs -- b256a6f.
  • (copilot) The walk reads aliased nodes at the locked alias path -- b256a6f.
  • (copilot) Marketplace declarations map to their locked entry at every depth -- b256a6f.
  • (CI) Fetched packages keep their origin so same-repo path: children expand -- 22d1649.
  • (delta panel) Lock round-trip assertion, aligned empty-selection handling, integration trap for replaced diamonds -- bccd2da.

Copilot signals reviewed

  • src/apm_cli/deps/apm_resolver.py -- LEGIT: replaced diamonds kept the first request's selection (resolved in b256a6f).
  • src/apm_cli/policy/ci_checks.py -- LEGIT: incomplete walk with empty subsets passed (resolved in b256a6f).
  • src/apm_cli/deps/reachability.py -- LEGIT: aliased diamonds read the wrong install directory (resolved in b256a6f).
  • src/apm_cli/deps/reachability.py -- LEGIT: transitive marketplace references were unmapped (resolved in b256a6f).

Deferred (out-of-scope follow-ups)

Regression-trap evidence (mutation-break gate)

  • 15 of 16 test_skill_selection_merge_lifecycle.py scenarios fail on the pre-fix source.
  • MutationCase install-deployment-selection-merge fails when the Phase C _record_edge_selection call is removed.
  • Each fold's trap (dev edge, target_subset audit, marketplace mapping at root and transitive depth, replaced diamond in unit and lifecycle tiers, fail-closed audit, alias path, fetched-package origin) failed with its guard removed and passed once restored.

Lint contract

ruff check and ruff format --check (pinned 0.15.12) silent; pylint R0801, auth-signal, architecture-boundary, file-length, YAML I/O and relative_to guards clean.

CI

gh pr checks 3786 at bccd2da: 23 pass, 3 skipping, 0 fail (after 1 CI fix iteration).

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3786 bccd2da ship_now 2 9 2 2 green MERGEABLE BLOCKED awaiting human review; lands after #3784

This panel is advisory. It does not block merge.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit e217a53 into main Nov 18, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t4-3735-selection-merge branch November 18, 2026 03:55
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
…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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
…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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
…-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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants