Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4c4c992
Code delta workers fetch the checkout under code_git_fetch_timeout_s
KaloyanNaumov Dec 2, 2026
13ab19f
code: delta workers force-check-out and update submodules under the f…
KaloyanNaumov Dec 2, 2026
3787e24
code: delta tiers' pass deadline covers the checkout move
KaloyanNaumov Dec 2, 2026
d0efea1
code: move_checkout docstring no longer cites the delta's 600 s
KaloyanNaumov Dec 2, 2026
bd89f37
Read a pass's outer deadline from the live settings at admission
KaloyanNaumov Dec 2, 2026
b44fed0
A pass deadline reads only the fetch timeout at admission
KaloyanNaumov Dec 2, 2026
81021f8
Merge remote-tracking branch 'origin/main' into wip/code-checkout-fet…
KaloyanNaumov Dec 2, 2026
79dc195
Fixtures patch the checkout seam each delta worker keeps
KaloyanNaumov Dec 2, 2026
55cb95d
Merge origin/main into the delta checkout budget branch
KaloyanNaumov Dec 3, 2026
cb78a1b
Fixtures patch the clang checkout seam the worker keeps
KaloyanNaumov Dec 3, 2026
d2be871
Merge upstream main (bd58b7b65) into the code checkout timeout line
KaloyanNaumov Dec 3, 2026
2cb3c75
Merge upstream main (30440ee80) into the code checkout timeout line
KaloyanNaumov Dec 3, 2026
43896a5
The worker snapshot carries git_fetch_budgets on the code calibration…
KaloyanNaumov Dec 3, 2026
3fbc555
Merge remote-tracking branch 'github/main' into wip/code-checkout-env…
KaloyanNaumov Dec 4, 2026
269986c
Merge remote-tracking branch 'github/main' into wip/checkout-budget-r39
KaloyanNaumov Dec 4, 2026
395b611
A compiler tier budgets every attempt of its checkout move (#2013)
KaloyanNaumov Dec 4, 2026
ef4552e
Run a checkout move under the git timeout its pass was admitted with
KaloyanNaumov Dec 5, 2026
541204e
Give the other compiler tiers' checkout steps one admitted timeout
KaloyanNaumov Dec 5, 2026
719cb51
Mark the checkout retry count as not a setting
KaloyanNaumov Dec 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 81 additions & 27 deletions server/code/app/index/compiler_tier.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import subprocess
from collections.abc import Awaitable, Callable, Mapping, Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Any, Protocol, TypedDict, Unpack
from typing import TYPE_CHECKING, Any, NamedTuple, Protocol, TypedDict, Unpack

from server.code.app.index import erasing, tier_health
from server.code.app.index.entry_lock import EntryLockHeld, EntryLockLost, check_held, entry_lock
Expand Down Expand Up @@ -652,40 +652,94 @@ def checkout_fetch_args(bare: Path | str, target: str) -> list[str]:
]


def fetch_timeout_s() -> float:
"""`code_git_fetch_timeout_s` as the supervisor read it when it admitted this pass
(the value the pass deadline is priced at), the live setting outside a supervised
pass. A checkout reads it once and gives it to every git step, so a runtime update
during the checkout cannot outlast the deadline."""
ctx = pass_context.current()
if ctx is not None and ctx.git_fetch_timeout_s is not None:
return ctx.git_fetch_timeout_s
return float(settings.code_git_fetch_timeout_s)


class GitBudget(TypedDict, total=False):
"""`git`'s time budget, forwarded by a helper that runs several git jobs."""

timeout_s: float
retries: int


class GitStep(NamedTuple):
"""One `git` call of a checkout move: its words after `git`, the bare clone a
fetch reads, and whether the step reaches the network."""

args: tuple[str, ...]
local_remote: Path | None = None
network: bool = False


# The submodule half of a checkout move. `update` fetches from the URL a submodule
# was first initialized with, so the URLs are synced from the checked-out
# .gitmodules: the top level's first, then, once it is at its pins, the nested ones'
# from their parents' new trees. A submodule three levels down that moved syncs a
# pass later.
SUBMODULE_STEPS: tuple[GitStep, ...] = (
GitStep(("submodule", "sync", "--quiet")),
GitStep(("submodule", "update", "--init", "--quiet"), network=True),
GitStep(("submodule", "sync", "--recursive", "--quiet")),
GitStep(("submodule", "update", "--init", "--recursive", "--quiet"), network=True),
)

# How many times `git` runs a timed-out step again, so one step is up to
# `1 + CHECKOUT_MOVE_RETRIES` attempts.
CHECKOUT_MOVE_RETRIES = 1 # not a setting: the retry count the pass deadline is priced at


def checkout_lead_steps(bare: Path, target: str) -> tuple[GitStep, ...]:
"""The move's steps ahead of the submodules: the fetch of `target` from the bare
clone and the forced checkout of it. The fetch never recurses: one submodule pin
rewritten away upstream fatals the whole fetch."""
return (
GitStep(tuple(checkout_fetch_args(bare, target)), local_remote=bare),
GitStep(("checkout", "--force", target)),
)


def checkout_move_attempts() -> int:
"""The most `git` runs one checkout move can make: the lead steps, then the
submodule steps (`update_submodules`), each run once more after a timeout. A tier
whose pass moves a checkout adds this many `code_git_fetch_timeout_s` budgets to
its deadline (`WorkerSpec.git_fetch_budgets`), read from here so the count cannot
fall behind the sequence. The empty arguments only size the list: the builders
take their paths and read no repository."""
return (len(checkout_lead_steps(Path(), "")) + len(SUBMODULE_STEPS)) * (
1 + CHECKOUT_MOVE_RETRIES
)


async def run_checkout_steps(
checkout: Path, steps: Sequence[GitStep], cfg: RepoConfig, **budget: Unpack[GitBudget]
) -> None:
"""Run `steps` in order as `git` jobs of `checkout`: the fetch reads its bare
clone and no network, the submodule updates reach the network with the entry's
token and proxy identity."""
for step in steps:
kwargs: dict[str, Any] = {"local_remote": step.local_remote, **budget}
if step.network:
kwargs.update(
network=True,
token=cfg.github_token,
remote=cfg.git_remote,
proxy_identity=cfg.git_proxy_identity,
)
await git(checkout, *step.args, **kwargs)


async def update_submodules(checkout: Path, cfg: RepoConfig, **budget: Unpack[GitBudget]) -> None:
"""Check the submodules out at their pins. `update` fetches from the URL a submodule
was first initialized with, so the URLs are synced from the checked-out .gitmodules:
the top level's first, then, once it is at its pins, the nested ones' from their
parents' new trees. A submodule three levels down that moved syncs a pass later."""
for recursive in ((), ("--recursive",)):
await git(
checkout,
"submodule",
"sync",
*recursive,
"--quiet",
**budget,
)
await git(
checkout,
"submodule",
"update",
"--init",
*recursive,
"--quiet",
network=True,
token=cfg.github_token,
remote=cfg.git_remote,
proxy_identity=cfg.git_proxy_identity,
**budget,
)
"""Check the submodules out at their pins, through `SUBMODULE_STEPS` (the steps a
checkout move's submodule half is budgeted for)."""
await run_checkout_steps(checkout, SUBMODULE_STEPS, cfg, **budget)


