Skip to content

Owner moves: one policy-outcome routing owner for every policy reader - #4151

Merged
Daniel Meppiel (danielmeppiel) merged 14 commits into
mainfrom
danielmeppiel-cuddly-train
Nov 20, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 14 commits into
mainfrom
danielmeppiel-cuddly-train

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

Owner consolidation for the 0.37 trust and integrity consistency hardening (group H1a: policy outcome routing). One canonical owner per decision, each guarded closed-world:

  • policy-outcome-routing (policy/outcome_routing.py): a closed set of 11 policy-discovery outcomes, each with exactly one route. apm install, apm audit --ci, apm approve, apm update and MCP admission take the same routed decision; an outcome outside the set blocks. A wrongly typed policy field is a malformed policy, routed like any other.
  • Remaining policy readers (audit drift replay, lifecycle scripts) route through the same owner.

Includes the S-3 lane (#4079).

Issue and approved scope

Fixes #4084 -- scope record: #4084 (comment)
Fixes #4140 -- scope record: #4140 (comment)
Fixes #4079 -- scope record: #4079 (comment)

Completes all three issues.

Type of change

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

Testing

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

Installed-CLI parity test (red on main 1b96706: 9 of 13 cases; green on this branch):
tests/integration/test_policy_outcome_routing_lifecycle.py::test_every_policy_reader_routes_the_outcome_like_install

Changelog

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

Spec conformance (OpenAPM v0.1)

  • N/A -- no new normative behaviour: every policy reader now applies the existing req-pl-003 / req-pl-010 outcome semantics that apm install already applied.

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

…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]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title Owner moves: policy outcome routing, egress route and scope manifest Owner moves: one policy-outcome routing owner for every policy reader Nov 20, 2026
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]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
@danielmeppiel
Daniel Meppiel (danielmeppiel) marked this pull request as ready for review November 20, 2026 11:46
Copilot AI balanced review requested due to automatic review settings November 20, 2026 11:46
Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Blocking policy outcomes can leave user approvals persisted despite reporting no write and still admit MCP servers through existing grants, while the routing guard misses equality-based bypasses.

3 open issues
What changed in this PR

This PR consolidates policy-discovery decisions in APM’s shared routing owner, addressing inconsistent handling across policy readers and malformed policy fields for #4084, #4079, and #4140.

Changes:

  • Defines 11 discovery outcomes with centralized routing and blocking behavior for unknown outcomes.
  • Routes additional policy readers through the owner and validates policy field types before use.
  • Adds architecture guards, mutation and lifecycle coverage, and updated policy documentation.
File Description
tests/​unit/​test_audit_policy_command.py Aligns audit fixtures with explicit discovery outcomes.
tests/​unit/​scripts/​test_architecture_runner.py Registers new guards in the frozen rule inventory.
tests/​unit/​policy/​test_parser.py Updates expected field-type diagnostics.
tests/​unit/​copilot_plugins/​test_pr2705_folds.py Uses a valid absent-policy result.
tests/​unit/​commands/​test_approve_deny.py Tests routed warnings and blocking approvals.
tests/​quality/​complexity_baseline.json Removes the simplified parser’s complexity exemption.
tests/​integration/​test_trust_integrity_consistency_lifecycle.py Covers audit replay and lifecycle-script policy failures.
tests/​integration/​test_policy_outcome_routing_lifecycle.py Adds command parity and malformed-field lifecycle tests.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds policy-routing and type-check guard mutations.
tests/​fixtures/​lifecycle_bug_ledger.json Records regression coverage for the three issues.
src/​apm_cli/​security/​trust.py Consumes routed policy decisions for MCP admission.
src/​apm_cli/​policy/​parser.py Centralizes field-type validation and malformed-policy errors.
src/​apm_cli/​policy/​outcome_routing.py Defines the outcome set and shared routing decisions.
src/​apm_cli/​policy/​install_preflight.py Updates the routing-owner comment.
src/​apm_cli/​policy/​discovery.py Documents all 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 on unexpected policy-check errors.
src/​apm_cli/​commands/​update.py Uses routed decisions for executable reconciliation.
src/​apm_cli/​commands/​policy.py Reports blocking policy errors during explanation.
src/​apm_cli/​commands/​audit.py Routes CI policy handling and drift replay centrally.
src/​apm_cli/​commands/​approve.py Uses shared policy resolution and reports blocking errors.
scripts/​architecture_linter/​checks/​install_trust_integrity.py Updates permitted discovery callers and trust-reader checks.
scripts/​architecture_linter/​checks/​install_policy_plugin_and_approval.py Requires approval to use shared policy resolution.
scripts/​architecture_linter/​checks/​install_policy_outcome_routing.py Adds outcome-routing and parser type-check guards.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Registers the new policy guards.
scripts/​architecture_linter/​checks/​contracts_lifecycle_script_gate.py Guards lifecycle 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 Updates policy-related script suppression guidance.
docs/​src/​content/​docs/​reference/​cli/​approve.md Documents blocking policy outcomes during approval.
CHANGELOG.md Records policy consistency and parser fixes.
.apm/​architecture/​owners/​install-deployment.json Registers the consolidated policy-routing owner.
.apm/​architecture/​owners/​contracts-tooling.json Associates lifecycle policy-error enforcement with its 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
Comment on lines +103 to +105
elif isinstance(node, ast.Compare) and any(
isinstance(op, (ast.In, ast.NotIn)) for op in node.ops
):
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 7c83644 into main Nov 20, 2026
41 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

2 participants