Skip to content

fix(policy): judge the declared constraint, accept package release tags - #3381

Closed
Kaustubh Arora (Kaustubh1235) wants to merge 9 commits into
microsoft:mainfrom
Kaustubh1235:fix/3224-pinned-constraint-declared
Closed

Kaustubh Arora (Kaustubh1235) wants to merge 9 commits into
microsoft:mainfrom
Kaustubh1235:fix/3224-pinned-constraint-declared

Conversation

@Kaustubh1235

@Kaustubh1235 Kaustubh Arora (Kaustubh1235) commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

require_pinned_constraint now judges the constraint the author declared, and recognises a package's own release tags.

Two things were wrong. The resolve phase rewrites a direct dependency's in-memory reference to the tag its semver range selected, and the install gate runs after that, so pkg-a#^1.0.0 was judged as pkg-a-v1.1.0. The literal-tag classifier also only knew v{version}, while the resolver selects from v{version}, {name}--v{version} and {name}-v{version} and the dependency guide tells people to pin the package-qualified forms.

The resolve phase now snapshots the manifest-declared refs of the direct dependencies before any rewrite (ctx.declared_direct_refs), and policy_gate and policy_target_check pass that map to run_dependency_policy_checks, which classifies it in place of the rewritten reference. Nothing else sees a different reference: download, drift and lockfile work keep the resolved tag, and preflight and audit already held the manifest view. The classifier accepts {name}-v{version} and {name}--v{version} for the dependency's own package name only, reusing the resolver's DEFAULT_TAG_PATTERNS and build_tag_regex, so pkg-b-v1.1.0, pkg-a-v1.1, release-pkg-a-v1.1.0 and pkg-a_v1.1.0 remain bare branches. The package name follows the resolver's rule (final virtual-path segment, else repository name), with a unit test asserting parity against _git_semver_package_name.

Docs updated where the rule is described (policy-reference.md, policy-schema.md, governance-on-the-consumer-ramp.md, manage-dependencies.md, and the REQUIRE_PINNED_CONSTRAINT_HELP text), including correcting two places that said transitive deps are classified; the check has been direct-only since #1494.

Issue and approved scope

Issue: #3224
Human scope-approval comment: #3224 (comment)

This PR completes the accepted issue scope. It does not request merge approval.

Type of change

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

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality

Unit (tests/unit/policy/test_pinned_constraint_declared.py, 13 tests): package-qualified forms for subdirectory and repository deps, prerelease and build suffixes, other-package and near-miss negatives, name parity with the resolver, declared_ref precedence (a declared main stays a violation after resolution replaced it with a tag; a declared >=1.0.0 stays open-upper when the reference is a SHA), and _check_pinned_constraints with and without declared_refs.

Gate wiring (TestDeclaredRefsWiring in test_require_pinned_constraint_e2e.py): pinned to the gate's own call. Verified it fails when either the gate stops forwarding declared_refs or the resolve phase stops recording them.

Real binary (tests/integration/policy/test_require_pinned_constraint_declared_e2e.py, e2e + requires_apm_binary): one local bare monorepo with a subdirectory package tagged pkg-a-v1.1.0 / pkg-a--v1.1.0 and the root tagged v1.0.0 only, so ^1.0.0 resolves to the package-qualified tag the old gate rejected. Policy reaches install the way the Govern contract does (ADO-shaped origin, leaf extending the strict policy at the cache-key path, policy status warm), and every governed command asserts the (cached diagnostic. Covers fresh install, frozen replay, repeat install, update --yes and audit for the range; the two literal forms; the repository-level range; and main, pkg-b-v1.1.0, >=1.0.0 blocked at install and failed by audit with the same hints. Audits are judged by the dependency-pinned-constraint check in the JSON, not the exit code.

Local validation: tests/unit/policy tests/unit/install tests/integration/policy tests/integration/test_policy_pinned_constraint_e2e.py: 4360 passed, 7 skipped, 1 xfailed. tests/spec_conformance/test_policy_reqs.py passes. The real-binary contract passed on three consecutive runs. Ruff check and format clean on every changed file.

Observed while writing the contract, out of scope here and identical on unmodified main (same scenario, same binary build, byte-for-byte the same lock and deployed state at every step): on this package shape, install --frozen right after a fresh install redeploys the 1.0.0 skill while the lock still records pkg-a-v1.1.0, and a plain repeat install drops constraint and resolved_tag and writes the raw range into resolved_ref; update --yes restores them. I'll file that separately with the probe script. The contract therefore asserts the policy verdict on those steps and not what they record.

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json}
  • N/A -- this PR does not change OpenAPM-observable behaviour.

req-pl-007 flags "a bare branch name"; a dependency's own release tag in a layout the resolver selects from is a tag, not a branch, so recognising it is a classification repair under the existing rule. req-pl-008 enumerates forms that MUST count as pinned and is unchanged. If the maintainers want req-pl-008 to list the package-qualified layouts explicitly, that would be a separate spec proposal under normal review.

Closes #3224

require_pinned_constraint judged the wrong string in two ways.

The resolve phase rewrites a direct dependency's in-memory reference to
the tag a semver range selected, and the install gate runs after that,
so a bounded range such as `pkg-a#^1.0.0` was classified as whatever tag
it resolved to. The resolve phase now records the manifest-declared refs
of the direct dependencies before any rewrite, and the gate and the
post-targets re-check classify those. The resolved reference is left in
place for download, drift and lockfile work; preflight and audit already
hold the manifest view and are unchanged.

The literal-tag classifier only knew the `v{version}` layout, while the
resolver selects from `v{version}`, `{name}--v{version}` and
`{name}-v{version}` and the dependency guide recommends pinning the
package-qualified forms. The classifier now accepts those layouts for
the dependency's own package name, using the resolver's tag patterns and
regex builder, so `pkg-a-v1.1.0` on a `pkg-a` dependency is pinned while
`pkg-b-v1.1.0`, `pkg-a-v1.1` or `release-pkg-a-v1.1.0` stay bare
branches. Missing refs, moving branches, wildcards and open-upper ranges
are classified as before, and a selected tag or SHA never launders an
unbounded declaration.

Refs microsoft#3224.

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

Duplicate dependency identities can overwrite declared constraints and let a branch pass the pinned-constraint gate; package-name derivation also needs one shared owner.

2 open issues
What changed in this PR

This PR addresses #3224 by making pinned-constraint policy checks evaluate declared references rather than resolved tags, and recognize package-qualified release tags.

Changes:

  • Capture direct dependency declarations and forward them to install policy checks.
  • Accept release tags matching the dependency's own package name.
  • Add regression coverage and clarify policy behavior in documentation.
File Description
tests/​unit/​policy/​test_pinned_constraint_declared.py Tests declared-ref precedence and package-qualified tags.
tests/​integration/​policy/​test_require_pinned_constraint_e2e.py Checks declaration forwarding to the policy gate.
tests/​integration/​policy/​test_require_pinned_constraint_declared_e2e.py Adds real-binary install, replay, update, and audit coverage.
src/​apm_cli/​policy/​policy_checks.py Passes declared refs into classification and diagnostics.
src/​apm_cli/​policy/​_help_text.py Clarifies accepted tags and declared-constraint semantics.
src/​apm_cli/​policy/​_constraint_pinning.py Recognizes package-qualified tags and declared-ref overrides.
src/​apm_cli/​install/​phases/​resolve.py Snapshots direct refs before resolution rewrites them.
src/​apm_cli/​install/​phases/​policy_target_check.py Forwards declarations during target checks.
src/​apm_cli/​install/​phases/​policy_gate.py Forwards declarations to the install gate.
src/​apm_cli/​install/​context.py Stores the declared-reference snapshot.
docs/​src/​content/​docs/​reference/​policy-schema.md Updates policy semantics and examples.
docs/​src/​content/​docs/​enterprise/​policy-reference.md Clarifies direct-only evaluation and accepted tags.
docs/​src/​content/​docs/​consumer/​manage-dependencies.md Explains policy acceptance of ranges and package tags.
docs/​src/​content/​docs/​consumer/​governance-on-the-consumer-ramp.md Clarifies that policy judges direct declarations.

Review effort: Balanced

Comment thread src/apm_cli/install/phases/resolve.py Resolved
@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

Thank you for contributing this policy repair. Issue #3224 has an explicit maintainer-approved scope, and this PR appears to implement it. The requested reviewers include Daniel Meppiel (@danielmeppiel) and Sergio Sisternes (@sergio-sisternes-epam). The license/cla check is currently queued. This is a recommendation for human review only, not merge approval.


Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added area/audit-policy apm-policy.yml schema, custom_checks, install-time enforcement. triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented. status/accepted Human scope approval; verify the issue's approval record and review contact before work. labels Nov 3, 2026
@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

