Repository navigation
fix(install): do not treat an empty skill directory as an unmanaged collision - #3449
Conversation
|
Thank you for contributing this fix. APM starts with an issue, not an implementation (https://github.com/microsoft/apm/blob/main/CONTRIBUTING.md). Please ask a maintainer to review and accept the scope in #3441 before implementation proceeds. This PR is labelled status/deferred until then. Current review requests include Daniel Meppiel (@danielmeppiel) and Sergio Sisternes (@sergio-sisternes-epam). Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors. |
Co-authored-by: Copilot App <[email protected]>
…ills The scope record for microsoft#3441 requires both the native-skill and the .apm sub-skill paths to deploy into an empty pre-existing skill directory, while other primitive types stay out of scope. The generic BaseIntegrator.check_collision change leaked to every primitive and the sub-skill path (_promote_sub_skills) still used target.exists(). Move the predicate into skill_support.skill_dir_has_content, which fails closed on symlinks, any non-directory entry, and unreadable subtrees, and use it on both skill paths. Addresses scope-gap review of PR microsoft#3449. Co-authored-by: Copilot App <[email protected]>
Proves the microsoft#3441 done-when through the CLI: install into a nested empty .agents/skills/NAME exits 0, deploys SKILL.md and records the deployment in apm.lock.yaml for both native and .apm sub-skill layouts, while a directory holding an unmanaged SKILL.md is still refused with exit 1. Co-authored-by: Copilot App <[email protected]>
Document that an empty skill destination tree is deployed into, and add the CHANGELOG entry crediting the contributor for microsoft#3449. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
os.path.islink does not report NTFS junctions on older Pythons, so a junction to an empty directory would read as an empty skill tree and let install write through it. Check the FILE_ATTRIBUTE_REPARSE_POINT bit from lstat for the root and every subdirectory and fail closed on lstat errors. Addresses supply-chain-security-expert panel finding on PR microsoft#3449. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
test_copy_failure_only_rolls_back_new_empty_destination asserted that a pre-existing empty skill directory blocks a later unmanaged install, which is the exact silent-skip microsoft#3441 fixes. Completion now depends only on whether user content (the partial SKILL.md) survives; rollback assertions are unchanged. Co-authored-by: Copilot App <[email protected]>
The fix restores conformance with existing normative text rather than adding behavior: OpenAPM v0.1 section 8.3.1 (req-pr-008) says a shared directory or skill name alone MUST NOT establish file ownership or an unmanaged-skill conflict. An empty pre-existing skill directory is exactly that case. apm-spec-waiver: conformance fix for existing 8.3.1 text; empty dir alone is not a conflict Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Single-owner predicate in skill_support.py, consistent across both skill paths, no leak to BaseIntegrator. |
| Test Coverage Expert | 0 | 0 | 0 | All Done-when clauses covered at unit and lifecycle tiers; expectation update is a legitimate #3441 behavior change. |
| Supply Chain Security Expert | 0 | 1 | 0 | Junction gap raised and folded; fold fails closed; no security regression. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 2 follow-ups
- [Supply Chain Security Expert] Add
ensure_path_withincontainment on the_promote_sub_skillstarget path. -- This gap existed before this PR and is unrelated to empty-directory handling. It deserves its own bounded hardening issue. - [Test Coverage Expert] Define preflight semantics for non-empty skill directories that hold a non-colliding unmanaged file (for example
notes.txt). -- Such a directory is still skipped with a warning and exit 0. The scope record leaves non-empty preflight semantics out of scope, so this needs a separate decision.
Recommendation
Ship after maintainer review. The panel agrees, the one security finding was folded with tests and mutation-break evidence, CI is green, and both deferred items are outside the approved scope. Track them as follow-up issues.
Folded in this run
- (panel) Sub-skill (
.apm/skills) path still skipped an empty pre-existing directory; now usesskill_dir_has_content-- resolved in bdea808. - (panel) Reverted the generic
BaseIntegrator.check_collisionchange, because other primitive types are out of scope; the predicate moved toskill_support, failing closed on symlinks and walk errors -- resolved in bdea808. - (panel) Installed-CLI regression for both layouts: a nested empty directory deploys
SKILL.md, theapm.lock.yamldeployment is recorded and install exits 0; a populated directory is still refused with exit 1 -- resolved in 48cbfed. - (panel) CHANGELOG entry crediting Mohammed Alkindi (@MohammedAlkindi); one sentence each in
reference/cli/install.mdand the apm-guidecommands.md-- resolved in 7a20780. - (panel) NTFS junctions are now treated as content by checking
FILE_ATTRIBUTE_REPARSE_POINT-- resolved in 176d49b. - (panel)
test_copy_failure_only_rolls_back_new_empty_destinationexpected the [BUG] An empty pre-existing skill directory makesapm installsilently skip the skill (exit 0, nothing deployed) #3441 silent skip; its expectation is updated and its rollback assertions are unchanged -- resolved in c33e051. - (panel) Spec conformance Mode B detector: added an
apm-spec-waivertrailer citing OpenAPM 8.3.1 -- resolved in f0e37c2.
Copilot signals reviewed
- (review) -- NOT-LEGIT: Copilot did not review this PR because the requester was out of quota; there was no content to act on.
Deferred (out-of-scope follow-ups)
- (panel) A skill directory holding a non-colliding unmanaged file is skipped with a warning and exit 0. Out of scope because the scope record excludes unmanaged-content preflight semantics for non-empty directories.
- (panel)
ensure_path_withincontainment on the sub-skill target path. Out of scope because it is a separate, pre-existing path-containment hardening.
Regression-trap evidence (mutation-break gate)
test_skill_integrator_hermetic.py::...::test_empty_preexisting_tree_is_deployed_not_skipped-- deleted the sub-skillskill_dir_has_contentguard; the test FAILED as expected; guard restored.test_native_skill_collision.py::test_native_skill_deploys_into_empty_preexisting_directory-- deleted the native guard; the test FAILED as expected; guard restored.test_empty_skill_dir_install_lifecycle.py::test_install_deploys_into_empty_nested_skill_directory[subskills,native]-- deleted both guards; both cases FAILED as expected; guards restored.test_skill_dir_has_content.pysymlink, unreadable-subtree and reparse-point tests -- deleted each fail-closed branch; each test FAILED as expected; branches restored.
Lint contract
ruff check, ruff format --check, pylint R0801, lint-auth-signals.sh and lint-architecture-boundaries.sh are all silent on HEAD merged with current main. skill_integrator.py is 2098 of the 2100-line cap.
CI
All 27 checks are green on f0e37c2, including Lint, Build & Test shards, Lifecycle Smoke, the Windows gates, Spec conformance gate and license/cla. This took 1 CI fix iteration. Locally, the full tests/unit suite passed (25679 tests).
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3449 | f0e37c2 |
ship_with_followups | 1 | 7 | 2 | 2 | green | MERGEABLE | BLOCKED | pending required review |
Convergence
1 outer iteration and 2 Copilot rounds. Final panel stance: ship_with_followups. Ready for maintainer review.
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]>
6d6ba4f
into
microsoft:main
#3532 added "and not new_path.is_symlink()" to migrate_lockfile_if_needed. The contracts-tooling-lockfile-read rule checked that fragment anywhere in lockfile.py, so removing it from resolve_lockfile_path_for_read no longer tripped the guard; the mutation test failed with "assert 2 == 1" in the release dry run (43039615994, macOS arm64). Check the resolver fragments within the resolver's own body and anchor the mutation on its clause. #3449 changed "if self.check_collision(" to "if target_existed and self.check_collision(", turning the native skill collision mutation into a no-op. Anchor it on "self.check_collision(". Refs #3567 Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>
Description
apm installtreats an empty pre-existing skill directory as an unmanaged collision becausetarget_path.exists()is true, skipping the skill while reporting success.check_collisionandtarget_existednow verify whether a directory contains files, deploying into empty directory trees.Issue and approved scope
Issue: Fixes #3441
Human scope-approval comment: #3441
Does this PR complete the issue, or what remains? Completes the issue.
Type of change
Testing
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdateddocs/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.