Repository navigation
policy: route a rejected inheritance chain in trust-policy discovery - #4947
Merged
Daniel Meppiel (danielmeppiel) merged 3 commits intoNov 23, 2026
Merged
Conversation
discover_trust_policy caught only OSError, ValueError and RuntimeError, so a PolicyInheritanceError (extends cycle, cross-host extends, chain depth) escaped every executables-trust reader as a traceback. It now catches the owner's POLICY_DISCOVERY_ERRORS and converts them with discovery_failure_result, so a rejected chain routes as the always-block incomplete_chain outcome: one named [x] line, non-zero exit, nothing written. Fixes #4925 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 23, 2026 08:17
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the rejected policy inheritance error-handling change.
No open issues 🎉
What changed in this PR
This PR fixes #4925 by routing rejected policy inheritance chains through the existing policy-outcome handler, so trust-policy readers report a named error instead of a Python traceback.
Changes:
- Catch the canonical
POLICY_DISCOVERY_ERRORSin trust-policy discovery. - Add a regression test checking that
apm approve --recommendedexits with a named error and leavesapm.ymlunchanged. - Document the user-visible fix in a changelog fragment.
| File | Description |
|---|---|
tests/unit/policy/test_trust_policy_discovery_errors.py |
Tests rejected-chain error handling and manifest preservation. |
src/apm_cli/policy/outcome_routing.py |
Uses the shared discovery-error tuple to catch inheritance failures. |
changelog.d/4947.fixed.md |
Records clearer errors for rejected policy inheritance chains. |
Review effort: Balanced
Daniel Meppiel (danielmeppiel)
deleted the
fix-4925-trust-policy-inheritance
branch
November 23, 2026 13:33
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 23, 2026
CI durations: main's file plus the train's parity-kit entries. Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
discover_trust_policycaught onlyOSError,ValueErrorandRuntimeError. APolicyInheritanceError(anextendscycle, a cross-hostextends, or chain depth over the limit) therefore escaped every executables-trust reader (apm installbundle preflight,apm approve, MCP admission and related readers) as a Python traceback.discover_trust_policynow catches the owner'sPOLICY_DISCOVERY_ERRORSand converts them withdiscovery_failure_result, the same pathapm audituses. A rejected chain routes as the existing always-blockincomplete_chainoutcome. Readers then print one named line,[x] Blocked by org policy: org policy inheritance chain is incomplete ..., exit non-zero and write nothing. No new routing path: the error tuple, the conversion and theincomplete_chainroute already exist inpolicy/outcome_routing.py.The printed hint
apm policy status --no-cachenames the underlying cause (for exampleCycle detected in policy extends chain: ...); this was checked by running it.Issue and approved scope
Issue: Fixes #4925
Human scope-approval comment: issue carries
status/accepted.Does this PR complete the issue, or what remains? Completes it.
Type of change
Testing
New module
tests/unit/policy/test_trust_policy_discovery_errors.py(component,P-OWN-policy-outcome-routing). Only discovery (the network boundary) is replaced.apm approve --recommendedwith a rejected chain -> exit 1, one[x]line, no traceback,apm.ymlunchangedValidation:
uv run --extra dev pytest -n 0 tests/unit/policy/test_trust_policy_discovery_errors.py: 1 passed (fails against main'soutcome_routing.py)uv run --extra dev pytest -n 4 tests/unit/policy/test_outcome_routing.py tests/unit/policy/test_trust_policy_discovery_errors.py tests/unit/commands/test_approve_deny.py tests/unit/test_audit_unresolved_policy.py: 163 passeduvx [email protected] check/format --check(changed files): passedpython scripts/check_test_assertions.py: clean;python scripts/lint_architecture_boundaries.py --root .: clean;python -m tests.quality.taxonomy --changed: cleanChangelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated