Repository navigation
fix(policy): an unreachable earlier candidate no longer hides the cached org policy (#4456) - #4464
Merged
Daniel Meppiel (danielmeppiel) merged 719 commits intoNov 21, 2026
Conversation
Co-authored-by: Copilot App <[email protected]>
…pack line Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
…ns; name every credential tried Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/core/auth.py # src/apm_cli/marketplace/version_pins.py # tests/fixtures/lifecycle_bug_ledger.json
…oject and user scope Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…er match without a local receipt; cleanup retains files the install kept Co-authored-by: Copilot App <[email protected]>
…eny refusal Co-authored-by: Copilot App <[email protected]>
The pre-download frozen MCP check stays silent (the hydrated check and the MCP phase report parked servers); the commit gate does not repeat the org policy discovery notice. An install refuses a symlinked lockfile only when it adds or removes a dependency or updates refs, so an unchanged install still reads through it. 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]>
Register update's provenance re-verification write as a commit site of the lockfile write authority, and name the install-writes-lockfile decision in one helper the preflight guard reads. 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]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…touched (#4318) apm update refreshes apm.yml dependencies only. With a local bundle installed it now names the bundle (from its hook ownership markers and compile staging slugs, else its file count) and gives the runnable next step: apm install <newer-bundle-file>. The lifecycle generator's strict cell rule|U8|update-leaves-a-local-bundle-untouched becomes required. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…/apm into danielmeppiel-p4-from-p3local
… writing `apm install --frozen --global` now checks each locked native plugin root against its recorded fingerprint in the frozen hash verification, before any write. A mismatch exits 1 naming the plugin, the expected and observed digests and `apm install --global`, as `apm audit --ci` reports it; nothing is written. A plain install that restores a changed root prints a [!] line. The lifecycle I1 oracle treats a path under a native_plugin root as recorded only when the same lock records that root, the observation is user scope and the tree carries the record's fingerprint. Four gate cells become required; six org-policy cells stay strict under #3703. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…; strict known cell for step 5 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…n, not a fixed column count (#4409) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
… not the patch (#4409) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…er match without a local receipt; cleanup retains files the install kept Co-authored-by: Copilot App <[email protected]>
…run on Windows Co-authored-by: Copilot App <[email protected]>
…configured width Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…verified-copy-4389
…n stderr (#4224) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…; one row re-keyed to #4443 Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
… on a terminal and honors NO_COLOR Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json # tests/utils/lifecycle_evidence.py
…fusals as [x] errors Co-authored-by: Copilot App <[email protected]> # Conflicts: # src/apm_cli/commands/update.py # tests/lifecycle/generator/rules.py
…_status (#4053) Co-authored-by: Copilot App <[email protected]>
…acts module tests/quality/test_generated_obligations.py is not in any CI job's file list; test_promise_obligations.py runs in Architecture Ratchet Contracts. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
native.py keeps every strict cell still failing on the merged tree: the re-keyed #4444/#4445/#4446/#4447 rows and the train #3703 native-plugin rows; the #4154 and #4225 cells whose fixes are in are dropped (35 native rows: 23 pass, 12 strict xfail). Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/lifecycle/machines/test_m_source.py # tests/lifecycle/security/gate_slices/bin.py
Replaces the remaining issue-less strict reasons with the open issue that tracks each defect. No cell is relaxed, skipped or removed. Co-authored-by: Copilot App <[email protected]>
…ble next step Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
…nt promise ids Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/quality/generated_obligations.json
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 18:33
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The witness catalog still exempts fixed stale-cache cells from required receipt coverage and references #4456 instead of #4458 for the update cell, causing the freshness check to fail.
1 open issue
What changed in this PR
This PR fixes organization-policy discovery so an unreachable earlier GitHub candidate does not hide a usable policy cached from a later candidate, addressing #4456.
Changes:
- Adds cache fallback for connection errors and timeouts while preserving fail-closed handling for authentication errors.
- Promotes stale-cache lifecycle cases to required regressions, retaining the update short-circuit failure under #4458.
- Documents offline behavior and carries forward issue-linked expected-failure reasons from #4461.
| File | Description |
|---|---|
tests/unit/policy/test_discovery.py |
Adds offline fallback and authentication-error regression tests. |
tests/spec_conformance/test_security_behavior_reqs.py |
Links expected failures to tracking issues. |
tests/quality/generated_obligations.json |
Updates generated witness and known-failure mappings. |
tests/lifecycle/security/test_policy_outcomes.py |
Requires fixed stale-cache cases and reassigns the update failure. |
tests/lifecycle/security/test_origin_and_credentials.py |
Links the provenance failure to #4228. |
tests/lifecycle/security/test_integrity.py |
Links integrity failures to tracking issues. |
tests/lifecycle/security/gate_slices/native.py |
Links the uninstall failure to #4446. |
tests/lifecycle/security/gate_slices/mcp.py |
Adds issue-linked MCP failure reasons. |
tests/lifecycle/security/gate_slices/lsp.py |
Adds issue-linked LSP failure reasons. |
tests/lifecycle/security/gate_slices/hook.py |
Adds issue-linked hook failure reasons. |
tests/lifecycle/security/gate_slices/bin.py |
Links the dry-run failure to #4454. |
tests/lifecycle/security/gate_slices/__init__.py |
Updates the expected-failure format comment. |
tests/lifecycle/security/egress_slices/__init__.py |
Updates the expected-failure format comment. |
tests/fixtures/lifecycle_bug_ledger.json |
Records #4456 and its regression coverage. |
src/apm_cli/policy/discovery.py |
Invokes cached-candidate fallback after transport failures. |
src/apm_cli/policy/_cached_candidates.py |
Selects a usable lower-precedence cached policy. |
docs/src/content/docs/reference/policy-schema.md |
Documents offline fallback and authentication-error behavior. |
CHANGELOG.md |
Records the user-visible offline policy fix. |
Review effort: Balanced
Comment on lines
+1083
to
+1086
| "P|install-pipeline|cache=stale<7d": "#4456", | ||
| "P|lifecycle-scripts|cache=stale<7d": "#4456", | ||
| "P|mcp-admission(trust.py)|cache=stale<7d": "#4456", | ||
| "P|mcp-install-preflight|cache=stale<7d": "#4456", |
…ng-rekey # Conflicts: # tests/lifecycle/security/gate_slices/bin.py # tests/lifecycle/security/gate_slices/hook.py # tests/lifecycle/security/gate_slices/mcp.py # tests/lifecycle/security/gate_slices/native.py # tests/quality/generated_obligations.json # tests/spec_conformance/test_security_behavior_reqs.py
…hed org policy (#4456) Offline, discovery tried .github-private first, failed to connect and returned cache_miss_fetch_fail before reaching .github, whose policy was cached (fresh, or stale within 7 days). Install, MCP install, lifecycle scripts and dry-run then ran without the policy. On a transport failure the cascade now serves the first lower-precedence candidate's cache entry, as that candidate's own refresh failure does (cached_stale when past TTL). Auth and other errors still fail closed. The cache=stale<7d site rows flip to required; update's row moves to the and CHANGELOG added. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Steward fold: the cascade fell through to ANY lower candidate's cache when a higher candidate was unreachable, which could downgrade a private .github-private policy to a public .github one. A fresh resolution now records its source and the candidates absent (404) above it. Offline, the cascade falls through only when that record proves the unreachable candidate was absent and names the lower source; otherwise the failure stands (block fails closed). Negative test added. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5 of 10 tasks
…iscovery (#4456) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-stale-cache-policy-4456
branch
from
November 20, 2026 18:51
63299f3 to
5b1c18b
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…onger hides the cached org policy (#4456) Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
6 of 10 tasks
…t the cache bytes The three #4456 discovery cells patched discovery's own _fetch_github_contents and asserted only on return values (AQ004, AQ003 over the baseline). They now fake only HTTP (policy_get) and credentials (AuthResolver.try_with_fallback), so the real fetch and error mapping run, and assert the cache files on disk are unchanged by the offline or denied refresh. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…4464/#4490/#4494/#4498 Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-stale-cache-policy-4456
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
When the org policy cache was stale but under 7 days old and refresh failed (offline), discovery tried
<org>/.github-privatefirst. It failed to connect and returnedcache_miss_fetch_failbefore reaching<org>/.github, whose policy was cached. Install, MCP-only install, lifecycle scripts and dry-run preflight then ran without the policy ("proceeding without policy enforcement").The fix is at the discovery owner (
policy/discovery.py_auto_discover, with a helper inpolicy/_cached_candidates.py). On a transport failure (connection error or timeout) of a GitHub/GHE candidate, the cascade serves the first lower-precedence candidate's cache entry:MAX_STALE_TTL(7 days) is served ascached_stalewith the fetch error, which is exactly what that candidate's own refresh failure gives. The output then says the policy is stale.Absent candidates (404) are not cached, so a cached
.githubpolicy means.github-privatewas absent when it was cached. Auth and other errors (401/403, HTTP errors, malformed) still fail closed, because a newly readable-but-denied private repo may hold a stricter policy. TTL and cache-pin verification are out of scope (#4218 / #4315).Stacked on #4461 (the S-lead re-key of these cells to #4456); the diff shrinks once it lands.
Issue and approved scope
Issue: Fixes #4456
Human scope-approval comment: apm-scope:v1 record on #4456 (status/accepted, milestone 0.37.0)
Does this PR complete the issue, or what remains? It completes it. The
cache=stale<7drows for install-pipeline, mcp-install-preflight, lifecycle-scripts, bundle-allow-map, install-dry-run-preflight, audit-ci, approve, policy-status, mcp-admission, bundle-install-preflight and the exec-map rows are now required.update-regate-shortcircuit|cache=stale<7dnow behaves exactly like its fresh-cache row, so it carries the same #4458 short-circuit xfail.Type of change
Testing
Tested locally (targeted)
All existing tests pass (pending CI)
Added tests for new functionality (if applicable)
tests/lifecycle/security/test_policy_outcomes.py: all 13cache=stale<7dcells were run locally. 12 pass and 1 is an xfail tied to apm update with nothing to change exits 0 when org policy is unavailable under block #4458 (with--runxfailbefore the re-key: 12 passed, update failed exactly like its fresh row)._OFFLINEis deleted.tests/unit/policy/test_discovery.py: newtest_unreachable_github_private_serves_the_stale_github_cachefails before the fix and passes after;test_github_private_auth_error_fails_closed_despite_a_cached_githubkeeps auth errors fail-closed. All 328 discovery unit tests pass.tests/quality/test_lifecycle_bug_ledger.pypasses, with the new org policy cached under 7 days is not applied the same way as a fresh one #4456 row.Arch linter, complexity ratchet and ruff are clean.
discovery.pyis at 2090 lines (limit 2100).Changelog
## [Unreleased]inCHANGELOG.md(Fixed).Spec conformance (OpenAPM v0.1)