Repository navigation
fix(policy): route the org policy fetch-failure remedy through the remediation catalog - #4500
Merged
Daniel Meppiel (danielmeppiel) merged 1 commit intoNov 21, 2026
Merged
Conversation
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 20:00
…mediation catalog The fetch_failure_default=block refusal now renders its remedy from the policy-fetch-failure-blocked catalog entry (apm policy status), naming the org policy source when discovery reports one. Adds an executed proof in test_remediation_advice_lifecycle.py and a unit check on the routing owner. Fixes #4450 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
p-4450-policy-remedy-catalog
branch
from
November 20, 2026 20:00
110f23c to
18c6bb6
Compare
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A missing proof registration breaks a frozen-policy test, while brace-containing paths crash refusal handling, wording departs from approved scope, and lifecycle coverage misses key outcomes.
5 open issues
Register the lifecycle test in the frozen-policy proof inventories · New Preserve approved wording and pin it in an independent assertion · New Braces in bound policy paths trigger a false unresolved-placeholder error · New Test named-source refusal with a hermetic HTTP 503 failure · New Verify policy status JSON before retrying install · New
What changed in this PR
This PR addresses #4450 by moving the org-policy fetch-failure remedy into APM's shared remediation catalog, keeping advice centralized without changing the fail-closed decision.
Changes:
- Adds catalog-based
apm policy statusadvice that names the policy source when available and never suggests a bypass. - Updates unit and installed-CLI tests to check catalog-backed advice and exercise recovery.
- Adds a changelog entry for the user-visible message change.
| File | Description |
|---|---|
tests/unit/policy/test_pr_832_findings.py |
Checks catalog-backed block advice and absence of bypass guidance. |
tests/integration/test_remediation_advice_lifecycle.py |
Adds a blocked-install, policy-status, and retry recovery scenario. |
tests/integration/test_mcp_policy_block_reason_lifecycle.py |
Replaces literal expected advice with the catalog sentence. |
src/apm_cli/policy/outcome_routing.py |
Renders the remedy through the catalog with an optional source. |
src/apm_cli/core/remediation.py |
Defines the policy fetch-failure remediation entry. |
CHANGELOG.md |
Records the updated policy-refusal advice. |
Review effort: Balanced
| # The way out of an org-enforced fail-closed block; never advertise a bypass. | ||
| # {source} binds to " (<source>)" when discovery named the source it tried, else "". | ||
| POLICY_FETCH_FAILURE_BLOCKED = _entry( | ||
| "policy-fetch-failure-blocked", |
Comment on lines
+1130
to
+1132
| "apm policy status", | ||
| "check that the org policy source{source} is reachable", | ||
| then="retry, or ask your org admin", |
| sentences.append(hint.rstrip(".")) | ||
| reason = ". ".join([*sentences, _FETCH_FAILURE_BLOCK_REMEDY]) | ||
| named = f" ({source})" if source != "unknown" else "" | ||
| remedy = POLICY_FETCH_FAILURE_BLOCKED.bind(source=named).sentence() |
Comment on lines
+1065
to
+1067
| with local_github_https_fixture( | ||
| tmp_path / "certs-unreachable", world.served_repositories() | ||
| ) as fx: |
Comment on lines
+1086
to
+1087
| advised = run(env, entry.argv()[1:], "remediation-run-policy-fetch-failure-blocked") | ||
| assert advised.returncode == 0, _result_evidence(advised) |
5 of 10 tasks
Daniel Meppiel (danielmeppiel)
deleted the
p-4450-policy-remedy-catalog
branch
November 21, 2026 05:24
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
The
policy.fetch_failure_default: blockrefusal printed a free-text remedy literal frompolicy/outcome_routing.py. It now renders from a newcore/remediation.pycatalog entry,policy-fetch-failure-blocked(commandapm policy status), so the single remediation owner holds it and an executed proof backs it.Check that the org policy source is reachable (apm policy status) and retry, or ask your org admin.Run 'apm policy status' to check that the org policy source (org:contoso/.github) is reachable, then retry, or ask your org admin.The source is named when discovery reports one. For outcomes that carry no source (
absent,no_git_remote), the source is omitted:Run 'apm policy status' to check that the org policy source is reachable, then retry, or ask your org admin.The advice never suggests--no-policy.Tests:
tests/integration/test_remediation_advice_lifecycle.py::test_policy_fetch_failure_remediation_clears_the_block: executed proof on the installed CLI. The install is blocked with no reachable org policy and prints the catalog sentence. The test then makes the source reachable, runs the advisedapm policy status(exit 0), and retries the install, which succeeds without the advice.tests/integration/test_mcp_policy_block_reason_lifecycle.py: asserts that the refusal ends with the catalog sentence instead of a hard-coded copy.tests/unit/policy/test_pr_832_findings.py: asserts that the routed block reason ends with the bound catalog sentence and contains no--no-policy.Issue and approved scope
Issue: Fixes #4450
Human scope-approval comment: #4450 (comment)
Does this PR complete the issue, or what remains? It completes the issue. One limitation: the source is named only when discovery reports one. The
absentandno_git_remoteoutcomes carry no source today, so their sentence omits it and keeps the same meaning.Type of change
Testing
Validation evidence (each run alone through the host load guard; full suites not run locally, so CI covers them):
APM_E2E_TESTS=1 APM_BINARY_PATH=<wrapper running python -m apm_cli.cli from this tree> python -m pytest tests/integration/test_remediation_advice_lifecycle.py -k policy_fetch_failure -n 0: passed (1 passed)APM_E2E_TESTS=1 APM_BINARY_PATH=<same> python -m pytest tests/integration/test_mcp_policy_block_reason_lifecycle.py -n 0: passed (2 passed)python -m pytest tests/unit/policy/test_pr_832_findings.py -n 0: passed (15 passed)python scripts/lint_architecture_boundaries.py --root <worktree>: passed (exit 0)uvx -q [email protected] check <5 changed .py files>: passeduvx -q [email protected] format --check <5 changed .py files>: passedChangelog
## [Unreleased]inCHANGELOG.md:user-visible effect first, 25 words or fewer, ending with
(#PR);breaking changes only under upgrade notes; no Highlights; see
.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
If this PR changes behaviour that an OpenAPM v0.1
req-XXXcovers,confirm the three-step ritual in the
development guide:
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.