Skip to content

Commit e3e4a4e

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(fork-sync): the land run waits out candidate CI, so the report names every red job (#1895)
## Problem Land run 40482587728's candidate had 4 red CI jobs; the attention issue named only `Test`. The driver stopped waiting at the first failed job, so a session or job reading the issue fixes one job per land cycle. ## Change - **Wait:** the whole run; jobs read once - **Report:** names every red job - **Docs:** `fork-sync.md` land-run bullets Cost: a few minutes per red run, against a full land cycle per missed job. ## Scope and approval Found by the #1886 proof run. Refs #1886 ## Verification - `vp run fork:ci` → exit 0, scripts suite included Claude Opus 5.5 via Claude Code. ## Fork trailers Squashes: - 7c9be1b fix(fork-sync): the land run waits out candidate CI, so the report names every red job (#1895) (#1895) - f0bd0f6 fixup! fix(fork-sync): the land run waits out candidate CI, so the report names every red job (#1895) (#1895) Fork-Domain: fork-meta Fork-Tier: bugfix Fork-Upstreamable: no Co-authored-by: donjor <[email protected]>
1 parent 664abd2 commit e3e4a4e

3 files changed

Lines changed: 18 additions & 24 deletions

File tree

‎docs/fork/operations/fork-sync.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ The land run pushes the trunk directly, so no pull request runs `hyprws CI` befo
4848
- **Run:** the full `hyprws CI` push run on that sha
4949
- **Reuse:** a sha with a run reuses it
5050
- **Gate:** new sha passes `vp run fork:ci` first
51-
- **Wait:** returns at the first failed job
51+
- **Wait:** the whole run, so every red job shows
5252
- **Red:** no run in 5 minutes, or none in an hour
5353
- **Push:** only the sha the run passed, leased
54-
- **On red:** `hyprws` stays; `ci.jobs` names jobs
54+
- **On red:** `hyprws` stays; `ci.jobs` names each
5555
- **Scope:** `fork:ci` scans from the new base
5656
- **Skipped:** stale-delete
5757

‎scripts/fork-sync.test.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -557,10 +557,10 @@ it("leaves the trunk alone and names the red jobs when hyprws CI is red on the c
557557
},
558558
(f) => {
559559
const shas = forkShas(f);
560-
// the run is still in progress: the first failed job already ends the wait
560+
// the wait outlasts the first red job, so the report names every one
561561
const recording = exec({ ci: { conclusion: "failure", pending: 3 } });
562562
const printed = capture(() => land(["v1.0.0"], { runner: recording.runner, root: f.root }));
563-
assert.strictEqual(recording.calls.filter(({ command }) => command === "sleep").length, 1);
563+
assert.strictEqual(recording.calls.filter(({ command }) => command === "sleep").length, 4);
564564
assert.strictEqual(printed.value, 1);
565565
const report = readReport(f.root, "v1.0.0");
566566
assert.strictEqual(report.outcome, "failed");
@@ -848,18 +848,16 @@ it("pushes the candidate, waits for hyprws CI, then lease-pushes the same sha",
848848
? `sleep ${args[0]}`
849849
: `${command} ${args[1]}`,
850850
);
851-
// the local battery, on the rebased lockfile, gates the candidate push; each poll reads the jobs
851+
// the local battery, on the rebased lockfile, gates the candidate push; the jobs are read once, at completion
852852
assert.deepStrictEqual(steps, [
853853
"gh list",
854854
"vp --frozen-lockfile",
855855
"vp fork:ci",
856856
`${tip}:refs/heads/sync/candidate`,
857857
"sleep 30",
858858
"gh list",
859-
"gh view",
860859
"sleep 30",
861860
"gh list",
862-
"gh view",
863861
"sleep 30",
864862
"gh list",
865863
"gh view",

‎scripts/fork-sync.ts‎

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,8 +1299,8 @@ const latestCiRun = (runner: CommandRunner, root: string, sha: string): CiRun |
12991299
) as ReadonlyArray<CiRun>
13001300
)[0] ?? null;
13011301

1302-
/** The run's finished jobs; a job still running has no verdict to report. */
1303-
const finishedJobs = (runner: CommandRunner, root: string, run: CiRun): ReadonlyArray<CiJob> =>
1302+
/** A completed run's jobs. */
1303+
const runJobs = (runner: CommandRunner, root: string, run: CiRun): ReadonlyArray<CiJob> =>
13041304
(
13051305
JSON.parse(
13061306
runRequire(
@@ -1309,10 +1309,8 @@ const finishedJobs = (runner: CommandRunner, root: string, run: CiRun): Readonly
13091309
["run", "view", String(run.databaseId), "--repo", FORK_REPOSITORY, "--json", "jobs"],
13101310
{ cwd: root, timeout: CI_READ_TIMEOUT_MS },
13111311
),
1312-
) as { readonly jobs: ReadonlyArray<CiJob & { readonly status: string }> }
1313-
).jobs
1314-
.filter((job) => job.status === "completed")
1315-
.map(({ name, conclusion, url }) => ({ name, conclusion, url }));
1312+
) as { readonly jobs: ReadonlyArray<CiJob> }
1313+
).jobs.map(({ name, conclusion, url }) => ({ name, conclusion, url }));
13161314

13171315
/**
13181316
* Run `vp run fork:ci` on the sync worktree's tip `sha`: the refusal as a
@@ -1344,7 +1342,7 @@ const localForkCi = (runner: CommandRunner, root: string, sha: string): string |
13441342
/**
13451343
* hyprws CI's verdict on `sha`. A sha with a run reuses it; any other runs the local
13461344
* `vp run fork:ci` first, so a refusal costs minutes instead of a CI round, then force-pushes to
1347-
* the candidate branch. Polls until the run completes or a job fails; one that never ends is not green.
1345+
* the candidate branch. Polls until the run completes; one that never starts or ends is not green.
13481346
*/
13491347
export const candidateCi = (runner: CommandRunner, root: string, sha: string): CandidateCi => {
13501348
let latest = latestCiRun(runner, root, sha);
@@ -1361,16 +1359,14 @@ export const candidateCi = (runner: CommandRunner, root: string, sha: string): C
13611359
}
13621360
const started = performance.now();
13631361
for (let waited = 0; ; waited += CI_POLL_SECONDS) {
1364-
if (latest !== null) {
1365-
const jobs = finishedJobs(runner, root, latest);
1366-
// One failed job already decides the verdict; the rest only delay the fix.
1367-
if (latest.status === "completed" || jobs.some((job) => job.conclusion === "failure"))
1368-
return {
1369-
run: latest.url,
1370-
conclusion: latest.status === "completed" ? latest.conclusion : "failure",
1371-
jobs,
1372-
};
1373-
}
1362+
// Waits out the whole run: the report must name every red job, or each
1363+
// fix round finds only the next one.
1364+
if (latest?.status === "completed")
1365+
return {
1366+
run: latest.url,
1367+
conclusion: latest.conclusion,
1368+
jobs: runJobs(runner, root, latest),
1369+
};
13741370
// Wall time counts slow GitHub reads; the sleep count bounds a faked sleep.
13751371
const elapsed = Math.max(waited, (performance.now() - started) / 1000);
13761372
if (elapsed >= (latest === null ? CI_START_SECONDS : CI_TIMEOUT_SECONDS))

0 commit comments

Comments
 (0)