Skip to content

chore(dispatcher): record a skipped relay's branch, drop unread landed - #270

Merged
sydevs-bot merged 2 commits into
mainfrom
claude/chore-263-relay-landed
Nov 17, 2026
Merged

sydevs-bot merged 2 commits into
mainfrom
claude/chore-263-relay-landed

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • docs/why.md#the-relay now says what becomes of a relay branch when decide skips an already-landed relay: only the run that lands a relay deletes its ref, so a hand-landed one stays, and that is accepted rather than cleaned up.
  • applyRelay returns the refusal or null, dropping the landed field no caller has ever read. No behaviour changes.

Change outline

Two joined parts in the relay path, one commit each. Part 1 is prose only — the recorded decision, under the existing docs/why.md#the-relay anchor. Part 2 is the only code.

applyRelay's six return sites all carried a flag that died at the call site.

 applyRelay(gh, { owner, repo }, { branch, head, sha }, log)   dispatcher/relay.mjs
-  → { landed: boolean, refusal: { what, why } | null }
+  → { what, why } | null                       # the refusal, or nothing to hand back
   the head already holds the sha      → landed: true,  refusal: null   → null
   the fast-forward or the merge won   → landed: true,  refusal: null   → null
   the relay ref is missing or moved   → landed: false, refusal: {…}    → { what, why }
   403 / 404 / 422 on the update       → landed: false, refusal: {…}    → { what, why }
   409, the merge conflicts            → landed: false, refusal: {…}    → { what, why }
   403 / 404 / 422 on the merge        → landed: false, refusal: {…}    → { what, why }
-  let landed                                   # assigned twice, read nowhere

The one caller already destructured refusal alone, so the guard it feeds is untouched.

 case 'relay':                                                dispatcher/apply.mjs
