Repository navigation
fix(policy): one host-bound identity for dependencies.require on every host - #4008
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addresses the spec and code panels on #4008: - drop the registry-proxy exception: require uses the same effective host as allow/deny, so a proxy-shaped URL on any host can no longer satisfy a github.com entry (supply-chain rec-1, spec panels) - read lock rows only via RequiredPackageMatch.locked_in; the version pin never compares a same-path row from another host (architect rec-1/rec-2); guard now rejects any other lock accessor - name the entry to write in the check message, which apm audit --ci prints; split deployed failures by cause (test-coverage rec-1, devx rec-1/rec-2) - req-pl-018: effective host honours manifest default_host:, which never rebinds a hostless entry (OCI blocker); violation routed through enforcement; first match in declaration order; dotless hosts, portability, 9.2 classification, explicit count - e2e covers the real github.com default host; conformance covers the lockfile side, no-skip, local paths and manifest default_host: - CHANGELOG marked BREAKING with default-host wording (docs, devx) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
APM Spec Guardian:
|
| Panel | Stance | Shocked | New B | New R | New N |
|---|---|---|---|---|---|
| Swagger / OpenAPI editor | ship_with_followups | 8/10 | 0 | 1 | 2 |
| OCI distribution editor | ship_with_followups | 8/10 | 0 | 0 | 2 |
| Package-manager registry-contract editor | ship_with_followups | 8/10 | 0 | 2 | 2 |
| Web-platform architect | ship_with_followups | 8/10 | 0 | 1 | 2 |
B = new blocking findings, R = new recommended, N = new nits (round 2).
Counts are signal strength, not gates. The maintainer ships.
Convergent themes (flagged by 2+ panels)
- T1 -- The 0.1.67 row must disclose that the shared effective-host change also changes host-qualified allow/deny verdicts. Folded. (supporting: sw-rec-r2-1, pkg-rec-r2-2, tag-nit-r2-2)
- T2 -- The allow/deny half of the requirements-manifest note was stale; it now uses the three-tier effective host. Folded. (supporting: sw-nit-r2-1, oci-nit-r2-1, tag-nit-r2-1)
- T3 -- The multi-match tie-break and the "evaluated dependency" set were undefined. The softened clause is folded, and F1 aligns the row. (supporting: sw-nit-r2-2, pkg-nit-r2-1, pkg-nit-r2-2)
- T4 -- Identifying a dependency on a dotless host. The qualifier is folded; the optional diagnostic note is deferred. (supporting: tag-rec-r2-1, oci-nit-r2-2)
- T5 -- Which host a shorthand dependency resolves to. The round-1 blocker on manifest
default_host:is closed, and the round-2 refinement to use the declaring manifest is folded. (supporting: oci-blk-r1-1, pkg-rec-r1-1, tag-rec-r1-1, sw-rec-r1-4, pkg-rec-r2-1)
Fold now (1 item, folded at 8e70a85)
- [F1 / T3] Appendix D, 0.1.67 (proposed) row -- Replace "the first identified dependency in declaration order is the one identified" with "...in the order the check evaluates dependencies (declaration order within one manifest)...".
Success criterion:grep -c 'first identified dependency in declaration order'returns 0. Done.
Defer to v0.1.1
Defer to v0.1.1 (4 items)
- [F2 / standalone] req-pl-018 clause (g) x req-rpl-002 -- Open a scoped issue defining how a require entry identifies a dependency under source replacement: by its declared host or by the replacement host. The 0.1.67 row states that source replacement is unchanged.
- [F3 / T3] req-pl-018 clause (g), multi-match tie-break -- Verify the cross-manifest evaluation order used at install and at audit. If it is deterministic, pin it in normative text; otherwise add an informative note.
- [F4 / T4] req-pl-018 clause (g), dotless-host sentence -- Optional informative note: a diagnostic should name the cause when the candidate dependency is on a dotless non-default host.
- [F5 / standalone] req-pl-018 clause (g) -- Informative note that different spellings of one require identity may each be reported.
Linter handoff: After F1, the stale phrase count is 0. Checks 1 (ASCII), 2 (forbidden tokens), 5 (anchor uniqueness), 6 (count unchanged at 148: 143 MUST, 5 SHOULD, as the row states), 7 (links) and 10 (changelog) pass. Checks 3, 4, 8 and 9 do not apply: no schema, fixture or mermaid changes. Two normative claims were verified against the reference implementation:
- Shorthand under a manifest
default_host:gets that host aspolicy_host, and host-qualifieddenyfollows it.APMPackage.from_apm_ymlparses each manifest inside its owndefault_host:scope, so transitive shorthand uses the declaring manifest's host.Check 11: 17 non-spec files (
src/,tests/) are in this PR, and the code panel (autopilot-pr-review-worker) reviews them separately.
Full per-panel findings (round 2; round-1 findings folded at e03cad0)
Swagger / OpenAPI editor -- shocked_meter 8/10, confidence high
Summary: All round-1 findings are closed: one host-bound identity on both sides, a violation outcome that can be tested, and a conformance test covering both sides. The 0.1.67 row needed to disclose the allow/deny effect (folded).
New recommended findings (1)
- [sw-rec-r2-1] Appendix D 0.1.67 row -- The shared effective-host change also flips host-qualified allow/deny verdicts under a manifest
default_host:. Folded.
New nit findings (2)
- [sw-nit-r2-1] The manifest note's allow/deny half was stale. Folded.
- [sw-nit-r2-2] The declaration-order tie-break was undefined for transitive dependencies. Folded (softened).
OCI distribution editor -- shocked_meter 8/10, confidence high
Summary: The round-1 blocker is closed, so the Section 10.8 claim now holds under the literal text. Removing the proxy carve-out eliminates the hidden-upstream bypass. Only the source-replacement interplay (deferred) and nits remain.
New nit findings (2)
- [oci-nit-r2-1] The manifest note's allow/deny half was stale. Folded.
- [oci-nit-r2-2] Optional: the diagnostic could name the dotless-host cause. Deferred (F4).
Package-manager registry-contract editor -- shocked_meter 8/10, confidence high
Summary: require now has one host-bound identity, aligned with allow/deny, with a deterministic tie-break and violations routed through enforcement.
New recommended findings (2)
- [pkg-rec-r2-1] clause (g) -- Which manifest supplies
default_host:for a transitive shorthand dependency. Folded: the declaring manifest. - [pkg-rec-r2-2] 0.1.67 row -- List the allow/deny verdict classes this changes. Folded.
New nit findings (2)
- [pkg-nit-r2-1] The "evaluated dependency" set was undefined. Folded (softened).
- [pkg-nit-r2-2] Say that a later identified dependency is not evaluated. Folded.
Web-platform architect -- shocked_meter 8/10, confidence high
Summary: Every round-1 finding is closed cleanly, and removing the proxy carve-out simplifies the model. The dotless-host sentence needed a qualifier (folded).
New recommended findings (1)
- [tag-rec-r2-1] clause (g) dotless-host sentence -- A dotless implementation-default host is identified by hostless entries, and the reference implementation passes such entries. Folded.
New nit findings (2)
- [tag-nit-r2-1] The manifest note's allow/deny half was stale. Folded.
- [tag-nit-r2-2] The row should list the allow/deny verdict change. Folded.
Preserved strengths confirmed (all panels)
- req-pl-018 is revised in place, with an explicit count of 148 (143 MUST, 5 SHOULD).
- A single effective-host grammar is shared by allow, deny and require, with no proxy exception.
- The lockfile side reads the identified dependency's own lockfile identity, and an entry that identifies no dependency is a violation routed through enforcement, never skipped.
- The new req-pl-018 conformance test covers both checks: host-qualified, hostless, absent, local-path and manifest
default_host:cases.
This panel is advisory. It does not block merge. Re-apply the spec-review label after addressing feedback to re-run.
Generated by apm-spec-guardian. This comment is AI-generated and may contain errors.
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 2 | 1 | Ownership is right. Folded the remaining host-blind version-check fallback and made the guard structural. |
| Test Coverage Expert | 0 | 2 | 1 | Tests fail on base. Folded: the hint is asserted in audit output, and the default host is covered end to end. |
| Doc Writer | 0 | 1 | 2 | Docs are accurate and concise. Folded the default-host wording in the upgrade note. |
| Supply Chain Security Expert | 0 | 1 | 2 | A net tightening. Folded the removal of the proxy exception and the portability note. |
| DevX UX Expert | 0 | 3 | 0 | The hint is actionable. Folded: neutral reason, deployed-check headline split by cause, BREAKING note. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 3 follow-ups
- [Supply Chain Security Expert] Confirm that the CHANGELOG and
policy-schema.mdcover users who write an explicit proxy URL, and pin the behavior with a test. -- Removing the proxy exception changes which hostless entries pass. Status: covered at e03cad0. The docs say any other host must be written with its host, andtest_proxy_shaped_reference_is_identified_by_its_written_hostpins it. - [Doc Writer] After docs: zero-based redesign around the agent supply chain #3996 moves the enterprise policy-reference page, add a cross-reference from its
requiresection to the host-binding rule. -- Deferred, not dropped. The page is not false today, and the delivery manager scoped doc edits toreference/policy-schema.md. - [Test Coverage Expert] Run the full CI on this change once the 0.37 stack retargets
main, before tagging. -- The stacked base only runslicense/cla, so the evidence so far is the local CI mirror.
Recommendation
Recommend merging into the 0.37 stack. The PR closes a silent-pass hole in an org governance check, its tests fail on the base, every in-scope finding is folded, and the breaking change is documented. Before tagging, check that full CI is green once the stack reaches main. Track the enterprise policy-reference cross-reference against #3996.
(Architecture diagrams from python-architect are omitted here because they describe the pre-fold head c95ee08. The terminal delta pass covers the folded shape.)
Full per-persona findings (panel head c95ee08; disposition at e03cad0)
Python Architect
- [recommended]
_check_required_package_versionstill falls back to a host-blind raw-name lock lookup atsrc/apm_cli/policy/policy_checks.py:444. -- Folded:index.find_or_undeclared, plustest_version_pin_never_reads_a_same_path_row_from_another_host. - [recommended] The closed-world guard is an attribute-name heuristic that is easy to bypass, and the lock index is rebuilt in three checks, at
scripts/architecture_linter/checks/contracts_dependency_policy.py:145. -- Folded: onelocked_inaccessor; the guard rejectsdependencies,get_dependency,has_dependency,get_unique_keyandfind_namein lock checks; three mutation tests. - [nit]
dependency_policy_name_matcheswas a test-only second implementation. -- Folded: it now routes throughDependencyPolicyIndex.find.
Test Coverage Expert
- [recommended] The expected-form hint never reached
apm audit --cioutput. -- Folded: the message carries "Declared on another host -- write 'X' as 'Y'", asserted by unit and e2e tests. - [recommended] No e2e covered a hostless entry on the real default host. -- Folded: the e2e installs
github.com/contoso/pkg, and the hostless andgithub.com-qualified entries pass both checks. - [nit] The proxy and legacy paths were tested only on the manifest side. -- Moot/folded: the proxy exception was removed, and a test pins the written host.
Doc Writer
- [recommended] The CHANGELOG named hosts by brand. -- Folded: it now names the default-host rule (
GITHUB_HOST, elsegithub.com). - [nit] The registry-proxy rule was not documented. -- Moot: the exception was removed.
- [nit] The enterprise policy-reference
requiresection is silent on host binding. -- Deferred to docs: zero-based redesign around the agent supply chain #3996.
Supply Chain Security Expert
- [recommended] The registry-proxy exception let
attacker.example/artifactory/x/acme/guardrailssatisfygithub.com/acme/guardrails, atsrc/apm_cli/models/dependency/identity.py:214. -- Folded: the exception was removed. - [nit] A hostless entry follows
GITHUB_HOST. -- Folded: portability sentence inpolicy-schema.mdandgovernance.md. - [nit] Ports are ignored for
requirematching. -- Folded: "Ports are ignored, as fordeny."
DevX UX Expert
- [recommended] The wrong-host reason hardcoded the hostless explanation. -- Folded: the reason is now neutral.
- [recommended] The deployed-check headline said "absent from the lockfile" for undeclared entries. -- Folded: failures are counted by cause.
- [recommended] The CHANGELOG line should be BREAKING and name
apm install. -- Folded.
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.
b6d04f6 to
246a2fe
Compare
8e70a85 to
746d783
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addresses the spec and code panels on #4008: - drop the registry-proxy exception: require uses the same effective host as allow/deny, so a proxy-shaped URL on any host can no longer satisfy a github.com entry (supply-chain rec-1, spec panels) - read lock rows only via RequiredPackageMatch.locked_in; the version pin never compares a same-path row from another host (architect rec-1/rec-2); guard now rejects any other lock accessor - name the entry to write in the check message, which apm audit --ci prints; split deployed failures by cause (test-coverage rec-1, devx rec-1/rec-2) - req-pl-018: effective host honours manifest default_host:, which never rebinds a hostless entry (OCI blocker); violation routed through enforcement; first match in declaration order; dotless hosts, portability, 9.2 classification, explicit count - e2e covers the real github.com default host; conformance covers the lockfile side, no-skip, local paths and manifest default_host: - CHANGELOG marked BREAKING with default-host wording (docs, devx) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Delta panel folds on #4008: - the message names the declared host and the required host, asks to declare the package on the required host first, and offers the policy rewrite only for a trusted host, since the declared host may be a typosquat (supply-chain delta rec-1); it says the fix is the policy require entry, not apm.yml (devx delta rec-1) - CHANGELOG: failure is under `enforcement: block`, and the command is `apm audit --ci` (docs delta rec-1) - docs: explicit registry-proxy paths are identified by the proxy host; prefer PROXY_REGISTRY_URL with shorthand (supply-chain delta rec-2) - refresh the stale version-check comment (architect delta) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
3dc87b0 to
3bc3715
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addresses the spec and code panels on #4008: - drop the registry-proxy exception: require uses the same effective host as allow/deny, so a proxy-shaped URL on any host can no longer satisfy a github.com entry (supply-chain rec-1, spec panels) - read lock rows only via RequiredPackageMatch.locked_in; the version pin never compares a same-path row from another host (architect rec-1/rec-2); guard now rejects any other lock accessor - name the entry to write in the check message, which apm audit --ci prints; split deployed failures by cause (test-coverage rec-1, devx rec-1/rec-2) - req-pl-018: effective host honours manifest default_host:, which never rebinds a hostless entry (OCI blocker); violation routed through enforcement; first match in declaration order; dotless hosts, portability, 9.2 classification, explicit count - e2e covers the real github.com default host; conformance covers the lockfile side, no-skip, local paths and manifest default_host: - CHANGELOG marked BREAKING with default-host wording (docs, devx) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Delta panel folds on #4008: - the message names the declared host and the required host, asks to declare the package on the required host first, and offers the policy rewrite only for a trusted host, since the declared host may be a typosquat (supply-chain delta rec-1); it says the fix is the policy require entry, not apm.yml (devx delta rec-1) - CHANGELOG: failure is under `enforcement: block`, and the command is `apm audit --ci` (docs delta rec-1) - docs: explicit registry-proxy paths are identified by the proxy host; prefer PROXY_REGISTRY_URL with shorthand (supply-chain delta rec-2) - refresh the stale version-check comment (architect delta) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 1 | 0 | Iteration-1 findings resolved. One deferred leftover: the undeclared-name raw version fallback. |
| Test Coverage Expert | 0 | 1 | 0 | Iteration-1 findings resolved; e2e 5/5. The explicit-proxy-URL lockfile side is deferred (it is lockfile identity). |
| Doc Writer | 0 | 1 | 0 | Iteration-1 findings resolved. BREAKING line now scoped to enforcement: block and apm audit --ci (folded). |
| Supply Chain Security Expert | 0 | 2 | 0 | Bypass closed and no new fail-open path. Hint is no longer a typosquat lever, and proxy identity is documented (both folded). |
| DevX UX Expert | 0 | 1 | 0 | Iteration-1 findings resolved. The hint now points to the policy require entry (folded). |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Test Coverage Expert] Run full CI on this head once the 0.37 stack retargets
main. The stacked base runs onlylicense/cla. -- Only the local CI mirror has validated this head, and it touches a governed-by-policy surface. - [Test Coverage Expert] Open an issue: explicit proxy-URL dependencies get a bare
get_unique_key()but a host-qualified lock row, sorequired-packages-deployedreports a false failure. -- This predates the PR and fails closed, but enterprises that use proxy paths will hit it. The fix is a lockfile identity change, which [BUG] On a non-default host, no form of adependencies.requireentry passes bothrequired-packagesandrequired-packages-deployed#3993 excludes. - [Spec] Open an issue for F2: how source replacement (req-rpl-002) interacts with require identity. -- Mirror and replacement setups are where host identity is most ambiguous.
- [Python Architect] In a follow-up, make the version check host-aware for names declared on no host, and update
test_required_version_retains_locked_only_mismatch_detaildeliberately. -- The mismatch detail can point at the wrong row during triage. - [Doc Writer] Add the enterprise policy-reference cross-link after docs: zero-based redesign around the agent supply chain #3996 moves the page.
Recommendation
Merge with the stack once full CI is green after the 0.37 stack retargets main. Every iteration-1 and delta finding is either folded or deferred with an explicit scope boundary, and both deferrals fail closed. The highest-signal item to track after merge is the explicit proxy-URL lockfile identity issue.
Full per-persona delta findings (reviewed at 746d783; folds at 3dc87b0)
Python Architect
- [recommended]
find_or_undeclaredkeeps a host-blind raw lock lookup for names declared on no host (src/apm_cli/policy/matcher.py:129). -- Deferred: the behavior is pinned by an existing test and outside scope. The stale comment was refreshed.
Test Coverage Expert
- [recommended] The written-host rule for explicit proxy-URL dependencies is tested only on the manifest side, and the lockfile side shows a false failure (
tests/unit/policy/test_required_package_host_identity.py:168). -- Deferred: this is lockfile identity and predates this PR. The docs steer users toPROXY_REGISTRY_URL.
Doc Writer
- [recommended] The BREAKING line overstated the failure (
CHANGELOG.md:12). -- Folded.
Supply Chain Security Expert
- [recommended] The wrong-host hint invited rewriting the policy to the declared host, a typosquat lever (
src/apm_cli/policy/policy_checks.py:269). -- Folded: the hint asks for the manifest fix first, and the policy rewrite applies only to a trusted host. - [recommended] Explicit proxy-path identity was undocumented (
docs/src/content/docs/reference/policy-schema.md:165). -- Folded.
DevX UX Expert
- [recommended] The
required-packageshint did not name the policyrequireentry as the place to fix (src/apm_cli/policy/policy_checks.py:245). -- Folded.
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.
246a2fe to
75c4a50
Compare
3bc3715 to
9aec162
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Addresses the spec and code panels on #4008: - drop the registry-proxy exception: require uses the same effective host as allow/deny, so a proxy-shaped URL on any host can no longer satisfy a github.com entry (supply-chain rec-1, spec panels) - read lock rows only via RequiredPackageMatch.locked_in; the version pin never compares a same-path row from another host (architect rec-1/rec-2); guard now rejects any other lock accessor - name the entry to write in the check message, which apm audit --ci prints; split deployed failures by cause (test-coverage rec-1, devx rec-1/rec-2) - req-pl-018: effective host honours manifest default_host:, which never rebinds a hostless entry (OCI blocker); violation routed through enforcement; first match in declaration order; dotless hosts, portability, 9.2 classification, explicit count - e2e covers the real github.com default host; conformance covers the lockfile side, no-skip, local paths and manifest default_host: - CHANGELOG marked BREAKING with default-host wording (docs, devx) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Delta panel folds on #4008: - the message names the declared host and the required host, asks to declare the package on the required host first, and offers the policy rewrite only for a trusted host, since the declared host may be a typosquat (supply-chain delta rec-1); it says the fix is the policy require entry, not apm.yml (devx delta rec-1) - CHANGELOG: failure is under `enforcement: block`, and the command is `apm audit --ci` (docs delta rec-1) - docs: explicit registry-proxy paths are identified by the proxy host; prefer PROXY_REGISTRY_URL with shorthand (supply-chain delta rec-2) - refresh the stale version-check comment (architect delta) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
502b197 to
4dbf495
Compare
On a non-default host (GitLab, GHES, Gitea) no require entry could pass both required-packages and required-packages-deployed: the manifest side compared the host-blind canonical name while the lockfile is keyed by host, and the deployed check skipped entries it could not resolve. DependencyPolicyIndex.find now resolves a require entry to one declared dependency by path AND host (hostless = default host; registry-proxy hosts are transport), and the lockfile row is addressed by that dependency's own unique key. Unresolved entries fail both checks with the expected entry form; nothing is skipped. The policy-identity architecture guard now forbids skips and host-blind lock lookups. Fixes #3993 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Delta panel folds on #4008: - the message names the declared host and the required host, asks to declare the package on the required host first, and offers the policy rewrite only for a trusted host, since the declared host may be a typosquat (supply-chain delta rec-1); it says the fix is the policy require entry, not apm.yml (devx delta rec-1) - CHANGELOG: failure is under `enforcement: block`, and the command is `apm audit --ci` (docs delta rec-1) - docs: explicit registry-proxy paths are identified by the proxy host; prefer PROXY_REGISTRY_URL with shorthand (supply-chain delta rec-2) - refresh the stale version-check comment (architect delta) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
After the stack restack, 0.1.66 is present in Appendix D, so the row no longer calls the version reserved. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
9aec162 to
3560d7f
Compare
Description
TL;DR
On a non-default git host (GitLab, GHES, Gitea), no
dependencies.requireentry could pass bothrequired-packagesandrequired-packages-deployed. This PR gives both checks one host-bound identity, owned byDependencyPolicyIndex.find. A hostless entry names the default host and a host-qualified entry names its host. The lockfile row is addressed by the matched dependency's own unique key, and an entry that resolves to nothing fails instead of being skipped.Important
Stacked on #3997 (
danielmeppiel-docs-037-native), at the top of the 0.37 stack. The delivery manager picked this base because the PR shares files with #3290, #3989 and #3992. It amends OpenAPM req-pl-018 clause (g) as proposed version 0.1.67.Problem (WHY)
required-packagesbuilt its lookup from the host-blindget_canonical_dependency_string()(group/sub/pkg), butrequired-packages-deployedused that name as a key into a lockfile keyed by host-qualifiedget_unique_key()(gitlab.example.com/group/sub/pkg). On a non-default host the lookup always missed.required-packagesfailed andrequired-packages-deployedpassed only because ofif lock_name is None: continue.GITHUB_HOST=ghes..., the hostless entry for a correctly declared and locked package also failedrequired-packages-deployed. This was found while writing the regression tests.required-executable-untrustedhad the same split identity, so a deployed package was reported as "present but untrusted".Result: with any
dependencies.require,enforcement: blockwas unusable on a self-managed host. The repo rule is "Every durable decision ... has exactly ONE canonical owner". Here two checks derived the require identity in two different ways.Approach (WHAT)
identity.py(owner) gainseffective_policy_hostandrequired_package_policy_hosts(entry).requireuses the same effective host asallow/deny, with no proxy exception, so a proxy-shaped URL on any host cannot satisfy agithub.comentry.DependencyPolicyIndex.find(entry)matches on path and host. The returnedRequiredPackageMatch.locked_in(lock)reads the row bydependency.get_unique_key(); it is the only lock read in the required checks.required-packages,-deployed,required-executable-untrustedandrequired-package-versionall route throughfind. The two presence checks never skip an entry.apm audit --ciprints) names the entry to write:Declared on another host -- write 'group/sub/pkg' as 'gitlab.example.com/group/sub/pkg'.contracts-tooling-policy-identityrejects acontinuein the two presence checks, and any lock accessor other thanlocked_in(dependencies,get_dependency,has_dependency,get_unique_key,find_name) in the lock-reading checks. Three mutation tests prove the rejections.Implementation (HOW)
src/apm_cli/models/dependency/identity.py: the host helpers above.DependencyReference.policy_hostnow delegates toeffective_policy_host(same behaviour);reference.pygets smaller.src/apm_cli/policy/matcher.py: the index stores host-aware match lists per normalized path.find,find_name,find_or_undeclaredandexpected_entryall share one_firstlookup, anddependency_policy_name_matchesroutes throughfind. The legacyfrom_namesset stays byte-exact.src/apm_cli/policy/policy_checks.py: routes the four required checks throughfindandlocked_in. Adds a shared_unresolved_required_subjectand a message-level_wrong_host_hint, and splits deployed failures by cause. The version pin never reads a same-path row from another host.scripts/architecture_linter/checks/contracts_dependency_policy.pyand.apm/architecture/owners/contracts-tooling.json: the guard is extended, and the record names the new decision.default_host:, which never rebinds a hostlessrequireentry; violations routed throughenforcement; never skipped), the Section 6.3.1 table and the 10.8 note, the 0.1.67 history row, the requirements-manifest note, a new req-pl-018 conformance test, and regenerated CONFORMANCE. Docs:reference/policy-schema.mdand the apm-usagegovernance.md.Diagrams
Both presence checks now resolve a
requireentry through one owner, then judge their own condition:flowchart LR E["require entry"] --> F["DependencyPolicyIndex.find<br/>path + host"] F -->|"match"| M["required-packages: pass"] F -->|"match.lock_key"| L{"in apm.lock.yaml?"} L -->|"yes"| D["-deployed: pass"] L -->|"no"| X["-deployed: fail + repair hint"] F -->|"no match"| U["both fail + expected entry form"]Trade-offs
requireis now default-host only, while hostlessallow/denystill match every host. This is deliberate and follows the accepted scope:requireis a grant of presence, so binding it to one host avoids a same-path package on another server satisfying it. The upgrade note names the migration.required-packages-deployednow fails an undeclared entry instead of skipping it. In--no-fail-fastaudits an absent package is reported twice, once per check. That is the "no silent skip" contract.allow/deny. An env-configured proxy keeps the declared reference hostless, so its identity is unchanged. The panel preferred this fail-closed default to a proxy-shaped exception that any host could claim.policy_hosttoLockedDependency. That keepsdeps/lockfile.pyout of the diff (fix(0.37): finish owner hardening for bundle MCP, audit copies, failed installs, MCP targets and plugin pins #3989 and fix(claude): install intact user plugins through Claude settings, owned by the lock #3290 also edit it), and reuses the lockfile's own key builder.Validation
Commands and results (all run locally; final head
8e70a856)uv run --extra dev pytest -q tests/unit/policy/test_required_package_host_identity.pyuv run --extra dev pytest -q tests/integration/policy/test_required_packages_host_identity_lifecycle.pygitlab.example.testandgithub.com); the original 3 on base: 3 faileduv run --extra dev pytest -q -n 8 tests/unit/policy tests/spec_conformance/test_policy_reqs.py tests/integration/test_wave7_policy_registry_coverage.py tests/integration/test_deep_coverage_deps_policy.py tests/integration/test_policy_coverage.py tests/integration/test_architecture_policy_bytecode.py tests/unit/test_audit_policy_command.py tests/unit/models tests/unit/scripts/test_architecture_runner.pytest_load_raw_apm_yml_permission_deniedfails identically on base because the sandbox runs as rootuv run --extra dev pytest -q -n 8 tests/integration/test_architecture_owner_rule_mutations.py -k "policy or identity"continueskip back in-deployedtest_qualified_entry_does_not_match_another_hostfailstest_version_pin_never_reads_a_same_path_row_from_another_hostfailstest_reporter_repro_hostless_entry_fails_both_with_expected_formfailsruff check+ruff format --check(CI-mirror paths)pylint R0801(CI-mirror paths)bash scripts/lint-auth-signals.shbash scripts/lint-architecture-boundaries.shpytest tests/spec_conformance --collect-only+python -m tests.spec_conformance.gen_statementScenario evidence
gitlab.example.testandgithub.com, thenapm audit --ci --policy: the host-qualified entry, and the hostless orgithub.com/entry for the default-host package, each pass both presence checkstest_required_packages_host_identity_lifecycle.py::test_host_qualified_require_passes_both_presence_checks(real install via a git URL rewrite; lock row carrieshost:)...::test_unmatched_require_fails_both_presence_checksdefault_host:never rebinds a hostless entry; a proxy-shaped URL cannot satisfygithub.comtest_manifest_default_host_never_rebinds_a_hostless_entry,test_proxy_shaped_reference_is_identified_by_its_written_host,tests/spec_conformance/test_policy_reqs.py::test_require_entry_is_one_host_bound_identity_on_manifest_and_lockfiletests/unit/policy/test_required_package_host_identity.pytest_architecture_policy_bytecode.py::test_required_package_guard_rejects_skip_and_host_blind_lock_lookupHow to test
uv run --extra dev pytest -q tests/unit/policy/test_required_package_host_identity.py tests/integration/policy/test_required_packages_host_identity_lifecycle.pydependencies.requireentry passes bothrequired-packagesandrequired-packages-deployed#3993: the qualified entry givesTrue ... | True ...; the hostless entry fails both checks and namesgitlab.example.com/group/sub/pkg.bash scripts/lint-architecture-boundaries.shexits 0, then re-addcontinuein_check_required_packages_deployedand seecontracts-tooling-policy-identityfail.Issue and approved scope
Issue: Fixes #3993
Human scope-approval comment: #3993 (comment) (eligibility
record-present, review contact Daniel Meppiel (@danielmeppiel))Does this PR complete the issue, or what remains? It completes the approved scope. The issue's "related observation" (audit judges direct declarations while install judges the resolved tree) is out of scope and unchanged.
Type of change
Testing
Changelog
## [Unreleased]inCHANGELOG.md:user-visible effect first, 25 words or fewer, ending with
(#PR);breaking changes only under upgrade notes; no Highlights; see
.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated (req-pl-018 clauses (a) and (g) revised in place, Section 6.3.1 table and 10.8 note aligned, 0.1.67 row).docs/public/specs/manifests/openapm-v0.1.requirements.ymlreq-pl-018 note updated.@pytest.mark.req("req-pl-018")test_policy_host_recognition_grammar_and_scopeextended, andtest_require_entry_is_one_host_bound_identity_on_manifest_and_lockfileadded.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statement(req-pl-018 is now bound to 4 tests; statement count unchanged).Panels: apm-spec-guardian (fold_and_ship, average 8.0, F1 folded) and review panel (ship_with_followups; every in-scope finding folded).
Co-authored-by: Copilot [email protected]