Skip to content

fix: restore the pinned policy invariants path fallback - #24

Merged
loadinglucian merged 1 commit into
mainfrom
fix/restore-pinned-invariants-fallback
Aug 2, 2026
Merged

fix: restore the pinned policy invariants path fallback#24
loadinglucian merged 1 commit into
mainfrom
fix/restore-pinned-invariants-fallback

Conversation

@loadinglucian

@loadinglucian loadinglucian commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

PR #23 removed the policy invariants path fallback on the understanding that it was dead code. It was not, and the consumer workflow failed on main straight after the merge:

autorelease consumer rejected input: policy capture path is not published:
https://raw.githubusercontent.com/bigpixelrocket/php-bin/2a9a100c701c3e1e769e8cab47e8c3af61e52d89/autorelease/policy-invariants.json

Policy captures do not read php-bin main. POLICY_COMMIT_SELECTOR_URL selects the most recent commit that touched support-policy.json, and the capture pins to that exact commit so the policy and its invariants always come from one reviewed state. That commit is still 2a9a100c from 2026-07-27, which predates the maintenance to autorelease rename, so the invariants it publishes are at maintenance/policy-invariants.json. The rename never touched support-policy.json, so the selector never moved forward.

This restores fetch_first_url and the two pinned invariants URLs. Behavior is identical to the state before #23. The only substantive change is the docstring, which now records the real condition for removing the fallback: a commit that touches support-policy.json landing after the rename, rather than php-bin main merging its rename, which already happened.

The two operator control fallbacks that #23 also removed stay removed. Both read at php-bin main's tip, so they were genuinely unreachable.

Summary by CodeRabbit

  • Bug Fixes
    • Improved retrieval of policy information when the primary location is unavailable.
    • Added fallback support for legacy policy locations, helping releases continue when current paths return “not found” responses.
    • Preserved clear error handling for other retrieval failures.

@cursor

cursor Bot commented Aug 2, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_785f6b1d-428f-47a7-8ead-fb8c7e7a4e80)

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6371da26-b8dc-44b6-800d-8a4f91345033

📥 Commits

Reviewing files that changed from the base of the PR and between e796cc2 and c6f2649.

📒 Files selected for processing (2)
  • autorelease/consumer.py
  • test/test_autorelease.py

📝 Walkthrough

Walkthrough

The policy consumer now retrieves invariant captures from current and legacy commit-pinned paths. It falls back after HTTP 404 responses and propagates other capture errors. Tests cover URL selection, fallback, and error handling.

Changes

Policy invariant fallback

Layer / File(s) Summary
Ordered invariant URL retrieval
autorelease/consumer.py
pinned_policy_urls returns current and legacy invariant paths. fetch_first_url selects the first available capture and only falls back for 404 responses.
Fallback behavior tests
test/test_autorelease.py
Tests validate current-path selection, legacy-path fallback, rejection of unpinned references, and propagation of ConsumerError failures.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a detailed summary but omits the required Verification and Security sections from the template. Add the Verification and Security sections and record the applicable test and security checklist results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes restoring the pinned policy invariants path fallback.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/restore-pinned-invariants-fallback

Comment @coderabbitai help to get the list of available commands.

@loadinglucian
loadinglucian merged commit 26562c8 into main Aug 2, 2026
4 of 5 checks passed
@loadinglucian
loadinglucian deleted the fix/restore-pinned-invariants-fallback branch August 2, 2026 19:45
loadinglucian added a commit that referenced this pull request Aug 2, 2026
## Summary

PR #24 restored the invariants path fallback after it turned out to be
load-bearing, but left a docstring promising its removal once a commit
touching `support-policy.json` landed after the rename. That removal
condition is wrong, so this replaces it.

`support-policy.json` carries `policyInvariantsDigest`, and
`consumer.py` rejects a capture where the captured policy does not match
the captured invariants. The two documents only agree inside the tree
php-bin reviewed them in, which is exactly why the capture pins to the
commit that last changed the policy: at that commit php-bin's own
validation had just checked one against the other.

That makes the pin correct rather than under-specified, and rules out
the obvious alternatives:

- Pinning to whichever of the two documents changed last would pair new
invariants with a policy still carrying the previous digest, and the
capture would fail on every invariants-only change.
- Advancing the pin with a fresh `support-policy.json` commit would need
a real edit, but every field in that file is a semantic claim and its
digest already matches. There is no honest change to make, and an empty
commit is not one.

So the pinned commit can be arbitrarily old, and the invariants path is
whatever php-bin's layout was at the time. The two-URL list is permanent
compatibility with historical layouts rather than a pending cleanup, and
the next path move should extend it. The docstring now says that and
explains why the alternatives do not work, so the reasoning sits with
the code.

Docstring and one test comment only. No executable change.

## Verification

- [x] `scripts/test.sh`
- [x] Unsupported-target behavior remains explicit
- [x] Release selection and checksum behavior are covered by tests
- [x] The `php-bin` release contract remains compatible

`scripts/test.sh` passes locally at 9 tests plus the plugin contract,
and `Plugin contract` is green on this PR. The remaining three items are
unaffected by construction: the diff changes a docstring and a comment,
so no target check, release selection, checksum path, or contract
surface is touched. `git diff` on this branch is confined to the
docstring body in `fetch_first_url` and two comment lines in
`test/test_autorelease.py`.

## Security

- [x] Downloads still require an exact SHA-256 entry
- [x] No credentials, generated fixtures, or install directories are
committed

Both hold for the same reason: there is no executable change. The
checksum requirement lives in the install path, which this PR does not
touch, and the diff adds no files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant