Repository navigation
feat(registry): align object-form registry deps with git skills: - #2166
Daniel Meppiel (danielmeppiel) merged 9 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Aligns registry object-form dependency parsing/serialization with the existing git object-form behavior by allowing a skills: subset and ensuring registry deps round-trip correctly through to_apm_yml_entry(). This improves manifest fidelity when users install a subset of skills from a registry-hosted SKILL_BUNDLE and then persist it back to apm.yml.
Changes:
- Accept
skills:on registry longhand (id/registry/version) entries by reusing the sharedparse_skill_subsetvalidator. - Add a dedicated
source == "registry"branch inDependencyReference.to_apm_yml_entry()so registry deps serialize as registry dict entries rather than malformed git entries. - Add unit tests covering registry
skills:parsing, validation, and round-trip serialization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tests/unit/test_reference_registry_shorthand.py | Adds unit tests for registry object-form skills: parsing/validation and to_apm_yml_entry() round-trips. |
| src/apm_cli/models/dependency/reference.py | Adds skills: support to registry object-form parsing and adds a registry serialization branch in to_apm_yml_entry(). |
Copilot review on microsoft#2166 correctly flagged that the new source == "registry" branch in to_apm_yml_entry() dropped target_subset: set_target_subset_for_entry() sets ref.target_subset directly and calls to_apm_yml_entry(), so a registry dependency's targets: write-back was silently lost. Since the PR's premise is full parity with git-longhand (which already supports both skills: and targets:), close the gap by adding targets: parsing/validation to the registry object-form parser (same parse_target_subset validator as git/local-path forms) and emitting it in to_apm_yml_entry(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Fixed the file-length CI failure: extracted |
|
Pushed Root cause: Fix:
Verified live against the real registry: the exact repro command now correctly leaves apm.yml as Also confirmed via a separate manual test: the other finding ( |
|
Fixed the Spec conformance gate / Mode B detector failure: my previous commit's fix in Since this is a genuine bug fix (not a no-op refactor), I did the proper three-step ritual rather than reaching for
Verified locally: |
959bb64 to
f3bf2ce
Compare
Copilot review on microsoft#2166 correctly flagged that the new source == "registry" branch in to_apm_yml_entry() dropped target_subset: set_target_subset_for_entry() sets ref.target_subset directly and calls to_apm_yml_entry(), so a registry dependency's targets: write-back was silently lost. Since the PR's premise is full parity with git-longhand (which already supports both skills: and targets:), close the gap by adding targets: parsing/validation to the registry object-form parser (same parse_target_subset validator as git/local-path forms) and emitting it in to_apm_yml_entry(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
|
Rebased onto latest
Re-verified after rebase: full relevant suite (3302 passed, same 2 pre-existing unrelated |
Copilot review on microsoft#2166 correctly flagged that the new source == "registry" branch in to_apm_yml_entry() dropped target_subset: set_target_subset_for_entry() sets ref.target_subset directly and calls to_apm_yml_entry(), so a registry dependency's targets: write-back was silently lost. Since the PR's premise is full parity with git-longhand (which already supports both skills: and targets:), close the gap by adding targets: parsing/validation to the registry object-form parser (same parse_target_subset validator as git/local-path forms) and emitting it in to_apm_yml_entry(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
f3bf2ce to
67ba729
Compare
Copilot review on microsoft#2166 correctly flagged that the new source == "registry" branch in to_apm_yml_entry() dropped target_subset: set_target_subset_for_entry() sets ref.target_subset directly and calls to_apm_yml_entry(), so a registry dependency's targets: write-back was silently lost. Since the PR's premise is full parity with git-longhand (which already supports both skills: and targets:), close the gap by adding targets: parsing/validation to the registry object-form parser (same parse_target_subset validator as git/local-path forms) and emitting it in to_apm_yml_entry(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
67ba729 to
64be936
Compare
|
Rebased onto latest
Verified post-rebase: 3411 tests pass (only the same pre-existing, environment-specific |
Fold items from shepherd-driver run: - CHANGELOG.md: add [Unreleased] entry for feat(registry) PR microsoft#2166 describing skills:/targets: parity for registry object-form deps - .apm/instructions/architecture.instructions.md: remove duplicate 'Effective package target authorization' row and remove the stale mcp_integrator_install.py selector from 'Effective install target selection' (already owned by 'MCP target-selection precedence'). Aligns with the same fix already landed on main in f87104f. - .github/instructions/architecture.instructions.md: same fix. Co-authored-by: Copilot <[email protected]>
…, CHANGELOG reword - Add verbose_detail log in propagate_existing_registry_source success path so --verbose mode shows source-propagation decisions (cli-logging-expert finding) - Reword CHANGELOG entry to lead with user benefit instead of internal method name to_apm_yml_entry() (devx-ux + oss-growth-hacker finding) - Add skills:/targets: example to manifest-schema.md registry dep section so the feature is discoverable from the reference page (oss-growth-hacker + doc-writer) - Add one-line note to install.md --skill flag: applies to both git-longhand and registry-longhand deps (devx-ux-expert finding) Shepherd fold commit (panel pass, PR microsoft#2166). Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 1 | 2 | Clean extraction + source-propagation fix; parameter-passing pattern is sound; one double-scan inefficiency in the hot path worth calling out. |
| CLI Logging Expert | 0 | 0 | 1 | Error path is well-surfaced; silent source propagation now has verbose breadcrumb (folded). |
| DevX UX Expert | 0 | 0 | 1 | Good parity fix; error message is well-crafted. CLI reference docs updated (folded). |
| Supply Chain Security Expert | 0 | 0 | 2 | No blocking security issues. Path traversal guards are correctly applied; registry-to-git conversion is properly gated. |
| OSS Growth Hacker | 0 | 0 | 1 | Strong parity fix removes a real footgun; CHANGELOG entry is solid; docs example folded. |
| Doc Writer | 0 | 0 | 1 | Spec req-mf-023 is valid and correctly added. Reference docs updated (folded). |
| Test Coverage Expert | 0 | 1 | 0 | Critical surfaces well-covered. One defense-in-depth error-routing path in install.py lacks a command-level assertion. |
| Performance Expert | 0 | 0 | 2 | Repeated O(n) manifest scans are algorithmically wasteful but add <15ms vs seconds of network I/O -- nit only. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 3 follow-ups
- [Python Architect] get_existing_dep_ref_for_identity called twice per package (propagate + skill merge) -- thread existing_ref to avoid redundant O(n) scan per install loop iteration.
- [Test Coverage Expert] Add command-level test exercising try_update_existing_dependency_entry error path through _resolve_package_references -- defense-in-depth error routing is untested at integration level; a regression here would surface only in production.
- [Performance Expert] _check_package_conflicts parses all entries then discards them; returning Dict[identity, DependencyReference] would eliminate all downstream re-scans -- follow-up code quality improvement.
Architecture
classDiagram
direction LR
class DependencyReference {
<<Dataclass>>
+repo_url str
+source str or None
+registry_name str or None
+skill_subset list or None
+target_subset list or None
+to_apm_yml_entry() str or dict
+to_canonical() str
+get_identity() str
+parse(s) DependencyReference
+parse_from_dict(d) DependencyReference
+_parse_registry_object_entry(d) DependencyReference
}
class parse_registry_object_entry {
<<Pure Function>>
+__call__(cls, entry) DependencyReference
}
class propagate_existing_registry_source {
<<IO Boundary>>
+__call__(dep_ref, current_deps, identity) bool
}
class get_existing_dep_ref_for_identity {
<<Pure Function>>
+__call__(current_deps, identity) Any or None
}
class try_update_existing_dependency_entry {
<<Adapter>>
+__call__(...) tuple bool str or None
}
class merge_structured_entry_into_current_deps {
<<IO Boundary>>
+__call__(current_deps, entry, identity, ...) None
}
DependencyReference ..> parse_registry_object_entry : delegates via classmethod
propagate_existing_registry_source ..> get_existing_dep_ref_for_identity : calls
propagate_existing_registry_source ..> DependencyReference : mutates .source .registry_name
try_update_existing_dependency_entry ..> merge_structured_entry_into_current_deps : wraps
merge_structured_entry_into_current_deps ..> DependencyReference : parses entries
Per-persona detailed findings
Python Architect:
- (recommended)
get_existing_dep_ref_for_identityis called twice per package in the install loop: once inpropagate_existing_registry_sourceand again viaapply_cli_skill_pin -> get_existing_skill_subset. Each call is O(n) parse work oncurrent_deps. Threading the already-foundexisting_refwould halve parse overhead for skill-pinned packages. (src/apm_cli/commands/install.py:421+package_resolution.py:163-189) - (nit)
propagate_existing_registry_sourceusesAnyfor dep_ref types; a lightweight Protocol withsource/registry_namefields would make the mutation contract self-documenting. - (nit)
try_update_existing_dependency_entrycatches onlyValueError; unexpectedTypeError/AttributeErrorfrom parse could propagate; currently shielded by the inner loop but worth noting.
CLI Logging Expert:
- (nit)
ValueErrormessage inpackage_resolution.py:374uses curly/smart quotes around{identity}; ASCII single-quotes are more grep-friendly in terminal contexts.
DevX UX Expert:
- (nit) Error message says "use the object form" but does not name
apm.ymlas the file to edit; adding "in apm.yml" would close the loop for users unfamiliar with the project structure.
Supply Chain Security Expert:
- (nit)
registry_namefield accepts arbitrary strings without pattern validation (registry_entry.py:48) -- pre-existing behavior, not a regression. - (nit)
versionfield for registry deps has no character restriction (registry_entry.py:70) -- pre-existing behavior.
Test Coverage Expert:
- (recommended)
try_update_existing_dependency_entryerror path through_resolve_package_references(install.py:499-503) is not exercised at command level. The underlyingValueErrorfrommerge_structured_entry_into_current_depsIS tested at unit level, but the routing from error toinvalid_outcomes+ user-visible diagnostic has no assertion. Suggested test: mock propagation to return False on a registry dep, then verifyinvalid_outcomescontains the expected message.
Performance Expert:
- (nit) Redundant double-scan of
current_depsfor same identity per install loop iteration (install.py:421+package_resolution.py:184). Adds <15ms at n=50; algorithmic nit. - (nit)
_check_package_conflictsparses all entries into aSet[identity]then discards the parsed objects; returningDict[identity, DependencyReference]would eliminate all downstream re-scans for a clean O(n) + O(m) total.
…lls: Object-form git dependencies (- git: ...) have long supported a skills: array to install a subset of a SKILL_BUNDLE package. The registry-longhand form (- id: owner/repo, registry:, version:) rejected the same field as unknown, with no way to narrow which skills get deployed. Reuses the existing parse_skill_subset validator so both forms share identical validation (non-empty, no path traversal, sorted+deduped). Also fixes to_apm_yml_entry(), which had no branch for source == "registry" at all: any registry dependency with a skill/target subset set (e.g. via apm install --skill ... --save) would previously serialize as a malformed git: entry, and even an alias-only registry entry collapsed to a bare canonical string, silently dropping registry:/id:/version:. Verified end-to-end against a live registry: published a package with 4 skills, installed a consumer with skills: [a, b], confirmed only 2 were deployed and apm.lock.yaml's skill_subset matched. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Copilot review on microsoft#2166 correctly flagged that the new source == "registry" branch in to_apm_yml_entry() dropped target_subset: set_target_subset_for_entry() sets ref.target_subset directly and calls to_apm_yml_entry(), so a registry dependency's targets: write-back was silently lost. Since the PR's premise is full parity with git-longhand (which already supports both skills: and targets:), close the gap by adding targets: parsing/validation to the registry object-form parser (same parse_target_subset validator as git/local-path forms) and emitting it in to_apm_yml_entry(). Co-Authored-By: Claude Sonnet 5 <[email protected]>
…le-length gate CI's file-length guardrail failed: reference.py was already at 2079 lines on main (the existing worst offender driving the 2100-line cap) and this PR's additions tipped it to 2124. Move _parse_registry_object_entry into a new sibling module models/dependency/registry_entry.py, matching the existing pattern of object_fields.py/subsets.py/identity.py/types.py -- reference.py delegates via a thin classmethod wrapper. The new module takes the DependencyReference class as a parameter instead of importing it, so there's no import cycle. reference.py: 2124 -> 2028 lines. Scoped to only the registry object-form parsing this PR touches; the rest of reference.py (git/URL shorthand parsing, GitLab/ADO handling, virtual package detection) is untouched. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Repro: apm.yml already has an object-form registry dependency (`- id: owner/repo`, `version: ...`). Running `apm install "owner/repo#1.0.0" --skill some-skill` rewrote that entry into a `git:`-shaped structured entry and then failed ls-remote (or worse, silently succeeded if `owner/repo` also happened to resolve as a real GitHub repo -- a dependency-confusion-shaped footgun). Root cause: DependencyReference.parse() (the CLI positional parser) has no registry awareness -- source is always None/"git" for a bare string. The --skill code path in _resolve_package_references() calls dep_ref.to_apm_yml_entry() before the (separate) default-registry routing check runs, so the registry-aware branch in to_apm_yml_entry() never fires for a freshly-parsed CLI arg, even when apm.yml already has this exact identity pinned to a registry. Fix: - _resolve_package_references() now looks up the existing apm.yml entry for the parsed identity before doing anything else; if it's source=="registry", propagate source/registry_name onto the freshly-parsed dep_ref so to_apm_yml_entry() takes the registry branch, and route the probe-skip decision the same way (routes_unscoped_to_registry treats an already- known registry source as "not ambiguous", so the existing-registry fact has to be OR'd in explicitly). - merge_structured_entry_into_current_deps() gets a defense-in-depth guard: refuse (ValueError, caught and reported as a normal invalid-package outcome) to overwrite a registry-sourced manifest entry with a non- registry-shaped structured entry, regardless of which upstream code path produced it. - Extracted the repeated "parse current_deps entries, find the one matching this identity" loop into get_existing_dep_ref_for_identity() (used by the new check and by get_existing_skill_subset(), which had its own copy of the same loop). Verified live against a real registry: the exact repro command now leaves apm.yml as a proper id/registry/version dict with skills: added, and apm.lock.yaml resolves it as source: registry from the actual registry URL. Co-Authored-By: Claude Sonnet 5 <[email protected]>
…rewrite
Spec-citation fold closing the Mode B silent-extension gate on
src/apm_cli/install/package_resolution.py (the --skill registry-to-git
silent-conversion fix).
Rebased onto latest main again (now at 107 normative statements, up from
104); req-mf-023 remains available (main's own concurrent additions used
req-lk-021, req-lk-022, req-sc-013, req-tg-008 instead).
Added req-mf-023 (Section 4.3.2, consumer MUST): a consumer MUST NOT
silently rewrite an existing id:-form (registry-sourced) manifest entry
into a git:-form entry when persisting a subsequent CLI-driven update
(e.g. an additive --skill pin) for the same dependency identity; the
existing entry's source MUST be honored, and an update that would
otherwise replace a registry-sourced entry with a non-registry-shaped
entry MUST be rejected with a diagnostic naming the identity.
Three-step ritual: spec anchor + Appendix C row + Section 4.9/11.3.2
enumerations + revision history row (counts: 107 -> 108, 102 -> 103 MUST);
manifest entry in openapm-v0.1.requirements.yml; @pytest.mark.req
("req-mf-023") test driving the real merge_structured_entry_into_current_deps
behavior. Regenerated CONFORMANCE.{md,json}. orphan_check passes (108
requirements aligned).
Co-Authored-By: Claude Sonnet 5 <[email protected]>
main's install.py grew from 2088 to (still under 2100) since the last rebase, and this PR's --skill registry-preservation fix tipped it back over. Extract the two small additions into package_resolution.py helpers: - propagate_existing_registry_source(): the existing-entry lookup + source/registry_name propagation, replacing a 16-line inline block with a 3-line call. - try_update_existing_dependency_entry(): wraps update_existing_dependency_entry_if_needed() and returns (updated, error) instead of raising, so the call site collapses from a try/except to a plain if-check. install.py: 2119 -> 2100 lines (exactly at the cap; verified against the CI guardrail's own NR > max check, which passes at equality). Updated test_install_resolve_refs.py's TestResolvePackageReferencesProbeSkipProvenance test: it patched apm_cli.commands.install.update_existing_dependency_entry_if_needed, which no longer exists in that module's namespace now that install.py calls the new wrapper instead -- repointed the patch to apm_cli.install.package_resolution.update_existing_dependency_entry_if_needed, where the wrapper actually calls it from. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Fold items from shepherd-driver run: - CHANGELOG.md: add [Unreleased] entry for feat(registry) PR microsoft#2166 describing skills:/targets: parity for registry object-form deps - .apm/instructions/architecture.instructions.md: remove duplicate 'Effective package target authorization' row and remove the stale mcp_integrator_install.py selector from 'Effective install target selection' (already owned by 'MCP target-selection precedence'). Aligns with the same fix already landed on main in f87104f. - .github/instructions/architecture.instructions.md: same fix. Co-authored-by: Copilot <[email protected]>
3848811 to
65eef62
Compare
…, CHANGELOG reword - Add verbose_detail log in propagate_existing_registry_source success path so --verbose mode shows source-propagation decisions (cli-logging-expert finding) - Reword CHANGELOG entry to lead with user benefit instead of internal method name to_apm_yml_entry() (devx-ux + oss-growth-hacker finding) - Add skills:/targets: example to manifest-schema.md registry dep section so the feature is discoverable from the reference page (oss-growth-hacker + doc-writer) - Add one-line note to install.md --skill flag: applies to both git-longhand and registry-longhand deps (devx-ux-expert finding) Shepherd fold commit (panel pass, PR microsoft#2166). Co-authored-by: Copilot <[email protected]>
…, CHANGELOG reword - Add verbose_detail log in propagate_existing_registry_source success path so --verbose mode shows source-propagation decisions (cli-logging-expert finding) - Reword CHANGELOG entry to lead with user benefit instead of internal method name to_apm_yml_entry() (devx-ux + oss-growth-hacker finding) - Add skills:/targets: example to manifest-schema.md registry dep section so the feature is discoverable from the reference page (oss-growth-hacker + doc-writer) - Add one-line note to install.md --skill flag: applies to both git-longhand and registry-longhand deps (devx-ux-expert finding) Shepherd fold commit (panel pass, PR microsoft#2166). Co-authored-by: Copilot <[email protected]>
65eef62 to
31c838d
Compare
During the rebase conflict resolution the HTML anchor in section 4.3.2 was left as <a id="req-mf-023"> and req-mf-024 was not added to the consumer-requirement enumeration lists in sections 4.9 and 11.3.2. Fix all three, then verify orphan_check passes (111 reqs aligned). Rebase conflict-resolution fixup (shepherd-driver, PR microsoft#2166). Co-authored-by: Copilot <[email protected]>
Shepherd-driver terminal state: advisory-with-deferredHead: All shepherd-driver work is complete. Summary: Folded (committed):
Deferred (out-of-scope follow-ups):
Owner-touch gate (v2): owner-extension classification, Spec: req-mf-024 (registry identity preservation) at spec line 574; req-mf-023 (VS Code OCI/Docker, from main 0.1.26) at line 679 -- no collision. No auto-merge; awaiting required maintainer review. |
98d2d9b
into
microsoft:main
The CI file-length guardrail (2100 lines) failed on src/apm_cli/commands/install.py at 2111 lines -- drift that landed on main via #2166 and #2200, surfaced here because CI evaluates the merge commit. Move `_get_invocation_argv` and `_split_argv_at_double_dash` (plus the explanatory block comment on Click's `--` swallowing) into the new `apm_cli/install/argv.py`. `commands/mcp.py` already reached through `commands/install.py` for both helpers, so they were never install-specific; `commands/install.py` re-exports them so the `_get_invocation_argv` test seam keeps working unchanged. install.py: 2111 -> 2080 lines. Ratchet the architecture invariant budget 2150 -> 2100 to match the CI guardrail. Validation: lint mirror green (ruff check + format, pylint R0801, auth-signals), architecture boundary lint clean, file-length guard clean, 2084 tests pass across tests/unit/install/ and tests/integration/test_architecture_authorities.py. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 11dbb707-3685-4a9e-80a4-19c73831232a
* chore: release v0.28.0 Bump pyproject.toml and uv.lock to 0.28.0 and convert the [Unreleased] CHANGELOG block into [0.28.0] - 2026-08-04 with one "so what" entry per user-facing PR merged since v0.27.0. MINOR is warranted: registry object-form dependencies gained new `skills:`/`targets:` manifest fields (#2166) and two new xAI Grok targets landed (#2420), alongside the Kiro agents primitive (#2440). Lint mirror is green locally (ruff check + format, pylint R0801, auth-signals). Post-merge: tag v0.28.0 to trigger the release workflow. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 11dbb707-3685-4a9e-80a4-19c73831232a * refactor(install): extract argv boundary helpers to unblock length gate The CI file-length guardrail (2100 lines) failed on src/apm_cli/commands/install.py at 2111 lines -- drift that landed on main via #2166 and #2200, surfaced here because CI evaluates the merge commit. Move `_get_invocation_argv` and `_split_argv_at_double_dash` (plus the explanatory block comment on Click's `--` swallowing) into the new `apm_cli/install/argv.py`. `commands/mcp.py` already reached through `commands/install.py` for both helpers, so they were never install-specific; `commands/install.py` re-exports them so the `_get_invocation_argv` test seam keeps working unchanged. install.py: 2111 -> 2080 lines. Ratchet the architecture invariant budget 2150 -> 2100 to match the CI guardrail. Validation: lint mirror green (ruff check + format, pylint R0801, auth-signals), architecture boundary lint clean, file-length guard clean, 2084 tests pass across tests/unit/install/ and tests/integration/test_architecture_authorities.py. Co-authored-by: Copilot App <[email protected]> Copilot-Session: 11dbb707-3685-4a9e-80a4-19c73831232a --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: 11dbb707-3685-4a9e-80a4-19c73831232a
Summary
- git: ...) have long supported askills:array to install a subset of skills from a SKILL_BUNDLE package. The registry-longhand form (- id: owner/repo,registry:,version:) rejected the same field as an unknown key, with no way to narrow which skills get deployed. This aligns registry-longhand with git-longhand by reusing the sameparse_skill_subsetvalidator (non-empty, no path traversal, sorted+deduped).to_apm_yml_entry(), which had no branch forsource == "registry": any registry dependency with a skill/target subset set (e.g. viaapm install --skill ... --save) previously serialized as a malformedgit:entry, and even an alias-only registry entry collapsed to a bare canonical string, silently droppingregistry:/id:/version:.Test plan
tests/unit/test_reference_registry_shorthand.py::TestObjectFormRegistrycovering: parsingskills:, empty-list rejection, path-traversal rejection, round-trip throughto_apm_yml_entry(), and that alias-only registry entries no longer collapse to a plain string.test_reference_registry_shorthand.py,test_skill_subset_persistence.py, and broader dependency/install/lockfile tests).skills: [skill-alpha, skill-beta], confirmed only 2 skills were deployed to.claude/skills/, andapm.lock.yaml'sskill_subsetmatched exactly.