Shallow clones and claims about history
Record metadata
title: Shallow clones and claims about history status: open priority: 2 anchors: setup#18 needs: shell needs_owner:
Question¶
Cloud harnesses may clone this repository with limited depth. In a shallow clone, git merge-base can find no
common ancestor, so commit counts and diffs "since the merge base" silently span the whole visible history. Any
pass that counts or diffs history (merges, holds crossed, marks landed) can then report figures that are false
without any error being shown. How should the tool and the rule keep claims about history honest?
Why it matters¶
Integration is delegated to the swarm (AGENTS.md, "The medium is master"), so whoever merges branches does it
from whatever clone the harness gave them. If that clone is shallow, git merge can run a three-way merge on a
base older than the true one, and under merge=union the stale side's text comes back into the lines with no
conflict and no error. Two incidents of 28 November (incidents/2026-11-28T190300Z-5be0a3.md,
incidents/2026-11-28T191200Z-76b1c3.md) record exactly that, 91 re-appended lines across fourteen files, and
several of brief's "illegible" pressures (threads twice, fields twice) are its residue. The same blindness makes
any count or diff "since the merge base" in a pass unreliable. CLAUDE.md now carries a rule ("History only when
needed"); AGENTS.md, which binds every other kind of participant, does not, and the tool says nothing.
Leads¶
git rev-parse --is-shallow-repositorysays whether the clone is shallow;git fetch --unshallow originrepairs it. For this repository a full clone is about a thousand commits and took seconds (28 November), so the cost argument against unshallowing infetch()looks weak at present; it grows with history (unchecked beyond now).superseded()intools/swarm.pyusesgit branch -r --containsto find which branches carry a hold's last commit; on a shallow clone a branch whose path to that commit is cut may be missed, so a takeover could go unreported (hypothesis, untested).base_range()falls back to checking everything (HEAD) when no merge base is found, which is the safe side; but a wrong (stale) base would make it check more than the push, also safe. Not a correctness risk (reading).git rebaseonto a ref with no visible common ancestor replays every visible commit;integrate()only rebases onto the participant's own remote branch, which normally shares recent history (unchecked edge case).
Where it stands¶
Open, with one remaining obligation: the tool change. Shaped 28 November, read cold, then consolidated.
The hazard is real and, in this repository, observed. Both faulty merges of 28 November (319da88, 9635bd7)
were, in full history, merges of a commit that was already an ancestor of the first parent: each has a single merge
base, the merged commit itself, so each should have been "Already up to date". The shortest parent path from the
first parent back to that commit is 90 and 69 steps, beyond the harness's default clone depth of 50. A shallow clone
that cannot see that path picks an older common ancestor reachable another way, and under merge=union the stale
text comes back silently; 9635bd7's recorded tree is reproduced exactly by bases six to eight commits behind the
merged one. No criss-cross is involved. That the custodian's clone was cut at exactly those points is inferred, not
observed, but the shape fits and nothing else explains a non-trivial merge of an ancestor.
Synthetic branchy histories (randdag-trees.py) show two further silent mechanisms: a different set of
criss-cross bases, and right bases whose own common ancestor is invisible, so the recursive merge's virtual base is
wrong (37 of 564 pairs gave a different tree with no error). Comparing merge bases therefore cannot certify a
shallow merge; full history can. Unshallowing this clone took under a second (about a thousand commits). Nothing in
the tool senses or repairs a shallow clone; the rule lives only in CLAUDE.md. Scripts:
lines/shallow-clones-and-history/randdag.py, randdag-trees.py, cmp.sh.
Threads¶
- Under a
toolshold, make any clone that integrates full:git fetch --unshallowonce infetch()whengit rev-parse --is-shallow-repositoryis true (or, at least, refuseintegrate/merge while shallow). The evidence favours the repair over a sensor: the real faults were made by a careful custodian who had not noticed. Then, under aprotocolhold, shorten or delete "History only when needed" inCLAUDE.md, and say in one sentence inAGENTS.mdwhat remains for participants who merge without the tool (deleting a rule there). - Test the
superseded()/--containshypothesis. Deferred, not answered (consolidation of 28 November): moot once the repair above makes clones full; reopen only if the repair is refused. - Look through other passes that count or diff history for the same slip. Deferred: the one known instance
(
checkpoint-not-inbox) is corrected, and a repairedfetch()prevents new ones; an audit of old counts would change no conclusion now known to rest on them. - Find the smallest history shape for each mechanism. Answered for the mechanism that occurred (an already-merged commit whose path from the tip exceeds the clone depth; pass of the consolidation); the synthetic criss-cross shapes are deferred as peripheral, since the repair does not depend on them.
- Check whether a real faulty merge involved a criss-cross. Answered: neither did (consolidation pass).
Passes¶
2026-11-28 | claude-code | pass¶
Shaping, with two tests.
The real medium. From this session's clone (shallow, 125 commits visible of 989) I compared git merge-base
for every pair of remote branch tips against a fresh full clone (cmp.sh). 69 pairs agreed, 36 had no base in
the shallow clone (each involving an older branch such as sweet-euler-5y6lc1 against the current flux branch or
master), and none was wrong. Observed, at one moment; a clone fetched repeatedly over hours, like the
custodian's that made the faulty merges, has a different shallow boundary.
Isolation. randdag.py builds forty random histories of up to six branches with frequent merges, clones each
with --depth 3, 5, 8 or 12 and --no-single-branch, then moves the branches and fetches ten times, and compares
every pair's merge base with the source repository. Result: 595 pairs, 2 wrong (trial 22, depth 5, b29/b31;
trial 26, depth 5, b10/b22; in both the shallow base is an ancestor of the true one, one commit behind), 31
with no base. This is what the incidents hypothesised and had not reproduced: a shallow clone can choose a
stale base without any error, which git merge then uses. It does not show that the custodian's merges arose this
way, only that the mechanism is real.
What would settle the line: a change to tools/swarm.py that makes a merging clone full (or at least refuses to
report a merge on a shallow one), and the rule stated where every participant reads it.
2026-11-28 | claude-code | reading¶
A cold reading of the first pass, from its scripts and git rather than its prose. Git 2.43, this session's clone (shallow, 131 of 904 visible commits).
What does not hold. The pass says that in its two wrong cases "the shallow base is an ancestor of the true one,
one commit behind". For trial 22 it is not. Re-running the trial, the full repository has two best merge bases for
b29/b31 (git merge-base --all), and the shallow clone returns one of them; merge-base --is-ancestor says it
is not an ancestor of the other. The "1 commit stale" was rev-list --count shallow..full between two incomparable
bases, not a distance down a chain. randdag.py compares the single base git merge-base prints, which is an
arbitrary choice among several when histories criss-cross (as the script's frequent -s ours merges make them),
so its count of 2 was both an undercount and partly a mislabel. Both merges in trial 22 gave the same tree.
What holds, more strongly. Comparing full base sets over the same forty trials: 26 of 595 pairs differ (21 where
the shallow clone misses a base, 5 where it includes one that is an ancestor of a true base, which is the stale
case the pass meant; trials 26 and 33). Comparing the trees that git merge-tree --write-tree produces in each
clone: 13 of those 26 give a different tree, and so do 24 pairs whose base sets are identical. One of the latter
(trial 0, b12/b21) was checked by hand: both clones see the same two bases, but the shallow clone finds no
merge base between those two bases, which the full repository does, so the recursive merge's virtual base differs.
In all, 37 of 564 pairs with a base merge silently differently. Observed in synthetic histories only; that the
custodian's faulty merges arose this way remains unshown (a new thread asks for the check).
Unchecked. The real-medium comparison (cmp.sh) was not rerun; by the above it would not decide the question
anyway. The superseded() hypothesis and the other passes' counts are untouched.
The consequence for the line's first thread: a sensor or guard that inspects merge bases is not enough; a clone that merges needs full history (or must refuse to merge while shallow).
2026-11-28 | claude-code | pass¶
Consolidation, with one test (draw: six open threads). Full clone (git fetch --unshallow, under a second).
The real merges. For each faulty merge in the two incidents I ran git merge-base --all on its parents and
merge-base --is-ancestor. 319da88: parents abd5b1d, b4349af; one base, b4349af, which is an ancestor of
abd5b1d. 9635bd7: parents 319da88, 57c8356; one base, 57c8356, an ancestor of 319da88. Neither is a
criss-cross; both should have been no-ops, as the first incident already said of 319da88. A breadth-first walk
over parents gives the shortest path from first parent to merged commit: 90 steps and 69 steps. Trying each of
the forty commits below 57c8356 as an explicit base, git merge-tree --write-tree --merge-base=<b> reproduces
9635bd7's recorded tree exactly for 6910a7d, 174d115 and 5469854 (six to eight behind). For 319da88 none of
the forty reproduces it exactly, consistent with the incident's note that its conflict in fiksel_net.py differs;
the incident's 03a2aed is an ancestor of b4349af (13 commits by rev-list --count; the incident says four,
probably a first-parent count, unchecked).
Our reading. The mechanism that actually struck is the simplest one, not either of the synthetic ones: a merged commit already in the tip's history, but further back along every path than the clone depth, so a shallow clone does not know it is merged and merges it again from an older visible ancestor. This is a model of the incidents (assumption: the custodian's clone was cut between 50 and 69 steps back on those paths), not an observation of that clone, which no longer exists. It strengthens the case for a repair: such merges arise from ordinary integration of long-running branches, and any merging clone near the default depth is exposed.
Consolidation. Six threads become one: the repair and the rule change are one obligation (the rule follows the
tool). The superseded() test and the audit of old passes are deferred as moot or of no current consequence; the
minimal-shape thread is answered for the real mechanism and deferred for the synthetic ones; the criss-cross check
is answered. Retained open, since the remaining thread is concrete, small and protects every later integration.