Skip to content

Commit dd1b537

Browse files
donjor-agent[bot]donjor
authored andcommitted
fix(fork-sync): the job always decides and runs from an rsi-pr-agent checkout (#1854)
## Problem The first live `fork-sync` job ([run_a24855ae](https://agent.rsi.nz/runs/run_a24855ae4dc78bc3194b411b85e9c7ea)) resolved about 17 rebase stops, then reported `blocked` at `b2a94da9bd` (desktop wheel zoom) after 19 of its 45 minutes. - **Rule:** "Unsure: report `blocked`" - **Root:** driver took `/home/agent/commits` - **`vp`:** not on PATH for worktree setup An rsi-pr-agent job keeps its git dir outside the work tree, so `dirname(--git-common-dir)` is not the checkout. The job worked around both by cloning a sibling checkout, which also lost its commit identity. ## Change - **Job mode:** decides every seam; never blocks - **Default:** upstream stands; port at the tip - **Failed port:** Retire, listed under `Verify:` - **Summary:** ends with what to test - **Driver:** separate git dir → `--show-toplevel` - **`vp`:** Job mode links it outside `node_modules` ## Scope and approval Part of #1841, which now has no human-review step: candidate CI gates landing. ## Verification - [x] **New test:** separate git dir blocks, then applies - [x] **Without the fix:** it fails - [x] `vp test run scripts/fork-sync.test.ts` → 79 ok - [x] `vp run fork:ci` → exit 0 Not yet proven: a live job deciding a seam it would have blocked on; the next sync proves it. Claude Opus 5.5 in Claude Code. ## Fork trailers Squashes: - 83669bb fix(fork-sync): the job always decides and runs from an rsi-pr-agent checkout (#1854) (#1854) - a0ab51c fixup! fix(fork-sync): the job always decides and runs from an rsi-pr-agent checkout (#1854) (#1854) Fork-Domain: fork-meta Fork-Tier: bugfix Fork-Upstreamable: no Co-authored-by: donjor <[email protected]>
1 parent 7c7dc13 commit dd1b537

4 files changed

Lines changed: 55 additions & 12 deletions

File tree

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

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,33 @@ The body keeps its open-since date, target count, and last five runs; a clean ru
147147

148148
A job resolves a blocked sync without writing the trunk or the candidate.
149149
It hands its resolutions to the next run as data on `sync/resolution`.
150+
No human reviews it: candidate CI gates the landing.
150151

151152
1. Add the `upstream` remote unless present
152-
2. Run `vp run fork:sync <tag> --dry-run`
153-
3. Resolve `manual` paths per [Conflict](#conflict)
154-
4. `git add` them in the kept worktree; rerun
155-
5. Repeat until the rebase finishes
156-
6. Commit tip adaptation there; rerun once
157-
7. `git update-ref --no-deref HEAD refs/fork-sync/resolution`
158-
8. Report `committed`: rsi-pr-agent pushes `HEAD`; the sync reruns
153+
2. Put `vp` on PATH, outside `node_modules`
154+
3. Run `vp run fork:sync <tag> --dry-run`
155+
4. Resolve `manual` paths per [Conflict](#conflict)
156+
5. `git add` them in the kept worktree; rerun
157+
6. Repeat until the rebase finishes
158+
7. Commit tip adaptation there; rerun once
159+
8. `git update-ref --no-deref HEAD refs/fork-sync/resolution`
160+
9. Report `committed`: rsi-pr-agent pushes `HEAD`; the sync reruns
159161

160162
```sh
161163
git remote add upstream https://github.com/pingdotgg/t3code.git
164+
mkdir -p /tmp/fork-bin && ln -sf "$PWD/node_modules/.bin/vp" /tmp/fork-bin/vp
165+
PATH=/tmp/fork-bin:$PATH vp run fork:sync <tag> --dry-run
162166
```
163167

168+
**Decide every seam.** Uncertainty never blocks a job:
169+
170+
- **Default:** upstream stands; port at the tip
171+
- **Port fails its checks:** Retire it
172+
- **Each Reshape or Retire:** one Verify item
173+
- **Blocked:** only a driver or setup failure
174+
175+
The report's summary ends with `Verify:` and those items: behaviour to exercise once the sync lands.
176+
164177
Every rebase rewrites `refs/fork-sync/resolution` before `ci`, so a `ci` failure in the job is expected.
165178
It is one parentless commit:
166179

‎.rsi-agent/workflows/fork-sync.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The `fork-sync` skill owns every step and rule; follow it, and copy nothing from
1717
Its "Job mode" section is this job's procedure, from a clean clone to `HEAD` at the resolution export.
1818

1919
- **Resolve:** by the skill's Conflict section
20-
- **Unsure:** report `blocked`; a human takes over
20+
- **Unsure:** decide per Job mode; never block
21+
- **Verify:** summary ends with what to test
2122
- **Never push `hyprws`:** the driver is its writer
2223
- **Never post:** to `pingdotgg/t3code`

‎scripts/fork-sync.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,32 @@ it("stops at a conflict rerere and hooks cannot resolve, then applies after a ha
323323
);
324324
});
325325

326+
it("runs from a checkout whose git dir lives elsewhere, as an rsi-pr-agent job's does", () => {
327+
withFixture(
328+
{
329+
forkContent: "line1\nline2 fork\nline3\n",
330+
upstreamContent: "line1\nline2 upstream\nline3\n",
331+
},
332+
(f) => {
333+
f.git(
334+
["init", "--quiet", `--separate-git-dir=${NodePath.join(f.root, "..", "gitdir")}`],
335+
f.root,
336+
);
337+
const resolve = (): number =>
338+
capture(() => run(["v1.0.0", "--dry-run"], { runner: exec().runner, root: f.root })).value;
339+
assert.strictEqual(resolve(), 1);
340+
assert.strictEqual(readReport(f.root, "v1.0.0").outcome, "blocked");
341+
NodeFS.writeFileSync(
342+
NodePath.join(f.worktree, "shared.txt"),
343+
"line1\nline2 resolved\nline3\n",
344+
);
345+
f.git(["add", "shared.txt"], f.worktree);
346+
assert.strictEqual(resolve(), 0);
347+
assert.strictEqual(readReport(f.root, "v1.0.0").outcome, "applied");
348+
},
349+
);
350+
});
351+
326352
it("carries a hand resolution and its fixups to a fresh runner through sync/resolution", () => {
327353
withFixture(
328354
{

‎scripts/fork-sync.ts‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,17 +251,20 @@ export interface ForkSyncReport extends Schema.Schema.Type<typeof ForkSyncReport
251251
const emptyDecision = (): DecisionRoute => ({ worktree: "", paths: [], resume: "" });
252252

253253
/**
254-
* The main checkout of the repository `cwd` belongs to. The sync runs from
255-
* there and keeps its state there, so a rerun from another lane, or from inside
256-
* the kept worktree it may drop, adopts the same state.
254+
* The main checkout of `cwd`'s repository, where the sync runs and keeps state, so a rerun from
255+
* another lane or from the kept worktree adopts it. A checkout whose git dir lives elsewhere (an
256+
* rsi-pr-agent job's) has no checkout beside that dir, so it is its own main checkout.
257257
*/
258258
const mainCheckout = (runner: CommandRunner, cwd: string): string => {
259259
const common = gitResult(runner, cwd, [
260260
"rev-parse",
261261
"--path-format=absolute",
262262
"--git-common-dir",
263263
]);
264-
return common.status === 0 ? NodePath.dirname(common.stdout.trim()) : cwd;
264+
if (common.status !== 0) return cwd;
265+
if (NodePath.basename(common.stdout.trim()) === ".git")
266+
return NodePath.dirname(common.stdout.trim());
267+
return git(runner, cwd, ["rev-parse", "--show-toplevel"]);
265268
};
266269

267270
export const reportPath = (root: string, tag: string): string =>

0 commit comments

Comments
 (0)