Repository navigation
chore(dispatcher): record a skipped relay's branch, drop unread landed - #270
Conversation
#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
left a comment
There was a problem hiding this comment.
🧐 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.mjswhole on the branch. Six return sites,force: falseintact, thegetRef→at !== sha→holds()→ refusal order and the 422-with-workflowpath unchanged.- Builder's ladder. The diff adds no piece to place.
applyRelayis imported once (apply.mjs:15) and called once (:379). Its consumer read atapply.mjs:92-107and387-396.git grep landedon the branch leaves only the comment atdecide.mjs:1123.git grep refusaloverdocs,workflowand.githubfinds no statement of the old shape.- The seven rewritten assertions each pin the new shape. Two now assert
whatas well. - The new
docs/why.mdparagraph reads true against the code. The delete isapplyRelay'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 deliberatethrowpaths into a null check. CI / testis green ond18dbbc. Reviewer profile read.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Summary
docs/why.md#the-relaynow says what becomes of a relay branch whendecideskips 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.applyRelayreturns the refusal ornull, dropping thelandedfield 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-relayanchor. 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 nowhereThe one caller already destructured
refusalalone, so the guard it feeds is untouched.Test results
claude plugin validate ./workflow --strictpassed,node --test workflow/lib/*.test.mjs143 passed, 0 failed. Its one warning is the pre-existing missing plugin icon.node --test dispatcher/test/*.test.mjs: 358 passed, 0 failed.dispatcher/relay.mjsreverted toorigin/mainand the new tests kept, all seven rewritten assertions fail. Each is pinned to the new shape.grep -rn "landed" dispatcher/*.mjsleaves one line: the explanatory comment atdispatcher/decide.mjs:1123. No field, no reader.node workflow/lib/comment-lint.mjs --base origin/main: no banned comment added.Manual verification
applyRelayis only reachable from a real dispatch, so watch one relay land end to end — a scratch@sydevs-bot reviseon a member-branch PR, orBOT_DISPATCH=dryto read the plan — and check the PR branch moves and the relay ref is deleted exactly as before.Notes for reviewer
docs(why):for the decision,refactor(dispatcher):for the code. Noworkflow/**orloop-config.jsonedit, so no skill change rides along with a ceiling change.decideandapply, against a leftover nothing reads.ci.ymlscopes it toworkflow/skills,workflow/hooksandworkflow/lib— andworkflow/.claude-plugin/plugin.jsonstays as it is. No skill changed, sorule-delta.mjshas nothing to measure.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 explicitthrowpaths into a null check, and it is a second behaviour in a PR that already carries two.words(e), whichrelay.mjs,apply.mjs,deps.mjsandindex.mjseach 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 } | nulland not a boolean. The caller's whole use of the result isif (refusal) handedOver.push(refusal), and eachhandedOverentry renders as itswhatin bold followed by GitHub's words fromwhy.whathas to come from the callee, because onlyapplyRelaytells "apply the relay" from "merge the relay".apply.mjsalready collects that exact shape through its ownhandOver(), so the relay case now matches the convention beside it instead of unpacking a bespoke wrapper.Checked for other readers.
applyRelayis imported once, atdispatcher/apply.mjs:15, and called once, at:379.decide.mjsimports onlypushRouteandrelayRefusal, neither touched. Nothing else reads the result.The docstring lost a claim as well as a field. It said every
whycarries 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 whatdocs/why.md#quote-the-refusal-do-not-name-a-causeactually asks for.Validation is untouched.
parseRequestindispatcher/markers.mjsandrelayRefusalstill gate the request, anddecide.mjsstill routes throughrelayRefusalbefore anyrelayaction is planned. InsideapplyRelaythe ordergetRef→at !== sha→holds()→ refusal still precedesupdateRefandrepos.merge, andforce: falseis 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 inrelay.mjsandapply.mjsstay valid.Closes #263
Generated by Claude Code