Skip to content

Commit e92487f

Browse files
fix(release): resolve a run-list count above a short page by walking the unfiltered runs (#33298)
Fixes #33195 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:稳定发布「在途」读取器(快照通道 stable-lane 与发布在途回填守卫共用)遇到 GitHub 状态过滤「总数比这一页列出的多、页又没满」并且重读三次仍不一致时,不再直接判 NOT MEASURED,而是往回翻 31 天内的不过滤运行列表、逐个按 id 读状态:找到被过滤漏掉的真实在途运行就照常判在途并拒绝;找不到就把「计数指向的运行不存在」连同翻过的范围写进读数行后放行。 - 为什么改:11-11 与 11-14 两次每日快照都因「计数 2、只列出本运行」被拒并报假卡;实测两次 release.yml 都只有本运行活着,而上一次加的重读修复(#32467)在 11-14 三次重读都没消掉这个多出来的 1。 - 风险与回滚:仍是 fail-closed:翻页任一页读不到、行没有创建时间、60 页内既没到 31 天边界也没到历史起点、或本运行重试预算已用尽,都照旧拒绝;只动两个脚本,不动 workflow 与 `version` 脚本链;回滚即还原本 PR。 - 先看:`scripts/release-pending-publish.mjs` 的 `readWholeRunList` / `resolveShortPage` / `walkRunList`(放行条件就在 `resolveShortPage` 的 proof 分支);`scripts/ci/snapshot-next.mjs` 的 `readStableLane` 合并段;`collectWaitingRuns` 的 `jobs: null`。 - 两分钟验证:`node scripts/release-pending-publish.mjs --self-test && node scripts/ci/snapshot-next.mjs --self-test`,预期 161 例 / 36 组、197 例 / 23 组全过。 - 需要你做的:无,席位落地。 ## What changes The ruling is A on #33195 (Ruling-ref 6879496577, recorded in 6879884762). - `scripts/release-pending-publish.mjs`, `readWholeRunList`: the re-read ladder is unchanged. When it ends with a status filter's `total_count` still above a page that is NOT full, the new `resolveShortPage` takes over. It walks the workflow's unfiltered run list newest first (`page=N`, 100 each) with `walkRunList`, back at most `RUN_WALK_DAYS` (31) or to the start of history. Every walked run whose row carries the filtered status and is not on the page is read by id. A direct read in that status is a row that lagged the filter, and it is added to the runs judged. The readings line then records one of three proofs: - `count N over page M names no run: the walk of K runs back to DATE (BOUND, P pages) found none other` - `... found L more in STATUS [ids], whose row(s) lagged the filter` - the same, plus `the other X name(s) no run` - Still throws, as before: a count above a FULL page; a count that is no number; a spent retry budget before the ladder ends. Newly throws: an unread walk page (5xx after the retries, or any non-200); a walk row with no `created_at`; a walk that reaches neither bound within `RUN_WALK_MAX_PAGES` (60); a candidate the direct read cannot answer. Each is the reader's own NOT MEASURED, which `publishInFlight` maps to `unreadable` and `stable-lane` to NOT MEASURED. - `collectPublishRuns` / `publishInFlight` take an optional `now` (default `Date.now()`) that dates the walk's bound. - `collectWaitingRuns`: a run it does not read past its status now carries `jobs: null` (NOT READ), never `[]`. `judgeWaitingRuns` reads `jobs` only for `waiting` runs, which are always read, so the sweep is unchanged; the new pin covers it. - `scripts/ci/snapshot-next.mjs`, `readStableLane`: it passes `now` to both readers. The merge reads `null` as NOT READ: the first reading that read the jobs speaks for the run, empty list included. A run still in flight whose jobs neither reader read has them read here. That is an older version commit's push run, which only the waiting reader probes. A publish running in such a run now refuses instead of merging as a run holding no job; the readings line names the runs read this way. `stableLane` takes an optional `now` for the self-test. ## Tests Both self-tests drive the real readers over stubbed Actions APIs. - `release-pending-publish --self-test`: 153 → 161 cases, 36 batteries. The in-flight listing battery is renamed to what it now pins, and its floor goes 7 → 14. Its case "a count still above the page on every read the ladder allows -> unreadable" becomes: - the 11-14 reading: count 2 over the calling run alone, a walk listing no other run in progress → clear, with the proof line; no completed row read; the queued filter read after it; - a dispatch run the rows left out but the walk lists → read by id, jobs read, publish in flight; - a walk row in progress whose direct read says completed → not added; - a walk explaining part of the excess → that run judged, the rest recorded as naming no run; - an unread walk page → unreadable, for the publish and the image alike; - a walk reaching neither bound in 60 pages → unreadable; - a walk stopping at the 31-day bound → the proof names the bound; - a walk row with no `created_at` → unreadable. The earlier "count over an empty page → unreadable" case now pins the unread-walk branch. The waiting-runs battery gains: "a version-commit push run in flight → jobs null, not read; the sweep leaves it untouched". - `snapshot-next --self-test`: 194 → 197 cases, 23 batteries. The stable-lane battery floor goes 13 → 16. The pinned "a count still above the page after every re-read the run allows THROWS" becomes three cases: - ⭐ the 11-14 reading passes, with the proof on the readings line; - ⛔ a walk finding a run in progress the rows left out → its jobs are read, and its stable publish refuses; - ⛔ an unread walk page still THROWS (NOT MEASURED). Plus ⛔ an older version commit's push run in flight, found by the waiting reader alone → its jobs are read in `readStableLane`, and its publish refuses. No ablation: `.claude/agents/os-dev.md` (标准条款) exempts scripts from ablation. ## Acceptance notes **Measured vs documented-only (the 31-day bound and the walk):** - Documented by GitHub, NOT measured here: a job held at an environment fails after 30 days, and a run can be re-run only within 30 days of its first attempt. Those two windows are the only ways a run created earlier than the bound can newly ENTER `in_progress` or `queued`. `RUN_WALK_DAYS = 31` is that plus one day of margin. - Measured, 2026-11-14: - A run stuck in a status since before the bound is already a row on the filter's page: ci.yml's `in_progress` filter lists run 31118082788, created 2026-08-06 (attempt 2), still `in_progress`. - At both refusals (runs 42938356503 on 11-11 and 43540146973 on 11-14), no release.yml run other than the lane's own was alive. That comes from a sweep of all 3,564 release.yml runs created 10-12..11-14 (paged by `page=N`; no other run's last update falls after the lane run started). So the walk would have explained both as phantom counts. - 135 samples of the `in_progress` filter on ci.yml, lint.yml and fleet-write.yml: 18 counts one above the page. In 4 the filter's rows lagged (the unfiltered list showed the run), so the count was the true witness. In 14 the count named no run either list showed. - In 75 id-level samples, the unfiltered newest page never omitted a live run the filter listed. The one difference was a run the filter still listed 2 s after it completed. - The unfiltered listing pages without the 1,000-result cap: page 36 answers rows from 2026-10-11, `total_count` 15062. - release.yml created about 108 runs a day over those 33 days, so a 31-day walk is about 34 pages. It is read only on a day the ladder ends short (2 of 8 lane days so far). The 60-page cap leaves the rate room to nearly double. - Not measured: whether GitHub ever deletes a run mid-walk (offset paging would skip one row), and whether the unfiltered rows can lag a run newly entering `in_progress` (no sample showed it). **Fence:** the `annotate-shipped` path, `.github/workflows/**` and the root `package.json` `version` script are untouched. `git diff --stat` covers the two files only. **No changeset:** the root package is private, and `scripts/` ships in no package's `files[]` (precedent #32467, same two files, `skip-changeset`). ## Verification Head `463bb2f1`. <details><summary>Both self-tests</summary> ```text node scripts/release-pending-publish.mjs --self-test exit 0 ✓ release-pending-publish self-test: 161 cases across 36 batteries pass. node scripts/ci/snapshot-next.mjs --self-test exit 0 snapshot-next: self-test OK -- 197 case(s) across 23 batteries ``` </details> <details><summary>Derived gates: 32 derived, 32 run, 0 unrun, every exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands` at `463bb2f1` (merge base `199e36244`, 2 paths, +300 / -66) named 32 commands. Each was run and its exit captured before any pipe, all 0: - check-closing-keyword-parity (+self-test), check-comment-mask-corpus, check-declaration-mirrors (+self-test) - check-self-test-wired (+self-test), check-self-test-workflow-commands (+self-test), check-whole-set-label-write (+self-test) - ci/plan-test-core-shards --self-test, ci/snapshot-next --self-test, pm/bare-root-worklist --self-test, release-pending-publish --self-test - `pnpm check:` agent-test-spelling, bash32-floor, ci-filter-parity, cli-command-ids, cross-package-test-inputs, driver-memory-census, entry-guard, gitlink-declared, nul-bytes, parse-guard, pm-dispatch-gates (fast tier, 2205 cases, 404 s), pnpm-filter-targets, pnpm-flag-spellings, ratchet-remedy-authority, refd-timer-probe, scripts-symbol-anchors, watch-hint-literal `--ran`: "32 derived famil(ies) accounted for — 32 run, 0 NOT-MEASURED". NOT MEASURED locally, left to CI: the type-check steps and `Plan Test Core shards` that the derivation names as CI-only shell. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcRZn9wGkMSrznVX4JS)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b96dd30 commit e92487f

2 files changed

Lines changed: 300 additions & 66 deletions

File tree

‎scripts/ci/snapshot-next.mjs‎

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,13 +1522,18 @@ export async function supersede({ workflow, dryRun = false, env = process.env, h
15221522
* waiting runs through `collectWaitingRuns` (the `?status=waiting` filter PLUS
15231523
* each version commit's push run by `head_sha`, since the filter was measured
15241524
* omitting a waiting run) and the in-flight runs through `collectPublishRuns`
1525-
* (`in_progress` and `queued`), merged by id with the jobs each read. Throws
1526-
* on anything unread -- a `TransientReadFailure` after the retries, a status
1525+
* (`in_progress` and `queued`), merged by id with the jobs each read; a run
1526+
* in flight whose jobs neither reader read has them read here. A status
15271527
* filter whose count stays above its page after the re-reads `budget` allows
1528-
* (the run's one `boardReadBudget`, the one `http` retries on), or any other
1529-
* failed read -- which the caller reports NOT MEASURED, never "clear".
1528+
* (the run's one `boardReadBudget`, the one `http` retries on) is resolved by
1529+
* the in-flight reader's walk of the unfiltered runs back to `now` minus 31
1530+
* days (release-pending-publish.mjs, `readWholeRunList`): a run whose row
1531+
* lagged is judged, a count naming no run is recorded with its proof. Throws
1532+
* on anything unread -- a `TransientReadFailure` after the retries, an unread
1533+
* or unbounded walk, or any other failed read -- which the caller reports NOT
1534+
* MEASURED, never "clear".
15301535
*/
1531-
export async function readStableLane({ http, repo, workflow, currentRunId, versionCommits, budget }) {
1536+
export async function readStableLane({ http, repo, workflow, currentRunId, versionCommits, budget, now = Date.now() }) {
15321537
// The walk is a generator (one `git show` per version commit): the newest
15331538
// version commit's tips are taken off the front and the rest is handed on
15341539
// unwalked, so the sweep's own bounds (its read-back and cap) still apply.
@@ -1538,32 +1543,46 @@ export async function readStableLane({ http, repo, workflow, currentRunId, versi
15381543
if (!first.done) yield first.value;
15391544
yield* iter;
15401545
};
1541-
const waiting = await collectWaitingRuns({ http, repo, workflow, versionCommits: rest(), currentRunId });
1542-
const inFlight = await collectPublishRuns({ http, repo, workflow, tips: first.done ? [] : first.value.tips, currentRunId, budget });
1546+
const waiting = await collectWaitingRuns({ http, repo, workflow, versionCommits: rest(), currentRunId, now });
1547+
const inFlight = await collectPublishRuns({ http, repo, workflow, tips: first.done ? [] : first.value.tips, currentRunId, budget, now });
15431548
const byId = new Map();
15441549
for (const run of [...waiting.runs, ...inFlight.runs]) {
15451550
const id = String(run.id);
15461551
const prev = byId.get(id);
1547-
// The first reading that holds jobs speaks for the run (the waiting
1548-
// reader leaves `[]` on a run it did not read past its status).
1549-
const jobs = prev && Array.isArray(prev.jobs) && prev.jobs.length > 0 ? prev.jobs : run.jobs;
1552+
// A reading that read the jobs speaks for the run: `null` is NOT READ
1553+
// (the waiting reader leaves it on a run it did not read past its status).
1554+
const jobs = prev && Array.isArray(prev.jobs) ? prev.jobs : run.jobs;
15501555
byId.set(id, { id, event: run.event, status: run.status, jobs });
15511556
}
1557+
// A run still in flight that only the waiting reader found -- an older
1558+
// version commit's push run, which the in-flight reader does not probe --
1559+
// has its jobs read here, so a publish running in it is judged, never
1560+
// merged as a run holding no job. The judge passes over the calling run.
1561+
const jobsRead = [];
1562+
for (const run of byId.values()) {
1563+
if (run.id === String(currentRunId) || run.status === 'completed' || Array.isArray(run.jobs)) continue;
1564+
const what = `listing run ${run.id}'s jobs`;
1565+
const jobs = expectOk(await http('GET', `/repos/${repo}/actions/runs/${run.id}/jobs?filter=latest&per_page=100`), what);
1566+
if (!jobs || !Array.isArray(jobs.jobs)) throw new Error(`${what} answered no jobs list`);
1567+
run.jobs = jobs.jobs.map((j) => ({ name: j.name, status: j.status }));
1568+
jobsRead.push(run.id);
1569+
}
1570+
const extra = jobsRead.length === 0 ? '' : `; jobs read for the waiting reader's in-flight run(s) ${jobsRead.join(', ')}`;
15521571
return {
15531572
runs: [...byId.values()],
1554-
readings: `\`?status=waiting\` listed ${waiting.filtered.ids.length} run(s), ${waiting.targeted.pushes.length} version-commit push(es) read, ${waiting.targeted.probes} head_sha probe(s); in flight: ${inFlight.readings}`,
1573+
readings: `\`?status=waiting\` listed ${waiting.filtered.ids.length} run(s), ${waiting.targeted.pushes.length} version-commit push(es) read, ${waiting.targeted.probes} head_sha probe(s); in flight: ${inFlight.readings}${extra}`,
15551574
anomalies: waiting.anomalies,
15561575
};
15571576
}
15581577

15591578
/**
15601579
* `stable-lane`: read, then judge. Reads only -- the client refuses every
15611580
* non-GET structurally (`dryRun: true`), so this mode cannot cancel or write.
1562-
* `env`, `http`, `sleep` and `versionCommits` are injectable for the self-test;
1563-
* the defaults are the live job's (the version commits walked on main's tip as
1564-
* this checkout fetched it, `fetch-depth: 0`).
1581+
* `env`, `http`, `sleep`, `versionCommits` and `now` are injectable for the
1582+
* self-test; the defaults are the live job's (the version commits walked on
1583+
* main's tip as this checkout fetched it, `fetch-depth: 0`; the clock).
15651584
*/
1566-
export async function stableLane({ workflow, env = process.env, http = null, sleep, versionCommits = null, root = REPO_ROOT, mainRef = MAIN_REF }) {
1585+
export async function stableLane({ workflow, env = process.env, http = null, sleep, versionCommits = null, root = REPO_ROOT, mainRef = MAIN_REF, now = Date.now() }) {
15671586
const repo = env.GITHUB_REPOSITORY;
15681587
if (!repo) throw new Error('GITHUB_REPOSITORY is required');
15691588
const currentRunId = env.GITHUB_RUN_ID || '';
@@ -1573,7 +1592,7 @@ export async function stableLane({ workflow, env = process.env, http = null, sle
15731592
// in-flight listing's re-reads spend it alike.
15741593
const budget = boardReadBudget({ sleep });
15751594
const reads = retryingReads(raw, budget);
1576-
const read = await readStableLane({ http: reads, repo, workflow, currentRunId, budget, versionCommits: versionCommits ?? versionCommitsOf({ cwd: root, head: mainRef }) });
1595+
const read = await readStableLane({ http: reads, repo, workflow, currentRunId, budget, now, versionCommits: versionCommits ?? versionCommitsOf({ cwd: root, head: mainRef }) });
15771596
return { ...judgeStableLane({ runs: read.runs, currentRunId }), read };
15781597
}
15791598

@@ -1593,7 +1612,7 @@ const SELF_TEST_BATTERIES = Object.freeze({
15931612
'the registry read: 404 is never published, anything unread is never guessed': 5,
15941613
'verify: next names the snapshot, latest never moves to it': 4,
15951614
'the same-commit check: next records the commit it was cut from, read back from npm': 10,
1596-
'the stable lane: a waiting stable prompt or a running stable publish refuses, read as the sweep reads': 13,
1615+
'the stable lane: a waiting stable prompt or a running stable publish refuses, read as the sweep reads': 16,
15971616
'the quiet skip: each expected kind skips on the schedule and refuses loudly on a dispatch; the unexpected stay red': 13,
15981617
'record-commit: gitHead into every manifest, read back by the guard': 4,
15991618
'dry-run: every early return records its reason': 3,
@@ -1876,8 +1895,10 @@ export async function selfTest() {
18761895
});
18771896
// The live path, with the stable sweep's readers over a stubbed Actions API.
18781897
// `counts[status]` is that filter's `total_count`, read by read, its last
1879-
// value repeating; absent, the count is what the page lists.
1880-
const laneHttp = ({ waiting = [], inProgress = [], queued = [], pushes = {}, runs = {}, fail = null, counts = {} }) => {
1898+
// value repeating; absent, the count is what the page lists. `walkRows` is
1899+
// page 1 of the UNFILTERED list the walk behind a short page reads, each
1900+
// `{ id, status }` (later pages empty).
1901+
const laneHttp = ({ waiting = [], inProgress = [], queued = [], pushes = {}, runs = {}, fail = null, counts = {}, walkRows = [] }) => {
18811902
const seen = [];
18821903
const reads = {};
18831904
const http = async (method, path) => {
@@ -1892,6 +1913,11 @@ export async function selfTest() {
18921913
if (/\/runs\?status=waiting/.test(path)) return list(waiting);
18931914
if (/\/runs\?status=in_progress/.test(path)) return list(inProgress, 'in_progress');
18941915
if (/\/runs\?status=queued/.test(path)) return list(queued, 'queued');
1916+
const walkPage = /\/workflows\/[^/]+\/runs\?per_page=\d+&page=(\d+)/.exec(path);
1917+
if (walkPage) {
1918+
const rows = walkPage[1] === '1' ? walkRows.map((w) => ({ ...w, event: runs[w.id]?.event ?? 'push', created_at: '2026-11-14T00:00:00Z' })) : [];
1919+
return { status: 200, body: { total_count: rows.length, workflow_runs: rows } };
1920+
}
18951921
const sha = /\/runs\?head_sha=([0-9a-f]+)/.exec(path);
18961922
if (sha) return list(pushes[sha[1]] ?? []);
18971923
const m = /\/actions\/runs\/(\d+)(\/jobs|\/pending_deployments)?/.exec(path);
@@ -1938,15 +1964,39 @@ export async function selfTest() {
19381964
const r = await lane(s);
19391965
return r.refusals.length === 0 && r.unread.length === 0 && s.reads.in_progress === 2;
19401966
});
1941-
await t('⛔ live: a count still above the page after every re-read the run allows THROWS (NOT MEASURED) -- never "clear"', async () => {
1942-
const s = laneHttp({ inProgress: [200], counts: { in_progress: [2] }, runs: { 200: current } });
1967+
// Run 43540146973 at 01:24:46Z, 11-14: the count stayed at 2 over the
1968+
// calling run alone through every re-read, while no other release.yml run
1969+
// was alive. The walk behind the short page is what tells the two apart.
1970+
const walked = (s) => s.seen.filter((x) => /[?&]page=\d/.test(x.path)).length;
1971+
await t('⭐ live: the 11-14 reading -- a count still above the calling run alone after every re-read, and a walk listing no other run in progress -> a pass, with the proof on the readings line', async () => {
1972+
const s = laneHttp({ inProgress: [200], counts: { in_progress: [2] }, runs: { 200: current, 90: { event: 'push', status: 'completed' } }, walkRows: [{ id: 200, status: 'in_progress' }, { id: 90, status: 'completed' }] });
1973+
const r = await lane(s);
1974+
return r.refusals.length === 0 && r.unread.length === 0 && s.reads.in_progress === 3 && walked(s) === 1 &&
1975+
/count 2 over page 1 names no run: the walk of 2 runs back to \S+ \(the start of history, 1 page\) found none other/.test(r.read.readings);
1976+
});
1977+
await t('⛔ live: a count above the page whose walk finds a run in progress the rows left out -> that run is read with its jobs, and its stable publish refuses', async () => {
1978+
const s = laneHttp({ inProgress: [200], counts: { in_progress: [2] }, runs: { 200: current, 160: { event: 'workflow_dispatch', status: 'in_progress', jobs: [publishJob('in_progress')] } }, walkRows: [{ id: 160, status: 'in_progress' }, { id: 200, status: 'in_progress' }] });
1979+
const r = await lane(s);
1980+
return r.refusals.length === 1 && /stable publish is running/.test(r.refusals[0].text) && r.refusals[0].text.includes('run 160') &&
1981+
s.seen.some((x) => /\/runs\/160\/jobs/.test(x.path)) && /found 1 more in in_progress \[160\], whose row lagged the filter/.test(r.read.readings);
1982+
});
1983+
await t('⛔ live: a count above the page whose walk cannot be read THROWS (NOT MEASURED) -- never "clear"', async () => {
1984+
const s = laneHttp({ inProgress: [200], counts: { in_progress: [2] }, runs: { 200: current }, fail: /[?&]page=1(&|$)/ });
19431985
try {
19441986
await lane(s);
19451987
return false;
19461988
} catch (err) {
1947-
return !(err instanceof TransientReadFailure) && s.reads.in_progress === 3;
1989+
return s.reads.in_progress === 3 && /the walk of the unfiltered run list, page 1/.test(err.message);
19481990
}
19491991
});
1992+
await t('⛔ live: an older version commit\'s push run in flight, found by the waiting reader alone -> its jobs are read here, and its stable publish refuses (never merged as a run holding no job)', async () => {
1993+
const C3 = 'c'.repeat(40);
1994+
const older = [...walk, { versionCommit: C3, version: '18.3.0', tips: [C3] }];
1995+
const s = laneHttp({ inProgress: [200], pushes: { [C3]: [140] }, runs: { 200: current, 140: { event: 'push', status: 'in_progress', jobs: [publishJob('in_progress', '18.3.0')] } } });
1996+
const r = await stableLane({ workflow: 'release.yml', env: laneEnv, http: s.http, sleep: async () => {}, versionCommits: older });
1997+
return r.refusals.length === 1 && /stable publish is running/.test(r.refusals[0].text) && r.refusals[0].text.includes('18.3.0') &&
1998+
s.seen.filter((x) => /\/runs\/140\/jobs/.test(x.path)).length === 1 && /jobs read for the waiting reader's in-flight run\(s\) 140/.test(r.read.readings);
1999+
});
19502000
await t('⛔ live: a total_count that is no number THROWS (NOT MEASURED) on the first read, never re-read', async () => {
19512001
const s = laneHttp({ inProgress: [200], counts: { in_progress: ['1'] }, runs: { 200: current } });
19522002
try {

0 commit comments

Comments
 (0)