Skip to content

Commit 434880c

Browse files
donjor-agent[bot]donjor
authored andcommitted
feat(fork-sync): a blocked sync labels its attention issue rsi:fork-sync (#1847)
## Problem A blocked sync labels its attention issue `ci` only, so rsi-pr-agent never starts on it. rsi-pr-agent runs a repository workflow only on its `rsi:<id>` label. ## Change A blocked publish adds `rsi:fork-sync` beside `ci`: ```diff - const { issue, publishedVia } = upsertStandingIssue(runner, root, stop.title, (previous) => - attentionIssueBody(report, previous), + const { issue, publishedVia } = upsertStandingIssue( + runner, + root, + stop.title, + key === "blocked" ? [AGENT_LABEL] : [], + (previous) => attentionIssueBody(report, previous), ); ``` - **Create:** `--label ci --label rsi:fork-sync` - **Rewrite:** `--add-label rsi:fork-sync` - **Unchanged body:** no write, so no relabel - **Failure issues:** `ci` only - **Docs:** one line in `fork-sync.md` rsi-pr-agent consumes the label when a run starts, so each changed blocked rewrite asks again. **Merge after** #1848 (the #1845 definition). rsi-pr-agent creates `rsi:fork-sync` only once that definition is on `hyprws`. Before then, `gh issue create --label rsi:fork-sync` refuses a missing label and the blocked publish fails. ## Scope and approval Refs #1843. Its condition, "The attention issue gets rsi:fork-sync", needs a live blocked sync after merge; the host owns that proof under #1841. ## Verification - [x] `vp test run scripts/fork-sync.test.ts → exit 0` - [x] Blocked create and rewrite carry `rsi:fork-sync` - [x] Failure create and rewrite carry `ci` only - [x] `vp run typecheck → exit 0` - [x] `vp run fork:ci → exit 0` - [ ] Live blocked sync labels its issue (after merge) Claude Opus 5.5, Claude Code. ## Fork trailers Fork-Domain: fork-meta Fork-Tier: qol Co-authored-by: donjor <[email protected]>
1 parent 21a1043 commit 434880c

3 files changed

Lines changed: 35 additions & 21 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ Its title names the step and target, so reruns never rename it; its body carries
132132

133133
The newest open `ci` issue matching `hyprws sync blocked` or `hyprws sync failed` is adopted, including legacy issues.
134134
Older matches close with a one-line pointer to the kept issue; only no match files a new one.
135+
A blocked run also adds `rsi:fork-sync` on create or rewrite, which starts rsi-pr-agent's `fork-sync` workflow; a failed run never does.
135136
A clean run (applied or already-applied) closes open matches with `gh issue close --reason completed --comment "Resolved by hyprws <sha>"`.
136137
A refused publication or close lands in the report and fails the run.
137138
Dry runs never publish or close issues.

‎scripts/fork-sync.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,7 +1570,7 @@ it("files one attention issue with the governed fields", () => {
15701570
assert.strictEqual(value("--type"), "Notification 🔔");
15711571
assert.deepStrictEqual(
15721572
args.filter((argument, index) => args[index - 1] === "--label"),
1573-
["ci"],
1573+
["ci", "rsi:fork-sync"],
15741574
);
15751575
const list = recording.calls.find(
15761576
({ command, args }) => command === "gh" && args[0] === "issue" && args[1] === "list",
@@ -1617,6 +1617,7 @@ it("edits the open issue in place when the rendered body drifts, never comments"
16171617
assert.strictEqual(args[2], "11");
16181618
const value = (name: string): string | undefined => args[args.indexOf(name) + 1];
16191619
assert.strictEqual(value("--title"), "hyprws sync blocked at rebase (v1.0.0)");
1620+
assert.strictEqual(value("--add-label"), "rsi:fork-sync");
16201621
assert.include(edits[0]!.body, blockingShaMarker("5".repeat(40)));
16211622
assert.strictEqual(
16221623
recording.calls.some(({ args }) => args[0] === "issue" && args[1] === "comment"),
@@ -1657,6 +1658,7 @@ it("rewrites the one standing issue for a new target and supersedes older open o
16571658
const args = edits[0]!.args;
16581659
assert.strictEqual(args[2], "12");
16591660
assert.strictEqual(args[args.indexOf("--title") + 1], "hyprws sync failed at check (v1.1.0)");
1661+
assert.notInclude(args, "--add-label");
16601662
const body = edits[0]!.body;
16611663
assert.include(body, "Open since 2026-09-21 across 2 targets;");
16621664
assert.include(body, "- 2026-09-22 · `v1.1.0` · check\n- 2026-09-21 · `v1.0.0` · check");
@@ -1746,10 +1748,10 @@ it("falls back to gh issue edit --type when gh rejects --type at create", () =>
17461748
assert.strictEqual(typeEdit!.args[2], "44");
17471749
const typeIndex = typeEdit!.args.indexOf("--type");
17481750
assert.strictEqual(typeEdit!.args[typeIndex + 1], "Notification 🔔");
1749-
// still exactly one label on the landed create
1751+
// the same labels on the landed create
17501752
assert.deepStrictEqual(
17511753
creates[1]!.args.filter((argument, index) => creates[1]!.args[index - 1] === "--label"),
1752-
["ci"],
1754+
["ci", "rsi:fork-sync"],
17531755
);
17541756
});
17551757

‎scripts/fork-sync.ts‎

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const SYNC_DIR = ".t3/fork-sync";
9898
const WORKTREE_DIR = "worktree";
9999
/** The attention issue keeps the governed label and outcome-shaped legacy titles. */
100100
const BLOCK_LABEL = "ci";
101+
/** A blocked stop also starts rsi-pr-agent's `.rsi-agent/workflows/fork-sync.md`. */
102+
const AGENT_LABEL = "rsi:fork-sync";
101103
const BLOCK_TITLE_PHRASE = '"hyprws sync blocked" in:title';
102104
const FAILURE_TITLE_PHRASE = '"hyprws sync failed" in:title';
103105
const REPORT_SCHEMA = "fork.sync-report.v2";
@@ -1549,8 +1551,13 @@ export interface GitHub {
15491551
const NOTIFICATION_TYPE = "Notification 🔔";
15501552

15511553
/** Every write goes through plain `gh`; `edit` rewrites title and body in one call. */
1552-
export const githubClient = (runner: CommandRunner, root: string): GitHub => {
1554+
export const githubClient = (
1555+
runner: CommandRunner,
1556+
root: string,
1557+
labels: ReadonlyArray<string> = [],
1558+
): GitHub => {
15531559
const repo = ["--repo", FORK_REPOSITORY];
1560+
const labelArgs = [BLOCK_LABEL, ...labels].flatMap((label) => ["--label", label]);
15541561
const list = (titlePhrase: string) =>
15551562
JSON.parse(
15561563
runRequire(
@@ -1587,8 +1594,7 @@ export const githubClient = (runner: CommandRunner, root: string): GitHub => {
15871594
bodyPath,
15881595
"--type",
15891596
NOTIFICATION_TYPE,
1590-
"--label",
1591-
BLOCK_LABEL,
1597+
...labelArgs,
15921598
],
15931599
{ cwd: root },
15941600
);
@@ -1598,17 +1604,7 @@ export const githubClient = (runner: CommandRunner, root: string): GitHub => {
15981604
// type by editing the fresh issue right after, noting either refusal.
15991605
const retry = runner.run(
16001606
"gh",
1601-
[
1602-
"issue",
1603-
"create",
1604-
...repo,
1605-
"--title",
1606-
title,
1607-
"--body-file",
1608-
bodyPath,
1609-
"--label",
1610-
BLOCK_LABEL,
1611-
],
1607+
["issue", "create", ...repo, "--title", title, "--body-file", bodyPath, ...labelArgs],
16121608
{ cwd: root },
16131609
);
16141610
if (retry.status !== 0 || retry.error !== undefined)
@@ -1627,7 +1623,17 @@ export const githubClient = (runner: CommandRunner, root: string): GitHub => {
16271623
runRequire(
16281624
runner,
16291625
"gh",
1630-
["issue", "edit", String(issue), ...repo, "--title", title, "--body-file", bodyPath],
1626+
[
1627+
"issue",
1628+
"edit",
1629+
String(issue),
1630+
...repo,
1631+
"--title",
1632+
title,
1633+
"--body-file",
1634+
bodyPath,
1635+
...labels.flatMap((label) => ["--add-label", label]),
1636+
],
16311637
{ cwd: root },
16321638
);
16331639
},
@@ -1676,9 +1682,10 @@ const upsertStandingIssue = (
16761682
runner: CommandRunner,
16771683
root: string,
16781684
title: string,
1685+
labels: ReadonlyArray<string>,
16791686
render: (previous?: string) => string,
16801687
): { readonly issue: number | null; readonly publishedVia: "gh" } => {
1681-
const github = githubClient(runner, root);
1688+
const github = githubClient(runner, root, labels);
16821689
const [standing, ...superseded] = [
16831690
...new Map(
16841691
[BLOCK_TITLE_PHRASE, FAILURE_TITLE_PHRASE]
@@ -1709,8 +1716,12 @@ export const publishAttention = (
17091716
const key = report.blocked !== null ? "blocked" : "failure";
17101717
const stop = report[key]!;
17111718
try {
1712-
const { issue, publishedVia } = upsertStandingIssue(runner, root, stop.title, (previous) =>
1713-
attentionIssueBody(report, previous),
1719+
const { issue, publishedVia } = upsertStandingIssue(
1720+
runner,
1721+
root,
1722+
stop.title,
1723+
key === "blocked" ? [AGENT_LABEL] : [],
1724+
(previous) => attentionIssueBody(report, previous),
17141725
);
17151726
return {
17161727
...report,

0 commit comments

Comments
 (0)