Skip to content

Policy and manifest parse owner: vendor keys, pin verification, hash prefix - #4259

Merged
Daniel Meppiel (danielmeppiel) merged 17 commits into
mainfrom
danielmeppiel-h-a-policy-parse-followup
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 17 commits into
mainfrom
danielmeppiel-h-a-policy-parse-followup

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Description

H-A follow-up to #4151 (depends on #4151; this branch carries #4151's commits until it lands, then merges main). Manifest and policy parse-owner fixes, part of the 0.37 trust and integrity consistency hardening:

  • Registry URLs are validated against the spec scheme rules, through one scheme-acceptance owner, under both manifest contracts.
  • registries.<name> key validation: a mistyped key is rejected and an x- vendor key is accepted, under both manifest contracts.
  • Cached policy content is verified against its pin before use.

Work in progress (draft).

Issue and approved scope

Fixes #4286 -- scope record: #4286 (comment)
Fixes #4252 -- scope record: #4252 (comment)
Fixes #4218 -- scope record: #4218 (comment)

Type of change

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

Testing

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

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit / manifest edit / test edit / CONFORMANCE regenerated as needed.

…ner (#4084)

Register policy/outcome_routing.py as the policy-outcome-routing owner
with a closed outcome set. audit --ci, approve, update and MCP admission
take the routed decision instead of local outcome lists; an outcome
outside the set blocks. Adds the install-deployment-policy-outcome-routing
guard and an installed-CLI parity test across every outcome.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Trust and integrity consistency hardening (#4079):

- apm audit --ci drift replay reads org policy through the trust-reader
  outcome owner (resolve_trust_policy / route_discovery_outcome), so a
  policy outcome that stops install also stops the replay (req-pl-010).
- The lifecycle script policy gate suppresses scripts, with a warning,
  when org policy cannot be resolved, including inheritance chain errors
  (req-pl-003, req-pl-010).
- Guards: install-deployment-trust-policy-outcome covers the audit replay
  reader; new contracts-tooling-lifecycle-policy-errors guard with its
  mutation case.
- Regression tests on the installed CLI and a lifecycle bug ledger row.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Type-check every policy field before membership, hashing or iteration;
load_policy turns any remaining shape error into a validation error so it
routes as malformed. Adds the install-deployment-policy-field-types guard.

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: owner consolidation; existing req-pl-003 and req-pl-010 policy outcome semantics now applied by every policy reader, no new normative behaviour

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Blocking policy decisions can leave approval-store changes behind after rejection and still allow MCP server admission, undermining policy enforcement.

2 open issues
What changed in this PR

This draft carries the policy-outcome consolidation from #4151 as groundwork for the planned manifest and cached-policy hardening. The reviewed changes centralize policy decisions across commands and improve handling of malformed policy fields.

Changes:

  • Introduces a shared routing decision for all 11 policy-discovery outcomes.
  • Routes policy readers through that owner and suppresses lifecycle scripts on unexpected policy errors.
  • Adds lifecycle regressions, architecture guards, mutation coverage, and documentation.
File Description
tests/​unit/​test_audit_policy_command.py Updates fixtures to use explicit discovery outcomes.
tests/​unit/​scripts/​test_architecture_runner.py Registers new guards in the expected inventory.
tests/​unit/​policy/​test_parser.py Updates expected type-validation diagnostics.
tests/​unit/​copilot_plugins/​test_pr2705_folds.py Uses a typed absent-policy result.
tests/​unit/​commands/​test_approve_deny.py Tests routed warnings and blocking approvals.
tests/​quality/​complexity_baseline.json Removes the parser's complexity exemption.
tests/​integration/​test_trust_integrity_consistency_lifecycle.py Adds audit replay and script-suppression regressions.
tests/​integration/​test_policy_outcome_routing_lifecycle.py Adds installed-CLI outcome parity and malformed-field tests.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutations for routing and parser guards.
tests/​fixtures/​lifecycle_bug_ledger.json Records policy-routing regression coverage.
src/​apm_cli/​security/​trust.py Uses shared policy classification for MCP admission.
src/​apm_cli/​policy/​parser.py Centralizes field-type validation and wraps construction errors.
src/​apm_cli/​policy/​outcome_routing.py Defines the closed outcome set and shared routing decisions.
src/​apm_cli/​policy/​install_preflight.py Updates routing-owner terminology in a comment.
src/​apm_cli/​policy/​discovery.py Documents outcomes and classifies plaintext URL rejection.
src/​apm_cli/​install/​phases/​policy_gate.py Updates comments to reference the routing owner.
src/​apm_cli/​core/​lifecycle_scripts.py Suppresses scripts after unexpected policy errors.
src/​apm_cli/​commands/​update.py Uses shared classification for executable reconciliation.
src/​apm_cli/​commands/​policy.py Handles blocking outcomes in policy explanations.
src/​apm_cli/​commands/​audit.py Routes CI checks and drift replay through shared decisions.
src/​apm_cli/​commands/​approve.py Uses routed policy loading and reports blocks.
scripts/​architecture_linter/​checks/​install_trust_integrity.py Updates permitted discovery callers and trust readers.
scripts/​architecture_linter/​checks/​install_policy_plugin_and_approval.py Requires approval to use the routing helper.
scripts/​architecture_linter/​checks/​install_policy_outcome_routing.py Adds outcome-routing and field-type guards.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Registers the new policy guards.
scripts/​architecture_linter/​checks/​contracts_lifecycle_script_gate.py Guards script suppression on policy errors.
packages/​apm-guide/​.apm/​skills/​apm-usage/​governance.md Documents outcome handling and malformed fields.
docs/​src/​content/​docs/​reference/​cli/​policy.md Lists all discovery outcomes.
docs/​src/​content/​docs/​reference/​cli/​lifecycle.md Expands policy-related script suppression notes.
docs/​src/​content/​docs/​reference/​cli/​approve.md Documents blocking policy outcomes.
CHANGELOG.md Records routing and parser fixes from #4151.
.apm/​architecture/​owners/​install-deployment.json Expands policy-routing ownership and guard references.
.apm/​architecture/​owners/​contracts-tooling.json Links lifecycle ownership to the policy-error guard.

Review effort: Balanced

A blocking outcome raises :class:`PolicyViolationError`; an outcome that
leaves no usable policy is reported and yields an empty policy.
"""
policy = resolve_trust_policy(project_root, logger=logger)
Comment on lines +315 to +317
policy = route.policy
if policy is None and (route.blocks or route.unresolved):
admission.policy_unavailable = route.outcome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants