Skip to content

fix: address post-merge review on #542#547

Merged
danielmeppiel merged 2 commits intomainfrom
fix/scope-partition-follow-up
Apr 2, 2026
Merged

fix: address post-merge review on #542#547
danielmeppiel merged 2 commits intomainfrom
fix/scope-partition-follow-up

Conversation

@danielmeppiel
Copy link
Copy Markdown
Collaborator

Follow-up to #542 addressing 4 post-merge review comments:

  1. Uninstall partition: partition managed files with both default (KNOWN_TARGETS) and resolved targets, then merge buckets -- ensures user-scope paths like .copilot/agents/... are bucketed alongside legacy .github/agents/... paths
  2. Orphan cleanup: pass resolved targets to validate_deploy_path so user-scope prefixes are accepted
  3. Unused variable: error_msg -> _ in skill_integrator
  4. CHANGELOG: consolidate Fixed entries per repo convention

Testing

  • All unit tests pass

- Partition uninstall managed files with both default and resolved
  targets so user-scope paths are bucketed correctly
- Pass resolved targets to orphan validate_deploy_path so user-scope
  paths are accepted for cleanup
- Fix unused variable (error_msg -> _)
- Consolidate CHANGELOG Fixed entries per repo convention

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 2, 2026 16:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Follow-up to #542 to address post-merge review items around user-scope uninstall/install cleanup, minor code cleanup, and changelog formatting consistency.

Changes:

  • Update uninstall partitioning to bucket managed files against both default KNOWN_TARGETS and scope-resolved targets, then merge the results.
  • Update orphan cleanup safety-gating to call validate_deploy_path(..., targets=_targets) so user-scope prefixes are accepted.
  • Replace unused error_msg variables in skill_integrator with _ and consolidate CHANGELOG.md fixed entries.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/apm_cli/integration/skill_integrator.py Removes unused error_msg binding from validate_skill_name call sites.
src/apm_cli/commands/uninstall/engine.py Merges partition buckets from default targets and resolved targets to improve uninstall cleanup across legacy/user-scope paths.
src/apm_cli/commands/install.py Passes resolved targets into validate_deploy_path during orphan cleanup to accept user-scope prefixes.
CHANGELOG.md Consolidates multiple #542 Fixed bullets into a single entry per changelog conventions.

Comment thread src/apm_cli/commands/install.py Outdated
Comment on lines +2341 to +2342
# Pass resolved targets so user-scope prefixes are accepted.
if BaseIntegrator.validate_deploy_path(_orphan_path, project_root, targets=_targets):
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

In user-scope installs, using only scope-resolved targets here means legacy orphaned paths that were written under project-scope prefixes (e.g., ".github/..." from older buggy user-scope installs) will fail validate_deploy_path() and will not be removed during orphan cleanup. Consider validating against both resolved targets and default KNOWN_TARGETS (or a union of allowed prefixes) so both ".copilot/..." and legacy ".github/..." orphan entries can be cleaned safely.

See below for a potential fix:

            # Build validation targets that cover both current scope-resolved
            # prefixes and default integrator targets so legacy project-scope
            # orphaned paths (for example, ".github/...") can be removed safely.
            _validation_targets = _targets or {}
            try:
                _default_targets = getattr(BaseIntegrator, "KNOWN_TARGETS", None)
            except Exception:
                _default_targets = None
            if _default_targets:
                _validation_targets = {**_default_targets, **_validation_targets}
            for _orphan_path in sorted(orphaned_deployed_files):
                # validate_deploy_path() is the safety gate: it rejects path-traversal,
                # requires a known integration prefix, and checks the resolved path
                # stays within project_root -- so rmtree is safe here.
                # Validate against both default and scope-resolved targets so
                # legacy project-scope prefixes are also cleaned up.
                if BaseIntegrator.validate_deploy_path(_orphan_path, project_root, targets=_validation_targets):

Copilot uses AI. Check for mistakes.
Comment on lines 254 to +258
_buckets = BaseIntegrator.partition_managed_files(sync_managed)
if user_scope and _resolved_targets:
_scope_buckets = BaseIntegrator.partition_managed_files(
sync_managed, targets=_resolved_targets
)
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

When user_scope is true, _resolved_targets is scope-resolved via TargetProfile.for_scope(), which filters out unsupported_user_primitives (e.g., Copilot removes "instructions"). As a result, partition_managed_files(..., targets=_resolved_targets) will not recognize/bucket managed paths for those filtered primitives under user-scope roots (e.g., legacy ".copilot/instructions/..." entries), so Phase 1 sync will never remove them even if they are present in all_deployed_files. If the intent is to clean up legacy installs, consider partitioning/cleanup against a target set that resolves user_root_dir but does not drop primitives (or otherwise explicitly include unsupported-primitive prefixes for removal only).

Copilot uses AI. Check for mistakes.
Merge KNOWN_TARGETS with scope-resolved targets for orphan cleanup
validation, matching the pattern used in uninstall engine. This
ensures legacy project-scope orphan paths (e.g., .github/...) are
also cleaned up during user-scope installs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@danielmeppiel danielmeppiel merged commit 7e46fe4 into main Apr 2, 2026
5 checks passed
@danielmeppiel danielmeppiel deleted the fix/scope-partition-follow-up branch April 2, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants