Repository navigation
feat(policy): host-qualified dependency allow/deny patterns - #3606
Daniel Meppiel (danielmeppiel) merged 19 commits into
Conversation
Every dependency, direct or transitive, is matched against its effective host: the written host, or GITHUB_HOST / github.com by default. A pattern whose first segment contains a dot names a host matched exactly (case and port ignored, no lookalikes or subdomains); hostless patterns keep matching every host. Shorthand, HTTPS and SSH references give the same result. apm audit now also checks locked transitive dependencies; violation details name the host. Amends OpenAPM req-pl-018 with clause (g). Fixes #3509 Co-authored-by: Copilot App <[email protected]>
…509-host-qualified-dep-patterns
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
Critical host-normalization flaws can bypass deny rules, while audit checks miss effective replacement sources and direct dev dependencies, allowing unapproved hosts to escape enforcement.
3 open issues
What changed in this PR
Adds host-qualified dependency allow/deny patterns to APM’s policy engine, supporting multi-host enterprise source restrictions requested in #3509 without changing lockfile identity.
Changes:
- Matches host-qualified patterns against dependencies’ effective hosts and includes hosts in violation details.
- Extends audit source checks to locked transitive dependencies.
- Adds regression and conformance coverage, architecture checks, and policy documentation.
| File | Description |
|---|---|
| tests/unit/policy/test_dependency_policy_host.py | Tests host matching, reference forms, compatibility, and transitives. |
| tests/unit/policy/test_dependency_identity_case.py | Updates expectations for host-qualified matching. |
| tests/spec_conformance/test_policy_reqs.py | Adds effective-host conformance coverage. |
| src/apm_cli/policy/policy_checks.py | Adds audit source inputs and host-aware diagnostics. |
| src/apm_cli/policy/matcher.py | Gates patterns by host before matching package paths. |
| src/apm_cli/models/dependency/reference.py | Exposes the effective policy host. |
| src/apm_cli/models/dependency/identity.py | Centralizes policy-host normalization and pattern splitting. |
| scripts/architecture_linter/checks/contracts_dependency_policy.py | Enforces centralized host-policy logic. |
| packages/apm-guide/.apm/skills/apm-usage/governance.md | Documents host-qualified governance patterns. |
| docs/src/content/docs/specs/openapm-v0.1.md | Defines host-aware policy semantics. |
| docs/src/content/docs/reference/policy-schema.md | Updates dependency-pattern reference guidance. |
| docs/src/content/docs/enterprise/policy-reference.md | Adds enterprise examples and matching rules. |
| docs/public/specs/manifests/openapm-v0.1.requirements.yml | Extends req-pl-018 notes with host semantics. |
| CONFORMANCE.md | Updates req-pl-018 test count. |
| CONFORMANCE.json | Records the new conformance test. |
| CHANGELOG.md | Announces host policies and the dotted-group compatibility change. |
Review effort: Balanced
Fixes the red CI on #3606: a first pattern segment beginning with a dot (./packages/**, ../shared/**) was read as a host, so a deny on a local dependency's canonical path silently stopped matching (failing test_dependency_policy_evaluates_the_selected_source and the req-pl-018/source-replacement conformance test). Host names never begin with a dot, so such segments now stay hostless. Also folds the two other in-scope Copilot findings: - normalize_policy_host strips a valid :port, so GITHUB_HOST with a port matches (and is denied by) the same host-qualified rules. - apm audit gates the effective direct sources (production, dev, and replace-selected) via project_manifest_dependencies, plus lockfile transitives; an unbindable replace table is a failing check. Spec req-pl-018(g), policy docs, apm-usage governance guide and CHANGELOG updated. Addresses Copilot inline on identity.py:190, identity.py:206 and policy_checks.py:1423. Co-authored-by: Copilot App <[email protected]>
…tterns Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 2 | Host-qualified policy matching cleanly respects canonical-owner discipline; identity helpers, protocol, and arch-linter guard are well-placed. |
| Supply Chain Security Expert | 0 | 1 | 0 | Host-qualified policy matching is architecturally sound; one defense-in-depth gap: trailing-dot FQDN in GITHUB_HOST silently bypasses deny rules. |
| Test Coverage Expert | 0 | 1 | 0 | All Done-when host-matching scenarios have regression traps; C1-C3 folds each tested. One gap: unbindable-replace audit error path lacks a test. |
| Doc Writer | 0 | 2 | 1 | Docs match the code, contain only ASCII and cross-link well. One gap: a dotted or wildcard-host deny pattern now silently matches nothing, and no page says so. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Supply Chain Security Expert] Strip trailing DNS dot in normalize_policy_host; add GITHUB_HOST trailing-dot regression test. -- Missing-test evidence on a secure_by_default surface. Silent deny-rule bypass when GITHUB_HOST has a trailing dot. One-line fix (rstrip) + one test. In the PR's approved scope ('exact host matching, no lookalike domains').
- [Doc Writer] Add a CHANGELOG Changed or Security entry naming the deny-side consequence of the dotted-segment host reinterpretation. -- Existing deny on 'my.group/**' silently fails open after upgrade. The Added entry names the rewrite but not the security consequence. In the PR's approved scope ('policy docs updated').
- [Doc Writer] State in policy-reference.md and governance.md that a wildcard host pattern (e.g. '*.corp.example/**') matches no dependency. -- Users from glob conventions expect expansion in the host segment; silence is a deny-disablement trap. In scope ('host-recognition rule unambiguous').
- [Test Coverage Expert] Add a test exercising the unbindable-replace audit error path (ValueError -> failing dependency-sources check). -- Missing-test evidence on the new audit error path introduced by the C3 fold. The try/except at policy_checks.py:1422 has no regression trap. In scope (audit path was added in this PR).
- [Python Architect] Wrap project_manifest_dependencies return in list() inside _audit_source_dependencies before appending. -- Defensive copy prevents invisible aliasing coupling. Nit severity, zero cost. In scope.
Architecture
classDiagram
direction LR
class DependencyReference {
<<Entity>>
+host str
+is_local bool
+policy_host str or None
+get_canonical_dependency_string() str
}
class identity_py {
<<CanonicalOwner>>
+normalize_policy_host(host) str
+split_policy_pattern_host(pattern) tuple
+normalize_package_policy_identity(value) str
}
class _DependencyPolicySubject {
<<Protocol>>
+policy_host str or None
+get_canonical_dependency_string() str
}
class PolicyMatcher {
<<Strategy>>
+check_dependency_allowed(dep, policy)
+dependency_policy_subject(dep) str
}
class PolicyChecks {
<<Facade>>
+run_dependency_policy_checks(deps, policy)
+run_policy_checks(root, policy)
}
class ArchLinter {
<<StaticGuard>>
+check_policy_identity(provider)
}
DependencyReference ..|> _DependencyPolicySubject : implements
DependencyReference ..> identity_py : policy_host delegates to
PolicyMatcher ..> _DependencyPolicySubject : depends on
PolicyMatcher ..> identity_py : host split and casing
PolicyChecks ..> PolicyMatcher : delegates matching
ArchLinter ..> identity_py : guards helper uniqueness
ArchLinter ..> PolicyMatcher : guards delegation calls
flowchart TD
A["apm audit / apm install"] --> B["run_policy_checks or install policy gate"]
B --> D["source deps: effective direct deps + locked transitives"]
D --> J["run_dependency_policy_checks"]
J --> K["allowlist / denylist checks"]
K --> L["check_dependency_allowed (matcher.py)"]
L --> N["split_policy_pattern_host (identity.py)"]
N --> O{"host-qualified pattern?"}
O -- yes --> P{"pattern host == dep.policy_host?"}
P -- no --> Q["skip pattern"]
P -- yes --> R["glob-match path (existing case rules)"]
O -- no --> R
R --> S{"match?"}
Recommendation
The architecture is sound, the test suite is green, and the spec-guardian panel found no blockers. The trailing-dot rstrip fix (follow-up 1) and the CHANGELOG deny-consequence entry (follow-up 2) are both one-line, in-scope changes that should be folded before landing -- they close the last gap between the approved scope's 'exact host matching' promise and what ships. The remaining follow-ups (wildcard-host docs note, unbindable-replace test, two nits, link dedup) are low-cost in-scope cleanups suitable for the same PR or an immediate successor.
Full per-persona findings
Python Architect
- [nit] _audit_source_dependencies mutates the list returned by project_manifest_dependencies via .append() at
src/apm_cli/policy/policy_checks.py:1358
Safe today (fresh list) but invisible aliasing coupling; defensive list() copy costs nothing.
Suggested: deps = list(project_manifest_dependencies(manifest)) - [nit] New source_deps parameter and _audit_source_dependencies lack type annotations at
src/apm_cli/policy/policy_checks.py:1193
Codebase standard is type hints on public APIs; cheap to add.
Suggested: source_deps: Iterable[DependencyReference] | None = None; _audit_source_dependencies(manifest: APMPackage, lock: LockFile | None) -> list[DependencyReference]
Supply Chain Security Expert
- [recommended] normalize_policy_host does not strip DNS trailing dot, enabling a deny-rule bypass when GITHUB_HOST contains one. at
src/apm_cli/models/dependency/identity.py:193
GITHUB_HOST='ghes.corp.example.' gives policy_host 'ghes.corp.example.' which misses deny 'ghes.corp.example/' (silent fail-open). Explicit-host references reject trailing dots at parse time, but default_host() from env does not. Low probability, silent failure mode.
Suggested: rstrip a trailing '.' in normalize_policy_host; add a GITHUB_HOST trailing-dot regression test.
Proof (missing at):tests/unit/policy/test_dependency_policy_host.py-- proves: A deny rule for ghes.corp.example/ blocks shorthand deps when GITHUB_HOST has a trailing dot.
Test Coverage Expert
- [recommended] New dependency-sources audit error path (unbindable replace table) has no regression trap at
src/apm_cli/policy/policy_checks.py:1422
run_policy_checks now aborts with a failing dependency-sources check when project_manifest_dependencies raises ValueError; no test exercises it (grep confirmed).
Suggested: Add TestAuditDirectSources test with an unbindable replace rule asserting a failing dependency-sources check.
Proof (missing at):tests/unit/policy/test_dependency_policy_host.py-- proves: When a replace rule cannot bind, apm audit reports a clear dependency-sources error
Doc Writer
- [recommended] An existing deny pattern with a dotted first segment silently stops denying after upgrade; docs present it only as a rewrite tip inside an Added entry at
CHANGELOG.md:12
my.group/** is now host 'my.group'; for deny that is fail-open. Upgrade notes should name the security consequence under ### Changed.
Suggested: Separate ### Changed entry naming the deny consequence; one line in policy-reference.md. - [recommended] Docs do not say a wildcard host pattern such as .corp.example/* matches nothing, which disables a deny at
docs/src/content/docs/enterprise/policy-reference.md:419
Host segment compared literally; readers from glob conventions expect expansion.
Suggested: State that such a pattern matches no dependency; list each host explicitly. Same in governance.md. - [nit] policy-schema.md restates the host-recognition rule at line 147 without linking the canonical table at
docs/src/content/docs/reference/policy-schema.md:147
State once, reference elsewhere.
Suggested: Replace parenthetical with a link to Host-qualified patterns.
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.
APM Spec Guardian:
|
| Panel | Stance | Shocked | New B | New R | New N |
|---|---|---|---|---|---|
| Spec Swagger Editor | ship_with_followups | 8/10 | 0 | 1 | 2 |
| Spec OCI Editor | ship_with_followups | 7/10 | 0 | 1 | 1 |
| Spec Pkgmgr Editor | ship_with_followups | 8/10 | 0 | 1 | 1 |
| Spec TAG Architect | ship_with_followups | 8/10 | 0 | 1 | 1 |
B = new blocking findings, R = new recommended, N = new nits.
Counts are signal strength, not gates. The maintainer ships.
Convergent themes (flagged by 2+ panels)
- T1 -- Host-qualified require entry is dead and undocumented (supporting: sw-rec-r1-1, oci-nit-r1-1)
- T2 -- Comma splice in clause (g) ports summary sentence (supporting: sw-nit-r1-2, tag-nit-r1-1)
Fold now (7 item(s))
- [F1 / T1] req-pl-018 clause (g) -- Append to clause (g): 'This clause does not apply to
dependencies.require. Arequireentry whose first segment resembles a host is compared literally under clause (a) and matches no dependency whose canonical path omits the host.'
Success criterion:grep -c 'does not apply to.*dependencies.require' openapm-v0.1.md returns 1 - [F2 / standalone] req-pl-018 clause (g) -- Replace both 'with any
:portsuffix removed' phrases with 'with any trailing colon followed by one to five ASCII digits (U+0030 through U+0039) removed'.
Success criterion:grep -c ':portsuffix' openapm-v0.1.md returns 0; grep -c 'U+0030 through U+0039' returns at least 2 - [F3 / T2] req-pl-018 clause (g) -- Replace 'Ports are ignored on both sides, the host segment is compared literally' with 'Ports are ignored on both sides; the host segment is compared literally'.
Success criterion:grep -c 'both sides, the host' openapm-v0.1.md returns 0 - [F4 / standalone] req-pl-018 clause (g) -- After each port-normalization phrase (per F2), insert ', and any single trailing U+002E removed' so pattern host and effective host both drop one trailing dot (companion code change in normalize_policy_host).
Success criterion:grep -c 'trailing U+002E removed' openapm-v0.1.md returns exactly 2 - [F5 / standalone] Appendix D -- Add a '0.1.58 (proposed) | 2026-11-12' revision row for the req-pl-018 clause (g) amendment ([Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 / PR feat(policy): host-qualified dependency allow/deny patterns #3606), count unchanged at 137, and mention 0.1.58 in the reconciliation paragraph.
Success criterion:grep -c '0.1.58' openapm-v0.1.md returns at least 2 - [F6 / standalone] req-pl-018 clause (g) -- Replace 'the implementation's configured default host' with 'the implementation-default host (Section 1.4)'.
Success criterion:grep -c 'implementation.s configured default host' openapm-v0.1.md returns 0 - [F7 / standalone] Section 6.3.1 dependencies table -- Deny row: 'Always wins over
allow; host-qualified pattern matching per req-pl-018 clause (g); case treatment per req-pl-018.'
Success criterion:grep 'deny.*clause (g)' openapm-v0.1.md returns 1 line in the Section 6.3.1 table
Defer to v0.1.1
- [F8 / standalone] req-pl-018 clause (g) / req-mf-019 -- When the implementation consults the manifest default_host: field for dependency-policy host resolution, revise clause (g) to delegate the effective default host to req-mf-019. Today the implementation does not read that field for policy; adding it is new behavior outside the approved [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 scope.
Linter notes (1 note)
- [11]
.pyfiles are modified in this PR (policy host matching); autopilot-pr-review-worker ran in parallel. Checks 1, 2, 5, 6 (137 at all three count sites), 7 and 10 pass; 3, 4, 8 and 9 are N/A (no schema, fixture or mermaid change).
Linter handoff: After F2 + F4: no '
:portsuffix' remains in clause (g); 'U+0030 through U+0039' appears twice; 'trailing U+002E removed' appears twice. After F5: Appendix D has a 0.1.58 (proposed) row and the reconciliation paragraph mentions 0.1.58. After F7: the 6.3.1 deny row contains 'clause (g)'. Count sites remain 137.
Full per-panel findings
Spec Swagger Editor -- shocked_meter 8/10, confidence high
Summary: Clean, well-integrated amendment. One recommended: require-field edge case undocumented. Nits: Appendix D row, comma splice.
New recommended findings (1)
- [sw-rec-r1-1] req-pl-018 clause (g) -- Clause (g) is silent on dependencies.require; a require entry whose first segment contains a dot is vacuously unsatisfiable under clause (a). Fail-closed but undocumented.
Recommended fix: Add a sentence to clause (g): this clause does not apply to dependencies.require; such an entry is compared literally under clause (a) and matches no dependency.
New nit findings (2)
- [sw-nit-r1-1] No Appendix D revision row documents this amendment. -- fix: Add a 0.1.58 (proposed) row: defensive amendment of req-pl-018 clause (g) for [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 / PR feat(policy): host-qualified dependency allow/deny patterns #3606; count unchanged at 137.
- [sw-nit-r1-2] Comma splice in 'Ports are ignored on both sides, the host segment is compared literally...'. -- fix: Split into separate sentences.
Preserved strengths confirmed
- RFC 2119 discipline on the new MUST
- Cross-reference accuracy across 6.3.1, req-rpl-002 sentence and 10.8
- Normative count consistency (137)
- Anchor stability
- Deny-precedence preservation
Spec OCI Editor -- shocked_meter 7/10, confidence high
Summary: Well-integrated; one recommended port-grammar tightening and one nit on require authoring trap; no blockers.
New recommended findings (1)
- [oci-rec-r1-1] req-pl-018 clause (g) -- ':port suffix' is not defined; implementations stripping only numeric ports vs any colon-tail disagree on malformed host tokens.
Recommended fix: Say 'any trailing colon followed by one or more ASCII digits (U+0030 through U+0039) removed'.
New nit findings (1)
- [oci-nit-r1-1] A host-qualified require entry is a dead entry; the authoring trap is silent. -- fix: Append a sentence to clause (g) stating it does not apply to dependencies.require.
Preserved strengths confirmed
- ASCII-only host case fold
- Explicit no-subdomain/no-prefix language
- Local-path exemption
- Replacement source host binding
- 10.8 note accurate
Spec Pkgmgr Editor -- shocked_meter 8/10, confidence high
Summary: Tight and well-scoped. One recommended: anchor 'configured default host' to req-mf-019. One nit on the deny table row.
New recommended findings (1)
- [pkg-rec-r1-1] req-pl-018 clause (g) -- 'the implementation's configured default host' is a third phrasing beside req-mf-019 (manifest default_host:) and the glossary term 'implementation-default host'; readers may disagree on which tier applies.
Recommended fix: Delegate to req-mf-019: 'the default host selected by req-mf-019 (the manifest default_host: value, or the declared implementation-default host when that field is omitted)'.
New nit findings (1)
- [pkg-nit-r1-1] The deny row does not mention clause (g) while the allow row does. -- fix: Append '; host-qualified pattern matching per clause (g)' to the deny row.
Preserved strengths confirmed
- Host-recognition heuristic separates local paths
- Port normalization on both sides
- Replace-selected source interaction addressed
- Deny-over-allow preserved
- Hostless backward compatibility explicit
Spec TAG Architect -- shocked_meter 8/10, confidence high
Summary: Clean, well-layered amendment. One recommended: normalize a trailing DNS dot. One nit: comma splice.
New recommended findings (1)
- [tag-rec-r1-1] req-pl-018 clause (g) -- A trailing DNS dot is not normalized before host comparison; github.com. and github.com are the same host, and a trailing-dot reference or default host could slip past a host-qualified deny.
Recommended fix: Append ', and any single trailing U+002E removed' where clause (g) removes the :port suffix, for both pattern host and effective host.
New nit findings (1)
- [tag-nit-r1-1] Comma splice in the ports sentence. -- fix: Use a semicolon or split the sentence.
Preserved strengths confirmed
- Purely syntactic deterministic grammar
- Clause (g) self-contained
- Implementation-agnostic default host phrasing
- Form-equivalence MUST
- Requirements manifest updated in lockstep
- 10.8 note updated
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.
A default host such as GITHUB_HOST=ghes.corp.example. kept its root dot, so host-qualified deny rules for ghes.corp.example silently missed shorthand dependencies. normalize_policy_host now drops one trailing dot on both the pattern and dependency side. Also defensively copies the projected manifest deps in the audit source set, adds type hints, and adds a regression test for the fail-closed dependency-sources check when replace rules cannot bind. Addresses panel follow-ups from supply-chain-security-expert, python-architect and test-coverage-expert. Co-authored-by: Copilot App <[email protected]>
An existing hostless pattern with a dotted first segment (my.group/**) now matches nothing, so as a deny it stops blocking. Record that under Changed, state that wildcard host patterns match nothing, mention the trailing-dot rule, and link policy-schema to the canonical table. Addresses doc-writer panel follow-ups. Co-authored-by: Copilot App <[email protected]>
Folds F1-F7 from the apm-spec-guardian round-1 synthesis: require is not host-qualified, numeric-only port grammar, trailing-dot removal, comma splice, implementation-default host glossary term, deny table parity and an Appendix D 0.1.58 revision row. F8 (req-mf-019 manifest default_host) is deferred: it needs new behavior outside the #3509 scope. Co-authored-by: Copilot App <[email protected]>
Spec req-pl-018(g) removes a trailing colon plus one to five digits from the pattern and effective host, but the code only removed a valid port (1-65535), so deny ghes.corp.example:99999/** matched nothing (fail-open). Use one regex on both sides so code and spec agree; pinned by a regression test. Addresses doc-writer delta-panel finding. Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Both round-1 nits (list() copy, type hints) resolved; trailing-dot normalization is sound; no new findings. |
| Supply Chain Security Expert | 0 | 0 | 0 | Trailing-dot DNS bypass fix is correct and symmetric; no new bypass introduced in the delta. |
| Test Coverage Expert | 0 | 0 | 0 | Prior fail-closed audit gap closed; trailing-dot normalization has a regression trap; 60/60 tests pass. Ship. |
| Doc Writer | 0 | 1 | 0 | All 3 round-1 doc items are fixed and the delta is ASCII-clean; one spec-vs-code mismatch remained on which port suffixes get stripped. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [spec-pkgmgr-editor] Spec-guardian F8: once the policy engine reads a manifest default_host:, delegate clause (g)'s effective default host to req-mf-019. -- Outside this PR's approved scope ([Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 excludes new settings; the implementation does not read default_host: for policy today). Track as a follow-up so spec and implementation converge.
Delta since the last advisory (a26b7b1 -> 925f440)
- Folded all 7 prior follow-ups (8513986, a872939) and spec-guardian fold-now F1-F7 (45b9f73); F8 (req-mf-019 manifest default_host:) deferred as outside the [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 scope.
- Delta doc-writer finding (spec vs code port grammar) folded in 925f440 with a mutation-verified regression test.
- CI green at 925f440 (23 pass, 3 skipped; license/cla SUCCESS); 0 unresolved review threads; lint mirror silent.
Recommendation
Every in-scope finding from both the full panel and the delta round is folded, regression-tested, and mutation-verified. The 4 delta panelists return unanimously clean. The sole remaining item (spec-guardian F8, default_host: field for policy) is explicitly outside the #3509 approved scope and is suitable for a post-merge follow-up issue. This PR is ready to land pending green CI on the final head.
Full per-persona findings
Python Architect
No findings.
Supply Chain Security Expert
No findings.
Test Coverage Expert
No findings.
Doc Writer
- [recommended] Spec clause (g) strips any colon plus 1-5 digits from a host, but the code stripped only valid ports 1-65535 at
docs/src/content/docs/specs/openapm-v0.1.md
normalize_policy_host suppressed the ValueError for ports 0 or above 65535, so deny ghes.corp.example:99999/** named host 'ghes.corp.example:99999' and matched nothing, while the spec reads it as ghes.corp.example. Code applied such a deny more loosely than the spec states.
Suggested: Align code and spec; add a test that pins an out-of-range port.
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.
…tterns Resolve Appendix D conflict: main took 0.1.58 for req-tg-018 (#2030); this PR's req-pl-018 clause (g) amendment becomes 0.1.59, count 138 (133 MUST, 5 SHOULD). Co-authored-by: Copilot App <[email protected]>
Adds test_policy_host_recognition_grammar_and_scope (@Req req-pl-018): leading-dot local-path patterns stay hostless, numeric ports and one trailing dot are removed on both sides, require is not host-qualified, and audit gates locked transitives. CONFORMANCE.{json,md} regenerated in full after collecting the whole tests/spec_conformance suite. Appendix D 0.1.59 row now ends with the Section 9.3 amendment-panel sentence (coordinator-required, precedent 0.1.8/0.1.9). Co-authored-by: Copilot App <[email protected]>
Folds spec-guardian round-2 convergent nit (oci-nit-r2-1, pkg-nit-r2-1): both 0.1.56 and 0.1.59 revise in place and add no statement. Co-authored-by: Copilot App <[email protected]>
APM Spec Guardian:
|
| Panel | Stance | Shocked | New B | New R | New N |
|---|---|---|---|---|---|
| Spec Swagger Editor | ship | 9/10 | 0 | 0 | 0 |
| Spec OCI Editor | ship | 9/10 | 0 | 0 | 1 |
| Spec Pkgmgr Editor | ship | 9/10 | 0 | 0 | 1 |
| Spec TAG Architect | ship | 9/10 | 0 | 0 | 0 |
B = new blocking findings, R = new recommended, N = new nits.
Counts are signal strength, not gates. The maintainer ships.
Convergent themes (flagged by 2+ panels)
- T1 -- Appendix D reconciliation paragraph 'in place' scope ambiguity (supporting: oci-nit-r2-1, pkg-nit-r2-1) -- folded in 8c65adf.
Defer to v0.1.1
- [F8 / standalone] req-pl-018 clause (g) / req-mf-019 -- When the implementation consults the manifest default_host: field for dependency-policy host resolution, revise clause (g) to delegate the effective default host to req-mf-019. Today the implementation does not read that field for policy; adding it is new behavior outside the approved [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 scope.
Linter notes (1 note)
- [11]
.pyfiles are modified (policy host matching); autopilot-pr-review-worker ran in parallel. Checks 1, 2, 5, 6 (138 at every count site), 7 and 10 pass; orphan_check OK (138 aligned); CONFORMANCE regenerated in full; 3, 4, 8, 9 N/A.
Linter handoff: No new folds to apply. Count sites remain 138 (133 MUST, 5 SHOULD); Appendix D row 0.1.59 ends with the Section 9.3 amendment-panel note; clause (g) carries the numeric port grammar and trailing-dot removal twice each.
Full per-panel findings
Spec Swagger Editor -- shocked_meter 9/10, confidence high
Summary: All round-1 findings closed by F1-F7; counts agree at 138; no new findings.
Round-1 closure: sw-rec-r1-1 closed by F1 (require exclusion sentence); nits closed by F5 (Appendix D row, now 0.1.59) and F3 (comma splice).
Preserved strengths confirmed
- RFC 2119 discipline on the clause (g) MUST
- Cross-reference accuracy (6.3.1 allow/deny rows, replacement sentence, Section 1.4 link, 10.8)
- Count consistency at 138 (133 MUST, 5 SHOULD) across all sites
- Anchor stability; 0.1.59 is the next free slot after main's 0.1.58
- Deny-precedence preserved
Spec OCI Editor -- shocked_meter 9/10, confidence high
Summary: All round-1 findings closed; one nit on reconciliation-paragraph wording.
Round-1 closure: oci-rec-r1-1 closed by F2 (1-5 ASCII digit port grammar on both sides); oci-nit-r1-1 closed by F1 (require exclusion).
New nit findings (1)
- [oci-nit-r2-1] '0.1.56 revises [req-tg-005] and 0.1.59 revises [req-pl-018] in place and add none' leaves the scope of 'in place' ambiguous. -- fix: '0.1.56 revises [req-tg-005] in place and 0.1.59 revises [req-pl-018] in place; neither adds a statement.'
Preserved strengths confirmed
- ASCII-only host case fold
- No-subdomain/no-prefix language
- Local-path exemption
- Replacement source host binding
- Port and trailing-dot normalization on both sides
- Appendix D 0.1.59 row with Section 9.3 note
- req-pl-018 conformance coverage 1 -> 3
Spec Pkgmgr Editor -- shocked_meter 9/10, confidence high
Summary: All round-1 findings closed; Appendix D numbering and counts consistent; one reconciliation nit.
Round-1 closure: pkg-rec-r1-1 closed by F6 (implementation-default host glossary anchor); F8 deferred appropriately; pkg-nit-r1-1 closed by F7.
New nit findings (1)
- [pkg-nit-r2-1] 'in place' attaches only to the 0.1.59 clause although both revisions are in place. -- fix: '0.1.56 revises [req-tg-005] in place and 0.1.59 revises [req-pl-018] in place; neither adds a statement.'
Preserved strengths confirmed
- Host-recognition heuristic separates local paths
- Numeric port and trailing-dot normalization on both sides
- Replace-selected source addressed
- Deny-over-allow preserved
- Hostless backward compatibility explicit
- All count sites consistent after main's 0.1.58
Spec TAG Architect -- shocked_meter 9/10, confidence high
Summary: Both round-1 findings closed; no new findings.
Round-1 closure: tag-rec-r1-1 closed: one trailing U+002E removed symmetrically on pattern and effective host; comma splice fixed.
Preserved strengths confirmed
- Purely syntactic deterministic grammar
- Clause (g) self-contained
- Default host anchored to the Section 1.4 glossary term
- Form-equivalence MUST preserved
- Requirements manifest updated in lockstep
- 10.8 note accurate
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.
…tterns Resolve policy_checks.py and policy-schema.md conflicts with #3652 by keeping both sides: source_deps (host-qualified allow/deny over effective direct + locked transitive sources) and declared_refs (authored constraint for require_pinned_constraint); both doc paragraphs kept. Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Merged composition is correct: both project_manifest_dependencies callers route through the single replacement owner; fail-closed ordering holds; no split authority. |
| Test Coverage Expert | 0 | 0 | 0 | New req-pl-018 clause (g) conformance test exercises all grammar rules (leading-dot hostless, port/trailing-dot removal, require unchanged, transitive gating); hermetic and passes; ship. |
| Doc Writer | 0 | 0 | 0 | The 0.1.59 row, reconciliation sum, Appendix C, Section 1.3 and CONFORMANCE agree. Text is ASCII. Ship. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [spec-pkgmgr-editor] Spec-guardian F8: once the policy engine reads a manifest default_host:, delegate clause (g)'s effective default host to req-mf-019. -- Outside the [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509 approved scope (the implementation does not read default_host: for policy today). Track as a post-merge follow-up issue.
Delta since the last advisory (925f440 -> c7085a8)
- Appendix D conflict with main's 0.1.58 (req-tg-018) resolved faithfully; this amendment is 0.1.59, count 138 (133 MUST, 5 SHOULD), row ends with the Section 9.3 amendment-panel sentence.
- New req-pl-018 conformance test; CONFORMANCE.{json,md} regenerated in full; orphan_check 138 aligned; Mode B passes (spec-concurrent).
- apm-spec-guardian round 2: all four panels ship, shocked avg 9.0; convergent nit folded in 8c65adf.
- Merged fix(policy): judge the declared constraint, accept package release tags (supersedes #3381) #3652: policy_checks.py and policy-schema.md conflicts resolved keeping both seams.
- CI green at c7085a8 (26 checks); license/cla SUCCESS; 0 unresolved review threads.
Recommendation
Every in-scope finding from the full panel, all delta rounds and both spec-guardian rounds is folded, regression-tested and verified, and CI is green at c7085a8 with 0 unresolved threads and license/cla passing. The sole remaining item (F8, default_host: field for policy) is outside the #3509 scope and suitable for a post-merge follow-up issue.
Full per-persona findings
Python Architect
No findings.
Test Coverage Expert
No findings.
Doc Writer
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-review-worker. This comment is AI-generated and may contain errors.
…ied-dep-patterns Co-authored-by: Copilot App <[email protected]>
Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <[email protected]>
Lane L: main merged for landing
This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel). |
…tives (#3658) main's source-dependency owner (#3606) already runs the allow and deny checks over effective direct deps plus locked transitives. This keeps the installed-CLI guard that install and audit --ci agree. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…kfile symlink, audit replay, targeted install, MCP cleanup) (#3672) * fix(export-patch): make subdirectory package patches apply from the repo root (#3649) A git: + path: (or marketplace git-subdir) dependency is cached as just its subdirectory, so exported diff paths were relative to that subdirectory while the patch header says to apply from the package repository root; git apply failed with 'No such file or directory'. Prefix the locked virtual_path for subdirectory packages. Co-authored-by: Copilot App <[email protected]> * fix(export-patch): export edits to Claude plugin packages (#3649) Install normalizes a Claude plugin (no apm.yml) by mirroring skills/, agents/ and commands/ into .apm/ inside the cache. export-patch indexed both copies, so every skill or agent edit in a marketplace plugin was skipped as 'ambiguous source'. When the cache carries the parser-owned normalization receipt, prefer the upstream candidate over the .apm/ mirror. Co-authored-by: Copilot App <[email protected]> * fix(view): accept logical absolute paths in view --file (#3649) apm view --file "$PWD/<file>" exited 2 ('outside the project deploy root') whenever the working directory was reached through a symlink (macOS /tmp and /var, symlinked workspaces): the deploy root comes from the physical getcwd() while the query kept its logical parents. When the lexical query is not under the deploy root, resolve only its parent directory so the queried leaf stays exact. Co-authored-by: Copilot App <[email protected]> * test(redteam): C5 marketplace, pack, export-patch and view --file chains (#3649) Co-authored-by: Copilot App <[email protected]> * fix(lockfile): refuse a symlinked lockfile before update or uninstall writes (#3649) apm update, apm install --update and apm uninstall detected a symlinked apm.lock.yaml (#3532) only when writing the lockfile, after deploying new files, cleaning stale ones and editing apm.yml. The command then exited 1 with the lockfile still describing the old state, and update reported that no transaction changes were committed. ensure_lockfile_writable() is now the single owner of the rule; LockFile.write uses it, and update (when the plan changes the graph) and uninstall (when it removes a locked package) call it before any other write, so the transaction rolls back cleanly. Co-authored-by: Copilot App <[email protected]> * fix(audit): replay local apm.yml packages with plugin.json as apm_package (#3649) apm install DIR (routed by #3604) and manifest-declared local deps classify a directory with apm.yml and a root plugin.json as apm_package and deploy only its .apm/ primitives. The audit --ci replay normalized any local dir with a plugin.json as a legacy plugin, integrating root agents/ and failing drift on a fresh install. Route the replay through detect_package_type, the same classifier install uses. Co-authored-by: Copilot App <[email protected]> * fix(install): keep a targeted package's dropped deps an unreached entry may need (#3649) apm install PKG drops the selected package's former descendants that this run's graph no longer contains (#3528). With #3571 the graph is rebuilt from the current apm.yml of every local package, so an unselected sibling edited since it was locked makes the graph omit retained entries it still locks. A shared dependency of such an entry was then removed while the entry stayed locked, leaving apm.lock.yaml without that entry's dependency while audit and prune passed. When the graph omits any retained entry it cannot prove the candidate unneeded, so drop nothing; the next full install reconciles. Co-authored-by: Copilot App <[email protected]> * fix(mcp): keep user short-name entries when a slashed server is removed (#3649) Stale MCP cleanup expanded every stale name to its last path segment, so removing self-defined com.example/server deleted a user-authored or still-declared 'server' entry from VS Code, Cursor, Copilot and OpenCode. Self-defined servers keep their declared key (#3493) and older truncated keys are reconciled only under ownership proof at install time, so derive the alias from the adapter key owner with self-defined context. Co-authored-by: Copilot App <[email protected]> * test(lifecycle): guard 0.36.0 release flows with lifecycle chains (#3649) Permanent APMLifecycle scenarios from the 0.36.0 pre-release sweep. They drive the real apm binary over hermetic local Git fixtures across install, install --frozen, update, audit --ci, prune, uninstall, pack, marketplace, export-patch, view --file, policy and user scope. They assert disk, lockfile, receipts and exit code after every step. Co-authored-by: Copilot App <[email protected]> * docs(changelog): record 0.36.0 red-team regression fixes (#3649) apm-spec-waiver: restores promised behavior of features merged since v0.35.0; no OpenAPM requirement changes Co-authored-by: Copilot App <[email protected]> * refactor(owners): route export-patch mirror, lockfile preflight, and MCP config-key through canonical owners (#3649) Fix 2: export_patch now routes .apm/ mirror classification through plugin_parser.is_install_generated_mirror() instead of hard-coding .apm/ prefix knowledge. The normalization owner decides what is a mirror. Fix 4: lockfile symlink write-guard consolidated into refuse_lockfile_before_mutation() in deps/lockfile.py (single owner). Both pipeline.py and uninstall/cli.py now call this owner API. Added owner registry guard contracts-tooling-lockfile-symlink-write-guard with a MutationCase proving its teeth. Fix 7: MCPClientAdapter._determine_config_key promoted to public determine_config_key(). All 17 call sites (adapters, integrators, ownership, cleanup) updated. No cross-module private access. Co-authored-by: Copilot App <[email protected]> * docs(changelog): cite #3672 for the red-team regression fixes (#3649) Co-authored-by: Copilot App <[email protected]> * fix(compile): never overwrite hand-authored nested context files (#3655) Distributed compile replaced a hand-authored subdirectory AGENTS.md or CLAUDE.md that carries no APM marker, then treated the replaced file as generated output and reported it as orphaned. The canonical owner hand_authored_root_context_blocks_write now applies its marker rule to catalog context filenames at any depth, the AGENTS.md and CLAUDE.md call sites route every placement through it, and nested Git repository skips are decided before protection so their accounting is unchanged. The static guard pins the any-depth rule, with mutation cases. Co-authored-by: Copilot App <[email protected]> * fix(uninstall): keep apm.lock.yaml truthful when uninstall refuses (#3656) When apm uninstall stopped because a tracked target file was edited or a user file sat in a managed skill directory, it had already removed the package's other target files but left apm.lock.yaml claiming all of them. The target-contraction owner (reconcile_target_deployed_files) now reports what each selected dependency still owns through SelectedCleanupOutcome, and the refusal applies it via DeploymentLedgerCodec.replace_legacy_owners and writes the lockfile, so it claims only files still on disk while apm.yml keeps the package for the retry. Preserved profile rows stay claimed. The retained-edit warning now carries its [!] symbol. Co-authored-by: Copilot App <[email protected]> * fix(uninstall): keep the other runtime's default root on selected-profile uninstall (#3661) A global uninstall retained for another Claude/Hermes profile removed rows under every USER_ROOT_ENV_VARS target's selected root, so a HERMES_HOME profile uninstall also deleted ~/.claude files (and vice versa). profile_scope now shares one other-profile record walk and removes only the selected roots of the runtimes whose profiles split the package. Co-authored-by: Copilot App <[email protected]> * fix(deps): replay proxy-routed lock rows under --frozen (#3657) A transparent registry proxy records the proxy host and registry_prefix instead of the upstream host, so drift classified every such row as a provider change and --frozen refused the lock the proxy had just written. ArtifactoryRouter now owns the proxy routing target (promoted from the resolver's private copy) and answers whether a dep routes to a locked proxy row; drift, download-ref replay and the cached-commit owner reuse it. Co-authored-by: Copilot App <[email protected]> * fix(audit): honor --no-cache for auto-discovered policy (#3659) The explicit --policy and auto-discovery branches now share one discovery call that always forwards no_cache, so 'apm audit --ci --no-cache' fetches the org policy fresh as documented. Co-authored-by: Copilot App <[email protected]> * test(policy): guard audit --ci agreeing with install on denied transitives (#3658) main's source-dependency owner (#3606) already runs the allow and deny checks over effective direct deps plus locked transitives. This keeps the installed-CLI guard that install and audit --ci agree. Co-authored-by: Copilot App <[email protected]> * fix(marketplace): real recovery hint, verified package refs, packed relative hook scripts (#3670) - apm pack on a branch-ref marketplace package no longer suggests the nonexistent --allow-head flag; it names the real recovery command (apm marketplace package set <pkg> --ref <tag-or-sha>). - marketplace package add/set --ref verify the ref on the entry's own host through the explicit-ref owner shared with marketplace check (ref_resolver.explicit_ref_error, package_entry_coordinates): a missing tag or unreachable remote exits 2 without changing apm.yml; --no-verify keeps the opt-out. Previously a non-default host looked 'network unavailable' and any missing tag was stored with exit 0. - apm pack carries hook scripts referenced as ./scripts/x from .apm/hooks the way install resolves them (resolve_relative_hook_script, promoted to public) and repoints the packed command. - Owner record marketplace-entry-ref-verification + AC10 guard + MutationCase. Co-authored-by: Copilot App <[email protected]> * fix(bundle): name skipped source symlinks in pack; skip plugin hooks in bundle installs (#3670) - apm pack keeps not following own-source symlinks (matching own-project install), but now names each dropped link in a pack warning instead of dropping it silently. The existing exporter walkers record the skipped links; both bundle exporters warn through _emit_pack_warning. - apm install <bundle> no longer copies a Claude plugin bundle's hooks.json raw into the target root or lowers hooks/ scripts through the hook descriptor extension (fmt.sh -> fmt.sh.json). The local-bundle routing owner (install/local_bundle_paths.py) skips plugin-native hook paths and reports one bundle_deploy_skip_warning per file; deployed-layout bundles keep routing their target hook files. Merging bundle hooks through the hook integrator is a follow-up. Co-authored-by: Copilot App <[email protected]> * fix(mcp): clean recorded servers after their runtime opt-in dir is pruned (#3664) Removing a dependency prunes an emptied .claude/ or .opencode/ before MCP stale cleanup runs, and remove_stale reused those write opt-in directories as cleanup gates, so the recorded server stayed in .mcp.json or opencode.json while its ledger ownership was dropped (apm uninstall and apm install after removing the dependency). install/mcp/ownership.py, the safe-removal owner, gains project_mcp_cleanup_reachable: ledger-scoped cleanup (an explicit runtime from the ownership ledger) stays reachable, otherwise the opt-in dir still gates. remove_stale routes both gates through it; Claude removal stays content-verified by require_removable_mcp_connections. The install-deployment-mcp-ownership-migration guard requires that route and rejects a raw .claude/.opencode is_dir gate in mcp_integrator.py, with a mutation case. Co-authored-by: Copilot App <[email protected]> * fix(hooks): retire merged events a hook source no longer declares (#3665) Merged hook targets cleared a source's earlier entries only for the events its current hook files declare. Deleting one hook file from a package or the root .apm/hooks while another remained left the old event entry in .claude/settings.json and apm-hooks.json, pointing at a deleted script, and apm audit --ci then reported drift. hook_ownership.py gains drop_source_entries, extracted from Cursor's inline whole-source clear. HookIntegrator now uses it for that clear and, after merging, to drop the source's entries from every event it did not re-declare, so hook_integrator.py shrinks. The neutral-hook-contract guard requires both calls and forbids a second definition, with a mutation case. Co-authored-by: Copilot App <[email protected]> * fix(mcp): exit apm mcp install through the install outcome (#3666) apm mcp install forwarded to apm install --mcp with cli.main(standalone_mode=False), which returns ctx.exit codes instead of raising them, so a failed forwarded install (for example an org policy block) exited 0. Run the forwarded command in standalone mode so its exit comes from install/outcome.py and Click's error handling exactly as for apm install. The install-deployment-outcome guard rejects standalone_mode=False under commands/, with a mutation case. Co-authored-by: Copilot App <[email protected]> * fix(deps): list the dependency key apm uninstall accepts (#3671) apm deps list showed a self-hosted GitLab dependency (type: gitlab) by its host-blind org/repo key with Source github, while apm deps tree showed the host-qualified key and apm uninstall only accepts that identity. deps list now shows the key deps tree derives (_dep_display_key, extracted from _dep_display_name) for remote locked dependencies, keeping host-blind keys for orphan detection, and labels Source through the canonical classify_host_provider with the declared or locked host_type. Co-authored-by: Copilot App <[email protected]> * fix(cleanup): never delete a deployed file without a matching recorded hash (#3663) Stale, orphan, contraction, prune and uninstall cleanup all route through integration/cleanup.py::remove_stale_deployed_files. Its provenance gate deleted any lockfile-claimed file without a recorded hash (legacy fall-through), so a hand-edited lockfile could make a receipt-less install delete user files. Gate 3 now keeps such files with a warning and reports them as retained, matching the documented rule that stale files are removed only when recorded hashes match. cowork:// rows stay exempt because install records no hashes for them yet. enterprise/security.md now states that a committed apm.lock.yaml is reviewed input with cleanup authority. Co-authored-by: Copilot App <[email protected]> * fix(audit): replay local packages through the install package image (#3667) apm install copies a local package with materialize_local_package, which dereferences in-package links and materializes single files. The audit --ci replay integrated straight from the source tree, where integrators skip links, so a clean install of a package with a contained link reported its deployed file as orphaned drift. materialize_local_package is now the one raising owner of the local package image: install (_copy_local_package), the uninstall survivor refresh and audit replay (materialize_local_package_for_replay) all copy through it. path_anchoring.resolve_local_dep_base owns the admission anchor for a locked local dep. The replay's raw-directory branch, the file-only replay materializer and the legacy-plugin normalizer's extra copy are gone. The single-file owner guard, registry record and mutation cases now pin the shared routes. Co-authored-by: Copilot App <[email protected]> * fix(prune): keep a hand-removed direct dependency another package still needs (#3668) prune and deps list retained lock entries recorded with depth > 1 only, so a dependency hand-removed from apm.yml that another installed package still declares looked orphaned and prune deleted its checkout, deployed files and lock entry. deps/reachability.py, the forward-reachability owner uninstall already uses, now answers which lock entries are retained (retained_lock_keys): recorded transitives plus stale direct entries still reachable from a declared package's manifest, failing closed when the walk is incomplete. _build_expected_install_paths (prune, deps list, orphan warning) and prune's lock-key selection route through it instead of re-deriving depth > 1. The walk treats a manifestless skill, skill bundle or hook package as a leaf (classified by detect_package_type) instead of an unverifiable node. The reachability guard rejects a parallel depth rule in prune or the selector; docs describe the kept package. Co-authored-by: Copilot App <[email protected]> * fix(uninstall): keep is_dev as install writes it and never report a withheld lock write (#3669) The forward-reachability walk that rescues a shared dependency after uninstall treated every survivor as production, so a dependency left reachable only through devDependencies was rewritten without is_dev and the next install rewrote apm.lock.yaml. compute_forward_reachable_keys now takes the surviving devDependencies separately and drains production paths first, reporting dev_only keys with the install resolver's rule (a production path wins); uninstall persists it with the resolved_by repair. LockFile.write/save return whether the file was persisted, so install --frozen no longer prints 'Updated apm.lock.yaml' for a write it withheld. Co-authored-by: Copilot App <[email protected]> * refactor(install): gate update plans through one plan_inputs owner (#3649) The update-plan confirmation and the symlinked-lockfile refusal now live in install/helpers/plan_inputs.confirm_update_plan, next to build_resolved_update_plan. The pipeline makes one call and drops its local helper, so pipeline.py stays under the install LOC budget. The plan is still built lazily, only when an unwritable lockfile needs it. Co-authored-by: Copilot App <[email protected]> * refactor(install): keep install modules within their LOC budgets (#3649) Moves SelectedCleanupOutcome (#3656) into install/selected_cleanup.py; the target-contraction owner re-exports it for its callers. Compacts the cached-commit tail in sources.py (#3657) with no behavior change. The dependency-replacement guard and its mutation case now pin the plan through plan_inputs.confirm_update_plan. Co-authored-by: Copilot App <[email protected]> * docs(changelog): record the #3649 fix wave (#3672) Co-authored-by: Copilot App <[email protected]> * docs(policy): state that org policy does not govern user-scope installs (#3660) Org policy discovery starts from the project's git remote, so apm install -g (user scope) is not governed by org policy today. Docs only; no behavior change. A user-scope policy source is tracked separately. Co-authored-by: Copilot App <[email protected]> * test(architecture): keep one matrix case per guard for sweep sub-rules (#3649) The #3664, #3665 and #3666 guard extensions now prove their teeth in a parametrized standalone test, so the owner-rule matrix keeps exactly one mutation case per registry guard. Co-authored-by: Copilot App <[email protected]> * fix(install): keep packages apm.yml no longer declares during --frozen (#3662) apm install --frozen tolerated lockfile entries that apm.yml no longer declares but still ran orphan cleanup, deleting their deployed files while the never-rewritten lockfile kept claiming them. The cleanup phase now retains every orphan under --frozen through the existing orphan_cleanup_retained map, so files, the apm_modules checkout and the lock rows stay in place, and prints one info line naming the kept packages with the remedy to run apm install. Retained orphans now carry their source rows' concrete targets, so the frozen build stays equivalent to the committed lockfile and no rewrite is withheld. Co-authored-by: Copilot App <[email protected]> * docs(changelog): record frozen orphan retention (#3662) Co-authored-by: Copilot App <[email protected]> * test(lifecycle): install vs audit --ci replay matrix across package shapes (#3649) Sixteen package shapes (APM package via Git/local/alias/target subset, monorepo subdirectory, contained links in Git and local packages, hooks via Git alias/local alias/symlinked path, Claude skill local alias and Git, skill bundle subset, Claude plugin Git and local alias, MCP-only, single file) driven through install, re-install, install --frozen, compile, cold clone without receipts or cache, and uninstall, asserting audit --ci agrees at every step. Guards the #3667 local package image replay for aliased and symlinked local paths. Co-authored-by: Copilot App <[email protected]> * fix(audit): keep local replay images out of the live apm_modules (#3667) The #3667 replay wrote each local package image at apm_modules_dir/<slot>. A cache-only replay (bare 'apm audit') passes the live project apm_modules there, so auditing silently rewrote the installed copy with unaudited source bytes and normalized legacy plugins in place; in --ci mode the image landed on the native plugin replay path and verify_native_plugin_cache then copied the source onto itself (SameFileError). Materialize local images under the scratch deployment root and let native verification hash that image instead of re-copying. Co-authored-by: Copilot App <[email protected]> * fix(deps): find case-equivalent installs in the reachability walk; keep sweep guards green (#3649) - models/dependency/materialization.installed_package_path is the one read-only lookup for where a dependency is materialized. It recognizes a case-equivalent directory. Prune's expected-path builder and the forward reachability walk both use it, so prune and uninstall no longer treat a casing-equivalent install as unverifiable on case-sensitive file systems (#3668). - integration/cleanup.py: a managed final symlink needs no content hash to be unlinked, because unlinking removes no file content (#3663). - Hook sync tests pass the recorded hashes that uninstall passes. The Claude MCP broadcast test pins the opt-in gate (#3664). The frozen rule inventory lists the lockfile symlink guard. Co-authored-by: Copilot App <[email protected]> * docs(changelog): drop the #3658 entry delivered by #3606 (#3649) Co-authored-by: Copilot App <[email protected]> * docs(changelog): remove stale placeholder bullets left by the rebase (#3649) Co-authored-by: Copilot App <[email protected]> * style(tests): format owner-rule mutations after rebase (#3649) Co-authored-by: Copilot App <[email protected]> * fix(install)!: fail --frozen when deployed bytes differ from locked hashes (#3654) BREAKING CHANGE: apm install --frozen now exits 1 when a deployed file's on-disk bytes differ from its deployed_file_hashes entry (OpenAPM req-lk-017), naming each path with its expected and observed envelope. Before, frozen exited 0 on a dirty tree and the next apm audit --ci failed with hash drift. This covers a kept local edit (e.g. a user-edited skill) and an APM upgrade that renders an already-locked file differently. Repair: run apm install without --frozen and commit. The per-record hash loop of audit content-integrity is extracted into policy/ci_checks.py verify_deployed_file_hashes, and audit scope/target resolution into resolve_audit_scope; audit and the existing post-deploy frozen owner (InstallService._enforce_frozen_no_rewrite) both call them. The install success line now reads 'Deployed files verified against apm.lock.yaml.'. Audit drift text no longer offers export-patch for a modified file whose bytes still match the lock; local_edits owns the new rendering-change hint. check_frozen pins both verifier call sites; docs, apm-usage skill, a req-lk-017 CLI conformance test and lifecycle guards are updated. Co-authored-by: Copilot App <[email protected]> * docs(changelog): record the frozen hash verification break (#3654) Co-authored-by: Copilot App <[email protected]> * test(spec): give the cleanup conformance context its frozen default (#3662) Co-authored-by: Copilot App <[email protected]> * fix(audit): keep user-scope local replay images out of the governed tree (#3667) At user scope the scratch modules root sits under the governed .apm directory, so local package images read as deployed drift. Replay now materializes local images in an ungoverned scratch apm_modules. At project scope that is the same directory as before. Co-authored-by: Copilot App <[email protected]> * test(lifecycle): parse git URLs in the SSH transport guard (#3640) Co-authored-by: Copilot App <[email protected]> * test(deps): guard the case-equivalent install lookup directly (#3668) Co-authored-by: Copilot App <[email protected]> * refactor(architecture): register MCP config-key derivation owner (#3649) Add guard hooks-integrations-mcp-config-key-derivation to the existing mcp-package-launcher owner in hooks-integrations.json, with a static check in mutation_mcp_target_and_scope.py that verifies: - determine_config_key exists as a definition in MCPClientAdapter - MCP consumers (mcp_integrator, mcp_integrator_install, mcp/ownership) route through determine_config_key() and do not re-derive config keys by splitting on "/" MutationCase proves the guard fires when the definition is renamed. Frozen rule inventory updated in test_architecture_runner.py. Co-authored-by: Copilot App <[email protected]> * test(install): guard frozen hash verification at user scope (#3654) Parametrize the warm kept-edit frozen guard over project and user scope: apm install -g, tamper with a deployed skill under the isolated HOME, then apm install --frozen -g must exit 1 naming the path with expected and observed hashes and leave $APM_HOME/apm.lock.yaml byte-identical; after the user resolves the edit and runs apm install -g, --frozen -g exits 0. Co-authored-by: Copilot App <[email protected]> * fix(uninstall): scope selected-profile removal per package in batched uninstalls (#3649) selected_profile_survivors combined the split runtimes of every requested package, so uninstalling two packages at once could delete files that two separate uninstalls keep (one package split across Hermes homes, the other across Claude profiles). The removable selected-profile prefixes are now computed per package before survivor rows are combined. Co-authored-by: Copilot App <[email protected]> * fix(install): refuse a symlinked lockfile before any update side effect (#3649) confirm_update_plan only refused a symlinked apm.lock.yaml when the resolved dependency plan had changes. A target-only change under apm install --update leaves the plan unchanged but still rewrites the deployment ledger, so files were deployed before the lockfile write failed. An update exists to rewrite the lockfile, so it now refuses unconditionally through refuse_lockfile_before_mutation(would_mutate=True), after the apm update plan callback and before any download, deploy or cleanup. Plain install, --frozen, apm lock and dry runs are unchanged. Co-authored-by: Copilot App <[email protected]> * fix(export-patch): classify plugin mirrors from path-specific receipt evidence (#3649) A normalization receipt does not prove every .apm/ file was generated: plugins can declare authored .apm/skills or .apm/agents sources. When such a source shared bytes with an unrelated repository file, export-patch dropped the real source and patched the unrelated file. The normalization owner now maps only .apm/skills/<name>/<tail> to the source directory its receipt records (install_generated_mirror_source), and export-patch drops a candidate only when that proven source is itself another candidate; otherwise the ambiguity skip is kept. Co-authored-by: Copilot App <[email protected]> * fix(pack): reject symlinked relative hook scripts before packing (#3649) resolve_relative_hook_script() resolved symlinks before pack validated the resource, so a contained ./scripts/alias.sh -> fmt.sh (or a linked scripts/ directory) was packed instead of rejected. The owner gains a lexical mode, like resolve_plugin_root_hook_script, so pack validates the unresolved path and its ancestors through the existing hook-resource symlink rule; install keeps resolving as before. Co-authored-by: Copilot App <[email protected]> * fix(pack): anchor packed relative hook scripts on the plugin root (#3649) A packed ./scripts/fmt.sh reference became ./hooks/scripts/fmt.sh, which resolves from the consumer's working directory rather than the installed plugin, so it could not find the bundled file. The plugin-root vocabulary owner gains plugin_root_script_reference, which anchors the packed path on ${CLAUDE_PLUGIN_ROOT} while keeping the authored quoting (unquoted, double- or single-quoted); pack uses it for relative script references. Co-authored-by: Copilot App <[email protected]> * fix(hooks): retire dropped events under safe legacy source markers (#3649) The #3665 retirement pass dropped a source's entries from events it no longer declares only under the canonical marker. An upgraded install whose sidecar still carries a leaf marker such as 'hooks' kept the dropped event pointing at a deleted script. HookIntegrator now computes the owned marker set once from _get_hook_source_markers (keeping its ambiguity rules) and passes it to both drop_source_entries passes. The neutral-hook-contract guard requires both passes to use it, with a mutation case. Co-authored-by: Copilot App <[email protected]> * docs(changelog): match export-patch and pack entries to the review folds (#3672) Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>

Description
TL;DR
Dependency policy
allow/denypatterns can now name a host (github.com/example-org/**,ghes.corp.example/**). Every dependency — direct or transitive, written with a host or defaulting toGITHUB_HOST/github.com— is matched against its effective host, exactly. Hostless patterns keep matching any host, so existing policies behave as before.apm auditnow also gates locked transitive dependencies.Important
One deliberate compatibility edge: a pattern whose first segment contains a dot is now read as a host. A hostless pattern for a dotted GitLab group (
my.group/**) must be writtengitlab.com/my.group/**. GitHub org names cannot contain dots, so default-host policies are unaffected. Called out in CHANGELOG and docs.Local preflight skipped by maintainer instruction (2026-11-12); CI is the gate.
Problem (WHY)
get_canonical_dependency_string(), which omits the host.example-org/**admittedexample-org/*on any host, including unapproved ones; host-qualified patterns never matched anything (pinned by the old testtest_host_qualified_pattern_does_not_match_host_blind_policy_identity).example-orgon github.com" — the exact policy in [Feature] Support host-qualified dependency allow/deny patterns for multi-host enterprise environments #3509.example-org/reposilently followsGITHUB_HOST; a host-blind allow list could not reject it when that host is unapproved.apm auditevaluated allow/deny on manifest (direct) deps only, so a transitive from an unapproved host passed audit even though install would see it.Approach (WHAT)
.is a host (mirrors host-qualified dependency shorthand). Host matched literally, ASCII-case-folded, port ignored; no wildcard expansion in the host.DependencyReferenceexposespolicy_host: written host, elsedefault_host();Nonefor local paths.apm auditadds lockfile transitive entries (depth > 1) to the allow/deny subject set only; require / pin / depth checks keep their existing inputs.ghes.other.example/example-org/repo: not in allowed sources).Implementation (HOW)
src/apm_cli/models/dependency/identity.py— newnormalize_policy_host()andsplit_policy_pattern_host(); the single owner for host recognition and host casing (matcher stays free of.lower()per the existing architecture guard).src/apm_cli/models/dependency/reference.py—DependencyReference.policy_hostproperty.src/apm_cli/policy/matcher.py— host gate in_first_matching_dependency_pattern;dependency_policy_subject()for diagnostics; protocol gainspolicy_host. Raw-stringcheck_dependency_allowed(str, …)API unchanged.src/apm_cli/policy/policy_checks.py—run_dependency_policy_checks(source_deps=…)(defaults todeps_to_install, so install is unchanged);_audit_source_dependencies()for the audit wrapper.scripts/architecture_linter/checks/contracts_dependency_policy.py— existingcontracts-tooling-policy-identityguard now also requires the matcher to route host splitting through the identity owner and forbids redefinition of the new helpers (verified: injecting.lower()into the matcher host compare trips the guard).enterprise/policy-reference.md(new Host-qualified patterns section),reference/policy-schema.md,packages/apm-guide/.apm/skills/apm-usage/governance.md, OpenAPM spec (below), CHANGELOG.Diagrams
How one pattern is evaluated against one dependency (new behavior boxed in the host gate):
flowchart LR P["policy pattern"] --> S{"first segment contains a dot?"} S -- "no: hostless" --> G["glob-match path<br/>(existing case rules)"] S -- "yes: host-qualified" --> H{"pattern host == dependency effective host?"} H -- "no" --> X["skip pattern"] H -- "yes" --> G D["dependency"] --> E["effective host<br/>written host, else GITHUB_HOST / github.com"] E --> H G --> R["match / no match"]Trade-offs
ghes.corp.examplesatisfyghes.corp.example/**— the lookalike attack this issue closes. Chose one unambiguous rule; dotted-group hostless patterns need their host.:7999) and HTTPS (:443) forms of one host must give identical results; keeping ports would break that.*.corp.example/**matches nothing, keeping "exact host, no implicit subdomains" literal.Benefits
example-org/**-style lookalike admission across hosts is closable with one host-qualified line.Issue and approved scope
Issue: Fixes #3509
Human scope-approval comment: #3509 (comment) (Daniel Meppiel (@danielmeppiel), review contact Daniel Meppiel (@danielmeppiel))
Completes the issue: every "Done when" item is covered by a test in
tests/unit/policy/test_dependency_policy_host.py(default-host gating incl.GITHUB_HOST, explicit hosts, lookalike/subdomain rejection, form equivalence, transitive install + audit, hostless compatibility, host-recognition rule incl. dotted GitLab groups) and docs are updated. Out of scope and untouched: lockfile identity (#773), MCP/registry source policy, new CLI flags, separate allowed-hosts setting.Type of change
Testing
TDD + mutation-break: the new tests were red before the fix; disabling the host gate in the matcher fails 18 tests, dropping
_audit_source_dependenciesfails the 2 audit-transitive tests; both restored.Local validation commands and results
Scenario evidence
github.com/example-org/**admitsexample-org/repoon the default host, rejects it whenGITHUB_HOSTis unapprovedTestDefaultHostDependenciestest_lookalike_and_subdomain_hosts_do_not_matchTestReferenceFormsAreEquivalentTestHostlessCompatibilityTestTransitiveDependenciesSpec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.md— req-pl-018 clause (a) no longer says the subject is host-blind-only; new clause (g) defines host-qualified patterns; §6.3.1allowrow, req-rpl-002 and threat §10.8 updated. No new req id, so no Appendix C row change.docs/public/specs/manifests/openapm-v0.1.requirements.ymlreq-pl-018 notes extended.test_policy_host_qualified_patterns_match_effective_host(@pytest.mark.req("req-pl-018")).CONFORMANCE.{md,json}regenerated viapython -m tests.spec_conformance.gen_statement(req-pl-018 test_count 1 → 2).How to test
apm-policy.ymlwithdependencies.allow: ["github.com/example-org/**"];apm install example-org/<repo>passes,apm install other-org/<repo>is blocked.GITHUB_HOST=ghes.other.example:example-org/<repo>is blocked, detail namesghes.other.example/….apm.lock.yaml;apm audit --ci --policy <file>failsdependency-allowlist.Co-authored-by: Copilot [email protected]