Skip to content

Commit 9fa7d12

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(fork-sync): a green dry-run keeps its tip for the real sync to publish (#1503)
## Problem A green `vp run fork:sync <tag> --dry-run` dropped `.t3/fork-sync/worktree`, so its proven tip sat on no ref. The real run rebased again; rerere replayed the resolutions but not the repairs committed after them, so it could publish a different, red tip. ## Change | Part | Change | | --- | --- | | Dry run | a green dry run keeps the worktree and its state file | | Report | `decision` names the worktree, `tip`, and `vp run fork:sync <tag>` | | Real run | adopts the kept tip on the same tag, target, and lease; reruns the battery; pushes that tip | | Recreate | a moved lease or a new tag still rebases from scratch (existing adoption key) | | Stops | the dry run's conflict rows still reach the real run's report | | Docs | fork-sync guide and skill state the dry-run-then-real route | The real run rechecks rather than trusting the dry run's battery: skipping would need proof the tree and battery are identical. ## Scope and approval Closes #1495. ## Close conditions - [ ] Kept: a green dry-run leaves a tip the real run adopts - [ ] Same tip: the real run after a green dry-run publishes that tip, with the same target and lease - [ ] Guard: a test fails when a green dry-run drops its tip - [ ] Runbook: the fork-sync guide states the dry-run-then-real route ## Verification - `vp test run scripts/fork-sync.test.ts` → 58 passed - New test: block, hand-resolve, commit a repair, green dry run, real run - It asserts the kept HEAD, `decision`, pushed tip, carried rows, no `rebase` call - Guard: with `dropWorktree` restored on the dry-run path, the new test fails - `vp run fork:ci` → exit 0 - `vp run typecheck` (scripts) → exit 0 Claude Opus 5.5 via Claude Code. ## Fork trailers Fork-Domain: fork-meta Fork-Tier: core Co-authored-by: donjor <[email protected]>
1 parent 4bcb299 commit 9fa7d12

4 files changed

Lines changed: 91 additions & 9 deletions

File tree

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ vp run fork:sync <tag> --dry-run
2020
`--dry-run` rebases and checks, then stops: no push, no issue, no publication.
2121
Any other flag is a defect.
2222

23+
A green dry run keeps its tip in the sync worktree for the real run:
24+
25+
1. Dry run reaches `applied`
26+
2. `decision.tip` names the kept tip
27+
3. `vp run fork:sync <tag>` adopts it
28+
4. The battery reruns; the tip pushes
29+
30+
A moved lease or a new tag rebases again instead.
31+
2332
## Read the report
2433

2534
`.t3/fork-sync/<tag>.json` is the only run authority; the printed Markdown is output.
@@ -34,7 +43,7 @@ Post-push recovery reads this file, never a comment.
3443
| `conflicts[]` | Every stop's path, fork and upstream commit, route |
3544
| `checks[]` | Each battery command and its result |
3645
| `decision` | A stopped run's worktree, paths, and exact resume commands |
37-
| `decision.tip` | A red check's rebased tip, kept in the worktree |
46+
| `decision.tip` | A red check's or green dry run's tip, kept in the worktree |
3847

3948
Never edit a report; a rerun supersedes it.
4049

@@ -115,6 +124,8 @@ Each body ends with its open-since date, target count, and last five runs; a cle
115124

116125
### Finished tip from elsewhere
117126

127+
A green dry run's tip needs none of this: the real run adopts it.
128+
118129
1. Open the kept worktree.
119130
2. `git rebase --abort` if one is in progress.
120131
3. `git reset --hard <sha>`.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ It folds each `fixup! <subject>` landing into the one fork commit it names, and
2424

2525
A tag the fork already sits on reports `already applied`, after closing any open block or failure issue.
2626
`--dry-run` rebases and checks, then stops: no push, no issue, no close.
27+
A green dry run keeps its tip in the [sync worktree](#unblocking-by-hand); `decision.tip` names it.
28+
The real run on the same tag and lease adopts that tip, reruns the battery, and pushes it, with no second rebase.
2729
An applied run cuts the nightly by itself: `hyprws-ci.yml` completion triggers `hyprws-release.yml` through `workflow_run`.
2830
The release gate needs the current `origin/hyprws` tip with a green `hyprws CI`; a red battery cuts no release (RSI-Software/t3code-hyprws#1181).
2931

@@ -70,7 +72,7 @@ Issue comments are projections of it: never parse one, and never treat an edit t
7072
| `trunk` | Trunk before and after |
7173
| `conflicts[]` | Every stop's path, fork and upstream commit, resolution |
7274
| `checks[]` | The check battery and each verdict |
73-
| `decision` | A blocked run's worktree, paths, and resume commands |
75+
| `decision` | A blocked run's or kept tip's worktree, paths, and resume |
7476

7577
Decisions persist to the report before any comment posts.
7678
Never edit a report; a rerun supersedes it.
@@ -126,6 +128,7 @@ After the sync, the [`fork-fold`](../../../.agents/skills/fork-fold/SKILL.md) re
126128

127129
**Kept sync worktree.** Created through the `t3.json` setup step, so a stop has dependencies installed.
128130
It carries every stop's rows between runs, so the report keeps them.
131+
A green dry run keeps it, so its tip and repairs reach the real run.
129132
Rerun after each stop: the report records only the stops a run saw.
130133

131134
## Failure lifecycle

‎scripts/fork-sync.test.ts‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,62 @@ it("carries a reshape extra committed in the kept worktree into the pushed tip",
454454
);
455455
});
456456

457+
it("keeps a green dry run's tip and the real run publishes exactly that tip", () => {
458+
withFixture(
459+
{
460+
forkContent: "line1\nline2 fork\nline3\n",
461+
upstreamContent: "line1\nline2 upstream\nline3\n",
462+
},
463+
(f) => {
464+
capture(() => run(["v1.0.0", "--dry-run"], { runner: exec().runner, root: f.root }));
465+
const blocked = readReport(f.root, "v1.0.0");
466+
NodeFS.writeFileSync(
467+
NodePath.join(f.worktree, "shared.txt"),
468+
"line1\nline2 resolved\nline3\n",
469+
);
470+
f.git(["add", "shared.txt"], f.worktree);
471+
f.git(["-c", "core.editor=true", "rebase", "--continue"], f.worktree);
472+
// a repair committed after the resolution: rerere would not replay it
473+
NodeFS.writeFileSync(NodePath.join(f.worktree, "repair.txt"), "repair\n");
474+
f.git(["add", "repair.txt"], f.worktree);
475+
f.git(["commit", "--quiet", "-m", "repair"], f.worktree);
476+
477+
const dry = capture(() =>
478+
run(["v1.0.0", "--dry-run"], { runner: exec().runner, root: f.root }),
479+
);
480+
assert.strictEqual(dry.value, 0);
481+
const proven = readReport(f.root, "v1.0.0");
482+
const tip = proven.trunk.after!;
483+
// the proven tip stays in the kept worktree the report names
484+
assert.strictEqual(f.git(["rev-parse", "HEAD"], f.worktree), tip);
485+
assert.deepEqual(proven.decision, {
486+
worktree: f.worktree,
487+
tip,
488+
paths: [],
489+
resume: "vp run fork:sync v1.0.0",
490+
});
491+
assert.match(dry.output, new RegExp(`Tip: \`${tip}\``));
492+
493+
const real = exec();
494+
const code = capture(() => run(["v1.0.0"], { runner: real.runner, root: f.root })).value;
495+
assert.strictEqual(code, 0);
496+
const report = readReport(f.root, "v1.0.0");
497+
assert.strictEqual(report.lease.expectedOld, proven.lease.expectedOld);
498+
assert.strictEqual(report.trunk.after, tip);
499+
assert.strictEqual(f.git(["rev-parse", "origin/hyprws"], f.root), tip);
500+
// the dry run's stop still reports its row
501+
assert.deepEqual(report.conflicts, blocked.conflicts);
502+
// no second rebase; the battery checks the adopted tip again
503+
assert.strictEqual(
504+
real.calls.some(({ command, args }) => command === "git" && args.includes("rebase")),
505+
false,
506+
);
507+
assert.strictEqual(report.checks.length, BATTERY_ROWS);
508+
assert.strictEqual(NodeFS.existsSync(f.worktree), false);
509+
},
510+
);
511+
});
512+
457513
it("recreates the kept worktree when the lease moves or the tag changes", () => {
458514
withFixture(
459515
{

‎scripts/fork-sync.ts‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
// sha, lease, and every stop's conflict rows beside it; a rerun on the same
1313
// three adopts the kept worktree — continuing a resolved rebase, or taking a
1414
// finished HEAD with any reshape extras committed there — and reports every
15-
// stop so far. A different tag or a moved lease recreates it. A new worktree
16-
// runs the repo's own worktree setup step, so a stop already has dependencies.
15+
// stop so far. A green dry run keeps it too, so the real run publishes the
16+
// tip the dry run proved. A different tag or a moved lease recreates it. A new
17+
// worktree runs the repo's own worktree setup step, so a stop already has
18+
// dependencies.
1719
//
1820
// | Step | Fails when |
1921
// | ------- | -------------------------------------------------- |
@@ -187,13 +189,14 @@ export const ConflictRow = Schema.Struct({
187189
export interface ConflictRow extends Schema.Schema.Type<typeof ConflictRow> {}
188190

189191
/**
190-
* The typed decision route a stopped run leaves behind. Recovery reads this —
191-
* resolve the named paths in the named worktree, continue the rebase, rerun.
192+
* The typed decision route a stopped run or a green dry run leaves behind.
193+
* Recovery reads this — resolve the named paths in the named worktree, continue
194+
* the rebase, rerun; after a green dry run, the real run publishes the kept tip.
192195
*/
193196
export const DecisionRoute = Schema.Struct({
194-
/** The detached worktree holding the stopped rebase; `""` when nothing to resume. */
197+
/** The detached worktree holding the stopped rebase or kept tip; `""` when nothing to resume. */
195198
worktree: Schema.String,
196-
/** The rebased tip a red check battery left in the worktree; trunk did not move. */
199+
/** The rebased tip a red battery or a green dry run left in the worktree; trunk did not move. */
197200
tip: Schema.optionalKey(Schema.String),
198201
/** The paths resolved by hand there. */
199202
paths: Schema.Array(Schema.String),
@@ -1781,13 +1784,22 @@ export const run = (argv: ReadonlyArray<string>, options: RunOptions = {}): numb
17811784
// push — the documented expected-old lease; a dry run reaches applied without it
17821785
step = "push";
17831786
if (dryRun) {
1784-
dropWorktree(runner, root);
1787+
// The worktree stays: the real run on the same tag and lease adopts the
1788+
// proven tip instead of rebasing again, since rerere replays resolutions
1789+
// but not the repairs committed after them (RSI-Software/t3code-hyprws#1495).
1790+
const worktree = worktreePath(root);
17851791
return finish(
17861792
frame({
17871793
outcome: "applied",
17881794
trunk: { before: expectedOld, after: newSha },
17891795
conflicts: [...rebase.recorded],
17901796
checks,
1797+
decision: {
1798+
worktree,
1799+
tip: newSha,
1800+
paths: [],
1801+
resume: `vp run fork:sync ${target.tag}`,
1802+
},
17911803
push: { pushed: false, detail: "dry run" },
17921804
}),
17931805
);

0 commit comments

Comments
 (0)