apm install: targets: (plural) leaks copilot deploy when target: (singular) absent
Summary
When apm.yml declares targets only via the plural targets: field (no singular target:), apm install deploys to both the configured target(s) and to copilot (.github/). The log line correctly reports the resolved set, but the deploy phase ignores it.
Reproduced on v0.15.0 (also present on main at the time of writing).
Repro
apm.yml:
name: example
version: 0.1.0
targets:
- claude
dependencies:
apm:
- somostuio/coding-agents-config/packages/core
apm install output:
[i] Targets: claude (source: apm.yml)
[+] github.com/somostuio/coding-agents-config/packages/core @1de9bcca
|-- 6 prompts adopted -> .github/prompts/
|-- 8 agents integrated -> .claude/agents/, .github/agents/
|-- 6 commands integrated -> .claude/commands/
|-- 7 instruction(s) integrated (7 adopted) -> .claude/rules/, .github/instructions/
|-- Skill integrated -> .agents/skills/, .claude/skills/
Provenance line says Targets: claude (source: apm.yml), but .github/{agents,instructions,prompts}/ are created and populated. The lockfile records both target trees as deployed_files.
Expected
With targets: [claude] (and no --target CLI override), only the claude profile should be deployed — equivalent behavior to target: claude (singular) or --target claude.
Root cause
src/apm_cli/install/phases/targets.py:117 reads only the singular attribute:
config_target = ctx.apm_package.target
_explicit = ctx.target_override or config_target or None
ApmPackage (see src/apm_cli/models/apm_package.py:230-237) stores target (singular) and targets (plural) as separate fields. With only targets: declared, apm_package.target is None, so _explicit is None for the legacy resolver call at :144.
The legacy resolver (src/apm_cli/integration/targets.py:825-898) with explicit_target=None skips branch 1 (explicit), runs branch 2 (auto-detect by directory presence), and on a clean workspace falls through to branch 3 — the hard-coded [copilot] fallback at line 898.
Meanwhile the v2 path (install/phases/targets.py:303-309) correctly reads both keys via _read_yaml_targets → parse_targets_field, so v2 returns [claude].
The merge at install/phases/targets.py:399-404:
_v2_names = {t.name for t in _v2_targets} # {'claude'}
_legacy_only = [t for t in _targets if t.name not in _v2_names] # [copilot]
_targets = _v2_targets + _legacy_only # [claude, copilot]
…re-injects the legacy copilot fallback into the final deploy set. The downstream integrators then deploy to both. The "Targets: claude (source: apm.yml)" log is emitted from v2 provenance only and never reflects this re-injection.
Suggested fix
Make the legacy resolver see the same explicit input as v2. Smallest change at install/phases/targets.py:117:
config_target = ctx.apm_package.target or ctx.apm_package.targets
Alternative: drop the unconditional copilot fallback from the legacy path when v2 has already resolved a non-empty target set, or refuse to merge legacy auto-detect results when an apm.yml-declared target intent exists.
Workaround for users
Use the singular form in apm.yml until fixed:
target: claude
CSV / list forms (target: claude,cursor or target: [claude]) also work because parse_target_field handles them.
Environment
- apm 0.15.0 (1b2c0f0)
- macOS arm64 (Darwin 24.4.0)
Triage decision
accept
Proposed labels
theme/portability
area/cli
area/multi-target
type/bug
status/accepted
priority/high
Milestone
0.14.0
Suggested next action
Apply the suggested fix at install/phases/targets.py:117 -- read ctx.apm_package.target or ctx.apm_package.targets so the legacy resolver sees the same explicit input as the v2 path -- and add a regression test for the targets: [claude] (plural only) case.
Suggested issue comment
Thanks for the exceptional bug report, `@juanmaorta`. The root cause analysis and suggested fix are accurate and the reproduction is unambiguous.
The panel accepts this as a high-priority bug. The core issue is that `install/phases/targets.py:117` reads only `ctx.apm_package.target` (singular) and ignores `ctx.apm_package.targets` (plural), so the legacy resolver never sees the explicit target and falls through to the hardcoded `[copilot]` fallback at line 898. The v2 path correctly reads both fields, but the merge at lines 399-404 re-injects the legacy fallback into the final deploy set.
The minimal fix you identified -- `config_target = ctx.apm_package.target or ctx.apm_package.targets` -- is the right approach. A regression test covering the `targets: [claude]` (plural only) case will prevent this from regressing.
If you would like to open a PR, the fix is bounded to `install/phases/targets.py:117`. The alternative of dropping the legacy-only merge is also valid but touches more code -- the minimal fix is preferred for a patch release.
Per-lens notes (collapsed)
DevX UX Expert -- User-Need Reviewer
Clear correctness bug with significant user impact: users who declare targets: [claude] (the plural form documented in the schema) get unexpected copilot deployment to .github/. The log line says "Targets: claude" but the deploy phase writes to both claude and copilot targets. This violates the principle of least surprise and could cause unwanted file creation in .github/ in production repositories.
Supply Chain Security Expert -- Risk-Surface Reviewer
The unexpected deploy to .github/ could be a mild concern in security-sensitive repos where .github/ contents are treated as privileged (workflow definitions, CODEOWNERS, etc.) -- unexpected AI primitive files appearing there could cause confusion. This is primarily a correctness issue, not a security issue. No lockfile, marketplace, MCP config, signing, or auth involvement.
OSS Growth Hacker -- Contributor-Tone Reviewer
Author has NONE association -- first-time contributor with an exceptional bug report: root cause traced to specific lines, code quoted, fix suggested, alternative fix noted. The reply acknowledges the quality of the diagnosis and gives a clear path to contribute a PR.
Python Architect -- Architecture Reviewer
The root cause analysis is accurate. The minimal fix (target or targets) is the right approach for a patch -- it is a one-line change with low regression risk. The legacy-resolver / v2-path co-existence is technical debt worth noting but not blocking this fix. The regression test for the targets: [claude] (plural) case is important to prevent future breakage as the legacy resolver is eventually removed.
Doc Writer -- Documentation Reviewer
Not activated -- bug fix only; no new user-facing documentation needed beyond a changelog note.
APM CEO -- Triage Arbiter
Accept at priority/high. The bug is unambiguous, the diagnosis is correct, and the fix is bounded. Unexpected deployment to .github/ is a user-visible correctness failure that affects anyone using the plural targets: form. Milestone 0.14.0 for a patch release fix.
{
"decision": "accept",
"decision_detail": "",
"theme": "theme/portability",
"areas": ["area/cli", "area/multi-target"],
"type": "type/bug",
"status": "status/accepted",
"priority": "priority/high",
"preserved_labels": [],
"milestone": "0.14.0",
"next_action": "Fix install/phases/targets.py:117 to read ctx.apm_package.target or ctx.apm_package.targets, and add a regression test for the targets plural-only case.",
"comment_markdown": "Thanks for the exceptional bug report, `@juanmaorta`. The panel accepts this as a high-priority bug -- minimal fix at targets.py:117 confirmed correct."
}
Triage status: agentic proposal pending human ratification. Silence is approval. Maintainers can:
- Override any label or milestone above by editing it directly -- human edits are authoritative and will not be reverted on subsequent runs.
- Re-trigger triage by applying the
status/needs-triagelabel, or by removingstatus/triagedto enroll the issue in the next daily sweep.Posted by the Triage Panel workflow. See .apm/skills/apm-triage-panel for the panel skill.
Generated by Triage Panel · sonnet46 7.9M · ◷