Skip to content

refactor(dispatcher): hold approval accounting in its own module #291

Closed

Description

@sydevs-bot

Summary

Approval accounting is now ten functions inside dispatcher/decide.mjs, which is 86KB — four times the next dispatcher module. Each answers a different question about who has approved what, and a rule change moves them together, but they sit scattered through a file that also holds every other plan. status.mjs already shows the shape this wants: one module per concern, imported by decide.mjs.

Approach

Move these from dispatcher/decide.mjs into a new dispatcher/approvals.mjs, keeping private whatever is private once #290 merges:

Symbol decide.mjs Imported outside decide.mjs by
proxyApproves :90 gather.mjs:11, status.mjs:19
stalePlan :528 —
standingApprovals :540 —
buriedApprovals :561 —
botArmedOwnerPr :585 —
contractSyncPlan :727 —
proxyPlan :752 —
proxyVerdict :795 status.mjs:19
armedByAuthor :807 —
vouched :825 —

Only proxyApproves and proxyVerdict cross a module boundary today, so the new module's exported surface is those two plus whatever decide.mjs itself calls.

Settle the cycle before moving code. decide.mjs would import approvals.mjs, and the moved functions call back into decide.mjs: the action constructors (dismissProxy, dismissStale, proxyApprove, armAutoMerge, disarmAutoMerge, requestReviewer, commentOnce, note), the login predicates (isBot, lower, fullTreatment, threadsWaiting), and HOLD_KEY / ARMED_HOLD_KEY / dispatcherMark. Move the action constructors and the predicates into a third module that both import. Passing them in as arguments instead keeps the file count down but grows every call site and hides the dependency in a signature, which is why it loses.

dispatcher/test/decide.test.mjs reaches most of these through evaluatePr, and test/status.test.mjs and test/contracts.test.mjs go through decide / evaluatePr too, so the suite should need no change beyond its imports.

Acceptance criteria

  • No function from the table above remains in dispatcher/decide.mjs
  • dispatcher/approvals.mjs exports only what another module imports
  • status.mjs and gather.mjs import proxyApproves and proxyVerdict from the new module, not from decide.mjs
  • No import cycle: dispatcher/index.mjs loads with no circular-dependency warning and no import undefined at module scope
  • Behaviour is unchanged — only imports are edited in the test files, never an assertion
  • dispatcher/predicates.mjs holds the whole small, pure predicate family, not only the members the cycle forced out (review, Ardnived, 2026-11-21)
  • loopMayNotMerge is in dispatcher/approvals.mjs, so mergePolicy's $comment names one file (review, Ardnived, 2026-11-21)
  • The two dead exports the move surfaced are gone: archiveCurrent with its apply.mjs arm, and decide.mjs's _internal (review, Ardnived, 2026-11-21)

Verification checklist

  • node --test dispatcher/test/*.test.mjs passes, with the same test count as the run before the move
  • node --test workflow/lib/*.test.mjs passes
  • node -e "import('./dispatcher/index.mjs').then(() => console.log('ok'))" prints ok
  • wc -c dispatcher/*.mjs shows decide.mjs below 86KB
  • grep -rn "from './decide.mjs'" dispatcher/ names no moved symbol

Notes

Raised by the adversarial review on #290, which added stalePlan, standingApprovals and buriedApprovals and asked whether the total had outgrown the file. Nothing in #290 is wrong: this is about the total, not that change.

Keep it a pure refactor. A behaviour change moved alongside ten functions cannot be reviewed, and this repo cannot be tested by running it — a skill or dispatcher edit takes effect on the next run, never the current one.

Activity

  1. added theissue type on Nov 20, 2026
  2. added
    proposal
    on Nov 20, 2026
  3. Ardnived commented on Nov 20, 2026

    @Ardnived
    Contributor

    @sydevs-bot implement

  4. added
    bot:working
    and removed
    proposal
    on Nov 20, 2026
  5. sydevs-bot commented on Nov 20, 2026

    @sydevs-bot
    ContributorAuthor

    🤖 no session running
    approved by Ardnived

    recent dispatches
    • 23:41Z implement · attempt 1 · session · done
    • 23:41Z implement · attempt 1 · session

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

  6. moved this from Awaiting to Working in SYDevelopers Technical Roadmapon Nov 20, 2026
  7. removed
    bot:working
    on Nov 21, 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

    Low

    Hold Until

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions