Repository navigation
fix(skills): rebuild recorded skills in the layout the install used (#3773) - #3793
Daniel Meppiel (danielmeppiel) merged 4 commits into
Conversation
…3773) `apm install --legacy-skill-paths` deploys skills to per-client roots (.github/skills, ~/.copilot/skills), but nothing downstream knew that: the `apm audit --ci` drift replay and the uninstall cleanup and survivor rebuild resolved targets without the flag, so a clean legacy install was reported as drift and uninstalling an unrelated package re-deployed survivors into .agents/skills unrecorded. integration/skill_layout.py now owns the effective skill layout: install passes its flag through resolve_skill_layout, and every flagless rebuild recovers the layout from the lockfile's recorded deployed paths (resolve_reintegration_targets; resolve_audit_targets routes through it). No lockfile schema change. Guarded by install-deployment-skill-layout. apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes 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 | Sound single-owner design that fixes the bug. Gaps: owner re-derives the skills root, closed-list guard misses export-patch, removed-package paths can set survivor layout. |
| Test Coverage Expert | 0 | 3 | 0 | Real-binary lifecycle proves copilot legacy layout at project and user scope. Gaps: env-var user roots (codex today) and catalog-wide per-target recovery; xfail hides one invariant. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Python Architect] [IN-SCOPE FOLD] In the uninstall engine, derive the survivors' rebuild layout from the survivors' recorded paths only; keep the removed package's paths only for cleanup, which needs both layouts. -- The combined set can move a survivor into a different layout in a mixed lockfile, which audit --ci reports drift after install --legacy-skill-paths #3773's scope excludes.
- [Test Coverage Expert] [IN-SCOPE FOLD] Run the env-var user-root lifecycle test for every USER_ROOT_ENV_VARS target with converged skills, so codex (CODEX_HOME) runs today and copilot (COPILOT_HOME) joins when fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782 lands. -- The absolute root_dir prefix match is the most fragile branch and has no test that runs today.
- [Test Coverage Expert] [IN-SCOPE FOLD] Split the strict-xfail skill-subset test: assert nothing is written to .agents/skills first, then xfail only the [BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760/fix(uninstall): keep surviving bundles' skills: selection (#3760) #3784 subset checks. -- Keeps the audit --ci reports drift after install --legacy-skill-paths #3773 invariant checked whichever PR merges first.
- [Test Coverage Expert] [IN-SCOPE FOLD] Add a parametrized unit round-trip over every KNOWN_TARGETS skills mapping with deploy_root, at project and user scope. -- If a target's per-client path differs from root_dir/subdir, rebuilds silently fall back to .agents/skills.
- [Python Architect] [FOLD: skills_rel_root / DEFERRABLE: export_patch] Build the legacy prefix from
apply_legacy_skill_paths([profile])[0].skills_rel_root; separately routeexport_patch._resolve_diff_targetsthroughresolve_audit_targetsand add it to the guard. -- Ties the layout check to where install writes; export_patch is harmless today.
Recommendation
Ship for 0.36.1 once the in-scope folds are in. The first priority is the survivor-only layout in uninstall, because without it the fix can cause the layout migration the scope rules out. Next come the codex env-root test and the xfail split, both small and both protecting the promise this PR makes. Reusing skills_rel_root and adding the catalog-wide unit round-trip are cheap and fit here too. Track export_patch routing as a separate follow-up. Coordinate the merge order with #3784 so the second PR to land rebases cleanly.
Full per-persona findings
Python Architect
- [recommended] The new owner rebuilds the skills-root path itself instead of using the existing skills_rel_root owner. at
src/apm_cli/integration/skill_layout.py:28
_records_legacy_skill_layoutjoins root_dir and subdir by hand, duplicatingTargetProfile.skills_rel_root; if the skills-root rule changes, the layout predicate drifts from where install writes.
Suggested:prefix = apply_legacy_skill_paths([profile])[0].skills_rel_root + "/" - [recommended] The static guard only checks 4 named modules and only flags
resolve_targets;commands/export_patch.py_resolve_diff_targetsmirrors drift but still calls the layout-blind resolver. atscripts/architecture_linter/checks/install_skill_layout.py:33
Harmless today because governed_root_dirs keeps only the first path segment, but the invariant is not enforced.
Suggested: Route_resolve_diff_targetsthroughresolve_audit_targetsand add export_patch.py to REBUILD_MODULES. - [recommended] Uninstall combines the removed package's paths with the survivors' paths, so a removed package's layout can move survivors to a different layout. at
src/apm_cli/commands/uninstall/engine.py:1161
Cleanup needs both layouts; the rebuild should follow survivors only.
Suggested: Resolve rebuild targets from survivors' recorded paths; the cleanup partition uses the union of both layouts.
Test Coverage Expert
- [recommended] Legacy-layout recovery under an env-var user root has no running test; only COPILOT_HOME covers it and is skipped until fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782. at
tests/integration/test_legacy_skill_layout_lifecycle.py
The absolute root_dir prefix match is the most fragile branch; codex (CODEX_HOME, skills deploy_root .agents) is affected today.
Suggested: Parametrize the env-root test over USER_ROOT_ENV_VARS targets with converged skills.
Proof (missing at):tests/integration/test_legacy_skill_layout_lifecycle.py-- proves: a -g --legacy-skill-paths install with an env root outside HOME keeps audit clean and leaks nothing into ~/.agents/skills. - [recommended] Per-target layout recovery is proven end to end for copilot only. at
tests/unit/integration/test_targets.py
A target whose per-client path differs from root_dir/subdir would silently fall back to .agents/skills.
Suggested: Catalog-parametrized unit round-trip over every KNOWN_TARGETS skills mapping with deploy_root, both scopes.
Proof (missing at):tests/unit/integration/test_targets.py-- proves: whatever client a user installed for with --legacy-skill-paths, audit and uninstall rebuild there. - [recommended] The strict xfail on the skill-subset uninstall test also hides the .agents/skills invariant for that scenario until fix(uninstall): keep surviving bundles' skills: selection (#3760) #3784 lands. at
tests/integration/test_legacy_skill_layout_lifecycle.py:117
xfail cannot tell which assertion failed; the audit --ci reports drift after install --legacy-skill-paths #3773 assertion runs after the [BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760 one.
Suggested: Assert the .agents/skills invariant first, then pytest.xfail only for the subset checks.
Proof (missing at):tests/integration/test_legacy_skill_layout_lifecycle.py-- proves: with a skills: subset dependency, uninstalling an unrelated package under the legacy layout never writes into .agents/skills.
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.
There was a problem hiding this comment.
🟡 Changes recommended
When CODEX_HOME equals HOME, the unnormalized ./skills/ prefix prevents legacy layout detection, causing audit replay and survivor rebuilding to incorrectly select .agents/skills.
1 open issue
What changed in this PR
This PR addresses #3773 by recovering the installed skill layout from lockfile deployment paths, so audit and uninstall can preserve legacy per-client locations without a schema change.
Changes:
- Centralizes skill-layout resolution and routes install, adoption, audit, and uninstall through it.
- Adds lifecycle tests, regression coverage, and an architecture guard against bypassing the layout owner.
- Documents layout preservation; selection and
COPILOT_HOMEscenarios remain coordinated with sibling fixes.
| File | Description |
|---|---|
tests/utils/skill_selection_world.py |
Adds isolated package fixtures and lifecycle helpers. |
tests/unit/test_surviving_deps_reintegration.py |
Covers legacy cleanup and survivor rebuilding. |
tests/unit/scripts/test_architecture_skill_layout_guard.py |
Tests layout-owner enforcement. |
tests/unit/scripts/test_architecture_runner.py |
Registers the guard in the expected inventory. |
tests/unit/integration/test_targets.py |
Tests recorded layout recovery and audit targets. |
tests/integration/test_legacy_skill_layout_lifecycle.py |
Covers project and user install/audit/uninstall lifecycles. |
tests/integration/test_architecture_owner_rule_mutations.py |
Adds a layout-bypass mutation case. |
src/apm_cli/integration/targets.py |
Makes audit recover recorded skill layouts. |
src/apm_cli/integration/skill_layout.py |
Introduces the shared layout resolver. |
src/apm_cli/install/phases/targets.py |
Routes the install flag through the resolver. |
src/apm_cli/install/local_bundle_handler.py |
Routes local-bundle layout selection through the resolver. |
src/apm_cli/commands/uninstall/engine.py |
Preserves recorded layouts during cleanup and rebuilding. |
src/apm_cli/commands/uninstall/cli.py |
Resolves cleanup targets using recorded paths. |
src/apm_cli/adopt/discovery.py |
Uses the resolver to inventory legacy roots. |
scripts/architecture_linter/checks/registry_owner_guards.py |
Updates required audit-target delegation. |
scripts/architecture_linter/checks/install_skill_layout.py |
Detects layout-owner bypasses. |
scripts/architecture_linter/checks/install_deployment_analyzers.py |
Registers the new analyzer. |
packages/apm-guide/.apm/skills/apm-usage/commands.md |
Explains audit and uninstall layout preservation. |
docs/src/content/docs/reference/targets-matrix.md |
Clarifies flagless reuse of recorded layouts. |
docs/src/content/docs/reference/cli/install.md |
Updates legacy-path flag documentation. |
CHANGELOG.md |
Records the lifecycle fix. |
.apm/architecture/owners/install-deployment.json |
Declares the layout owner and guard. |
Review effort: Balanced
Panel folds for #3793: - uninstall rebuilds survivors in the layout the survivors recorded; the removed packages' paths only feed cleanup, which now recognises both layouts (with_every_skill_layout), so a mixed lockfile never migrates a survivor between layouts - the owner derives the per-client prefix from skills_rel_root - export-patch diff targets follow the recorded layout like the replay; export_patch.py joins the guard's rebuild modules - tests: env-rooted user scope lifecycle over every USER_ROOT_ENV_VARS target with converged skills (codex runs today, copilot with #3782), catalog-wide unit round-trip, mixed-layout uninstall cases, and the RT4 subset test checks .agents/skills before xfailing on #3760 only apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]>
A harness user root equal to HOME (for example CODEX_HOME=$HOME) scopes to root_dir ".", so the per-client prefix was "./skills/" while the lockfile records "skills/...". Normalize the prefix before matching. apm-spec-waiver: skill layout recovery for audit and uninstall rebuilds; no spec requirement changes Co-authored-by: Copilot App <[email protected]>
Folded in this run
Copilot signals reviewed
Regression-trap evidence (mutation-break gate)
Lint contract
CIObserved green at exact head d2cdf56: 23 pass, 3 skipping, 0 pending/failed (Lint, Build & Test shards, Lifecycle Smoke shards, Architecture Ratchet/Scaling, Windows gates, Spec conformance gate, CodeQL, gate) (after 1 CI fix iteration(s)). Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
#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]>
) * 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]> * 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]> * 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]> * 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]> --------- Co-authored-by: danielmeppiel <[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]>

Description
apm install --legacy-skill-pathsdeploys skills to per-client roots (.github/skills/at project scope,~/.copilot/skills/or$COPILOT_HOME/skills/at user scope) instead of the shared.agents/skills/. Nothing persisted that choice, and the paths that rebuild recorded deployments later run without the flag:apm audit --cireplayed into.agents/skills/, so a clean legacy install failed drift (unintegrated: .agents/skills/...,orphaned: .github/skills/...).apm uninstall <unrelated pkg>re-integrated survivors into.agents/skills/(unrecorded), and uninstalling the skill package itself left its.github/skills/files on disk (cleanup looked only under.agents/skills/).Fix: one owner,
src/apm_cli/integration/skill_layout.py, decides the effective skill layout.resolve_skill_layout(targets, legacy_skill_paths=..., recorded_paths=...): install passes its flag (unchanged semantics); flagless rebuilds pass the lockfile's recorded deployed paths, and a target whose recorded skills live under its per-client root keeps that layout. No lockfile schema change.resolve_reintegration_targets(...)=resolve_targets+ recorded layout. Routed through it:resolve_audit_targets(so the drift replay,audit_replay, ci_checks and the content scanner all follow), uninstall cleanup (commands/uninstall/cli.pystep 3), the uninstall survivor rebuild (engine._sync_integrations_after_uninstall: survivors rebuild in the layout the survivors recorded; Phase 1 cleanup of the removed packages' paths recognises both layouts viawith_every_skill_layout, including at project scope, so a mixed lockfile never migrates a survivor), and theapm export-patchdiff targets (same layout as the replay).install/phases/targets.py,install/local_bundle_handler.py,adopt/discovery.py) callresolve_skill_layout(..., legacy_skill_paths=True)instead ofapply_legacy_skill_pathsdirectly.Static guard
install-deployment-skill-layout(registered on the newskill-layoutowner record in.apm/architecture/owners/install-deployment.json): no module outside the owner touchesapply_legacy_skill_paths; the rebuild modules (uninstall cli/engine, drift, audit_replay, export_patch) never call the layout-blindresolve_targets(one allowlisted native-registration read);resolve_audit_targetsmust recover the recorded layout. The existingregistry_delegation.audit_target_selectioncheck now requiresresolve_audit_targetsto delegate toresolve_reintegration_targets.Issue and approved scope
Issue: Fixes #3773
Human scope-approval comment: #3773 (comment) (current record; supersedes the earlier record on the same issue)
Does this PR complete the issue, or what remains? Completes it. Two oracle scenarios depend on sibling PRs and are wired to activate on their own:
test_uninstall_of_an_unrelated_package_keeps_the_legacy_skill_layout(RT4 copy) asserts the audit --ci reports drift after install --legacy-skill-paths #3773 invariant first (nothing under.agents/skills/,alphaunder.github/skills/), then callspytest.xfailnaming [BUG] apm uninstall re-deploys every skill of surviving skill bundles, ignoring skills: selection #3760 / fix(uninstall): keep surviving bundles' skills: selection (#3760) #3784 only while the surviving bundle still re-deploys all four skills instead of itsskills: [alpha]selection. Once fix(uninstall): keep surviving bundles' skills: selection (#3760) #3784 is on main the test passes outright. RT4 confirmed 39/39 of its suite green on a scratch merge of fix(deps): merge diamond skill and target selections through one owner (#3735) #3786 (incl. fix(uninstall): keep surviving bundles' skills: selection (#3760) #3784) + fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782 + this PR, including this test andtest_copilot_home_user_scope_diamond_shrinks_under_copilot_home[complete|missing-survivor-manifest].test_env_rooted_legacy_skill_layout_survives_audit_and_uninstallruns for everyUSER_ROOT_ENV_VARStarget with converged skills:codex(out-of-HOMECODEX_HOME) runs today;copilotis skipped until the COPILOT_HOME owner from fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782 adds its key and then runs automatically. The copilot case was verified locally on a scratch merge with fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782 head, along with fix(targets): one owner for harness user roots; honor COPILOT_HOME (#3745) #3782'stest_harness_user_root_lifecycle.pyandtest_copilot_home_profile_lifecycle.py(12 passed).Type of change
Testing
Oracle scenarios (real binary, local git/HTTPS fixtures, temp HOME, no network),
tests/integration/test_legacy_skill_layout_lifecycle.pywith helpertests/utils/skill_selection_world.py(copied verbatim from the RT4 red-team worktree):legacyanddefaultlayouts: install ->audit --cigreen -> uninstall unrelated package (skills unchanged, nothing in.agents/skills/for legacy, bundledeployed_filesunchanged) ->audit --cigreen -> uninstall the bundle (skills root empty)..github/skills/alpha/SKILL.md, never.agents/skills).proto_legacy.py:audit rc 0 {}, skills only under.github/skills/.Panel folds (advisory comment #3793 (comment)): survivor-only rebuild layout + both-layout cleanup, owner prefix from
skills_rel_root, export-patch routing + guard coverage, env-rooted lifecycle, catalog-wide unit round-trip, mixed-layout uninstall unit cases, xfail split.Fail-before evidence (src reverted to
main1759e1e, tests from this head):8 failed, 4 passedacross the legacy lifecycle cases (project, user, real drift, RT4, codex env root) and all three uninstall layout cases (legacy, removed-legacy/survivor-converged, removed-converged/survivor-legacy). First-commit run:4 failed, 2 passed(default-layout cases pass; legacy project/user audit fails withunintegrated: .agents/skills/alpha/SKILL.md ... orphaned: .github/skills/...; drift test reports.agents/skills; RT4 uninstall leaves 4 skills in.agents/skills).git apply -R):6 failed(resolve_audit_targetslegacy case ->.agents/skills; uninstall leaves.github/skills/gone; owner tests).Validation commands on this head:
APM_E2E_TESTS=1 APM_BINARY_PATH=.venv/bin/apm .venv/bin/python -m pytest -p no:xdist tests/integration/test_legacy_skill_layout_lifecycle.py tests/integration/test_local_shared_root_skill_cleanup.py tests/integration/test_agent_skills_target.py tests/integration/test_hook_wipe_target_scope_e2e.py tests/integration/test_audit_primitive_contract.py tests/integration/test_copilot_app_targets_coverage.py->294 passed, 1 skipped, 1 xfailed(first commit); after foldstests/integration/test_legacy_skill_layout_lifecycle.py tests/integration/test_local_shared_root_skill_cleanup.py tests/integration/test_hook_wipe_target_scope_e2e.py tests/integration/test_audit_primitive_contract.py->139 passed, 1 skipped, 1 xfailed.venv/bin/python -m pytest -p no:xdist tests/unit/test_audit_*.py (ci_command, command, deployment_owners, fail_on_drift) tests/unit/test_drift_detection.py tests/unit/test_uninstall_*.py (engine helpers/phase3w5/validation, reintegration, shared diamond/ownership, transitive cleanup) tests/unit/install/test_drift*.py tests/unit/install/test_install_local_bundle*.py tests/unit/install/phases/test_targets_phase.py tests/unit/adopt tests/unit/install/test_skill_path_migration.py tests/unit/policy/test_audit_claim_paths.py tests/unit/integration/test_copilot_cowork_target.py tests/unit/test_surviving_deps_reintegration.py tests/unit/integration/test_targets.py tests/unit/test_deployment_materialization_receipts.py->818 passed, 1 skipped(first commit); after foldstests/unit/commands/test_export_patch.py, uninstall/reintegration/receipts unit files,test_targets.py, guard + runner inventory + skill-layout mutation + audit-target tests ->357 passed, 1 skipped.venv/bin/python -m pytest -p no:xdist tests/unit/scripts/test_architecture_skill_layout_guard.py tests/unit/scripts/test_architecture_skills_root_guard.py tests/unit/scripts/test_architecture_runner.py::test_registered_rule_inventory_matches_frozen_semantic_contract tests/integration/test_architecture_owner_rule_mutations.py -k "skill or registered or matrix"->23 passed;tests/integration/test_architecture_audit_targets.py+ audit-target mutation case ->7 passeduvx [email protected] check/format --checkonsrc/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py-> clean;pylint R0801-> 10.00/10;bash scripts/lint-auth-signals.sh-> clean;bash scripts/lint-architecture-boundaries.sh-> exit 0; file-length, YAML andrelative_toguards -> clean.Spec 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.