Skip to content

A superproject gitlink must name a commit on the submodule's main — three legs today pinned shas that can never exist there #301

Closed

Description

@atrawog

Three superproject legs in one day pinned a submodule at a sha that could never appear on that submodule's main. Two were caught before merging; the pattern is consistent enough to be a rule rather than three PR comments.

Why a PR head can never be a valid pin

The landing sequence guarantees it:

author pushes            <head A>
pr-validator PASSES, then finalizes the CalVer by ADDING a commit   -> <head B>
squash-merge produces a third sha                                   -> <merge C>
branch deleted

Only C is ever on main. A and B survive solely under refs/pull/<N>/head, and only while the PR exists. So pinning any sha observed on an open PR names a commit that will be reachable from no branch, permanently.

This is the same mechanism as the already-known trap that "after a validator passes, the sha you last pushed is not the sha that merged" — pointed at gitlinks instead of at status queries.

The three instances

leg pinned what it was caught
charly#296 plugins@4d63f91b plugins#195's then-current head, unmerged before merge
charly#297 plugins@84cd062e a superseded head of plugins#200 — that PR had pushed since open now
charly#289 re-derived from plugins/main at every staging step — n/a — the correct behaviour

#297's is the instructive one: the sha was not on main, and not even the PR's current tip. A git submodule update there fails for anyone who has not fetched that PR ref.

The rule

A superproject gitlink may only name a commit reachable from the submodule's main. Re-derive it from origin/main at the moment you stage the bump — never from an earlier reading, and never from a sha observed on an open PR.

charly#289 had its pins invalidated five times in one evening by other chains landing, and every invalidation was a non-event, because it re-derived at staging every time. The cost of the discipline was zero; the cost of skipping it is a dangling pin in a merge commit.

Distinguish stale from dangling — the remedy is the same, the urgency is not

STALE     the pin is an ancestor of the submodule's main. A clone works today; it merely lags.
DANGLING  the pin is not reachable from main. A clone FAILS.

git -C <sub> merge-base --is-ancestor <pin> origin/main separates them in one command. Reporting a stale pin as gone sends someone after a recovery procedure they do not need — and an over-alarming report costs more than the wasted procedure, because the next accurate alarm is discounted.

A cheap mechanical guard

The defect is invisible in review: a 40-hex sha in a gitlink looks identical whether or not it is reachable. A pre-merge check that runs merge-base --is-ancestor <pinned> <submodule origin/main> for each changed gitlink would catch all three instances, and it needs no judgement — the same argument as every other guard this codebase has adopted after paying for it repeatedly.

Related: #294 (a check reading a path where the committed object is meant — same family: the artifact you can reach is not the artifact you ship).

Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)

Activity

  1. atrawog commented on Aug 18, 2026

    @atrawog
    ContributorAuthor

    A fourth instance, live right now: charly#297

    charly#297 pins plugins@c7b6cc38. Measured:

    c7b6cc38  "Merge remote-tracking branch 'origin/main' into feat/kube-host-generated-disambiguation"
      ancestor of plugins/main : NO
      reachable from           : origin/feat/kube-host-generated-disambiguation  (only)
    
    a9a94e4b  plugins#200's squash-merge
      ancestor of plugins/main : YES
    

    c7b6cc38 is a merge commit on plugins#200's feature branch. It was never on plugins/main and never could be — the squash-merge minted a9a94e4b instead. So #297 pinned an unmerged PR's branch head, and the squash orphaned it. Exactly the shape this issue names.

    Remedy for that PR: re-pin to a9a94e4b, or the tag v2026.230.1151.

    One precision worth adding to this issue's model, because it changes the detection story. A fresh validator described the pin as "superseded and now unreachable from any branch (feat branch deleted on merge)". That is not the current state — origin/feat/kube-host-generated-disambiguation still exists, so the pin still resolves. A clone succeeds. The defect is not that it dangles; it is that it names a commit off main, which is this issue's actual criterion.

    That distinction matters for how the class gets caught: a dangling pin fails loudly at fetch time, while a pin that resolves to a live feature branch is silent — everything clones, everything builds, and the superproject is simply pointing at work that was never merged. If the branch is later deleted, the same pin becomes a hard failure with no code change in between. So the observable symptom depends on someone else's branch-cleanup timing rather than on the defect.

    This one is also load-bearing for a chain right now. charly#289's gate cannot go green until #297 merges, so this pin is holding a second PR indirectly. Not an argument for lowering the bar on #297 — its validator raised two further blocking findings — but worth recording that the cost of this defect class is not confined to the PR that carries it.

    Detection suggestion, offered rather than prescribed: the check this issue implies is git -C <submodule> merge-base --is-ancestor <pin> origin/main, which distinguishes correctly in both cases above and does not care whether the branch still exists.

    Assisted-by: Claude Code Anthropic Claude Opus 5 (analysed on a live system)

  2. atrawog commented on Aug 28, 2026

    @atrawog
    ContributorAuthor

    Validation (2026-08-28) — RESOLVED

    Verified against current repos. The rule was codified: marketplace/internals/skills/git-workflow/references/branch-and-pr-loop.md:115 now reads "Before merging a superproject leg, verify every gitlink is an ANCESTOR of its own repo's..." — the pattern is a rule, not three PR comments. Current superproject pins are all valid (each submodule at a main-head commit).

    Closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions