Skip to content

Commit 998088f

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(fork-sync): a session runs fork:ci on its tip before the hand-off (#1890)
## Problem A session wrote a finished marker without checking its tip. The land run's local `fork:ci` was then the first check to see a red tip. The proof run hit this: 1. Land run 40458348479 adopted marker `643b1c9` and carried #1889 2. Its `fork:ci` refused 4 misformatted files 3. The session's own `fork:ci` had run in the main checkout, on the trunk ## Change - **`localForkCi`:** the install and `fork:ci` preflight, shared - **Session:** runs it on the tip after the carry - **Refusal:** fails at step `check`; no hand-off printed - **Land:** unchanged; `candidateCi` calls the helper - **Skill and docs:** the `failed` `check` row ## Scope and approval Found by the fork-sync proof run for #1886. Refs #1886 ## Verification - `fork-sync.test.ts`: a red local `fork:ci` fails a session at `check` (79/79) - `vp run fork:ci` → exit 0 Claude Opus 5.5 via Claude Code. ## Fork trailers Fork-Domain: fork-meta Fork-Tier: bugfix Fork-Upstreamable: no Co-authored-by: donjor <[email protected]>
1 parent c7d647c commit 998088f

4 files changed

Lines changed: 67 additions & 29 deletions

File tree

‎.agents/skills/fork-sync/SKILL.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Never edit a report; a rerun supersedes it.
5151
| `rebased` | 0 | [tip work](#tip-work), then [hand off](#hand-off) |
5252
| `blocked` | 1 | [resolve](#resolve) the seams |
5353
| `failed` `carry` | 1 | [resolve](#resolve) the pick |
54+
| `failed` `check` | 1 | fix it as [tip work](#tip-work), rerun |
5455
| `failed` other | 1 | fix the remote, tag, or `error`; rerun |
5556

5657
## Procedure
@@ -114,7 +115,8 @@ Adaptation the candidate needs (build or test fixes, ports) commits at the tip o
114115
- **Owner:** newest fork commit on those lines
115116
- **Find it:** `vp run fork:fixup-fold`
116117
- **Unmarked fork line:** the fixup marks it
117-
- **Local checks:** `vp run fork:ci`, `vp test run`
118+
- **Local checks:** each rerun runs `fork:ci`
119+
- Focused tests: `vp test run`
118120
- **Gate:** candidate CI in the land run
119121

120122
Run `vp test run` inside the package.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Issue comments are projections of it: never parse one, and never treat an edit t
7676
| Outcome | Exit | Run | Means |
7777
| ----------------- | ---- | ------- | -------------------------------------- |
7878
| `already-applied` | 0 | both | the trunk contains the tag |
79-
| `rebased` | 0 | session | finished marker written |
79+
| `rebased` | 0 | session | finished marker; tip passes `fork:ci` |
8080
| `applied` | 0 | land | trunk moved to a green candidate |
8181
| `blocked` | 1 | both | manual seam; partial marker written |
8282
| `failed` | 1 | both | `fetch` through `blocked`; see `error` |

‎scripts/fork-sync.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,19 @@ it("refuses the candidate push when the local fork:ci battery is red", () => {
618618
);
619619
});
620620

621+
it("refuses a session's hand-off while the local fork:ci battery is red on its tip", () => {
622+
withFixture(CLEAN, (f) => {
623+
const recording = exec({ vp: (args) => (args[1] === "fork:ci" ? refused("fmt") : ok()) });
624+
const { value } = capture(() => run(["v1.0.0"], { runner: recording.runner, root: f.root }));
625+
assert.strictEqual(value, 1);
626+
const report = readReport(f.root, "v1.0.0");
627+
assert.strictEqual(report.outcome, "failed");
628+
assert.strictEqual(report.failure?.step, "check");
629+
assert.strictEqual(report.ci?.conclusion, "skipped: local fork:ci failed (exit 1)");
630+
assert.notInclude(report.decision.resume, "sync/resolution");
631+
});
632+
});
633+
621634
const redThenGreen = (): { readonly red: Recording; readonly green: Recording } => ({
622635
red: exec({ ci: { conclusion: "failure" } }),
623636
green: exec(),

‎scripts/fork-sync.ts‎

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,33 @@ const finishedJobs = (runner: CommandRunner, root: string, run: CiRun): Readonly
12491249
.filter((job) => job.status === "completed")
12501250
.map(({ name, conclusion, url }) => ({ name, conclusion, url }));
12511251

1252+
/**
1253+
* Run `vp run fork:ci` on the sync worktree's tip `sha`: the refusal as a
1254+
* conclusion, or null when green. A session runs it before it hands off and a
1255+
* land run before its candidate push, so neither hands on a tip CI refuses.
1256+
*/
1257+
const localForkCi = (runner: CommandRunner, root: string, sha: string): string | null => {
1258+
const worktree = worktreePath(root);
1259+
// The rebase may have moved the lockfile past what setup installed before
1260+
// it. Setup itself refuses an unpublished HEAD, so install directly.
1261+
const install = runner.run("vp", ["i", "--frozen-lockfile", "--", "--yes"], {
1262+
cwd: worktree,
1263+
env: verificationEnv(worktree),
1264+
stream: true,
1265+
});
1266+
if (install.status !== 0 || install.error !== undefined)
1267+
return `skipped: install for the local fork:ci failed (exit ${install.status})`;
1268+
process.stdout.write(`sync: running vp run fork:ci on ${sha.slice(0, 7)}\n`);
1269+
const local = runner.run("vp", ["run", "fork:ci"], {
1270+
cwd: worktree,
1271+
env: verificationEnv(worktree),
1272+
stream: true,
1273+
});
1274+
return local.status !== 0 || local.error !== undefined
1275+
? `skipped: local fork:ci failed (exit ${local.status})`
1276+
: null;
1277+
};
1278+
12521279
/**
12531280
* hyprws CI's verdict on `sha`. A sha with a run reuses it; any other runs the local
12541281
* `vp run fork:ci` first, so a refusal costs minutes instead of a CI round, then force-pushes to
@@ -1257,32 +1284,8 @@ const finishedJobs = (runner: CommandRunner, root: string, run: CiRun): Readonly
12571284
export const candidateCi = (runner: CommandRunner, root: string, sha: string): CandidateCi => {
12581285
let latest = latestCiRun(runner, root, sha);
12591286
if (latest === null) {
1260-
const worktree = worktreePath(root);
1261-
// The rebase may have moved the lockfile past what setup installed before
1262-
// it. Setup itself refuses an unpublished HEAD, so install directly.
1263-
const install = runner.run("vp", ["i", "--frozen-lockfile", "--", "--yes"], {
1264-
cwd: worktree,
1265-
env: verificationEnv(worktree),
1266-
stream: true,
1267-
});
1268-
if (install.status !== 0 || install.error !== undefined)
1269-
return {
1270-
run: "",
1271-
conclusion: `skipped: install for the local fork:ci failed (exit ${install.status})`,
1272-
jobs: [],
1273-
};
1274-
process.stdout.write(`sync: running vp run fork:ci on ${sha.slice(0, 7)} before the push\n`);
1275-
const local = runner.run("vp", ["run", "fork:ci"], {
1276-
cwd: worktree,
1277-
env: verificationEnv(worktree),
1278-
stream: true,
1279-
});
1280-
if (local.status !== 0 || local.error !== undefined)
1281-
return {
1282-
run: "",
1283-
conclusion: `skipped: local fork:ci failed (exit ${local.status})`,
1284-
jobs: [],
1285-
};
1287+
const refused = localForkCi(runner, root, sha);
1288+
if (refused !== null) return { run: "", conclusion: refused, jobs: [] };
12861289
const ref = `refs/heads/${SYNC_CANDIDATE_BRANCH}`;
12871290
// A retry after a push that started no run would push an unchanged ref,
12881291
// which GitHub records as no event; recreate the branch so it fires one.
@@ -2091,7 +2094,26 @@ export const run = (argv: ReadonlyArray<string>, options: RunOptions = {}): numb
20912094
}
20922095
const newSha = finished.tip;
20932096

2094-
if (!land)
2097+
if (!land) {
2098+
// check — the land run's local battery, so a handed-off tip is one it accepts
2099+
step = "check";
2100+
const refused = localForkCi(runner, root, newSha);
2101+
if (refused !== null)
2102+
return fail({
2103+
conflicts: [...rebase.recorded],
2104+
ci: { run: "", conclusion: refused, jobs: [] },
2105+
marker: markerReport(finished),
2106+
decision: {
2107+
worktree,
2108+
tip: newSha,
2109+
paths: [],
2110+
resume: [
2111+
`# fix the refusal as tip work in ${worktree}, then rerun:`,
2112+
`vp run fork:sync ${target.tag}`,
2113+
].join("\n"),
2114+
},
2115+
error: `${refused} on ${newSha.slice(0, 7)}; hand off only a green tip`,
2116+
});
20952117
return finish(
20962118
frame({
20972119
outcome: "rebased",
@@ -2109,6 +2131,7 @@ export const run = (argv: ReadonlyArray<string>, options: RunOptions = {}): numb
21092131
},
21102132
}),
21112133
);
2134+
}
21122135

21132136
// ci — hyprws CI on the candidate sha is the one gate before the trunk moves
21142137
step = "ci";

0 commit comments

Comments
 (0)