Skip to content

A checkout fetch from a shallow mirror records its head - #2017

Merged
zlareb1 merged 2 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/code-checkout-shallow-mirror
Dec 2, 2026
Merged

zlareb1 merged 2 commits into
ClickHouse:mainfrom
KaloyanNaumov:pr/code-checkout-shallow-mirror

Conversation

@KaloyanNaumov

@KaloyanNaumov KaloyanNaumov commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #2016

TL;DR: A compiler-tier checkout fetch from a shallow mirror dropped refs/loom/scip-head with a warning and exit 0, so every pass fetched the whole pack again. checkout_fetch_args now passes --update-shallow, and the fetch records the ref; against a full mirror the flag changes nothing.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in a release)

Changelog entry (one or two sentences a user of Loom can read without the diff; the release pull request collects these into the release notes):

The compiler tiers record their checkout's fetched head when the repository's remote serves truncated (shallow) history, so later passes fetch only new commits instead of the whole pack.

Why

clone_mirror clones without a depth, but a remote that serves truncated history makes the mirror shallow anyway. The checkout fetch then has to add shallow roots to a checkout that has none, and git fetch refuses that ref update unless it gets --update-shallow: it prints rejected refs/loom/scip-head because shallow roots are not allowed to be updated and exits 0. compiler_tier.git only sees the exit code, so the pass continues with no ref recorded, and the next fetch has nothing to negotiate from. On a 13.7 GB pack that is a full transfer per pass. --update-shallow lets the checkout take the mirror's shallow roots, which is the history the mirror holds.

Scope and risk

One argument in checkout_fetch_args, which all five checkout fetches use (scip_delta, scip_go_delta, scip_ts_delta, scip_py_delta, scip_full.move_checkout). It is inserted after --recurse-submodules=no, so the workers' tests that check the leading arguments are unchanged.

  • Full mirror: git writes no shallow file and the fetch behaves as before.
  • Shallow mirror: the checkout takes the mirror's shallow roots, so a history walk in the checkout stops there. The tiers only diff two commits and test that the base exists, which work across the roots. A harness that diffs a window whose base lies before the cut-off already fails today, because the mirror lacks that commit too.
  • Left alone: clone_mirror (a shallow mirror is what the remote serves), the 600 s limit on the delta workers' fetch (Delta workers fetch the compiler-tier checkout under a hard-coded 600 s limit #2012, PR Delta workers fetch the compiler-tier checkout under code_git_fetch_timeout_s #2013), and the checkout's git checkout --force. No check was added for a ref missing after a fetch that exits 0: with this flag the shallow-root refusal is the only cause of that state that this fetch can meet.

Compatibility, rollout and rollback

  • Wire: none.
  • Operator steps: none. An existing checkout that never recorded the ref records it on its next successful fetch.
  • Rollback: reverting brings back the dropped ref and the full refetch per pass for shallow mirrors; a checkout that took shallow roots keeps its .git/shallow, which a later fetch without the flag accepts.

Tests

tests/unit/test_scip_checkout_fetch_ref.py::test_a_fetch_from_a_shallow_mirror_lands_on_the_ref builds a real shallow chain in a temporary directory: a five-commit source, a --depth 2 bare remote, a mirror cloned from it with git clone --bare --no-local as clone_mirror does (asserted shallow), and an empty git init checkout. It fetches the mirror head with checkout_fetch_args and asserts refs/loom/scip-head, then pushes two commits to the mirror, fetches again and asserts the new head and that the fetch brought in at most six objects (commit, tree and blob per commit), as the full-mirror test does, so a fetch that re-sent the history fails.

Before the change it fails at the first assertion, while the fetch itself exits 0:

subprocess.CalledProcessError: Command '['git', 'rev-parse', 'refs/loom/scip-head']' returned non-zero exit status 128.

After it, it passes. Focused run over the touched test file and the tests that reach checkout_fetch_args:

