Skip to content

refactor(dispatch): one predicate for an open PR closing this issue - #112

Merged
Ardnived merged 1 commit into
mainfrom
claude/refactor-110-in-flight-predicate
Sep 18, 2026
Merged

Ardnived merged 1 commit into
mainfrom
claude/refactor-110-in-flight-predicate

Conversation

@sydevs-bot

Copy link
Copy Markdown
Contributor

Summary

  • decide.mjs asked "does an open PR close this issue?" at four sites in three shapes. inFlight(s) now states it once, beside isBot and respondTo.
  • No behaviour change, and none was found: 15,424 plans re-derived against main differ in none.
  • The ticket's open question — where the ?. lives — is answered the other way: the read stays bare, and sweep-awaiting tests kind. See Notes for reviewer.

Changes

  • dispatcher/decide.mjs — the predicate, plus its four callers: the in-flight guard (296), unlock's answered (384) and its Status done write (386), and sweep-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

  • Lean gate: ✓ claude plugin validate ./workflow --strict
  • Targeted specs: 76 passed — node --test dispatcher/test/*.test.mjs. Same count as main at b4aa42b, and no test added or changed: an unchanged suite is the evidence a refactor asks for.
  • Build: N/A

Two proofs beyond the suite:

  • Differential. decide() from origin/main and from this branch, over 15,424 (snapshot, reason, facts) combinations — every openPrsClosingIt value, label set, lock, verb, park and blocker crossed with issue_comment, unlock, sweep-awaiting and sweep-recheck, plus PR snapshots. 0 plans differ.
  • Mutation. Delete s.kind === 'issue' && from the sweep arm and the awaiting sweep leaves a ticket whose PR is open, and does not throw on a PR fails with a TypeError. That is the guard surviving the extraction, which is what the ticket's checklist asked for.

Manual verification

  1. The ticket's last checklist item — a BOT_DISPATCH=dry sweep over a repo with an open bot PR, confirming the note still logs and no awaiting is 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 at sweep-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 an if (s.kind === 'pr') block whose every branch returns. There a missing key is a gather.mjs bug, 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. The kind test 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, drop s.kind === 'issue' &&. Both shapes pass the suite.

Five review lenses came back clean. One finding was accepted, three rejected — below.

Detail

Accepted: inFlight(s) !== null was a second shape. The commit's whole point is one statement of one fact, and that site shipped with a third spelling of it. Now Boolean(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 in gather.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.mjs pushing sweep-awaiting for PRs. That is a behaviour change with its own failure to state, and #106 ruled it out of scope until a wrong awaiting on a PR is actually seen. PRs do carry awaiting, so the correction is real there too.

Note on the house idiom. decide.mjs guards other kind-specific fields with ?. at the read site (s.park?.until, s.linkedLocked?.length), so the kind test 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-toolkit is 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.mjs skipped itself — it needs typescript resolvable, and this repo has no package manager.

Docs checked, nothing stale. docs/why.md#a-pr-is-the-answer-to-an-implement-verb states the rule, not the shape, and both the predicate and the sweep arm cite it.

Not owed. No skill or loop-config.json change, so no version bump in workflow/.claude-plugin/plugin.json, and rule-delta.mjs does not apply. Security review skipped: the diff matches no path in securityReview.triggerPattern.

Closes #110

🤖 Generated with Claude Code

https://claude.ai/code/session_01J6vvtULNyZFphz3fUuWuj1


Generated by Claude Code

`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]>
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Adversarial review skipped: 1 file(s), 24 changed line(s), under review.skipWhen. Say @sydevs-bot review to force one.

🤖 sydevs dispatcher

@Ardnived
Ardnived merged commit 0e41d6f into main Sep 18, 2026
6 checks passed
@Ardnived
Ardnived deleted the claude/refactor-110-in-flight-predicate branch September 18, 2026 01:36
@sydevs-bot sydevs-bot moved this from Revising to Done in SYDevelopers Technical Roadmap Sep 18, 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.

refactor(dispatch): one predicate for an open PR closing this issue

3 participants