-  const { refusal } = await applyRelay(gh, args, a, log)
+  const refusal = await applyRelay(gh, args, a, log)
   if (refusal) handedOver.push(refusal)        # unchanged: one hand-over per refusal

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict passed, node --test workflow/lib/*.test.mjs 143 passed, 0 failed. Its one warning is the pre-existing missing plugin icon.
  • node --test dispatcher/test/*.test.mjs: 358 passed, 0 failed.
  • Coverage check: with dispatcher/relay.mjs reverted to origin/main and the new tests kept, all seven rewritten assertions fail. Each is pinned to the new shape.
  • grep -rn "landed" dispatcher/*.mjs leaves one line: the explanatory comment at dispatcher/decide.mjs:1123. No field, no reader.
  • node workflow/lib/comment-lint.mjs --base origin/main: no banned comment added.

Manual verification

  1. The no-behaviour-change claim is what deserves a human's eye. applyRelay is only reachable from a real dispatch, so watch one relay land end to end — a scratch @sydevs-bot revise on a member-branch PR, or BOT_DISPATCH=dry to read the plan — and check the PR branch moves and the relay ref is deleted exactly as before.

Notes for reviewer

  • One commit per part, each separately revertable: docs(why): for the decision, refactor(dispatcher): for the code. No workflow/** or loop-config.json edit, so no skill change rides along with a ceiling change.
  • Part 1 adds no code on purpose. The ticket weighed cleaning the ref up and chose to record it: deleting it needs a cleanup action of its own in decide and apply, against a leftover nothing reads.
  • Nothing the plugin ships is touched, so CI's version-bump check does not apply — ci.yml scopes it to workflow/skills, workflow/hooks and workflow/lib — and workflow/.claude-plugin/plugin.json stays as it is. No skill changed, so rule-delta.mjs has nothing to measure.
  • The wording to check is the new paragraph's first sentence. An earlier draft said the skip "leaves the relay branch behind", which overstates: in the SahajCloud#1167 case the previous paragraph narrates, an earlier run already deleted it. The paragraph now states the rule instead — only the run that lands a relay deletes its ref — and names the hand-landed case as the one that leaves a leftover.
  • Dismissed, with reasons:
    • Collapse the three status-to-refusal lines behind one refuse(what, e, why) helper. Rejected. It is pre-existing duplication this diff only re-wraps, the helper would carry a widened [403, 404, 409, 422] list and turn two explicit throw paths into a null check, and it is a second behaviour in a PR that already carries two.
    • Extract words(e), which relay.mjs, apply.mjs, deps.mjs and index.mjs each copy. Rejected here. Two of the four cap at 220 characters and two at 160, so unifying them needs a decision about the cap first, not a silent merge.
Detail

Why { what, why } | null and not a boolean. The caller's whole use of the result is if (refusal) handedOver.push(refusal), and each handedOver entry renders as its what in bold followed by GitHub's words from why. what has to come from the callee, because only applyRelay tells "apply the relay" from "merge the relay". apply.mjs already collects that exact shape through its own handOver(), so the relay case now matches the convention beside it instead of unpacking a bespoke wrapper.

Checked for other readers. applyRelay is imported once, at dispatcher/apply.mjs:15, and called once, at :379. decide.mjs imports only pushRoute and relayRefusal, neither touched. Nothing else reads the result.

The docstring lost a claim as well as a field. It said every why carries GitHub's words. Two refusals compose the dispatcher's own — <branch> is at <sha>, not the requested <sha> and <branch> does not exist — so it now says GitHub is quoted where GitHub refused, which is what docs/why.md#quote-the-refusal-do-not-name-a-cause actually asks for.

Validation is untouched. parseRequest in dispatcher/markers.mjs and relayRefusal still gate the request, and decide.mjs still routes through relayRefusal before any relay action is planned. Inside applyRelay the order getRef → at !== sha → holds() → refusal still precedes updateRef and repos.merge, and force: false is intact.

Docs sweep. No AGENTS.md, docs/ page or skill described the old return shape — the JSDoc was the only statement of it. docs/routine-setup.md's two relay lines describe the token's scopes, not the shape. The paragraph adds no new anchor, so the (why: docs/why.md#the-relay) pointers in relay.mjs and apply.mjs stay valid.

Closes #263


Generated by Claude Code

#260 made the relay idempotent by skipping it in `decide` when the request's
sha is already the PR's head. Deleting the relay ref is the last thing
`applyRelay` does, so the skip never reaches it: where no run ever landed the
relay, `claude/relay-<pr>-<sha>` stays. A member fast-forwarding the PR's
branch by hand is that case.

Nothing reads that ref again, and clearing it would need a cleanup action of
its own in `decide` and `apply`. Machinery against an uncounted harm is the
more expensive answer, so the leftover is accepted and recorded.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVDhgtTec2Bn1xyk2f
`applyRelay` documented and returned `{ landed, refusal }`, #260 added a third
`landed: true` return, and the only caller destructured `{ refusal }` alone.
Nothing has ever read `landed`, so a documented field that three return sites
set invites the next change to branch on it.

It now returns the refusal or `null`: the `let landed` and its two assignments
go, and the doc comment says the new shape. The caller becomes
`const refusal = await applyRelay(...)`, with its `if (refusal)` unchanged.
The same comment no longer claims every `why` is GitHub's, since two refusals
compose the dispatcher's own words.

Every GitHub call, every log line and every ref written stay as they were, so
the dispatcher's behaviour does not change. The seven `landed` assertions in
relay.test.mjs assert the refusal, or `null`, in their place; all seven fail
against the old return shape.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVDhgtTec2Bn1xyk2f
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 17, 2026
@sydevs-bot

sydevs-bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:38Z review-pr · attempt 1 · session · done
  • 19:38Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 17, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The diff is smaller than its ticket and adds nothing the ticket did not ask for: 28 lines, four files, two commits, no new file, function, constant or dependency. Part 2 is behaviour-identical. The old caller destructured refusal from a wrapper that was always built, so the same value now arrives directly into the same handedOver.push guard, and the six return sites map one-to-one. Part 1 records the decision instead of building the cleanup the ticket weighed and rejected, which is the cheaper answer. The one contract here is applyRelay → apply.mjs, and { what, why } | null now matches handOver()'s own entries beside it.

Findings: none.

What was checked

  • #263 against the diff. Both parts named, four acceptance criteria met, nothing extra.
  • relay.mjs whole on the branch. Six return sites, force: false intact, the getRef → at !== sha → holds() → refusal order and the 422-with-workflow path unchanged.
  • Builder's ladder. The diff adds no piece to place.
  • applyRelay is imported once (apply.mjs:15) and called once (:379). Its consumer read at apply.mjs:92-107 and 387-396.
  • git grep landed on the branch leaves only the comment at decide.mjs:1123. git grep refusal over docs, workflow and .github finds no statement of the old shape.
  • The seven rewritten assertions each pin the new shape. Two now assert what as well.
  • The new docs/why.md paragraph reads true against the code. The delete is applyRelay's last call, so a skip deletes nothing.
  • Both dismissals in the body hold. A refuse() helper would widen the status list to 409 and turn two deliberate throw paths into a null check.
  • CI / test is green on d18dbbc. Reviewer profile read.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 17, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 17, 2026 19:43
@sydevs-bot
sydevs-bot requested a review from Ardnived November 17, 2026 19:43
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 17, 2026
@sydevs-bot
sydevs-bot enabled auto-merge November 17, 2026 20:17
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 17, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Pending in SYDevelopers Technical Roadmap Nov 17, 2026
Merged via the queue into main with commit 9f82d20 Nov 17, 2026
31 checks passed
@sydevs-bot
sydevs-bot deleted the claude/chore-263-relay-landed branch November 17, 2026 20:45
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

chore(dispatcher): record a skipped relay's branch, drop unread landed

3 participants