Repository navigation
refactor(dispatch): one predicate for an open PR closing this issue - #112
Merged
Merged
Conversation
`decide.mjs` asked "does an open PR close this issue?" at four sites in three shapes: `s.openPrsClosingIt.length` with two more reads for the comment text (288), `.length > 0` (372), `.length` (374), and `?.length` (399). One fact, four statements, and the next arm to need it picks a fifth shape. `inFlight(s)` now states it once, beside `isBot` and `respondTo`. It returns the list rather than a boolean so the in-flight guard can name the PR without reading the field again. #110 left the guard's shape open: put the `?.` in the predicate, or leave `sweep-awaiting` holding the only guarded read. The `?.` in the predicate would reach three sites that provably hold issue snapshots only — they sit after an `if (s.kind === 'pr')` block whose every branch returns — and there a missing key is a `gather.mjs` bug that the bare read is what surfaces. Silencing it at three sites to serve one is a fail-loud-to-fail-silent trade inside a refactor that is meant to change no behaviour. So the read stays bare and `sweep-awaiting` tests `kind` instead. That arm is the only one pushed for PRs as well as issues (`sweep.mjs:112`), and a PR snapshot carries no such key, because `gather.mjs:117` sets it on the issue arm alone. `s.kind` is the discriminator the rest of the file already splits on, and `gather.mjs:93` sets it on every snapshot. The test that pins the PR case still fails with a `TypeError` when the guard is removed, which is what proves it survived the extraction. No behaviour change. The suite is unchanged at 76 passing, which is the evidence: a refactor that needed a new test would have changed something. Closes #110 Claude-Session: https://claude.ai/code/session_01J6vvtULNyZFphz3fUuWuj1 Co-authored-by: Claude <[email protected]>
Contributor
Author
|
Adversarial review skipped: 1 file(s), 24 changed line(s), under 🤖 sydevs dispatcher |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
decide.mjsasked "does an open PR close this issue?" at four sites in three shapes.inFlight(s)now states it once, besideisBotandrespondTo.maindiffer in none.?.lives — is answered the other way: the read stays bare, andsweep-awaitingtestskind. See Notes for reviewer.Changes
dispatcher/decide.mjs— the predicate, plus its four callers: the in-flight guard (296),unlock'sanswered(384) and its Statusdonewrite (386), andsweep-awaiting(410).Contract impact
dispatcher/is the shared workflow all five sydevs repos call, so a merge reaches them on their next event. This changes no plan on any reachable input — see the differential run below.Test results
claude plugin validate ./workflow --strictnode --test dispatcher/test/*.test.mjs. Same count asmainatb4aa42b, and no test added or changed: an unchanged suite is the evidence a refactor asks for.Two proofs beyond the suite:
decide()fromorigin/mainand from this branch, over 15,424(snapshot, reason, facts)combinations — everyopenPrsClosingItvalue, label set, lock, verb, park and blocker crossed withissue_comment,unlock,sweep-awaitingandsweep-recheck, plus PR snapshots. 0 plans differ.s.kind === 'issue' &&from the sweep arm andthe awaiting sweep leaves a ticket whose PR is open, and does not throw on a PRfails with aTypeError. That is the guard surviving the extraction, which is what the ticket's checklist asked for.Manual verification
BOT_DISPATCH=drysweep over a repo with an open bot PR, confirming the note still logs and noawaitingis planned (docs/routine-setup.md§6) — was not run. A routine cannot reach the GitHub API, so this needs an attended run.Notes for reviewer
One decision, and it goes against the ticket's checklist. #110 left the shape open: put the
?.inside the predicate, or leave the guard atsweep-awaiting. Its verification checklist assumed the first and proposed narrowing the predicate's?.to.as the proof. This PR ships the second.Why: the
?.inside the predicate also reaches three sites that provably hold issue snapshots only — they sit after anif (s.kind === 'pr')block whose every branch returns. There a missing key is agather.mjsbug, and the bare read is what surfaces it. Swallowing it at three sites to serve one turns fail-loud into fail-silent inside a refactor meant to change nothing. Thekindtest costs one comparison at the one arm whose input actually varies, and the mutation proof above replaces the checklist's.If you would rather hold the checklist literally, it is a one-line flip:
?.in the predicate, drops.kind === 'issue' &&. Both shapes pass the suite.Five review lenses came back clean. One finding was accepted, three rejected — below.
Detail
Accepted:
inFlight(s) !== nullwas a second shape. The commit's whole point is one statement of one fact, and that site shipped with a third spelling of it. NowBoolean(inFlight(s)), matching the bare truthiness the other sites use.Rejected: return the first PR number rather than the list (
s.openPrsClosingIt?.[0] ?? null). Only one caller names a PR, and only[0], so the list looks like unused generality. But the field holds every open PR closing the ticket (gather.mjs:49, capped at 10), and a predicate that silently keeps the first would make a second one invisible at the read site. The ticket names the list shape for the same reason. The ambiguity that finding really objected to — "is a falsy non-null return possible?" — is gone with the accepted fix above.Rejected: normalize
openPrsClosingIt: []onto the PR snapshot ingather.mjs. #107 rejected this already: the key is meaningless on a PR, an empty array there asserts "no open PR closes this PR", and it singles out one of five issue-only fields that all rely on their read-site guard. Unchanged here.Rejected: stop
sweep.mjspushingsweep-awaitingfor PRs. That is a behaviour change with its own failure to state, and #106 ruled it out of scope until a wrongawaitingon a PR is actually seen. PRs do carryawaiting, so the correction is real there too.Note on the house idiom.
decide.mjsguards other kind-specific fields with?.at the read site (s.park?.until,s.linkedLocked?.length), so thekindtest is a small deviation. It buys the loud failure at three sites; the idiom buys one character. Flag it if you disagree — see the one-line flip above.Lenses run.
pr-review-toolkitis not installed in this environment, so step 2 ran as/simplify(reuse, simplification, efficiency, altitude) plus/code-review. Correctness, reuse and efficiency came back clean with evidence, each naming the files read.comment-lint.mjsskipped itself — it needstypescriptresolvable, and this repo has no package manager.Docs checked, nothing stale.
docs/why.md#a-pr-is-the-answer-to-an-implement-verbstates the rule, not the shape, and both the predicate and the sweep arm cite it.Not owed. No skill or
loop-config.jsonchange, so noversionbump inworkflow/.claude-plugin/plugin.json, andrule-delta.mjsdoes not apply. Security review skipped: the diff matches no path insecurityReview.triggerPattern.Closes #110
🤖 Generated with Claude Code
https://claude.ai/code/session_01J6vvtULNyZFphz3fUuWuj1
Generated by Claude Code