Skip to content

fix(pack): refuse a Claude dependency whose installed copy is missing (#4755) - #4824

Merged
Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-p2-4755-pack-missing-cache
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 4 commits into
mainfrom
danielmeppiel-p2-4755-pack-missing-cache

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

In a Claude project, apm pack silently left out a dependency's instructions routed to AGENTS.md when the dependency's whole apm_modules/<dep> copy was missing. The bundle shipped the dependency's other primitives (for example, a deployed skill) without its locked guidance.

routed_claude_rule_renders (src/apm_cli/integration/instruction_integrator.py) now makes pack refuse in that case, in both pack formats, and write no bundle. The refusal applies when the dependency's lock row records a content_hash, and it tells the user to run apm install. Pack still succeeds only when the lockfile records the dependency edge excluding Claude (its target_subset omits claude). A missing Claude deployment is not treated as proof. Lock rows without a content_hash keep the existing deployed-only behaviour.

Issue and approved scope

Issue: Fixes #4755

Human scope-approval comment: #4755 (comment)

Does this PR complete the issue, or what remains? It completes the issue.

Type of change

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

Testing

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

Not yet run: under host park mode (rule 17), the full suite runs in CI only. The excludes-Claude control below was added after the fix and has not been re-run locally. A broader local run was killed at about 96% and showed one unidentified failure, so CI is the verdict.

  • Regression: tests/integration/test_claude_agents_md_pack_lifecycle.py::test_pack_refuses_a_claude_dependency_whose_cache_directory_is_missing (a Claude dependency with a routed always-on instruction plus a deployed skill, with apm_modules/<dep> deleted). Before the fix it failed at assert 0 != 0: pack exited 0 with "Packed 2 file(s)" and shipped the skill without the guidance.
  • Control: ::test_pack_keeps_packing_a_dependency_that_excludes_claude_without_its_cache (edge targets: [copilot]).
  • Inference regression: ::test_pack_refuses_when_only_a_prompt_was_deployed_without_its_cache.
  • Local results: before the rebase onto main, the whole pack lifecycle file passed (9 tests, including the regression).
  • Lint: clean on the rebased branch (ruff 0.15.12 check and format, pylint R0801, auth signals, complexity ratchet, assertion ratchet, taxonomy, architecture boundaries).

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

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.

In a Claude project, pack skipped routed-rule rendering when a shipped
dependency's whole apm_modules/<dep> directory was missing, so both
pack formats shipped its skill without the guidance routed to
AGENTS.md. For an attested lock row, pack now refuses with the
'apm install' remedy unless the lock proves Claude receives nothing
from the dependency: its edge excludes Claude, or it deployed a skill,
agent, command or prompt for another target but nothing for Claude.

Closes #4755

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.38.0 milestone Nov 22, 2026
Copilot AI balanced review requested due to automatic review settings November 22, 2026 21:40
…agment to #4824

Co-authored-by: Copilot App <[email protected]>

apm-spec-waiver: pack refusal for a missing dependency cache is APM CLI bundling behaviour; no OpenAPM v0.1 requirement governs it.

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

The target-exclusion check can silently omit Claude guidance after cache deletion and incorrectly reject Copilot-only instruction packages, requiring authoritative exclusion records and regression coverage for both pack formats.

2 open issues
What changed in this PR

This PR addresses #4755 by making apm pack reject missing installed dependencies when their locked Claude guidance cannot be rendered, rather than silently producing an incomplete bundle.

Changes:

  • Adds a missing-source check with apm install remediation and lock-based Claude-exclusion handling.
  • Adds lifecycle coverage for refusal and excluded-Claude behavior in both pack formats.
  • Documents the user-visible fix in a changelog fragment.
File Description
tests/​integration/​test_claude_agents_md_pack_lifecycle.py Adds missing-cache regression and excluded-Claude control tests.
src/​apm_cli/​integration/​instruction_integrator.py Checks missing dependency copies and evaluates Claude-exclusion evidence.
changelog.d/​4824.fixed.md Records the pack refusal behavior.

Review effort: Balanced

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

Inferring Claude exclusion from missing deployments can silently omit required guidance after cache deletion, while incomplete target and layout evidence also blocks valid Copilot-only dependencies.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Recognize legacy skill paths when checking Claude exclusion

src/​apm_cli/​integration/​instruction_integrator.py:1077

A Claude-excluding Copilot dependency installed with --legacy-skill-paths records .github/skills/..., but these prefixes recognize only the default .agents/skills/... layout. If it has no other qualifying deployments, deleting its cache makes both pack formats incorrectly refuse it. Use skill_layout.with_every_skill_layout to recognize both supported layouts, and add the legacy-layout variant to the exclusion control.

Review effort: Balanced

…pendency cache (#4755)

A non-Claude deployment never proved Claude was excluded: a collision can
block the Claude copy while another target deploys, and Claude has no
prompts primitive. Drop that inference so pack refuses unless the lock
records the edge excluding Claude; the control now excludes Claude on the
edge, and a prompt-only regression covers the inference.

Co-authored-by: Copilot App <[email protected]>

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.

🟢 Approval recommended

No active review issues block the change that prevents apm pack from silently omitting routed Claude guidance.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit d0a48e1 into main Nov 22, 2026
73 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-p2-4755-pack-missing-cache branch November 22, 2026 23:38
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 23, 2026
… regenerate

Keeps #4843's native observation (a root half plus the enabledPlugins declaration half, native_gaps). Builds _surface_hits on train 5's entry-aware surfaces (JsonEntry, MergedHooks) and _observable. projected_cells keeps #4843's native projection plus the shared-root loose skill (#4559). #4751 fixed #4744, so the user-scope bin target-change cell drops its strict known and is required (known 9 -> 8, L15).

Co-authored-by: Copilot App <[email protected]>
Antonin Rouxel (Antonin-Rouxel-LaPoste-BGPN) pushed a commit to anrouxel/apm that referenced this pull request Nov 23, 2026
…s missing (microsoft#4850)

Since microsoft#4824, pack refused a missing apm_modules/<dep> unless the lock
recorded the edge excluding Claude, so a package excluding Claude through
its own targets: was over-refused. Install now records that restriction on
the lock row (package_targets, decided by target_filter.recorded_package_targets),
and pack consults it through target_filter.recorded_targets_exclude. Old
lockfiles load unchanged (an absent field proves nothing, so pack still
fails closed). _copy_subset_pairings moves to models/dependency/subsets.py
to keep lockfile.py under its size cap.

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

Development

Successfully merging this pull request may close these issues.

[BUG] apm pack silently omits routed Claude guidance when a dependency's whole cache directory is missing

2 participants