async def git(
Expand Down
35 changes: 18 additions & 17 deletions server/code/app/index/scip_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,27 @@ def __init__(self, returncode: int, tail: str, *, kind: str = "") -> None:
async def move_checkout(checkout: Path, bare: Path, target: str, cfg: RepoConfig) -> None:
"""Fetch `target` from the bare clone, force-check it out, then the submodules
exactly at their pins. Never recurse submodules on the fetch: one pin rewritten
away upstream fatals the whole fetch. Each step gets a real budget and one retry
(the delta's 600 s is sized for a few merges); the fetch reads the bare clone,
the submodule pins come from the network."""
await compiler_tier.git(
away upstream fatals the whole fetch. Every step runs under
`code_git_fetch_timeout_s` with one retry (`compiler_tier.CHECKOUT_MOVE_RETRIES`):
the fetch reads the bare clone, the submodule pins come from the network.
`compiler_tier.checkout_move_attempts` counts the steps of both halves, and the
registry gives a tier's pass deadline that many budgets, so the deadline covers
the whole move rather than a hand-counted part of it. The timeout is the one
the pass was admitted with (`pass_context.git_fetch_timeout_s`), read once for
every step: a runtime update during the move cannot outlast the pass deadline."""
timeout_s = compiler_tier.fetch_timeout_s()
await compiler_tier.run_checkout_steps(
checkout,
*compiler_tier.checkout_fetch_args(bare, target),
local_remote=bare,
timeout_s=settings.code_git_fetch_timeout_s,
retries=1,
)
await compiler_tier.git(
checkout,
"checkout",
"--force",
target,
timeout_s=settings.code_git_fetch_timeout_s,
retries=1,
compiler_tier.checkout_lead_steps(bare, target),
cfg,
timeout_s=timeout_s,
retries=compiler_tier.CHECKOUT_MOVE_RETRIES,
)
await compiler_tier.update_submodules(
checkout, cfg, timeout_s=settings.code_git_fetch_timeout_s, retries=1
checkout,
cfg,
timeout_s=timeout_s,
retries=compiler_tier.CHECKOUT_MOVE_RETRIES,
)


Expand Down
14 changes: 7 additions & 7 deletions server/code/workers/scip_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
from typing import TYPE_CHECKING

from server.code.app.index.compiler_tier import (
checkout_fetch_args,
checkout_move_attempts,
compiler_target,
git,
harness_failure,
open_tier_delta,
passthrough_env,
Expand All @@ -42,12 +41,11 @@
resolve_checkout,
run_harness,
run_tier,
update_submodules,
)
from server.code.app.index.entry_lock import check_held
from server.code.app.index.gitrepo import git_config_env
from server.code.app.index.sandbox import tool_mounts
from server.code.app.index.scip_full import work_dir
from server.code.app.index.scip_full import move_checkout, work_dir
from server.core.paths import SCIP_HARNESS_DIR
from server.settings import settings

Expand All @@ -60,6 +58,10 @@
_HARNESS = SCIP_HARNESS_DIR / "run_delta.sh"
PRODUCER = "clang"
WATERMARK = "scip_commit"
# The checkout move's worst case: every git attempt `move_checkout` can make (its
# steps, retried once each). The registry reads this for the pass deadline's git
# budget, so the deadline covers the sequence the pass actually runs.
CHECKOUT_MOVE_ATTEMPTS = checkout_move_attempts()


@dataclass
Expand Down Expand Up @@ -127,9 +129,7 @@ async def _run_repo(repo: CodeRepo, cfg: RepoConfig, result: CodeScipDeltaResult
# fetch and stalls the compiler tier. Only `submodule update` below needs
# pins, and only the ones at the target itself; it fetches the URLs the
# repository's .gitmodules names, so it goes through the egress proxy.
await git(checkout, *checkout_fetch_args(bare, target), local_remote=bare)
await git(checkout, "checkout", "--force", target)
await update_submodules(checkout, cfg)
await move_checkout(checkout, bare, target, cfg)
Comment thread
zlareb1 marked this conversation as resolved.
Resolved
Comment thread
zlareb1 marked this conversation as resolved.
Resolved

with tempfile.TemporaryDirectory(prefix="scip_delta_", dir=work_dir()) as tmp:
delta_path = Path(tmp) / "delta.json"
Expand Down
17 changes: 15 additions & 2 deletions server/code/workers/scip_go_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
TierDegraded,
checkout_fetch_args,
compiler_target,
fetch_timeout_s,
git,
harness_failure,
open_tier_delta,
Expand Down Expand Up @@ -315,8 +316,20 @@ async def _run_repo(repo: CodeRepo, cfg: RepoConfig, result: CodeScipGoDeltaResu
if missing:
result.skipped.append(f"{cfg.namespace}: {missing}")
return False
await git(checkout, *checkout_fetch_args(bare, target), local_remote=bare)
await git(checkout, "checkout", "--force", target)
fetch_s = fetch_timeout_s() # one read for both steps
await git(
checkout,
*checkout_fetch_args(bare, target),
local_remote=bare,
timeout_s=fetch_s,
)
await git(
checkout,
"checkout",
"--force",
target,
timeout_s=fetch_s,
)
retry = await _known_retry(repo, cfg, checkout, retry)

# base -> the modules to run from it; [] is every module. A module still to retry
Expand Down
17 changes: 15 additions & 2 deletions server/code/workers/scip_py_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from server.code.app.index.compiler_tier import (
checkout_fetch_args,
compiler_target,
fetch_timeout_s,
git,
gone_documents,
harness_failure,
Expand Down Expand Up @@ -101,8 +102,20 @@ async def _run_repo(repo: CodeRepo, cfg: RepoConfig, result: CodeScipPyDeltaResu
if missing:
result.skipped.append(f"{cfg.namespace}: {missing}")
return
await git(checkout, *checkout_fetch_args(bare, target), local_remote=bare)
await git(checkout, "checkout", "--force", target)
fetch_s = fetch_timeout_s() # one read for both steps
await git(
checkout,
*checkout_fetch_args(bare, target),
local_remote=bare,
timeout_s=fetch_s,
)
await git(
checkout,
"checkout",
"--force",
target,
timeout_s=fetch_s,
)
with tempfile.TemporaryDirectory(prefix="scip_py_delta_") as tmp:
delta_path = Path(tmp) / "delta.json"
await _run_harness(checkout, scip_commit or "--full", target, delta_path, cfg=cfg)
Expand Down
17 changes: 15 additions & 2 deletions server/code/workers/scip_ts_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from server.code.app.index.compiler_tier import (
checkout_fetch_args,
compiler_target,
fetch_timeout_s,
git,
gone_documents,
harness_failure,
Expand Down Expand Up @@ -121,8 +122,20 @@ async def _run_repo(repo: CodeRepo, cfg: RepoConfig, result: CodeScipTsDeltaResu
if missing:
result.skipped.append(f"{cfg.namespace}: {missing}")
return
await git(checkout, *checkout_fetch_args(bare, target), local_remote=bare)
await git(checkout, "checkout", "--force", target)
fetch_s = fetch_timeout_s() # one read for both steps
await git(
checkout,
*checkout_fetch_args(bare, target),
local_remote=bare,
timeout_s=fetch_s,
)
await git(
checkout,
"checkout",
"--force",
target,
timeout_s=fetch_s,
)
lockfile_changed = bool(scip_commit and await _lockfile_changed(checkout, scip_commit, target))
if lockfile_changed:
note = (
Expand Down
5 changes: 5 additions & 0 deletions server/workers/pass_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class PassContext:
# an `idle_interval_seconds` is next run after that instead of its
# interval: it asks less often while the last answer was "nothing".
idle: bool = False
# `code_git_fetch_timeout_s` as the supervisor read it at admission, the value
# the pass deadline was computed from. A checkout move runs its git steps under
# it, so an operator raising the setting mid-pass cannot outlast that deadline.
# None outside a supervised pass.
git_fetch_timeout_s: float | None = None
# The outcome `status.record_pass(worker)` recorded when this pass's
# block finished cleanly; None when it recorded none (it raised, it was
# cancelled, or the worker does not use `record_pass`). The status row
Expand Down
Loading
Loading