Skip to content

Commit 357fb1e

Browse files
fix(ci): bound every git transfer by its byte rate so a stalled checkout or history fetch retries instead of running to its timeout (#35032)
Fixes #34994 Clause-②: no Metadata-protocol: none Tier: S. `.github/workflows/**` is a governed surface, and `check-governed-merges --pr 35032` reads this diff as Tier S by content (the workflows split, ruling record 6722205630, letter C; no Tier H trigger). Governed: `.github/workflows/ci.yml`, `.github/workflows/lint.yml`. Landing: L1-a, then the seat's PASS contract review on the head, then the owning seat's area queues it (claim amendment on #34994). ## 维护者速读 - **改了什么**:合并队列里 `Checkout repository` / `Fetch this commit's history` 卡死、跑满 14–25 分钟超时、把 PR 踢出队列的问题,这个 PR 就是修它的。做法是在 ci.yml 和 lint.yml 加一个工作流级 `env:`(`GIT_HTTP_LOW_SPEED_LIMIT=1000`、`GIT_HTTP_LOW_SPEED_TIME=120`):git 的一次传输如果连续 120 秒低于 1000 字节/秒,curl 就主动中止,actions/checkout 自带的重试(3 次)和 fetch-history.sh 的重试(3 次)随即接手。fetch-history.sh 还会实时打印每个阶段;lint-eslint 这条 lane 不读历史,改为浅检出。 - **为什么改**:过去 48 小时里,合并队列和 main 上有 29 个作业卡死在这两步,PR 运行上另有 19 个,全部是服务器一直没开始发包。#34561 的静默看门狗没触发,因为卡住期间服务器还在不断输出 `remote: Counting objects` 进度,日志一直在长。最近 24 小时,失败的合并队列运行里有 18/65 死在这里。 - **风险与回滚**:风险低。阈值离健康值很远:健康传输是每秒 MiB 级,服务器开始发包前最慢只等约 15 秒,慢但还在动的传输不会被切断;步骤超时和作业墙钟一个没改。回滚就是 revert 这一个 PR。 - **先看**:① `.github/workflows/ci.yml` 顶部的 `env:` 块及其注释;② `scripts/ci/fetch-history.sh` 的头注释和 `current_phase`/实时阶段打印;③ `.github/workflows/lint.yml` 中 `lint-eslint` 去掉 `fetch-depth: 0` 的那一处。 - **两分钟验证**:本地跑 `bash scripts/ci/fetch-history.selftest.sh`,最后一行应是 `fetch-history self-test: all checks passed`;本 PR 自己的 CI 里,每个 checkout 都已带着这个限速运行。 - **需要你做的**:无需审批。这是 Tier S 受管 PR,由 L1 与席位合同审查通过后由座位入队。合入后如果停顿仍然出现,再按下方的 GitHub Support 工单方案处理。 ## What changes - **`.github/workflows/ci.yml` and `.github/workflows/lint.yml`: a workflow-level `env:`** with `GIT_HTTP_LOW_SPEED_LIMIT: '1000'` and `GIT_HTTP_LOW_SPEED_TIME: '120'`, plus a short reasoning comment. - git applies these to every curl handle, so every git HTTP request in every job of both files is covered: actions/checkout, `fetch-history.sh`, `select-shard-packages`' deepen, and spec's one-tag fetch. - A request that moves under 1000 B/s for 120 s exits 128 (`curl 28 Operation too slow`). The retry around it then runs: - actions/checkout v7's `fetch()` is wrapped in `retryHelper.execute` (3 attempts, 10–20 s apart), and its git inherits `process.env`; - `fetch-history.sh` makes 3 attempts. - **`scripts/ci/fetch-history.sh`:** - exports the same two defaults only when they are unset, so a workflow's values win and a local run is bounded too; - prints `fetch-history: +Ns PHASE` each time a new phase starts, reading only complete lines, so a step that still hits its wall names where it stood; - prints the bound once per run; - corrects the #34561 header reading: a hung fetch can keep printing server sideband progress; - keeps the 60 s silence watchdog as the backstop for a request that sends nothing. - **`lint.yml` `lint-eslint`:** checks out at depth 1. Its three steps (`pnpm lint`, `check:engine-double-contract`, lane verdict) read no history. The note that justified `fetch-depth: 0` named the slot-lookup ratchet, which runs in `lint-scoped-slot-corpus` since the lane split. That reason now stands on `lint-repo-tooling`'s checkout; the six "same reason as" pointers, the `lint` job's lane note and `typecheck-source-gates`' CHECKOUT BUDGET note follow it. - **Not changed:** every step budget and job wall, `governed-surface-guard.yml` (0 stalls measured on it), and the other 11 lint lanes' `fetch-depth: 0`. - **No changeset:** `.github/**` and `scripts/ci/**` ship in no package (the root package is private). This PR is labelled `skip-changeset`. ## Measurement (Actions API, 2026-11-15T22:00Z → 2026-11-17T22:26Z) **Wall hits (merge_group and main push): 29 jobs.** - `fetch-history.sh`, 18: - 852–853 s at the 14-min budget; - 1213 s at 20 min; - 493 s at 8 min. - lint.yml full-ref checkout, 10: 1500 s at 25 min, or 1200 s at 20 min. - ci.yml depth-1 checkout, 1: cancelled at its 20-min job wall. **PR-event runs since 2026-11-16T22:00Z: 19 more**, including PR #34992's `Lint · scoped · query-options erasure` job 134411985185. **Queue impact:** in the 24 h to 22:26Z, 18 of 65 failed or cancelled merge_group runs failed in these steps. | step | n | p50 | p95 | p99 | over 150 s, succeeded | wall hits | |:--|--:|--:|--:|--:|--:|--:| | ci.yml `fetch-history.sh` | 12,368 | 57 s | 72 s | 88 s | 5 | 18 | | lint.yml full-ref checkout | 10,296 | 65 s | 85 s | 120 s | 31 | 10 | | ci.yml depth-1 checkout | 21,518 | 27 s | 34 s | 39 s | 34 (13 at 15–22 min) | 1 | **The tail is bimodal**, not #29980's flat hazard: - Same-run siblings of a hung fetch take 51–65 s (run 44173519141: 12 Test UI shards at 51–65 s, shard 6 at 852 s). - P(wall | over 150 s) = 18/23 for the fetch, so a retry at about 2 min draws again from a distribution where P(over 150 s) is about 0.2%. - Wall hits by day: 11-12: 4; 11-13 to 11-15: 0; 11-16: 9; 11-17: 20. All fell on weekdays between 16:00Z and 00:05Z. **Healthy pre-pack wait, measured locally** (this fetch shape, git 2.43): | fetch | pack starts at | total | size | |:--|--:|--:|--:| | depth-1 | 13.5 s | 25 s | 153 MiB | | `--unshallow` | 14.7 s | 77 s | 660 MiB (`pack-reused 0`) | | full-ref | 4.0 s | 82 s | 1.30 GiB (pack reuse) | `GIT_HTTP_LOW_SPEED_TIME=120` is 8x the slowest of these, and it still holds a 6.5x slowdown like 2026-11-03's. <details><summary>Measured job ids</summary> merge_group / main: 133435052239 133462684295 133470361132 133557664420 133577089390 133628404121 133637316745 133640228994 133645669009 133708987651 134190769187 134248343224 134250079846 134252806729 134257792648 134263160306 134282169394 134300103634 134314160613 134316771638 134330131026 134330172643 134348709261 134348509034 134348594081 134348634118 134358477635 134360293444 134393319006 pull_request: 133644413587 133664673312 133694024292 133695937589 133699212754 133700332558 134179666962 134211418703 134221147317 134234042188 134242570257 134245502895 134337923899 134359661557 134377275418 134377467166 134398650398 134404354815 134411985185 Queries: `GET /repos/objectstack-ai/objectstack/actions/workflows/{ci,lint,governed-surface-guard}.yml/runs` by event in 6 h windows, then `GET /actions/runs/RUN_ID/jobs?filter=all` for 1,937 runs and 329 PR runs, and `GET /actions/jobs/JOB_ID/logs` for every wall hit read. The full report is on the card. </details> ## Diagnosis: why #34561's stall bound did not fire 1. **The attempts hang before the pack.** Every wall hit's orphan list (the runner's `Terminate orphan process` lines) is `git`, `git` (the remote-https wrapper) and `git-remote-https`, plus the script's `bash` and `sleep` for fetch-history. It is never `index-pack`, and fetch-pack starts `index-pack` only once it reads the pack header. This holds for fetch-history, full-ref and depth-1 checkouts alike, so neither size nor depth is the cause. 2. **The watchdog ran and never fired.** Its `sleep` is among the orphans, and its PID climbs about 3/s across the whole budget (2234 → 4969 over 852 s). All 13 post-#34582 wall hits show `Attempt 1 of 3`, no `::warning::` and no attempt 2. 3. **The log grew because the server kept talking.** While the server enumerates, counts and compresses, the sideband demux prints `remote: ... objects: N%` lines, and no pack bytes arrive. Reproduced locally: `GIT_HTTP_LOW_SPEED_LIMIT=100000000 GIT_HTTP_LOW_SPEED_TIME=5` aborted a v2 fetch while `remote: Compressing objects: 36%..38%` was still streaming (rc 128, `error: RPC failed; curl 28 Operation too slow`). So curl's byte-rate bound fires exactly where the silence bound cannot. 4. **The phase was never printed.** The attempt's log printed only when the attempt ended, and the step timeout kills the script first. The live phase lines fill that gap. 5. **The same stall ends by itself after 17–22 min.** 13 depth-1 checkouts in jobs with no step timeout finished in one attempt after 1000–1351 s (for example 134182008086). That is why the budgets read as timeouts rather than errors. ## Tests - **`bash scripts/ci/fetch-history.selftest.sh`** (= `pnpm check:fetch-history`) at b4162ea: `fetch-history self-test: all checks passed`, 65 PASS. New cases: - the healthy run hands git `1000 120`, and a preset `5 7` is kept; - `talk-then-curl28,ok`: a stub prints `remote: Counting objects` every second for 5 s, longer than the 2 s stall bound, then exits 128 with `curl 28`. The script retries it, and attempt 2 succeeds, ends unshallowed and shows no stall warning. Both attempts ran under the bound, and the live line `fetch-history: +Ns remote: Counting objects` prints; - the slow case prints its phase live, once; - both workflows' single `env:` block carries the script's defaults; - `lint-eslint` sets no `fetch-depth`. - **Ablation, one-shot, via `scripts/ablation-replace.mjs`** (the mutation landed per its blob/anchor proof; restored with `git checkout HEAD --`, blobs equal to HEAD): - the two `export` lines made plain assignments: 7 FAIL (healthy env, talk-then-ok env, script defaults, the four workflow env pins); - lint.yml `GIT_HTTP_LOW_SPEED_TIME: '120'` → `'60'`: exactly 1 FAIL (`lint.yml's env: sets GIT_HTTP_LOW_SPEED_TIME to the script's default`). ## Acceptance notes - **If stalls persist after this lands (maintainer's option):** open a GitHub Support ticket citing the job ids above. The ticket would say: - smart-HTTP fetches against github.com stall before the pack header for 14–22 min, depth-1 single-sha fetches included; - weekdays, 16:00–00:05Z, since 2026-11-12; - same-run siblings take 51–65 s. Larger runners are not expected to help, because the runner sits idle while the server stalls. - **Post-landing plan:** re-measure 24 h of merge_group runs after the merge and post the wall-hit count for `Checkout repository` and `Fetch this commit's history and the base branch` on #34994. Expected: 0 wall hits, and `curl 28` followed by `Waiting N seconds before trying again` (checkout) or `Attempt 2 of 3` (fetch-history) where a stall was caught. - `scripts/check-published-files.mjs`'s refusal text still truthfully cites lint.yml's `fetch-depth: 0`. The lane that runs it keeps depth 0. - Out of scope, noted only: the other 11 lint lanes could move to a depth-1 checkout plus `fetch-history.sh`. Measured, it is about 20 s slower per lane at p50 and adds no stall coverage, so it stays with #22034. ## Verification Local runs at b4162ea. `dispatch-gates --commands` derived 64 commands, and `--ran` reconciles 64 derived, 64 run, 0 unrun. <details><summary>Local gate results (exit code captured before any pipe)</summary> - **60 exited 0**, among them: - `check:fetch-history`, `check:ci-filter-parity`, `check:required-contexts` and `check:stall-guard-budget`; - `check:stall-guard-headroom`, `check:workflow-status-functions`, `check:workflow-step-name-quoting` and `check:self-test-workflow-commands`; - `check:pm-dispatch-gates` (364 s), `check:pm-governed-merges`, `check:nul-bytes`, `check:bash32-floor` and `check:select-gate-families`; - `check:type-check-coverage` and `check:type-check-debt`. - **4 NOT MEASURED** (exit 3, prerequisite: built `dist/`): `check:dts-closure`, `check:dual-build-cjs-loads`, `check:lean-entry-closure`, `check:sourcemap-no-sources-content`. These whole-tree families read build output, and this diff touches no package; CI builds and runs them. - Not run locally, CI-owned: the repo-wide `pnpm lint`, `test:repo`, the type-check lanes and the path-scheduled jobs. This PR's own CI runs every checkout and fetch with the new env, which is the live positive control. - `overlap-check` on b4162ea: `VERDICT clean exit 0` (origin/main merges cleanly, 0 open PR heads share a file). </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzgwLiKcfujYUug7sPs --> Co-authored-by: Claude <noreply@anthropic.com>
1 parent d4b2a75 commit 357fb1e

4 files changed

Lines changed: 184 additions & 30 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@ concurrency:
185185
# main-only job reads the probe. The 4-hourly `schedule` run is untouched: it
186186
# is the full battery.
187187

188+
# ⭐ EVERY GIT TRANSFER IN THIS FILE IS BOUNDED BY ITS BYTE RATE (#34994).
189+
# A git HTTP request that moves under 1000 bytes/s for 120 s is aborted by curl
190+
# (exit 128, "curl 28 Operation too slow"), so the retry around it runs:
191+
# actions/checkout's own fetch retry (3 attempts) and the "Fetch this commit's
192+
# history" step's (scripts/ci/fetch-history.sh, 3 attempts). On 2026-11-16/17,
193+
# 48 checkout or fetch steps here and in lint.yml ran to their 8-25 minute
194+
# budget with no index-pack running: the server never started the pack, while
195+
# its `remote:` progress kept the log moving, and siblings in the same run
196+
# took 51-65 s. The slowest healthy wait for the pack is ~15 s and a healthy
197+
# receive runs at MiB/s, so neither number cuts a slow transfer that moves.
198+
# The step budgets stay the outer wall. Same block in lint.yml; the script
199+
# sets the same defaults for a local run.
200+
env:
201+
GIT_HTTP_LOW_SPEED_LIMIT: '1000'
202+
GIT_HTTP_LOW_SPEED_TIME: '120'
203+
188204
jobs:
189205
queue-verdict:
190206
name: Queue verdict
@@ -1105,6 +1121,11 @@ jobs:
11051121
# group and retried (#34561): on 2026-11-16/17 a stalled transfer held
11061122
# attempt 1 silent until this budget killed it, four times, so the retry
11071123
# never ran, while sibling shards fetched the same history in 47-96 s.
1124+
# That bound missed the next stalls: a server that never starts the pack
1125+
# keeps printing `remote:` progress, so the log never went silent. Each
1126+
# attempt is now also cut by its byte rate, under 1000 bytes/s for 120 s
1127+
# (the workflow `env:` block above, #34994), and the script prints each
1128+
# phase as it starts, so a step that still hits this budget names it.
11081129
# A fetch that keeps moving is never cut. The script's header has the
11091130
# reading; its self-test runs in lint.yml.
11101131
#

‎.github/workflows/lint.yml‎

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ concurrency:
214214
# affected-package type check) carries its own note saying how.
215215
# ─────────────────────────────────────────────────────────────────────────────
216216

217+
# ⭐ EVERY GIT TRANSFER IN THIS FILE IS BOUNDED BY ITS BYTE RATE (#34994).
218+
# A git HTTP request that moves under 1000 bytes/s for 120 s is aborted by curl
219+
# (exit 128, "curl 28 Operation too slow"), so actions/checkout's own fetch
220+
# retry (3 attempts) runs instead of the CHECKOUT BUDGET expiring. On
221+
# 2026-11-16/17, 20 of this file's full-history checkouts ran to that 20-25
222+
# minute budget with no index-pack running: the server never started the pack.
223+
# The slowest healthy wait for the pack is ~15 s (this fetch reuses the
224+
# server's packs: ~4 s), and a healthy receive runs at MiB/s, so neither number
225+
# cuts a slow transfer that moves. The CHECKOUT BUDGET stays the outer wall.
226+
# ci.yml carries the same block and says more.
227+
env:
228+
GIT_HTTP_LOW_SPEED_LIMIT: '1000'
229+
GIT_HTTP_LOW_SPEED_TIME: '120'
230+
217231
jobs:
218232

219233
schedule-gate:
@@ -311,10 +325,11 @@ jobs:
311325
# header). What each lane repeats is the six setup steps, the gate-family
312326
# selector where the lane carries a scoped step, and, since #23191, the
313327
# `Lane verdict` step that ends it (it replaced the unmeasured-tail
314-
# reporter pair). Every lane keeps the single job's full-history checkout:
315-
# which of the ~190 gates read history was not re-derived for this split,
316-
# and a gate that loses its history degrades to "not verified" rather than
317-
# going red.
328+
# reporter pair). Every lane but `lint-eslint` keeps the single job's
329+
# full-history checkout: which of the ~190 gates read history was not
330+
# re-derived for this split, and a gate that loses its history degrades to
331+
# "not verified" rather than going red. `lint-eslint`'s three steps were
332+
# re-derived (#34994): none reads history, so it checks out at depth 1.
318333
#
319334
# The lanes are independent. The only inter-step reads in the single job
320335
# were `steps.gate-families.outputs.*` (nine `if:` lines, one step `id:`),
@@ -525,12 +540,11 @@ jobs:
525540
# CHECKOUT BUDGET: `typecheck-source-gates` sizes it; the `lint` job
526541
# above says why every lane carries it.
527542
timeout-minutes: 25
528-
with:
529-
# The slot-lookup ratchet compares the baseline against its state at
530-
# the merge base with main — the only way to see a file being ADDED
531-
# to the grandfather list. A shallow clone has no merge base, and the
532-
# check would degrade to "not verified" on every run.
533-
fetch-depth: 0
543+
# Depth 1, the default (#34994): nothing in this lane reads history.
544+
# ESLint and the engine test-double gate read the working tree only,
545+
# and the slot-lookup ratchet that once needed the merge base here
546+
# runs in `lint-scoped-slot-corpus` since the lane split. The other
547+
# lanes keep `fetch-depth: 0` for their own history readers.
534548

535549
- name: Setup workspace
536550
uses: ./.github/actions/setup-workspace
@@ -610,7 +624,12 @@ jobs:
610624
# above says why every lane carries it.
611625
timeout-minutes: 25
612626
with:
613-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
627+
# Gates in this lane and the scoped lanes below compare against the
628+
# merge base with main — the slot-lookup ratchet, for one, sees a
629+
# file being ADDED to its grandfather list only that way. A shallow
630+
# clone has no merge base, and such a check degrades to "not
631+
# verified" on every run. (This note stood on `lint-eslint`'s
632+
# checkout until that lane, which reads no history, went to depth 1.)
614633
fetch-depth: 0
615634

616635
- name: Setup workspace
@@ -1956,7 +1975,7 @@ jobs:
19561975
# above says why every lane carries it.
19571976
timeout-minutes: 25
19581977
with:
1959-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
1978+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
19601979
fetch-depth: 0
19611980

19621981
- name: Setup workspace
@@ -3008,7 +3027,7 @@ jobs:
30083027
# above says why every lane carries it.
30093028
timeout-minutes: 25
30103029
with:
3011-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
3030+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
30123031
fetch-depth: 0
30133032

30143033
- name: Setup workspace
@@ -4158,7 +4177,7 @@ jobs:
41584177
# above says why every lane carries it.
41594178
timeout-minutes: 25
41604179
with:
4161-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
4180+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
41624181
fetch-depth: 0
41634182

41644183
- name: Setup workspace
@@ -4318,7 +4337,7 @@ jobs:
43184337
# above says why every lane carries it.
43194338
timeout-minutes: 25
43204339
with:
4321-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
4340+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
43224341
fetch-depth: 0
43234342

43244343
- name: Setup workspace
@@ -4464,7 +4483,7 @@ jobs:
44644483
# above says why every lane carries it.
44654484
timeout-minutes: 25
44664485
with:
4467-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
4486+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
44684487
fetch-depth: 0
44694488

44704489
- name: Setup workspace
@@ -4654,7 +4673,7 @@ jobs:
46544673
# above says why every lane carries it.
46554674
timeout-minutes: 25
46564675
with:
4657-
# `fetch-depth: 0`: same reason as the `lint-eslint` checkout above.
4676+
# `fetch-depth: 0`: same reason as the `lint-repo-tooling` checkout above.
46584677
fetch-depth: 0
46594678

46604679
- name: Setup workspace
@@ -4816,6 +4835,11 @@ jobs:
48164835
# one retry inside the same total gains nothing (the hazard is flat).
48174836
# Healthy runs pay nothing for it: max 435 s over 3,576 checkouts of this
48184837
# workflow after the incident. The queries are in #29980's dev report.
4838+
# That flat hazard is a SLOW transfer's. A STALLED one (the server never
4839+
# starts the pack, 2026-11-16/17) is cut inside git by the workflow `env:`
4840+
# block above, and actions/checkout retries it within this budget (#34994),
4841+
# so the budget only binds a transfer that moves. `lint-eslint` checks out
4842+
# at depth 1 since then and keeps the same budget, unchanged.
48194843
# The one exception is `typecheck-workspace`: its body budget is 35, and
48204844
# 35 + 20 = 55 is already the cap the `lint` job argues, so that lane
48214845
# keeps 20 until its body is faster or the fetch is narrowed (#22034).
@@ -4855,8 +4879,9 @@ jobs:
48554879
# touches no spec file at all) go red for "deleting"
48564880
# ui/BulkActionDef:requiredPermissions — a key main had just ADDED.
48574881
#
4858-
# Same line as the ESLint job above, opposite failure mode, and that
4859-
# is why it is spelled out here rather than cross-referenced: shallow
4882+
# Same line as the `lint-repo-tooling` checkout above, opposite
4883+
# failure mode, and that is why it is spelled out here rather than
4884+
# cross-referenced: shallow
48604885
# degrades the slot-lookup ratchet to "not verified" (a false GREEN),
48614886
# and degrades this gate to a false RED on an innocent PR.
48624887
fetch-depth: 0

‎scripts/ci/fetch-history.selftest.sh‎

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#
88
# The property under test is the one the four 2026-11-16/17 step timeouts
99
# broke: an attempt that STALLS is ended and retried, while an attempt that
10-
# keeps moving is left alone. A real stalled transfer cannot be ordered on
10+
# keeps moving is left alone. Since #34994 a stall is also one that keeps
11+
# PRINTING server progress while no pack arrives: curl's low-speed abort ends
12+
# it (exit 128, "curl 28"), so the cases pin that the script hands git that
13+
# bound and retries what it ends, and that each phase prints as it starts. A real stalled transfer cannot be ordered on
1114
# demand, so a stub `git` on PATH plays `fetch` per attempt (healthy, silent
1215
# hang, hang after some progress, slow but moving, fast failure) and hands
1316
# every other git command to the real git. A healthy `fetch` IS the real one,
@@ -17,8 +20,10 @@
1720
# Each case pins the exit status, the attempt count, the `fetch` arguments, the
1821
# ::warning:: / ::error:: lines, and for a hang that the stub's child process
1922
# (standing in for git-remote-https) is gone afterwards -- the process-group
20-
# kill. The last section reads ci.yml and pins that all five jobs call the
21-
# script and no inline copy of the old loop is left.
23+
# kill. The last sections read ci.yml and lint.yml: all five ci.yml jobs call
24+
# the script and no inline copy of the old loop is left; both workflows carry
25+
# the same low-speed bound as the script's defaults; `lint-eslint` checks out
26+
# at depth 1.
2227
#
2328
# Offline; ~40 s (the stall bound is 2 s here, 60 s in CI). Every fixture path
2429
# is under a mktemp directory; none is spelled as a repo path
@@ -28,6 +33,7 @@ cd "$(git rev-parse --show-toplevel)" || exit 1
2833

2934
SCRIPT_REL='scripts/ci/fetch-history.sh'
3035
WORKFLOW_REL='.github/workflows/ci.yml'
36+
LINT_WORKFLOW_REL='.github/workflows/lint.yml'
3137
SCRIPT="$PWD/$SCRIPT_REL"
3238
REAL_GIT="$(command -v git)"
3339
FIX=$(mktemp -d "${TMPDIR:-/tmp}/os-fetch-history-selftest.XXXXXX") || exit 1
@@ -58,6 +64,7 @@ if [ "${1:-}" != fetch ]; then exec "$STUB_REAL_GIT" "$@"; fi
5864
n=$(( $(cat "$STUB_DIR/attempts" 2> /dev/null || echo 0) + 1 ))
5965
echo "$n" > "$STUB_DIR/attempts"
6066
echo "$*" >> "$STUB_DIR/argv"
67+
echo "${GIT_HTTP_LOW_SPEED_LIMIT-unset} ${GIT_HTTP_LOW_SPEED_TIME-unset}" >> "$STUB_DIR/env"
6168
step=$(echo "$STUB_PLAN" | cut -d, -f"$n")
6269
case "$step" in
6370
ok) exec "$STUB_REAL_GIT" "$@" ;;
@@ -69,6 +76,14 @@ case "$step" in
6976
wait
7077
exit 1
7178
;;
79+
talk-then-curl28)
80+
# The 2026-11-17 shape: no pack, but server progress every second, longer
81+
# than the stall bound, then curl's low-speed abort as git reports it.
82+
for i in 1 2 3 4 5; do printf 'remote: Counting objects: %d0%% (%d/10)\r' "$i" "$i" >&2; sleep 1; done
83+
echo "error: RPC failed; curl 28 Operation too slow. Less than 1000 bytes/sec transferred the last 120 seconds" >&2
84+
echo "fatal: expected 'packfile'" >&2
85+
exit 128
86+
;;
7287
slow)
7388
for i in 1 2 3 4 5; do printf 'Receiving objects: %d0%% (%d/10)\r' "$i" "$i" >&2; sleep 1; done
7489
exec "$STUB_REAL_GIT" "$@"
@@ -90,8 +105,13 @@ run_case() {
90105
fi
91106
local start end
92107
start=$(date +%s)
108+
local low=()
109+
if [ -n "${CASE_LOW_SPEED:-}" ]; then
110+
low=(GIT_HTTP_LOW_SPEED_LIMIT="${CASE_LOW_SPEED% *}" GIT_HTTP_LOW_SPEED_TIME="${CASE_LOW_SPEED#* }")
111+
fi
93112
(
94113
cd "$case_dir/ws" &&
114+
env -u GIT_HTTP_LOW_SPEED_LIMIT -u GIT_HTTP_LOW_SPEED_TIME ${low[@]+"${low[@]}"} \
95115
PATH="$bin:$PATH" STUB_REAL_GIT="$REAL_GIT" STUB_DIR="$case_dir/stub" STUB_PLAN="$plan" \
96116
FETCH_HISTORY_STALL_SECONDS=2 FETCH_HISTORY_RETRY_SLEEP=0 PR_BASE_REF="$base" RUNNER_TEMP="$case_dir" \
97117
bash "$SCRIPT" > "$case_dir/out" 2>&1
@@ -102,6 +122,7 @@ run_case() {
102122
attempts=$(cat "$case_dir/stub/attempts" 2> /dev/null || echo 0)
103123
out=$(cat "$case_dir/out")
104124
argv1=$(head -n 1 "$case_dir/stub/argv" 2> /dev/null)
125+
env1=$(head -n 1 "$case_dir/stub/env" 2> /dev/null)
105126
ws="$case_dir/ws"
106127
}
107128
children_gone() {
@@ -124,6 +145,13 @@ check "healthy clone has all 5 commits" '[ "$("$REAL_GIT" -C "$ws" rev-list --co
124145
check "healthy fetched no tag" '[ -z "$("$REAL_GIT" -C "$ws" tag)" ]'
125146
check "healthy prints the History line" 'grep -q "^History: 5 commit(s) behind HEAD, shallow=false, no tags" <<< "$out"'
126147
check "healthy prints no warning" '! grep -q "::warning::" <<< "$out"'
148+
check "healthy hands git the low-speed defaults (1000 B/s for 120 s)" '[ "$env1" = "1000 120" ]'
149+
check "healthy names the bound once" '[ "$(grep -c "^Each attempt ends when it moves under 1000 bytes/s for 120s (curl) or writes nothing for 2s, and is retried.$" <<< "$out")" = 1 ]'
150+
151+
echo "-- #34994: a bound the workflow already set is kept, not overwritten"
152+
CASE_LOW_SPEED="5 7" run_case preset ok
153+
check "preset exits 0" '[ "$rc" = 0 ]'
154+
check "preset hands git the workflow's values" '[ "$env1" = "5 7" ]'
127155

128156
echo "-- a PR into another branch fetches that branch too; a PR into main does not repeat main"
129157
run_case pr-release ok shallow release-x
@@ -160,6 +188,17 @@ check "slow takes one attempt" '[ "$attempts" = 1 ]'
160188
check "slow ran longer than the stall bound" '[ "$elapsed" -ge 4 ]'
161189
check "slow prints no warning" '! grep -q "::warning::" <<< "$out"'
162190
check "slow prints one line for its progress phase" '[ "$(grep -c "^Receiving objects:" <<< "$out")" = 1 ]'
191+
check "slow names its phase live, once" '[ "$(grep -cE "^fetch-history: \+[0-9]+s Receiving objects$" <<< "$out")" = 1 ]'
192+
193+
echo "-- #34994: a fetch that keeps printing server progress but gets no pack is ended by curl and retried"
194+
run_case talk-then-ok talk-then-curl28,ok
195+
check "talk-then-ok exits 0" '[ "$rc" = 0 ]'
196+
check "talk-then-ok takes two attempts" '[ "$attempts" = 2 ]'
197+
check "talk-then-ok: the silence bound did not fire (it cannot: the log kept growing)" '! grep -q "::warning::git fetch wrote nothing" <<< "$out"'
198+
check "talk-then-ok: both attempts ran under the low-speed bound" '[ "$(grep -c "^1000 120$" "$case_dir/stub/env")" = 2 ]'
199+
check "talk-then-ok shows curl's abort" 'grep -q "curl 28 Operation too slow" <<< "$out"'
200+
check "talk-then-ok names the server phase it stood in, live" 'grep -qE "^fetch-history: \+[0-9]+s remote: Counting objects$" <<< "$out"'
201+
check "talk-then-ok ends unshallowed" '[ "$("$REAL_GIT" -C "$ws" rev-parse --is-shallow-repository)" = false ]'
163202

164203
echo "-- three fast failures end red, named"
165204
run_case fail3 fail,fail,fail
@@ -188,6 +227,24 @@ check "each fetch step's run line is the script" '[ "$(grep -A4 "^ - name:
188227
check "each fetch step passes PR_BASE_REF" '[ "$(grep -A4 "^ - name: Fetch this commit'"'"'s history and the base branch$" "$wf" | grep -c "PR_BASE_REF: \${{ github.event.pull_request.base.ref }}")" = 5 ]'
189228
check "no inline fetch loop is left in ci.yml" '! grep -q "git fetch --no-tags \"\${deepen\[@\]}\"" "$wf"'
190229

230+
echo "-- #34994: both workflows set the script's low-speed bound for every job"
231+
lint_wf="$PWD/$LINT_WORKFLOW_REL"
232+
script_limit=$(sed -n 's/^export GIT_HTTP_LOW_SPEED_LIMIT="\${GIT_HTTP_LOW_SPEED_LIMIT:-\([0-9]*\)}"$/\1/p' "$SCRIPT")
233+
script_time=$(sed -n 's/^export GIT_HTTP_LOW_SPEED_TIME="\${GIT_HTTP_LOW_SPEED_TIME:-\([0-9]*\)}"$/\1/p' "$SCRIPT")
234+
check "the script's defaults read as 1000 and 120" '[ "$script_limit" = 1000 ] && [ "$script_time" = 120 ]'
235+
for f in "$wf" "$lint_wf"; do
236+
name=$(basename "$f")
237+
block=$(awk '/^env:$/ { on = 1; next } on && /^[^ ]/ { on = 0 } on' "$f")
238+
check "$name has one workflow-level env: block" '[ "$(grep -c "^env:$" "$f")" = 1 ]'
239+
check "$name's env: sets GIT_HTTP_LOW_SPEED_LIMIT to the script's default" 'grep -qx " GIT_HTTP_LOW_SPEED_LIMIT: '"'"'$script_limit'"'"'" <<< "$block"'
240+
check "$name's env: sets GIT_HTTP_LOW_SPEED_TIME to the script's default" 'grep -qx " GIT_HTTP_LOW_SPEED_TIME: '"'"'$script_time'"'"'" <<< "$block"'
241+
done
242+
243+
echo "-- #34994: lint-eslint reads no history, so it checks out at depth 1"
244+
eslint_job=$(awk '/^ lint-eslint:$/ { on = 1; next } on && /^ [a-z0-9_-]+:$/ { on = 0 } on' "$lint_wf")
245+
check "lint.yml has the lint-eslint job" '[ -n "$eslint_job" ] && grep -q "uses: actions/checkout@" <<< "$eslint_job"'
246+
check "lint-eslint's checkout sets no fetch-depth" '! grep -qE "^ +fetch-depth:" <<< "$eslint_job"'
247+
191248
echo ""
192249
if [ "$fails" -gt 0 ]; then
193250
echo "fetch-history self-test: $fails check(s) FAILED"

0 commit comments

Comments
 (0)