From 48b4fb156b6f5cf1333b6891a3819a65f940cbee Mon Sep 17 00:00:00 2001 From: Kaloyan Naumov Date: Wed, 2 Dec 2026 09:44:39 +0000 Subject: [PATCH 1/2] code: a checkout fetch from a shallow mirror records refs/loom/scip-head A mirror cloned from a remote that serves truncated history is shallow. A fetch from it into a compiler-tier checkout warns "rejected refs/loom/scip-head because shallow roots are not allowed to be updated", exits 0 and records no ref, so every later fetch has nothing to negotiate from and sends the whole pack again. `--update-shallow` lets the checkout take the mirror's shallow roots; against a full mirror it changes nothing. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Kaloyan Naumov --- server/code/app/index/compiler_tier.py | 5 +++- tests/unit/test_scip_checkout_fetch_ref.py | 30 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/server/code/app/index/compiler_tier.py b/server/code/app/index/compiler_tier.py index f20d34651b9..0b030e796fe 100644 --- a/server/code/app/index/compiler_tier.py +++ b/server/code/app/index/compiler_tier.py @@ -623,10 +623,13 @@ def resolve_binary(configured: str) -> Path: def checkout_fetch_args(bare: Path | str, target: str) -> list[str]: """`git` arguments that fetch `target` from the local bare clone into a checkout: no submodule recursion, and the commit recorded on - `SCIP_HEAD_REF` so the next fetch sends only what is new.""" + `SCIP_HEAD_REF` so the next fetch sends only what is new. A mirror of a remote + that serves truncated history is shallow, and without `--update-shallow` git + drops the ref and still exits 0.""" return [ "fetch", "--recurse-submodules=no", + "--update-shallow", *upload_pack_args(str(bare)), str(bare), f"+{target}:{SCIP_HEAD_REF}", diff --git a/tests/unit/test_scip_checkout_fetch_ref.py b/tests/unit/test_scip_checkout_fetch_ref.py index 6bfe1c98c45..d3888917ffd 100644 --- a/tests/unit/test_scip_checkout_fetch_ref.py +++ b/tests/unit/test_scip_checkout_fetch_ref.py @@ -134,3 +134,33 @@ async def test_a_local_remote_another_uid_owns_is_read(tmp_path: Path, monkeypat ) heads = await gitrepo.remote_branches(str(checkout / ".git"), str(bare)) assert heads["master"] == target + + +def _shallow_mirror(tmp_path: Path) -> tuple[Path, Path, Path]: + """(source, mirror, empty checkout) for a remote that serves only its last two + commits: the mirror, cloned from it without a depth as the bootstrap clones, is + shallow too.""" + src = tmp_path / "src" + src.mkdir() + _git(src, "init", "-q", "-b", "master") + _commits(src, 5, "base") + remote = tmp_path / "remote.git" + _git(tmp_path, "clone", "-q", "--bare", "--depth", "2", f"file://{src}", str(remote)) + mirror = tmp_path / "mirror.git" + _git(tmp_path, "clone", "-q", "--bare", "--no-local", str(remote), str(mirror)) + assert _git(mirror, "rev-parse", "--is-shallow-repository") == "true" + checkout = tmp_path / "checkout" + _git(tmp_path, "init", "-q", str(checkout)) + return src, mirror, checkout + + +def test_a_fetch_from_a_shallow_mirror_lands_on_the_ref(tmp_path: Path) -> None: + src, mirror, checkout = _shallow_mirror(tmp_path) + first = _git(mirror, "rev-parse", "master") + _git(checkout, *checkout_fetch_args(mirror, first)) + assert _git(checkout, "rev-parse", SCIP_HEAD_REF) == first + + second = _commits(src, 2, "next") + _git(src, "push", "-q", str(mirror), "master") + _git(checkout, *checkout_fetch_args(mirror, second)) + assert _git(checkout, "rev-parse", SCIP_HEAD_REF) == second From 609dbce36933e3c315dc6697a24033d6a3e3a4ee Mon Sep 17 00:00:00 2001 From: Kaloyan Naumov Date: Wed, 2 Dec 2026 09:53:48 +0000 Subject: [PATCH 2/2] Test that the next fetch from a shallow mirror sends only new objects The shallow-mirror test checked that the ref was written but not what the ref is for. After two new commits the second fetch must send about three objects per commit, as in the full-mirror test, not the history. Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Kaloyan Naumov --- tests/unit/test_scip_checkout_fetch_ref.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_scip_checkout_fetch_ref.py b/tests/unit/test_scip_checkout_fetch_ref.py index d3888917ffd..0a275f8c199 100644 --- a/tests/unit/test_scip_checkout_fetch_ref.py +++ b/tests/unit/test_scip_checkout_fetch_ref.py @@ -162,5 +162,6 @@ def test_a_fetch_from_a_shallow_mirror_lands_on_the_ref(tmp_path: Path) -> None: second = _commits(src, 2, "next") _git(src, "push", "-q", str(mirror), "master") - _git(checkout, *checkout_fetch_args(mirror, second)) + got = _received(checkout, checkout_fetch_args(mirror, second)) assert _git(checkout, "rev-parse", SCIP_HEAD_REF) == second + assert got <= 2 * 3 # two commits: commit + tree + blob each, not the history