pytest tests/unit/test_scip_checkout_fetch_ref.py tests/unit/test_code_compiler_checkout.py tests/unit/test_repo_job_sandbox_hostile.py tests/unit/test_repo_job_sandbox.py tests/unit/test_code_scip_{delta,go_delta,ts_delta,py_delta}_worker.py tests/unit/test_code_compiler_tiers.py tests/unit/test_code_compiler_tier_runner.py tests/unit/test_code_scip_base_unknown.py tests/unit/test_code_compiler_target.py tests/unit/test_code_scip_harness_group_kill.py tests/unit/test_tunable_constants.py
301 passed, 17 skipped, 1 failed

The one failure, test_repo_job_sandbox.py::test_the_relay_is_given_the_live_idle_timeout, is AttributeError: module 'os' has no attribute 'memfd_create' from the local Python build; it does not touch the fetch. ruff check, ruff format --check, scripts/gates/function_length_gate.py and scripts/gates/mypy_gate.py pass.

AI assistance in the code (leave one; writing this description with AI is fine):

  • AI-generated (an agent wrote most of the diff): Claude Code wrote the change and the test. The linked issue carries a plain-git reproduction of the dropped ref, and the red and green runs are in Tests above.

  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint, type checks and focused tests pass. The full make test-unit and applicable integration results are reported by CI; a full local run is not required before pushing.
  • Generated files are regenerated in this PR, not by hand: no generated file is affected (no setting, op or plugin file changed).
  • A new migration is additive and numbered after the latest on main; no merged migration is edited. (No migration.)
  • A behaviour change to any file a plugin ships bumps both plugin manifests' version. (No plugin file changed.)
  • The frontend builds and its tests pass, if frontend/ changed. (Not changed.)
  • Docs under docs/ describe the system as it now is, and this description names any operator steps and wire changes.
  • Repository text has no dates, people, host names, internal namespaces, ticket or decision numbers; the history goes in this description (tests/unit/test_public_copy.py).
  • Commits are signed off (git commit -s), as CONTRIBUTING.md asks.
  • I signed the Contributor License Agreement (CLA) if CLA assistant requested a signature.

Note

Low Risk
Single Git flag on shared checkout fetch args; full mirrors are unchanged, and behavior only fixes shallow-remote edge cases.

Overview
Fixes compiler-tier checkout fetches against shallow mirrors (when the upstream serves truncated history) so refs/loom/scip-head is actually updated instead of being silently rejected while git fetch still exits 0.

checkout_fetch_args now passes --update-shallow, allowing the checkout to adopt the mirror’s shallow roots when recording the fetched target. Without it, subsequent passes had nothing to negotiate from and could re-download huge packs every run.

A new unit test builds a shallow mirror chain and asserts the ref is set on first fetch and updated incrementally on the next.

Reviewed by Cursor Bugbot for commit 609dbce. Bugbot is set up for automated code reviews on this repo. Configure here.

KaloyanNaumov and others added 2 commits December 2, 2026 09:44
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 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
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 <noreply@anthropic.com>
Signed-off-by: Kaloyan Naumov <knaumov@gmail.com>
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Dec 2, 2026 10:21am UTC
loom-telemetry Ready Ready Preview Dec 2, 2026 10:21am UTC

Request Review

@zlareb1 zlareb1 self-assigned this Dec 2, 2026

@zlareb1 zlareb1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The shared checkout fetch records the target ref for both shallow and full mirrors. The focused fetch tests passed both negotiation cases. The two foreign-owner cases skipped on this Git build.

@zlareb1
zlareb1 merged commit 611ce2f into ClickHouse:main Dec 2, 2026
77 of 78 checks passed
@KaloyanNaumov
KaloyanNaumov deleted the pr/code-checkout-shallow-mirror branch December 4, 2026 23:07
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.

A compiler-tier checkout fetch from a shallow mirror never records its head

2 participants