Skip to content

fix(policy): count exact [email protected] release tags as pinned - #3775

Merged
Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
danielmeppiel-3731-package-release-tags
Nov 18, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 7 commits into
mainfrom
danielmeppiel-3731-package-release-tags

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

require_pinned_constraint rejected npm workspaces / Changesets release tags such as shadcn/ui#[email protected] and upstash/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.Z or @<scope>/<name>@X.Y.Z; optional leading v; semver prerelease/build allowed; at most one scope segment) as a declared release. The version part is validated by the existing parse_semver owner. 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 as v1.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, --frozen and require_hashes pin 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

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

Testing

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

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, --frozen and audit --ci agree for [email protected] and @acme/[email protected]; release@next, feature/[email protected], pkg-a@^1.2.0 stay violations under block and warn). Without the src change, the two new positive cases fail.
  • uvx [email protected] check and format --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)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- req-pl-008 sets a floor for pinned constraints; recognising one more exact-release tag shape stays conforming. No spec text change (out of scope per the record).

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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 17, 2026
Copilot AI balanced review requested due to automatic review settings November 17, 2026 15:46
…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]>

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 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

@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Treats [email protected] release tags as pinned under require_pinned_constraint, closing a false-positive that blocked real-world monorepo dependencies like [email protected].

panel-mode=lean; personas=supply-chain-security-expert,test-coverage-expert,doc-writer,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three panelists converge: the classifier change is well-bounded (regex + parse_semver two-layer guard, no bypass shapes found), the docs honestly reframe the immutability boundary, and the CHANGELOG entry is correct. Supply-chain-security-expert returned zero findings, confirming the relaxation does not widen the attack surface beyond declared release intent. The remaining work is completeness, not correctness.

The test-coverage-expert identified two missing installed-CLI parametrize entries (a/b/[email protected], [email protected]) that the scope record's "Done when" names explicitly. Unit tests cover all five negatives, so the classifier logic is proven, but the governed-by-policy surface wants the integration-tier guardrail too. This ranks above the doc findings despite sharing the same severity.

The doc-writer surfaced three stale-claim sites: two pages still assert tag immutability (consumer/manage-dependencies.md, apm-usage/dependencies.md), and consumer/governance-on-the-consumer-ramp.md omits the new pinned shape. These contradict the clarification this PR introduces. The require_hashes qualification and the repeated immutability note are polish.

Aligned with: Governed by policy -- extends the classifier to recognize a real-world pinned shape; Secure by default -- the regex + parse_semver guard introduces no bypass, and immutability stays with the lockfile and require_hashes as documented; OSS community driven -- reworks contributor PR #3740 by Mohammed Alkindi (@MohammedAlkindi) with co-author credit and closes community-filed #3731; Pragmatic as npm -- removes a false positive that forced SHA workarounds for shadcn/ui and @upstash/context7-mcp style refs.

Panel summary

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

  1. [Test Coverage Expert] Add ("multi-slash-at-tag", "a/b/[email protected]") and ("partial-version-at-tag", "[email protected]") to the e2e parametrize list in test_require_pinned_constraint_declared_e2e.py. -- "Done when" names all five negatives at installed-CLI tier; two parametrize entries, zero new fixtures.
  2. [Doc Writer] Remove tag-immutability claims from consumer/manage-dependencies.md:408 and apm-usage/dependencies.md:826. -- Both now contradict the "declared release intent, not immutability" framing this PR introduces.
  3. [Doc Writer] Add [email protected] / @scope/[email protected] to the pinned-shape list in consumer/governance-on-the-consumer-ramp.md and the _constraint_pinning.py module docstring. -- Readers starting at the consumer ramp will not discover the new shape; the docstring is the in-code contract.
  4. [Doc Writer] Qualify bare require_hashes as security.integrity.require_hashes and 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:408 says "Branches move; tags and SHAs do not." and apm-usage/dependencies.md:826 says Tag "Production -- immutable reference".
    Suggested: drop the tag immutability claim; use "release tag; the lockfile pins the commit" to match manifest-schema.md.
  • [recommended] The pinned-shape list in governance-on-the-consumer-ramp.md omits [email protected] and @scope/[email protected]. at docs/src/content/docs/consumer/governance-on-the-consumer-ramp.md:40
    Readers starting there will think [email protected] fails; the _constraint_pinning.py module 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_hashes is not qualified. at docs/src/content/docs/reference/policy-schema.md:150
    State a concept once and reference it elsewhere; the key is security.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_violations omits a/b/[email protected] and [email protected], required by the scope record at installed-CLI tier. at tests/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]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Delta clears all four prior follow-ups and two Copilot round-2 folds; one deferred semver-leniency item remains as a post-merge issue.

panel-mode=delta; personas=supply-chain-security-expert,test-coverage-expert,doc-writer,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

All three delta panelists agree this can ship and raise no new findings. Since the last advisory (head 7b56d83), five commits resolved every open follow-up: FU-1 (installed-CLI negatives for a/b/[email protected] and [email protected]), FU-2/FU-3/FU-4 (pinned-shape lists, tag-mutability wording, and the require_hashes qualification), plus Copilot C2 (separating --frozen replay from require_hashes hash presence) and C3 (a cross-name [email protected] tag installed on the pkg-a subdirectory). The mutation evidence at head is load-bearing: widening the scope-segment regex, dropping parse_semver, or binding the name to pkg-a each makes the matching installed-CLI test fail.

The only remaining item is the deferred Copilot C1: parse_semver in marketplace/semver.py accepts leading-zero segments (01.2.3) and Unicode digits via \d, so [email protected] would count as pinned. The existing v-tag regex has the same \d leniency, so this PR adds no new attack surface. Tightening the shared parser touches 45 call sites, including git-semver and marketplace resolution, which is a resolver-semantics change outside the #3731 scope. It is tracked as a separate post-merge follow-up.

Aligned with: Governed by policy -- exact [email protected] release tags now count as pinned, closing a gap where policy rejected valid declared releases; Secure by default -- no new attack surface, and the pre-existing semver leniency is inherited, not widened, and tracked; OSS community driven -- reworks contributor PR #3740 by Mohammed Alkindi (@MohammedAlkindi) with co-authorship preserved, and every Copilot item is either folded or explicitly deferred with a reason.

Panel summary

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

  1. [Supply Chain Security Expert] File a post-merge issue to tighten parse_semver in marketplace/semver.py: reject leading-zero segments (01.2.3, 1.2.3-01) and use [0-9] instead of \d across the shared parser and the v-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.md and apm-usage/dependencies.md -- resolved in 5a399d1.
  • (panel FU-3, doc-writer) New shape listed in consumer/governance-on-the-consumer-ramp.md and the _constraint_pinning.py module docstring -- resolved in 5a399d1.
  • (panel FU-4, doc-writer) Qualified security.integrity.require_hashes and trimmed the repeated immutability note -- resolved in 5a399d1.
  • (Copilot C3) Installed-CLI case for a tag that names another package ([email protected] on the pkg-a subdirectory) through install, --frozen and audit --ci -- resolved in 8dbc3d8.
  • (Copilot C2) Separated --frozen replay from require_hashes hash presence in policy-schema.md and apm-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_semver accepts 01.2.3, 1.2.3-01 and Unicode digits; deferred, see below.
  • docs/src/content/docs/enterprise/policy-reference.md -- LEGIT: require_hashes is 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_semver grammar (leading zeros, Unicode digits) -- scope boundary: marketplace/semver.py has 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 existing v-tag regex shares the same leniency; suggested follow-up: a separate issue for strict SemVer parsing across the parser and the v-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 the parse_semver check 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 to pkg-a; FAILED as expected; guard restored.

Lint contract

At head:

  • uvx [email protected] check and format --check over 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 . and bash 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=1 test_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.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit da21d5b into main Nov 18, 2026
26 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-3731-package-release-tags branch November 18, 2026 06:36
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 18, 2026
…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]>
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.

require_pinned_constraint rejects [email protected] release tags as bare branches

2 participants