Repository navigation
fix(policy): count exact [email protected] release tags as pinned - #3775
Daniel Meppiel (danielmeppiel) merged 7 commits into
Conversation
require_pinned_constraint now treats an exact package release tag (<name>@X.Y.Z or @<scope>/<name>@X.Y.Z, optional leading v, semver prerelease/build allowed, at most one scope segment) as a declared release, through the existing classifier in policy/_constraint_pinning.py. Dist-tags, ranges, partial versions and multi-segment names stay violations. This changes the #3224 ruling that rejected another package's tags, for this exact-release shape only. Docs state that the check judges declared release intent, not immutability; the lockfile, --frozen and require_hashes pin content. Reworks #3740 with the contributor's classifier approach and tests. Co-authored-by: Mohammed Alkindi <[email protected]> Co-authored-by: Copilot App <[email protected]>
…aints apm-spec-waiver: req-pl-008 is a floor; accepting exact release tags stays conforming and the record excludes spec text changes. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The pinning classifier accepts invalid SemVer as pinned, and the installed-CLI coverage and hash-policy documentation have unresolved gaps.
3 open issues
What changed in this PR
Extends APM’s pinned-constraint policy to recognize package-style release tags, addressing #3731 for npm workspaces and Changesets monorepos without changing semver range resolution.
Changes:
- Recognizes
[email protected]and@scope/[email protected]through the existing classifier and semver parser. - Adds unit and installed-CLI coverage for accepted release tags and rejected non-exact forms.
- Updates policy guidance, removes the manifest example’s tag-immutability claim, and records the fix.
| File | Description |
|---|---|
tests/unit/policy/test_pinned_constraint_declared.py |
Adds accepted and rejected package-release tag cases. |
tests/integration/policy/test_require_pinned_constraint_declared_e2e.py |
Covers installation, frozen replay, audit, and warn/block behavior. |
src/apm_cli/policy/_constraint_pinning.py |
Adds package-release tag recognition to the canonical classifier. |
packages/apm-guide/.apm/skills/apm-usage/governance.md |
Documents the new tag forms in governance guidance. |
docs/src/content/docs/reference/policy-schema.md |
Expands policy syntax, examples, and declared-release guidance. |
docs/src/content/docs/reference/manifest-schema.md |
Corrects the comment describing tag immutability. |
docs/src/content/docs/enterprise/policy-reference.md |
Explains package-release tags and lockfile-related guarantees. |
CHANGELOG.md |
Records the policy fix and contributor credit. |
Review effort: Balanced
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 0 | 0 | Regex + parse_semver two-layer guard is well-bounded; no bypass shapes found, docs honestly state the immutability boundary. |
| Test Coverage Expert | 0 | 1 | 0 | "Done when" names five negatives at installed-CLI tier; e2e covers three (same code paths). Add a/b/[email protected] + [email protected] parametrize entries. |
| Doc Writer | 0 | 3 | 0 | New doc claims match the regex and parse_semver; two sibling pages still say tags do not move, and one pinned-shape list is stale. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 4 follow-ups
- [Test Coverage Expert] Add
("multi-slash-at-tag", "a/b/[email protected]")and("partial-version-at-tag", "[email protected]")to the e2e parametrize list intest_require_pinned_constraint_declared_e2e.py. -- "Done when" names all five negatives at installed-CLI tier; two parametrize entries, zero new fixtures. - [Doc Writer] Remove tag-immutability claims from
consumer/manage-dependencies.md:408andapm-usage/dependencies.md:826. -- Both now contradict the "declared release intent, not immutability" framing this PR introduces. - [Doc Writer] Add
[email protected]/@scope/[email protected]to the pinned-shape list inconsumer/governance-on-the-consumer-ramp.mdand the_constraint_pinning.pymodule docstring. -- Readers starting at the consumer ramp will not discover the new shape; the docstring is the in-code contract. - [Doc Writer] Qualify bare
require_hashesassecurity.integrity.require_hashesand deduplicate the immutability note. -- Accuracy and DRY; lowest signal of the doc findings.
Recommendation
The classifier change is correct and the supply-chain surface is clean. Fold the two missing e2e parametrize entries and the two stale tag-immutability claims before landing to fully satisfy "Done when" and keep docs consistent with the new framing. The require_hashes qualification can land with them or later.
Full per-persona findings
Supply Chain Security Expert
No findings.
Doc Writer
- [recommended] Two sibling pages still say tags are immutable, contradicting the new "a tag can be moved" wording. at
docs/src/content/docs/consumer/manage-dependencies.md:408
consumer/manage-dependencies.md:408says "Branches move; tags and SHAs do not." andapm-usage/dependencies.md:826says Tag "Production -- immutable reference".
Suggested: drop the tag immutability claim; use "release tag; the lockfile pins the commit" to matchmanifest-schema.md. - [recommended] The pinned-shape list in
governance-on-the-consumer-ramp.mdomits[email protected]and@scope/[email protected]. atdocs/src/content/docs/consumer/governance-on-the-consumer-ramp.md:40
Readers starting there will think[email protected]fails; the_constraint_pinning.pymodule docstring pinned list also omits the shape.
Suggested: list the shape or link to the policy schema reference; add one docstring bullet. - [recommended] The immutability note appears three times and
require_hashesis not qualified. atdocs/src/content/docs/reference/policy-schema.md:150
State a concept once and reference it elsewhere; the key issecurity.integrity.require_hashes. CHANGELOG entry format is correct.
Suggested: qualify the key; keep the full sentence in policy-schema.md and shorten policy-reference.md to a pointer.
Test Coverage Expert
- [recommended] E2e
test_non_exact_package_release_tags_stay_violationsomitsa/b/[email protected]and[email protected], required by the scope record at installed-CLI tier. attests/integration/policy/test_require_pinned_constraint_declared_e2e.py:393
Unit covers all five negatives (52 passed). E2e covers three of five under both enforcement modes; grep found no e2e hit for the other two.
Suggested: add two parametrize entries.
Proof (missing at):tests/integration/policy/test_require_pinned_constraint_declared_e2e.py::test_non_exact_package_release_tags_stay_violations[multi-slash-at-tag-block]-- proves: multi-slash refs and partial versions stay violations at installed-CLI level [governed-by-policy]
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-review-worker. This comment is AI-generated and may contain errors.
The #3731 scope record requires installed-CLI tests showing that multi-segment names and partial versions after @ stay violations under warn and block; only unit tests covered them. Addresses panel follow-up FU-1 (test-coverage-expert). Co-authored-by: Copilot <[email protected]>
Sibling pages still called tags immutable or listed pinned shapes without exact [email protected] release tags, contradicting the new policy docs. Qualifies require_hashes as security.integrity.require_hashes and trims the repeated immutability note. Addresses panel follow-ups FU-2, FU-3 and FU-4 (doc-writer). Co-authored-by: Copilot <[email protected]>
Resolves the CHANGELOG [Unreleased] conflict with #3771: keep both entries, Changed before Fixed per Keep a Changelog. Co-authored-by: Copilot <[email protected]>
The motivating ref shadcn/ui#[email protected] names the published package, not the directory APM derives the name from. The installed-CLI cases only used pkg-a tags on pkg-a, so this adds [email protected] on the pkg-a subdirectory through install, --frozen and audit. Addresses Copilot inline on tests/integration/policy/ test_require_pinned_constraint_declared_e2e.py:295. Co-authored-by: Copilot <[email protected]>
require_hashes only requires a content hash on each locked entry; an update can still record a moved tag's new commit. Replaying the lockfile with --frozen is what installs the locked commit. Addresses Copilot inline on docs/src/content/docs/enterprise/policy-reference.md. Co-authored-by: Copilot <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Supply Chain Security Expert | 0 | 0 | 0 | Delta docs correctly separate --frozen replay from the require_hashes presence check; C1 deferral is sound -- no new attack surface from shared semver leniency. |
| Test Coverage Expert | 0 | 0 | 0 | FU-1 and Copilot C3 resolved: a/b/[email protected] and [email protected] negatives plus the [email protected] cross-name positive run at installed-CLI tier; 24 e2e passed at head. |
| Doc Writer | 0 | 0 | 0 | FU-2, FU-3, FU-4 and Copilot C2 resolved accurately; the fold introduced no new inaccuracy and the require_hashes link target exists. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [Supply Chain Security Expert] File a post-merge issue to tighten
parse_semverinmarketplace/semver.py: reject leading-zero segments (01.2.3,1.2.3-01) and use[0-9]instead of\dacross the shared parser and thev-tag regex. -- 45 call sites share the leniency. It adds no new attack surface here, but a malformed version string passing policy is a latent false positive that should be closed before the parser gains more consumers.
Recommendation
All prior follow-ups and the foldable Copilot items are resolved at head, with strong test and mutation evidence. Per the maintainer's sequencing, the PR lands after v0.36.1 is tagged. Track the parse_semver tightening (Copilot C1) as a separate issue for a future milestone.
Folded in this run
- (panel FU-1, test-coverage-expert) Installed-CLI negatives
a/b/[email protected]and[email protected]under warn and block -- resolved in cc909cc. - (panel FU-2, doc-writer) Dropped tag-immutability claims in
consumer/manage-dependencies.mdandapm-usage/dependencies.md-- resolved in 5a399d1. - (panel FU-3, doc-writer) New shape listed in
consumer/governance-on-the-consumer-ramp.mdand the_constraint_pinning.pymodule docstring -- resolved in 5a399d1. - (panel FU-4, doc-writer) Qualified
security.integrity.require_hashesand trimmed the repeated immutability note -- resolved in 5a399d1. - (Copilot C3) Installed-CLI case for a tag that names another package (
[email protected]on thepkg-asubdirectory) through install,--frozenandaudit --ci-- resolved in 8dbc3d8. - (Copilot C2) Separated
--frozenreplay fromrequire_hasheshash presence inpolicy-schema.mdandapm-usage/governance.md-- resolved in db84a25. - (merge) Merged
main. The CHANGELOG[Unreleased]conflict with ci(release): shard Linux integration, slim macOS, promote verified tags #3771 is resolved (Changed before Fixed) -- resolved in 07ed429.
Copilot signals reviewed
src/apm_cli/policy/_constraint_pinning.py:184-- LEGIT:parse_semveraccepts01.2.3,1.2.3-01and Unicode digits; deferred, see below.docs/src/content/docs/enterprise/policy-reference.md-- LEGIT:require_hashesis hash presence, not frozen replay (resolved in db84a25).tests/integration/policy/test_require_pinned_constraint_declared_e2e.py:295-- LEGIT: installed-CLI cases did not cover a tag naming a different package (resolved in 8dbc3d8).
Deferred (out-of-scope follow-ups)
- (Copilot C1) Tighten the shared
parse_semvergrammar (leading zeros, Unicode digits) -- scope boundary:marketplace/semver.pyhas 45 call sites, including git-semver and marketplace resolution; changing it alters resolver semantics, which the require_pinned_constraint rejects [email protected] release tags as bare branches #3731 scope record excludes, and the existingv-tag regex shares the same leniency; suggested follow-up: a separate issue for strict SemVer parsing across the parser and thev-tag regex.
Regression-trap evidence (mutation-break gate)
test_non_exact_package_release_tags_stay_violations[multi-slash-at-tag-a/b/[email protected]{block,warn}]-- widened the single scope-segment prefix in_PACKAGE_AT_TAG_RE; both FAILED as expected; guard restored.test_non_exact_package_release_tags_stay_violations[[email protected]{block,warn}]-- removed theparse_semvercheck in_is_package_at_release_tag; both FAILED as expected; guard restored.test_package_qualified_literal_tags_install_and_audit[[email protected]]-- bound the tag name topkg-a; FAILED as expected; guard restored.
Lint contract
At head:
uvx [email protected] checkandformat --checkover src/, tests/ and the CI script paths: silent.- pylint R0801: 10.00/10.
bash scripts/lint-auth-signals.sh: clean.scripts/lint_architecture_boundaries.py --root .andbash scripts/lint-architecture-boundaries.sh: exit 0.
CI
gh pr checks 3775: 23 pass, 3 skipping on db84a25 (after 0 CI fix iterations). One merge of main was needed because the PR was DIRTY (CHANGELOG).
Local exact-head functional evidence:
- unit policy tests: 100 passed, 1 xfailed.
APM_E2E_TESTS=1test_require_pinned_constraint_declared_e2e.py: 24 passed.
Mergeability status
| PR | head SHA | CEO stance | iters | folds | defers | Copilot rounds | CI | mergeable | mergeStateStatus | notes |
|---|---|---|---|---|---|---|---|---|---|---|
| #3775 | db84a25 |
ship_with_followups | 2 | 7 | 1 | 2 | green | MERGEABLE | BLOCKED | pending required review; lands after v0.36.1 is tagged |
Convergence
2 outer iterations; 2 Copilot rounds. Final panel stance: ship_with_followups. Ready for maintainer review.
Full per-persona findings
Supply Chain Security Expert
No findings.
Doc Writer
No findings.
Test Coverage Expert
No findings.
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.
The #3775 and #3783 entries landed inside the [0.36.1] block when main was merged; they ship in 0.37.0. Move them, with #3777, under [Unreleased]. Co-authored-by: Copilot App <[email protected]>
The #3775 and #3783 entries landed inside the [0.36.1] block when main was merged; they ship in 0.37.0. Move them, with #3777, under [Unreleased]. Co-authored-by: Copilot App <[email protected]>
…d routes (#3777) * docs(registry-proxy): correct the range-resolution premise and name the supported routes (#3756) Registry proxies such as Artifactory do have listing APIs; APM simply fetches exact versions only through a proxy and does not call vendor listing APIs. registry-proxy.md now says so and names the two supported routes under PROXY_REGISTRY_ONLY: exact pins plus lockfile replay, or a server implementing the APM Registry HTTP API (GET /v1/packages/{owner}/{repo}/versions). The RegistryOnlySemverError hint names the same two routes; apm view versions and apm outdated drop the same false claim. No resolution behavior changes. apm-spec-waiver: message and documentation wording only; no resolver behavior change. Co-authored-by: Copilot App <[email protected]> * docs(changelog): note the registry-only range guidance (#3777) Co-authored-by: Copilot App <[email protected]> * fix(deps): keep the unset escape hatch in the registry-only range hint The reworded RegistryOnlySemverError hint dropped "unset PROXY_REGISTRY_ONLY", which the installed-CLI contract test_install_range_fails_with_remedy_without_contacting_source_host asserts. Restore it as the third option, tighten the hint so it no longer states the premise twice, and reflow the 111-char docstring line. A unit assertion now traps the escape hatch (mutation-break verified: removing the clause fails the unit and integration tests). Addresses panel follow-up 3 (doc-writer, hint verbosity) on #3777. Co-authored-by: Copilot App <[email protected]> * docs(registry-proxy): drop the remaining only-upstream-can-list claims registry-proxy.md still said a version listing is something only the upstream host can provide, contradicting the APM Registry HTTP API route named a few lines below. The apm-guide authentication resource still said the proxy has no tag listing. Both now state that APM does not list through the proxy by design and name the supported routes; the troubleshooting row matches the error hint. Addresses panel follow-ups 1 and 2 (doc-writer) on #3777. Co-authored-by: Copilot App <[email protected]> * docs(changelog): file 0.37 entries under [Unreleased] The #3775 and #3783 entries landed inside the [0.36.1] block when main was merged; they ship in 0.37.0. Move them, with #3777, under [Unreleased]. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>


Description
require_pinned_constraintrejected npm workspaces / Changesets release tags such asshadcn/ui#[email protected]andupstash/context7/skills/context7-mcp#@upstash/[email protected]as bare branches, so users of those monorepos could not satisfy the policy except with a full SHA.The single classifier owner,
policy/_constraint_pinning.py::classify_unbounded_reason, now treats an exact package release tag (<name>@X.Y.Zor@<scope>/<name>@X.Y.Z; optional leadingv; semver prerelease/build allowed; at most one scope segment) as a declared release. The version part is validated by the existingparse_semverowner. The name is not bound to the dependency's own name, because these tags name the published package (shadcn), not the directory APM derives its name from (ui). Dist-tags (release@next), ranges (name@^1.2.0), partial versions ([email protected]) and multi-segment names (feature/[email protected],a/b/[email protected]) stay violations under warn and block.Ruling change (approved in the scope record): the #3224 ruling rejected "another package's tags"; this relaxes it for the exact-release
@shape only, which is as bounded asv1.2.3. The old negative test case[email protected]is now a positive case.Docs now state that the check judges declared release intent, not immutability (a tag can move; the lockfile,
--frozenandrequire_hashespin content), and the manifest reference no longer calls a tag ref "immutable".Reworks contributor PR #3740 by Mohammed Alkindi (@MohammedAlkindi) (co-authored): same classifier step, plus the tighter shape (its regex accepted
feature/[email protected]), installed-CLI tests and docs.Issue and approved scope
Issue: Fixes #3731
Human scope-approval comment: #3731 (comment)
Does this PR complete the issue, or what remains? Completes it. Selecting
<name>@tags for semver ranges in the git-semver resolver is out of scope per the record.Type of change
Testing
Validation evidence (local, this head):
.venv/bin/python -m pytest tests/unit/policy/test_pinned_constraint_declared.py tests/unit/policy/test_pinned_constraint.py -p no:xdist -q: 100 passed, 1 xfailed. Without the src change: 8 failed.APM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/python -m pytest tests/integration/policy/test_require_pinned_constraint_declared_e2e.py -p no:xdist -q -k "literal_tags_install_and_audit or non_exact": 10 passed (install,--frozenandaudit --ciagree for[email protected]and@acme/[email protected];release@next,feature/[email protected],pkg-a@^1.2.0stay violations under block and warn). Without the src change, the two new positive cases fail.uvx [email protected] checkandformat --check(CI paths): clean. pylint R0801: 10.00/10.bash scripts/lint-auth-signals.sh: clean.scripts/lint_architecture_boundaries.py --root .: exit 0.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated