Skip to content

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

Closed

Description

@sydevs-bot

Summary

dispatcher/decide.mjs asks "does an open PR close this issue?" at several sites, in several shapes. One fact, several statements, and the next arm that needs it picks a new shape. This is a refactor with no behaviour change.

⚠ The four-site duplication this ticket was written against does not exist on main. The fourth site arrives with #107, which is open, draft, and unmerged. main today carries three sites in two shapes. See below, and the Blocked by: line in Notes.

What is duplicated

Every site reads s.openPrsClosingIt, set by gather.mjs:117 on the issue arm alone.

On main today (82b1559) — three sites, two shapes:

Line Arm Shape
288 issue_comment, implement verb — the in-flight guard s.openPrsClosingIt.length, then s.openPrsClosingIt[0] twice for the comment
372 session-end, issue — answered s.openPrsClosingIt.length > 0
374 session-end, issue — Status done, drop awaiting s.openPrsClosingIt.length

Once #107 merges — a fourth site, in a third shape:

Line Arm Shape
399 sweep-awaiting s.openPrsClosingIt?.length

That guard is the reason this ticket exists — #107's review thread noted the fourth copy and that nothing owned the duplication. Line 399 is confirmed against #107's diff: the hunk adds a ?. rationale comment and the guard directly after decide.mjs:397.

Why the shapes differ, and why that is the whole decision

Only the sweep-awaiting site can see a PR snapshot. sweep.mjs:112 pushes sweep-awaiting for PRs as well as issues (push(i.pull_request ? 'pr' : 'issue', …)), and gather.mjs sets the key on the issue arm only, so a bare .length throws there. The other three sit after an if (s.kind === 'pr') block whose every branch returns (decide.mjs:276-282, decide.mjs:355-365), so they only ever hold issue snapshots — where a missing key is a gather.mjs bug, and the bare .length is what surfaces it.

So a single ?. predicate is not a free win: it silences that signal at three sites to serve one. Pick deliberately.

Without #107 the decision does not arise. Three bare sites in two shapes are still worth one predicate, but there is no ?. to place and no signal to weigh against it.

Approach

Add one predicate beside isBot / respondTo (decide.mjs:35-41) and call it from every site. Line 288 also needs the PR number for its comment text, so either the predicate returns the list and each caller tests it, or a second value-returning helper covers 288.

// an issue whose PR is open is the PR's turn, not the human's
// (why: docs/why.md#a-pr-is-the-answer-to-an-implement-verb)
const inFlight = (s) => s.openPrsClosingIt?.length ? s.openPrsClosingIt : null

Returning the list rather than a boolean lets 288 read inFlight(s)[0] and keeps one read of the field. Whether the ?. belongs inside the predicate is the open question below.

Acceptance criteria

  • grep -n "openPrsClosingIt" dispatcher/decide.mjs shows the field named once, inside the predicate
  • Every site in the tables above calls it, and the plan each arm produces is byte-identical to today's
  • sweep-awaiting on a PR snapshot still does not throw, and its plan is unchanged
  • The chosen shape is stated where the reader meets it — a comment on the predicate, not only in a PR body

Verification checklist

  • node --test dispatcher/test/*.test.mjs → 0 fail, and the pass count matches the base branch it started from. main at 82b1559 runs 75; fix(dispatch): the awaiting sweep leaves a ticket whose PR is open #107 adds one case, so the base is 76 once that merges. No test is added or changed — an unchanged suite is the evidence
  • node --test dispatcher/test/decide.test.mjs with the predicate's ?. narrowed to . → the awaiting sweep leaves a ticket whose PR is open, and does not throw on a PR fails with a TypeError on its PR-snapshot case. That is what proves the guard survived the extraction. Needs fix(dispatch): the awaiting sweep leaves a ticket whose PR is open #107 merged — that test does not exist on main
  • git diff main -- dispatcher/decide.mjs touches only the sites above and the predicate
  • claude plugin validate ./workflow --strict passes

Open questions

Notes

Blocked by: #106 — the fourth site and the test that pins it arrive with #107, which closes that ticket

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

Activity

  1. added theissue type on Sep 17, 2026
  2. added
    proposal
    on Sep 17, 2026
  3. added
    bot:working
    and removed on Sep 17, 2026
  4. sydevs-bot commented on Sep 17, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running

    recent dispatches
    • 00:17Z implement · attempt 1 · session · done
    • 00:17Z implement · attempt 1 · session
    • 05:15Z revise · attempt 1 · session · done
    • 05:15Z revise · attempt 1 · session

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

  5. sydevs-bot commented on Sep 17, 2026

    @sydevs-bot
    ContributorAuthor

    Revised. The four-site duplication this ticket describes is not on main — the fourth site arrives with #107, which is open and unmerged.

    Effort stays Easy. Priority is yours.

    @sydevs-bot implement starts work. This comment does not.

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


    Generated by Claude Code

  6. added and removed
    bot:working
    on Sep 17, 2026
  7. moved this from Proposed to Revising in SYDevelopers Technical Roadmapon Sep 17, 2026
  8. sydevs-bot commented on Sep 18, 2026

    @sydevs-bot
    ContributorAuthor

    @Ardnived unblocked: every blocker is closed. Say @sydevs-bot implement to start.

    🤖 sydevs dispatcher

  9. Ardnived commented on Sep 18, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  10. added
    bot:working
    and removed
    proposal
    on Sep 18, 2026
  11. moved this from Revising to Approved in SYDevelopers Technical Roadmapon Sep 18, 2026
  12. removed
    bot:working
    on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    Priority

    None yet

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions