fix(pin-gate): fail when a github pin names a sha unreachable from the default branch - #354
Merged
Merged
Conversation
…e default branch The gate compared versions only, so a pin that named an unmerged PR head read as current on every run. Cortex #351 pinned cortex-viz twice this way (ee0d41db, then 7e297ebc); both were `ahead` of main, and the squash-merge of #107 did orphan 7e297ebc — it now reports `diverged`. The marketplace would have kept serving a commit no branch reaches, with a green gate. New check PIN_SHA_UNREACHABLE: for any github source carrying a `sha`, require compare/{default_branch}...{sha} in {identical, behind}. `ahead` and `diverged` mean the pin carries commits the branch does not. Source for the status vocabulary: GitHub REST "Compare two commits" — status is exactly one of ahead / behind / identical / diverged. Degradation contract unchanged: an unresolvable repo or a network failure emits a NOTICE and exits 0, matching every other network leg of this gate. Proof: suite 26/26; mutation (REACHABLE_FROM_DEFAULT widened to accept ahead/diverged) fails exactly the 2 new tests; end-to-end against the live API — 7e297ebc FAIL `diverged`, 1c1940e2 PASS, absent sha FAIL; full gate on the real marketplace.json at b29dfce exits 0 with no false positive. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JMNwLEZS6SsrWMLwd1cQ6p
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.
The hole
The pin gate compared versions only. A pin that names an unmerged PR head reads as current on every run — the version is right, the commit is doomed.
This is not hypothetical. #351 pinned
cortex-vizat an unmerged PR head twice (ee0d41db, then7e297ebc). Both wereaheadof main. The squash-merge of cortex-viz#107 did orphan7e297ebc— it reportsdivergedtoday. The marketplace would have kept serving a commit no branch reaches, and this gate would have stayed green throughout.The check
PIN_SHA_UNREACHABLE— for any github source carrying asha, require:compare/BASE...HEADdescribes HEAD relative to BASE. With BASE = the default branch,identicalmeans the pin is the tip andbehindmeans it is an ancestor — both reachable.aheadanddivergedmean the pin carries commits the branch does not: an unmerged PR head, which stops being reachable the moment that PR is squash-merged.Status vocabulary source: GitHub REST — Compare two commits;
statusis exactly one of ahead / behind / identical / diverged.Degradation contract — unchanged
An unresolvable repo (404) or a network failure emits a
NOTICEand exits 0, matching every other network leg of this gate. A pin gate that hard-fails on a flaky API is a gate that gets disabled.Proof
REACHABLE_FROM_DEFAULTwidened to acceptahead/diverged7e297ebcFAILdiverged·1c1940e2PASS · absent sha FAILmarketplace.json@b29dfce0ruff(PLR2004 + E501 blocking)Diff is 159 insertions, 0 deletions — no existing behaviour altered.
Note on the automatised-pipeline mirror
The docstring's byte-identical claim holds. AP's
canonical-driftjob ran green on the last cron (2026-08-03 09:26Z); the current one-hunk divergence was introduced by the merge of #351 itself (b29dfce0, 2026-08-04 06:06Z) and the next cron would have caught it. AP must be re-synced frommainafter this merges — one resync, not two. The change is functionally inert there (AP declares a single plugin with source"./", no github source, no sha), but the byte-identity contract requires it.