Hi Kaustubh Arora (@Kaustubh1235), thanks for this fix for #3224. The scope has been accepted, so the next step is on the Contributor License Agreement: CI cannot run on this PR until the CLA is signed. Please follow the instructions in the CLA comment above (reply with @microsoft-github-policy-service agree, adding company="..." if you are contributing on behalf of an employer). Once that is done the checks will start and we can continue with the review.


Generated by autopilot-pr-ready-worker. This comment is AI-generated and may contain errors.

Brings the PR up to current main (includes microsoft#3571, which touched install/phases/resolve.py) before folding review follow-ups.

Co-authored-by: Copilot App <[email protected]>
The declared-ref map was keyed by unique key, which excludes the ref, so a package declared under both dependencies and devDependencies kept only the last declaration and a bounded one could cover a branch; a missing ref was dropped and fell back to the rewritten reference. collect_declared_refs now keeps every declaration (None included) and the check classifies each one. The snapshot moves to InstallContext construction in the pipeline, before any phase can rewrite a reference, which also keeps install/phases/resolve.py within its LOC budget after merging main.

The policy no longer re-derives the git-tag package name: _is_package_literal_tag calls ref_reuse.git_semver_package_name (the git-semver owner, now public) and requires the captured version to parse like the resolver does. A static guard in transport-platform-git-semver-preflight and a mutation test keep the policy on that owner.

Addresses Copilot inline on src/apm_cli/install/phases/resolve.py:421 (P1) and src/apm_cli/policy/_constraint_pinning.py:139 (P2), and the matching panel follow-ups; also asserts the policy_target_check wiring and drops a non-ASCII ellipsis from a docstring.

Co-authored-by: Copilot App <[email protected]>
On current main a no-op apm update returns before the install pipeline, so the contract's update step evaluated no policy. The contract now publishes pkg-a-v1.2.0 and asserts update selects it through the gate while the declared range stays the judged constraint. Adds the object-form declaration and the dependencies/devDependencies collision negative control from the approved scope, and injects apm_binary_path per test instead of through a module fixture (architecture lint AC9).

Co-authored-by: Copilot App <[email protected]>
The approved scope requires packaged usage guidance to describe the bounded-choice rule; the apm-guide governance remediation still listed only vX.Y.Z tags. Adds the Unreleased Fixed entry crediting the author and trims a duplicated paragraph in policy-reference (addresses doc-writer panel follow-ups).

Co-authored-by: Copilot App <[email protected]>
Picks up microsoft#3598 (preflight gate revert) and the other changes on main since the previous merge.

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

apm audit evaluates the dependencies block only (unchanged on main), so the entry no longer implies audit also checks devDependencies. Addresses doc-writer delta-panel follow-up.

Co-authored-by: Copilot App <[email protected]>
Resolves the conflicting state after microsoft#2506 and microsoft#3534 landed on main.

Co-authored-by: Copilot App <[email protected]>
Keeps the PR current with main before landing.

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

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_with_followups

Repairs require_pinned_constraint so it judges the declared constraint, recognises a package's own release tags, and no longer lets a sibling declaration hide an unbounded ref.

panel-mode=delta; personas=python-architect,test-coverage-expert,doc-writer,performance-expert,supply-chain-security-expert (adhoc: the PR changes what an org-policy gate accepts),apm-ceo

cc Kaustubh Arora (@Kaustubh1235) Daniel Meppiel (@danielmeppiel) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

This run reviewed the PR twice: a full pass on the original head, then a delta pass after the in-scope follow-ups were folded onto the author's branch. This comment covers both.

All five panelists converged to zero required findings on the delta head. The iteration-1 surface was substantive: python-architect and supply-chain-security-expert independently identified a data-flow bypass where get_unique_key() silently overwrote declared refs when deps and devDeps shared an identity, letting a bounded tag launder an unbounded branch through the policy check. The fix (collect every declaration per unique key, classify each, deduplicate post-classification) was folded with a mutation-break regression trap and an owner-routing static guard. Both Copilot inline comments (P1 duplicate-key overwrite, P2 shared package-name derivation) were confirmed as legitimate and folded. Test-coverage-expert confirmed the gaps are closed, and 9/9 real-binary e2e tests pass. Doc-writer's final delta finding (CHANGELOG implying audit covers devDependencies) was folded with scoped wording.

The two deferrals are legitimate scope exclusions. Extending apm audit to evaluate devDependencies is a pre-existing coverage gap on main; the approved scope for #3224 targets declared-vs-resolved consistency, not expanding the audit dependency set. The third package-name derivation in deps/revision_pins.package_name (update/outdated) is pre-existing duplication on main. Neither leaves a regression path in the code this PR touches.

A policy check that evaluates the wrong input either rejects valid bounded choices (the reported bug) or, once corrected naively, risks accepting moving refs; this PR does neither. The CLA is unsigned; Kaustubh Arora (@Kaustubh1235) must sign it before landing. CI is green apart from the pending license/cla check.

Aligned with: governed by policy (the check judges what the developer wrote, not the resolver's output); secure by default (declaration order can no longer launder an unbounded ref); OSS community driven (community fix for a maintainer-accepted issue, with unit, integration and real-binary tests).

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 Prior findings resolved: canonical owner routed, dual guardrail shipped, every declaration kept including None.
Test Coverage Expert 0 0 0 Duplicate-declaration trap (unit + e2e), target-check wiring and e2e verified at head; no new gaps.
Doc Writer 0 1 0 Prior findings resolved; CHANGELOG audit/devDependencies wording folded in d186200.
Performance Expert 0 0 0 O(N) collector, K~1-2 refs per key, lazy imports deferred; no hot-path regression.
Supply Chain Security Expert 0 0 0 Laundering and .git-suffix findings resolved with tests; no remaining bypass path found.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 3 follow-ups

  1. [Supply Chain Security Expert] Extend apm audit to evaluate devDependencies against pinned-constraint policy. -- Pre-existing gap on main: audit reads only dependencies, so an unbounded devDependencies ref passes audit while install rejects it.
  2. [Python Architect] Consolidate deps/revision_pins.package_name with the canonical ref_reuse.git_semver_package_name. -- Install and policy now route through the owner; update/outdated keeps its own derivation with different .git handling.
  3. [Performance Expert] Evaluate whether the DEFAULT_TAG_PATTERNS import can avoid the full resolver graph on a cold audit. -- One-time ~10-30ms cost; declined here to keep the resolver's constant as the single source of truth.

Recommendation

The PR delivers the full approved scope for #3224 with zero open required findings across all five panelists. The two deferrals are pre-existing on main and outside scope. Recommended next action: Kaustubh Arora (@Kaustubh1235) signs the CLA, and Daniel Meppiel (@danielmeppiel) / Sergio Sisternes (@sergio-sisternes-epam) complete their CODEOWNERS review. The audit devDependencies follow-up is the highest-signal item to track after merge.

Folded in this run

  • (copilot) Keep every direct declaration when dependency identities collide; a missing ref stays NO_REF -- resolved in cbb15de.
  • (copilot) Take the git-tag package name from the resolver owner ref_reuse.git_semver_package_name, guarded by a static check -- resolved in cbb15de.
  • (panel) Move the declared-ref snapshot to InstallContext construction (keeps install/phases/resolve.py within its LOC budget after merging main) -- resolved in cbb15de.
  • (panel) Regression traps for duplicate declarations, declared None, owner routing, and policy_target_check wiring -- resolved in cbb15de.
  • (panel) Real-binary contract: apm update now selects a newly published pkg-a-v1.2.0 through the policy check (a no-op update on current main returns before the pipeline), plus object-form and dependencies/devDependencies collision controls -- resolved in 395767e.
  • (panel) Packaged apm-guide governance guidance, CHANGELOG entry, trimmed policy-reference paragraph -- resolved in 7816250.
  • (panel) Scope the CHANGELOG audit claim to dependencies -- resolved in d186200.
  • PR body now ends with Closes #3224 (append-only); both Copilot threads answered and resolved; branch merged with current main.

Copilot signals reviewed

  • src/apm_cli/install/phases/resolve.py:421 -- LEGIT: last-wins dict keyed by a ref-less unique key let a bounded devDependencies ref cover a branch (resolved in cbb15de).
  • src/apm_cli/policy/_constraint_pinning.py:139 -- LEGIT: package-name rule duplicated the git-semver owner with different .git handling (resolved in cbb15de).

Deferred (out-of-scope follow-ups)

  • (panel) Extend apm audit to evaluate devDependencies -- scope boundary: changes which dependency set audit evaluates; pre-existing on main, outside the declared-vs-resolved repair.
  • (panel) Consolidate deps/revision_pins.package_name -- scope boundary: pre-existing split on main in update/outdated, which this PR does not touch.
  • (panel) Lighter import for DEFAULT_TAG_PATTERNS -- scope boundary: import-graph refactor of the resolver constants; current cost is one-time and noise-level.

Regression-trap evidence (mutation-break gate)

  • tests/unit/policy/test_pinned_constraint_declared.py::test_bounded_declaration_does_not_cover_an_unbounded_one -- deleted the per-key accumulation in collect_declared_refs; test FAILED as expected; guard restored.
  • tests/unit/policy/test_pinned_constraint_declared.py::test_declared_missing_ref_stays_no_ref_after_a_tag_was_selected -- deleted the declared-None sentinel; test FAILED as expected; guard restored.
  • tests/unit/policy/test_pinned_constraint_declared.py::test_tag_name_comes_from_the_resolver_owner -- replaced the owner call with a local derivation; test FAILED as expected; guard restored.
  • tests/integration/policy/test_require_pinned_constraint_e2e.py::TestDeclaredRefsWiring -- deleted the pipeline snapshot; test FAILED as expected; guard restored.
  • tests/integration/test_architecture_owner_rule_mutations.py::test_pinned_constraint_tag_name_must_use_resolver_owner -- deleted the new static subchecks; test FAILED as expected; guard restored.

Lint contract

ruff check and ruff format --check (src, tests, architecture linter scripts), pylint R0801 (10.00/10), lint-auth-signals.sh and lint-architecture-boundaries.sh all silent on the merged head.

CI

All 23 required checks green on 903968e (CI, Merge Gate, CodeQL, Spec conformance, NOTICE Drift, Deploy Docs, lifecycle smoke, Windows compatibility); license/cla pending until the author signs (after 0 CI fix iteration(s)).

Mergeability status

PR head SHA CEO stance iters folds defers Copilot rounds CI mergeable mergeStateStatus notes
#3381 903968e ship_with_followups 2 7 3 2 green MERGEABLE BLOCKED CLA unsigned; awaiting CODEOWNERS review

Convergence

2 outer iteration(s); 2 Copilot round(s). Final panel stance: ship_with_followups. Ready for maintainer review.


Full per-persona findings

Python Architect

  • [recommended] (iteration 1, resolved in cbb15de) package_tag_name duplicated _git_semver_package_name with .git/rstrip divergence at src/apm_cli/policy/_constraint_pinning.py:128
  • [recommended] (iteration 1, resolved in cbb15de) declared_direct_refs keyed by get_unique_key() dropped duplicate declarations at src/apm_cli/install/phases/resolve.py:417
  • Delta: no findings.

Test Coverage Expert

  • [recommended] (iteration 1, resolved in cbb15de) no regression trap for the dependencies/devDependencies key collision.
  • Delta: no findings.

Doc Writer

  • [recommended] (iteration 1, resolved in 7816250) packaged apm-guide governance row still listed only vX.Y.Z tags.
  • [recommended] (iteration 1, resolved in 7816250) missing CHANGELOG Fixed entry.
  • [recommended] (delta, resolved in d186200) CHANGELOG implied apm audit checks devDependencies at CHANGELOG.md:16
    Suggested: narrow the claim, or make audit read all apm dependencies (deferred above).

Performance Expert

  • Iteration 1 import-weight remark declined (single source of truth). Delta: no findings.

Supply Chain Security Expert

  • [recommended] (iteration 1, resolved in cbb15de) duplicate unique key across dependencies/devDependencies laundered an unbounded ref at src/apm_cli/install/phases/resolve.py:421
  • Delta: 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.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
The entry ships through #3652, which rebuilds #3381; the changelog
convention ends each bullet with the merging PR number. Credit to the
original author is kept in the bullet.

Refs #3224

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

Copy link
Copy Markdown
Collaborator

Thank you Kaustubh Arora (@Kaustubh1235) for this fix for #3224 -- the diagnosis, the declared-ref approach and the real-binary contract are excellent work.

The Contributor License Agreement on this PR has stayed pending for more than 6 days, and we want this repair to ship in 0.36.0. So we rebuilt the same converged change (head 903968e) onto current main as #3652. Your authorship is credited via Co-authored-by: Kaustubh1235 on every commit there, the CHANGELOG entry keeps "by Kaustubh Arora (@Kaustubh1235)", and the #3652 body links back here.

Closing this PR in favor of #3652. If anything there diverges from your intent, please say so on #3652 -- we would value your review.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
…gs (supersedes #3381) (#3652)

* fix(policy): judge the declared constraint, accept package release tags

require_pinned_constraint judged the wrong string in two ways. The
resolve phase rewrites a direct dependency's in-memory reference to the
tag its semver range selected, and the install gate ran after that, so
pkg-a#^1.0.0 was judged as pkg-a-v1.1.0. The literal-tag classifier also
only knew v{version}, while the resolver selects from v{version},
{name}--v{version} and {name}-v{version}.

InstallContext now snapshots every manifest-declared ref of each direct
dependency before any rewrite; policy_gate and policy_target_check pass
that map to run_dependency_policy_checks, which classifies each
declaration instead of the rewritten reference, so a bounded
devDependencies declaration cannot hide an unbounded one. The classifier
accepts {name}-v{version} and {name}--v{version} for the dependency's
own package name only, taking the name from the resolver owner
ref_reuse.git_semver_package_name and the patterns from
DEFAULT_TAG_PATTERNS; a static architecture check guards that routing.

Unit, wiring and real-binary lifecycle tests cover fresh install, locked
replay, repeat install, update and audit, with negative branch, range
and other-package controls.

Rebuilt from #3381 by @Kaustubh1235 to ship in 0.36.0 (CLA pending).

Refs #3224

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

* docs(policy): describe the bounded-choice pinned-constraint rule

Policy reference, schema, consumer governance and dependency guides, the
packaged apm-guide governance usage file and the CHANGELOG now say that
require_pinned_constraint judges each direct dependency's declared
constraint and counts a package's own release tags as pinned. Two places
that said transitive dependencies are classified are corrected; the
check is direct-only.

Rebuilt from #3381 by @Kaustubh1235 to ship in 0.36.0 (CLA pending).

Refs #3224

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

* docs(changelog): point the #3224 entry at successor PR #3652

The entry ships through #3652, which rebuilds #3381; the changelog
convention ends each bullet with the merging PR number. Credit to the
original author is kept in the bullet.

Refs #3224

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

* fix(policy): snapshot declared deps after replace selection

Copilot review on #3652 found two gaps in the declared-ref snapshot.
It was taken from the raw manifest before replace: rules, and a
replacement keeps the original unique key, so a bounded original such
as acme/widget#^1.0.0 covered an unbounded fork ref; the docs say
policy uses the selected source and original refs are provenance only.
It also stored bare ref strings, so declarations sharing a
case-folded key (acme/Widget, acme/widget) were matched against the
resolved dep's package name instead of their own.

The pipeline now snapshots project_manifest_dependencies(), and
collect_declared_refs keeps a shallow copy of each declaration, which
the check classifies directly. classify_unbounded_reason and
humanize_reason no longer need ref overrides and return to their main
signatures. Regressions cover a replaced dep at unit and pipeline-wiring
level and the case-colliding declarations; each was mutation-checked.

apm-spec-waiver: classification repair under existing req-pl-007; declared-constraint snapshot, no new normative behaviour (#3224)

Refs #3224

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

* fix(policy): apm audit judges replace: rules like the install gate

The #3652 review panel (doc-writer, supply-chain-security-expert) found
that run_policy_checks still passed the raw manifest to the pinned
constraint check, so apm audit judged a bounded original while install
judged the unbounded ref a replace: rule selects; the docs promise the
two agree.

collect_manifest_declarations(manifest) is now the single owner of the
source-selected declaration snapshot; the install pipeline and
run_policy_checks both use it (this also keeps pipeline.py within its
LOC budget). Unit, wiring and a real-binary replace: scenario
(fork tag passes, fork branch is blocked at install and fails audit)
were each mutation-checked against both call sites. Policy reference and
the packaged governance guide note that a replace: rule is judged by the
ref it selects.

Refs #3224

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

---------

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

Copy link
Copy Markdown
Contributor Author

sorry was delay was occupied with some urgent work
@microsoft-github-policy-service agree.

@Kaustubh1235

Kaustubh Arora (Kaustubh1235) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/audit-policy apm-policy.yml schema, custom_checks, install-time enforcement. status/accepted Human scope approval; verify the issue's approval record and review contact before work. triage/recommended Automated advice completed; not human scope approval. type/bug Something does not work as documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] require_pinned_constraint flags git semver ranges as bare branches: checks the resolved tag and rejects {name}-v{version} literal tags

4 participants