Skip to content

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

Merged
sydevs-bot merged 16 commits into
mainfrom
claude/refactor-291-approvals-module
Nov 22, 2026
Merged

sydevs-bot merged 16 commits into
mainfrom
claude/refactor-291-approvals-module

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Approval accounting is now dispatcher/approvals.mjs — ten functions moved verbatim out of decide.mjs, which falls from 86KB to 69KB.
  • The cycle that move would have created is settled by two modules below both, actions.mjs and predicates.mjs, which import nothing.
  • Joined, from the cleanup pass: relay.mjs took fullTreatment as a parameter only because it could not import it without a cycle — the alternative this ticket's approach rejected, still standing in the one place the cycle had forced it. It imports it now.
  • Joined: three one-liners the move made importable (lower ×2, nowOf) were still being spelled out by their callers.
  • Adopted, from the adversarial review: the two new owners now hold what they claim — actions.mjs constructs all four actions it had left inline, predicates.mjs gives back the two symbols its rule did not cover, and standingApprovals imports the review states it had retyped.
  • Answered, by the reviewer: B on both question threads. predicates.mjs holds the whole small, pure predicate family rather than only what the cycle forced out, so stackedPr and isRoadmap join it and loopMayNotMerge goes to approvals.mjs, where mergePolicy's other half already is. The two dead exports the move surfaced — actions.mjs's archiveCurrent and decide.mjs's _internal — are deleted.

Change outline

A responsibility moved out of the file that held every plan, and the vocabulary it shares with that file moved below both.

Files

 dispatcher/
+├── actions.mjs     # every action a plan is made of, constructed nowhere else
+├── predicates.mjs  # the whole small, pure predicate family
+├── approvals.mjs   # who has approved what, and the one wall no approval clears
 ├── decide.mjs      # every other plan, 86KB -> 69KB
 ├── relay.mjs       # imports fullTreatment instead of being handed it
 ├── apply.mjs       # reviewerFor inlines its one-reader predicate; one dead arm gone
 └── status.mjs      # reads each question from the module that owns it

 workflow/lib/
 └── merge-gate.mjs  # STATE_BEARING is exported, so approvals.mjs can cite it

actions.mjs and predicates.mjs are one module split in two, not two ideas. One file would have held both, on the rule "whatever decide.mjs and approvals.mjs both need" — a rule that described 8 of its 37 exports, so it could not have decided where the next shared helper went. The two audiences are disjoint: decide.mjs and approvals.mjs are the only readers of the action vocabulary, while most of dispatcher/ asks the predicates.

Flow — the import graph

Everything shared sits below both deciders, so nothing resolves at module scope.

 index.mjs
   decide.mjs
+    approvals.mjs
+      actions.mjs       # imports nothing
+      predicates.mjs    # imports nothing
       markers.mjs       # dispatcherMark
       verbs.mjs         # parseVerb
+    actions.mjs
+    predicates.mjs
     relay.mjs
+      predicates.mjs    # was: fullTreatment passed in by the caller
-  markers.mjs           # decide.mjs's only consumer was vouched, which left

The rejected alternative is the ticket's: pass the action constructors and predicates into each moved function as arguments. It needs no new file, and it grows every call site and hides each dependency in a signature. relay.mjs was the live example of that cost, which is why its injection went with the move.

Behaviour — what moved, and what it exports

Nine of the ten had no importer outside decide.mjs, so only six are exported.

 dispatcher/approvals.mjs
+  export proxyApproves       # decide.mjs, gather.mjs, status.mjs
+  export proxyVerdict        # status.mjs
+  export stalePlan           # decide.mjs
+  export botArmedOwnerPr     # decide.mjs
+  export contractSyncPlan    # decide.mjs
+  export proxyPlan           # decide.mjs
+  export loopMayNotMerge     # decide.mjs, status.mjs
+         standingApprovals   # private
+         buriedApprovals     # private
+         armedByAuthor       # private
+         vouched             # private
+         HOLD_KEY            # private
+         ARMED_HOLD_KEY      # private

Each importer now names the real home, with no re-export pass-through left in decide.mjs. Nine modules read their predicates from predicates.mjs rather than through decide.mjs, which also removes the apply.mjs -> decide.mjs edge. status.mjs now asks decide.mjs for one export, needsAddressReview.

Membership is what the review, and then the reviewer, moved. Each module now matches its header:

 dispatcher/actions.mjs      # every action a plan is made of
+  export ensure, unlocked, retry, timeout   # were nine literals in decide.mjs
-  export archiveCurrent                    # no plan constructs it; apply.mjs's arm goes too
 dispatcher/predicates.mjs   # the whole small, pure family, not only what a cycle forced out
-  export hasAccess, ACCESS                 # back in decide.mjs, its one reader
-  export isReviewer                        # inlined in apply.mjs, its one reader
+  export stackedPr, isRoadmap              # were decide.mjs's, and status.mjs reads both
 dispatcher/approvals.mjs
+  export loopMayNotMerge                   # merge policy, so mergePolicy's $comment names one file
 dispatcher/decide.mjs
-  export _internal                         # a test seam with no importer

The rule each new module applies is in its header, so the next helper has somewhere to go. needsAddressReview stayed behind because its dependency tail is decide.mjs's own, and merge policy sits with the approvals it overrides.

Test results

  • Lean gate: ✓ claude plugin validate ./workflow --strict passes; node --test workflow/lib/*.test.mjs 156 passed. Run from the checkout and again from a .claude/worktrees/ worktree, as implement-ticket does.
  • Targeted specs: node --test dispatcher/test/*.test.mjs 399 passed — the same count as origin/main, which is the ticket's evidence that no rule was lost.
  • node -e "import('./dispatcher/index.mjs')…" prints ok. A walk of every import in all 22 dispatcher/*.mjs finds no cycle anywhere in the directory.
  • comment-lint.mjs --base origin/main: no banned comment added.
  • origin/main merged in twice: at 9582d43, clean, and at ed20ab1, one conflict. Both sides had bumped version off 5.9.0 — main to 5.10.0 for feat(finalize-pr): let a session open its PR through finalize-pr #294, this branch to 5.9.1 for its merge-gate.mjs export. Resolved to 5.10.1, so the plugin cache key moves for both changes.
  • Security review: run twice, because the diff matches securityReview.triggerPattern both rounds. No findings either time. The second pass checked that every non-comment, non-import line of the three new modules occurs verbatim in origin/main:dispatcher/decide.mjs — the only exceptions are standingApprovals's STATE_BEARING.has and the four new constructors — that nothing mutates the now-exported STATE_BEARING Set, and that apply.mjs's default arm only logs, so deleting the archiveCurrent arm opens no fail-open path. The first pass added 42,000 comparisons on evaluatePr, decide, deriveStatus, hasAccess and reviewerFor, with 0 mismatches.
  • Build: N/A

Manual verification

  1. Nothing. No behaviour changed, and the checks below are mechanical.
Evidence that the move is verbatim and behaviour-identical

Textual. Sorting the whole diff's removals and additions and cancelling them leaves only import lines, the three new module headers, and the declarations that gained export. Each of the ten functions was also extracted from git show origin/main:dispatcher/decide.mjs by brace-matching and compared with its new home: proxyApproves, buriedApprovals, proxyVerdict, armedByAuthor, vouched, HOLD_KEY and ARMED_HOLD_KEY are identical; stalePlan, botArmedOwnerPr, contractSyncPlan and proxyPlan differ only by a leading export. standingApprovals is the one exception, and deliberately so after the review: its three retyped states are now merge-gate.mjs's exported STATE_BEARING. hasAccess and its ACCESS set are byte-identical to main in decide.mjs, where they started. This round's three moves were checked the same way: stackedPr and isRoadmap in predicates.mjs, and loopMayNotMerge in approvals.mjs, are byte-identical to main.

Behavioural. Re-measured at 2bd4085, after your two answers. A harness imported origin/main's tree (git worktree add) and this branch's side by side and deep-compared decide, evaluatePr and deriveStatus, plus apply.mjs's reviewerFor, on the same snapshots, varying the fields an outsider controls: PR author, head author (including the null fail-closed case), headCommittedAt absent, autoMergeArmed / autoMergeBy / draft, twelve review sets with forged logins, a lower-case approved state, a null reviewer login and stale commit_ids, prCommits with null authors and off-PR second parents, comment bodies carrying @sydevs-bot verbs from eight logins at eleven author associations, waiting question threads, and every record shape a lease can be in.

Run Comparisons Differences
decide: 32 event reasons × 12 records × lock × CI, on a PR and an issue 4,608 0
hasAccess: 11 author associations × 8 logins × 6 comment bodies 968 0
Approval accounting: 12 review sets × 6 commit lists × author × armed × draft 2,592 0
Focused proxy-approval path: head author × 15 review sets × armed-by × threads 17,280 0
reviewerFor, exhaustive over the logins and their casings 12 0
Total, review round 25,460 0

Coverage was measured rather than assumed. Across 25,460 comparisons the runs emitted proxyApprove 1,584 times, dismissProxy 216, dismissStale 1,248, disarmAutoMerge 1,440, and each of the four newly-constructed actions: ensure 690, timeout 168, unlocked 102, retry 12. 622 comparisons threw, identically on both sides — the invalid-config combinations. reviewerFor returned both the configured reviewer and the fallback human.

This round's two commits got their own pass, over the axes the three moved predicates read: the repo name, so loopMayNotMerge answers both ways; four base refs, so stackedPr sees stacked, unstacked and a null defaultBranch; and five item.type values including a lower-case roadmap, so isRoadmap sees a near miss.

Run Comparisons Differences
evaluatePr + deriveStatus: 3 repos × 4 bases × 3 CI × 6 review sets × 4 thread sets × 3 PR authors × draft × armed 31,104 0
decide: 17 event reasons × 11 records × lock, on a PR across 3 repos × 2 bases, and on an issue across 5 item types × 4 comment sets 7,106 0
Arming path: 3 repos × 4 bases × 3 review sets × 3 PR authors × 4 thread sets × 3 review decisions × size × a waits-on 10,368 0
isRoadmap's own axis, through every arm that reads it 410 0
Total, this round 48,988 0

The arming path is where decide.mjs reads loopMayNotMerge and stackedPr together, so it was reached deliberately rather than hoped for: it emitted armAutoMerge 324 times and markReady 486. archiveCurrent was emitted 0 times in 38,620 plans derived from origin/main's own code, which is what makes its deletion unreachable code rather than a removed capability.

One input diverges, named here because the harness cannot see it: with config.assignment absent, apply.mjs's reviewerFor throws on assignment.reviewer where it used to throw on assignment.respondTo. Both throw; the config cannot occur.

Scope. No file outside dispatcher/ imports any moved name, and .github/workflows/dispatcher.yml only ever imports dispatcher/index.mjs, which is unchanged. One file under workflow/ changed — merge-gate.mjs gained an export keyword and nothing else — so version carries the patch bump cut-release asks for a workflow/lib/** change — now 5.10.1, over main's 5.10.0. No skill changed, so rule-delta.mjs does not apply.

Notes for reviewer

  • The size finding is not answered, and I am not claiming it is. decide.mjs is 69KB — still the directory's outlier, about twice apply.mjs, and still holding four concerns behind section rules it draws itself. This ticket moved one of them. Cutting the rest (the issue verbs are a self-contained ~200 lines) is a separate PR, and worth its own ticket if you want it.
  • predicates.mjs's membership is settled, and both question threads are closed. You chose B on each. The rule is now the whole small, pure family, which is a rule that can place the next helper — "what the cycle forced out" could not, as hasAccess showed. stackedPr and isRoadmap are in, and loopMayNotMerge is in approvals.mjs, where you asked for it. needsAddressReview is the one left behind: moving its dependency tail would dwarf this PR. status.mjs and gather.mjs still import three modules each, which B does not change and I said it would not.
  • Considered and rejected: moving contractSyncPlan to contracts.mjs, which already owns that concern. The ticket names approvals.mjs for it, and contracts.mjs fetches while approvals.mjs is pure and only emits plan actions — folding a pure decider into a fetching module cuts against this repo's rule that a script decides and never fetches. Happy to move it if you disagree.
  • Deferred, not missed: isDispatcherComment is the single symbol keeping gather.mjs dependent on decide.mjs, and it is a two-line test for markers markers.mjs already owns. Moving it there would drop that edge entirely. Out of this ticket's scope, and a clean follow-up.
  • Docs checked. loop-config.json's mergePolicy $comment named two files after the move; with loopMayNotMerge in approvals.mjs it names one, which is what your thread asked for. docs/why.md names these functions without naming their file, and its two dispatcher/decide.mjs references point at pendingReviewVerb and conflictPlan, which stayed.
  • No test was added, deliberately: the ticket's verification is the same test count before and after, and a new test would have broken that evidence. The 399 existing tests reach the moved code through decide and evaluatePr, and the harness above covers every commit, this round's two included.
  • The branch's first commit is the move with the shared vocabulary in one file; the second splits it. That shape is an artifact of a denied force-push, not a change of mind — the reasoning for the split is in its commit body.
  • The four fix(dispatcher): commits after the first base merge are the review round, one per finding. The two after the second are your two answers, one each. All six are separately revertable.
  • archiveCurrent is the one deletion worth a second look, because it removes a capability rather than dead weight: apply.mjs's arm archived a session whose end was never seen. It was unreachable, not latent — the harness above derived 38,620 plans on origin/main's code and emitted the action 0 times — and git revert brings both halves back together. You chose B knowing that.

Closes #291

Ten functions answered a different question each about who has approved
what, scattered through decide.mjs's 86KB alongside every other plan. A
rule change moves them together, so they now sit together in
dispatcher/approvals.mjs: proxyApproves, stalePlan, standingApprovals,
buriedApprovals, botArmedOwnerPr, contractSyncPlan, proxyPlan,
proxyVerdict, armedByAuthor and vouched, moved verbatim.

Only six cross a module boundary, so the rest are private: the new
module exports proxyApproves, proxyVerdict, stalePlan, botArmedOwnerPr,
contractSyncPlan and proxyPlan, and nothing else.

The cycle is settled before the move, not around it. decide.mjs imports
approvals.mjs, and the moved functions call back for the action
constructors, the login predicates, nowOf, isQuestion and
threadsWaiting. Those are now dispatcher/plan.mjs, which imports
nothing and both import — one direction, nothing undefined at module
scope. Passing them as arguments would have grown every call site and
hidden the dependency in a signature.

Each importer now names the real home: status.mjs and gather.mjs read
proxyApproves and proxyVerdict from approvals.mjs, and apply, deps,
gather, journal, reconcile, record, resolve, status and sweep read their
predicates from plan.mjs rather than through decide.mjs. No
re-export pass-through is left behind.

decide.mjs falls from 86KB to 69KB. No behaviour changes: the only test
edit is relay.test.mjs's import line, and the suite is 398 tests before
and after.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
The move put the action constructors and the login predicates in one
`plan.mjs`, on the rule "whatever `decide.mjs` and `approvals.mjs` both
need". That rule described 8 of the file's 37 exports, so it could not
have decided where the next shared helper went, and the file would have
drifted into a grab-bag.

Two audiences, two modules, each with one charter:

  actions.mjs     every action a plan is made of, constructed nowhere
                  else. Two importers: decide.mjs and approvals.mjs.
  predicates.mjs  the predicates a login, a config or a snapshot is read
                  with. Most of dispatcher/ imports it.

Both still import nothing, so the cycle stays settled either way.

It also fixes the name. "Plan" is this repo's word for what `decide`
returns, and every function that builds one is named `*Plan` and lives
elsewhere, so `plan.mjs` was the one file in the directory with no plan
in it.

Two leftovers of the move go with it: `decide.mjs` kept an import of
`dispatcherMark` that `vouched` had been its only consumer of, and the
`// ---- issue verbs ----` header lost the blank line above it when the
approval block was cut out. Four comments that pointed at functions by
bare name now name the module they moved to.

398 tests pass, unchanged.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
`pushRoute` and `relayRefusal` took `fullTreatment` as a trailing
parameter for one reason: `relay.mjs` could not import it from
`decide.mjs` without a cycle, and `decide.mjs` is where it lived.

It lives in `predicates.mjs` now, which imports nothing, so the
injection has nothing left to dodge. Taking it as an argument is the
alternative this ticket's approach rejected, and it was still standing
in the one place the cycle had forced it.

Two production call sites and twelve assertions drop their last
argument, and the test stops importing a predicate only to hand it
straight back.

Behaviour is unchanged: every caller passed the same `fullTreatment`.
A different one would have silently changed who gets the loop, with
nothing in `relay.mjs` to catch it.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
The move made three one-liners importable, and three callers were
still spelling them out.

- `lower` had three definitions: `predicates.mjs` plus private copies in
  `deps.mjs` and `apply.mjs`, both of which now import from
  `predicates.mjs` already. The `apply.mjs` one was rebuilt on every
  `reviewerFor` call.
- `deriveStatus` spelled the snapshot clock inline as `s.now || new
  Date()`, which is `nowOf`. Two spellings meant a change to how `s.now`
  is honoured had to find both.
- `standingApprovals` named the state-bearing review states and said
  "what GitHub counts". `merge-gate.mjs` owns that rule as
  `STATE_BEARING`, and its `reviewDecisionFrom` comment says in so many
  words that other files should cite it rather than restate it. It now
  does. The set itself is left where it is: merge-gate's version
  allowlists authorised logins and returns a decision string, not the
  review objects `buriedApprovals` needs.

Every body is identical to the copy it replaces, so behaviour is
unchanged. 398 tests pass.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
`proxyApprove`'s rules moved to `dispatcher/approvals.mjs` with the rest
of the approval accounting, so the `$comment`'s pointer was half wrong.
`loopMayNotMerge` is still `decide.mjs`'s, and the line now says which
is which.

The pointer is the whole job of a `$comment` under this repo's
three-homes rule, so a stale one costs the reader the only navigation
aid the config offers.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
Two claims in the new headers were wrong as written.

`predicates.mjs` said nine modules ask it; twelve import it. The count
was the only support for the layering claim, so it now says "most of
the directory" rather than a number that drifts.

`approvals.mjs` said `decide.mjs` imports these, which reads as the
whole dependency list and would license an import back into
`status.mjs` — the one edit that would give the directory its first
cycle. It now names `status.mjs` and `gather.mjs` too, and says the
edge may not be reversed.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj
The header said `status.mjs` and `gather.mjs` read "the two that only
read", which reads as both reading both. `gather.mjs` takes only
`proxyApproves`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVMENvk6vPDtXTTWcj

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 question(s) for the reviewer, one per thread.

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


Generated by Claude Code

Comment thread dispatcher/predicates.mjs Resolved
Comment thread dispatcher/actions.mjs Resolved
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot

sydevs-bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 18:27Z resolve-conflicts · attempt 1 · session · done
  • 18:27Z resolve-conflicts · attempt 1 · session
  • 02:15Z address-review · attempt 1 · session · done
  • 02:15Z address-review · attempt 1 · session
  • 00:39Z address-review · attempt 1 · session · done

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

@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 21, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

The move is what the ticket asked for, and its evidence holds: nine of the ten functions are byte-identical to main, and decide.mjs drops to 70853 bytes. Splitting the shared vocabulary in two, where the ticket said one, is the right deviation.

Membership is what is unsettled, on both sides of each new owner. actions.mjs says it is the only place an action is constructed while four types are still built inline in decide.mjs, and predicates.mjs holds two symbols its own stated rule does not cover. One question about the approach, not four about pieces.

Findings

  • should-fix actions.mjs:2 — claims sole ownership; ensure, retry, timeout, unlocked are built inline at nine sites in decide.mjs.
  • should-fix approvals.mjs:51 — cites merge-gate.mjs's STATE_BEARING, private there, while line 55 retypes its list.
  • should-fix predicates.mjs:32 (Streamline) — hasAccess and isReviewer have one reader each.
  • should-fix approvals.mjs:12 (Streamline) — the header's inventory restates the imports below it.

Second opinion on both question threads: B — neither is what was built, so both stay open.

What was checked

The ticket's five acceptance criteria re-derived, the cycle by walking imports in all 20 dispatcher/*.mjs. The ten functions extracted from origin/main by brace match and diffed: nine identical, standingApprovals' comment reworded — which the body calls identical. Cancelling removals against additions leaves 43 lines: imports, signatures, headers, comments. The three new modules read whole; apply.mjs's case arms compared against actions.mjs's types. workflow/ untouched, so version correctly stays. Streamliner: 53 pieces, 50 kept, 5 findings, all held — 3 posted, 2 in the open threads. Profile read; CI green on arrival, not re-run.

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


Generated by Claude Code

Comment thread dispatcher/actions.mjs Resolved
Comment thread dispatcher/approvals.mjs Resolved
Comment thread dispatcher/predicates.mjs Resolved
Comment thread dispatcher/approvals.mjs Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Nov 21, 2026
`actions.mjs`'s header claims to be the only place an action is
constructed, and four types were still built as literals at nine sites
in `decide.mjs`: `ensure` ×4, `timeout` ×3, `retry` and `unlocked`.

An owner that leaves four members outside is worse than no owner: a
reader who trusts the header stops looking, and the next `ensure` gets
spelled a tenth time. The alternative was narrowing the header to the
members it had, which keeps the drift and only stops advertising it.

`unlocked` keeps its `handler` field. `apply.mjs` does not read it, but
the dry-run plan log prints it, and dropping it would change that
output.

Behaviour-identical: each constructor returns the literal it replaced.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWk74XVfXZFabcixV2
`standingApprovals` pointed at `merge-gate.mjs`'s `STATE_BEARING` and
then retyped its three states. The pointer did not resolve — the set
was private there — so the comment named an authority a reader could
not reach, and nothing would have caught the two lists drifting apart.

`merge-gate.mjs` now exports the set and `approvals.mjs` imports it.
`gather.mjs` already imports that module, so the edge is not new, and
it fetches nothing, so `approvals.mjs` stays pure.

This also settles the one place the move was not verbatim: the
reworded comment the review flagged is now the whole of that
function's difference from `main`.

`version` bumps to 5.9.1 because `workflow/lib/**` changed: an
installed plugin's cache is keyed by it.
(why: docs/why.md#an-installed-plugin-does-not-track-main)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWk74XVfXZFabcixV2
`predicates.mjs`'s rule is "what the cycle forced out", and neither of
these was. Each has one reader.

`hasAccess` and its `ACCESS` set go back to `decide.mjs`, byte-identical
to `main`, beside the only function that calls them. They were an
unimported export there too, so the dead-export question stays the one
the open thread asks, not one this commit answers.

`isReviewer` is inlined at its only call site, `apply.mjs`'s
`reviewerFor`, which already imported `lower`. Moving it to `decide.mjs`
instead would have put back the `apply.mjs -> decide.mjs` edge this
branch removed.

Equivalent at the call site: the inline drops an optional chain on
`config.assignment`, and the next line already dereferences it, so both
spellings throw on the same absent config.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWk74XVfXZFabcixV2
Four lines listed who imports `proxyApproves` and `proxyVerdict`, and
that the actions are `actions.mjs` and the predicates `predicates.mjs`.
The import lines immediately below say the second half, and a grep says
the first, so prose that restates a source above it goes
(`docs/documentation.md`).

What a reader cannot see stays: the edge back into `decide.mjs` or
`status.mjs` is the one this directory must not grow, and nothing here
fetches.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWk74XVfXZFabcixV2
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Four findings adopted, one commit each, on a clean merge of origin/main (9582d43).

  • actions.mjs:2 — the four actions have constructors, and the nine inline sites call them. 301ab25
  • approvals.mjs:51 — merge-gate.mjs exports STATE_BEARING. version → 5.9.1. 3d4b868
  • predicates.mjs:32 — hasAccess back in decide.mjs, isReviewer inlined. 8088b9c
  • approvals.mjs:12 — the header's import inventory is gone. 29fbd3d

Nothing rebutted. Both question threads stay open — a second opinion is not your answer.

399 dispatcher and 156 lib tests pass. A differential harness against origin/main: 25,460 comparisons, 0 differences, emitting proxyApprove 1,584, dismissStale 1,248 and all four new constructors. Body refreshed.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 21, 2026 00:57
@sydevs-bot
sydevs-bot requested a review from Ardnived November 21, 2026 00:57
@sydevs-bot
sydevs-bot enabled auto-merge November 21, 2026 00:57
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 21, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 21, 2026
Conflict: workflow/.claude-plugin/plugin.json version. main bumped 5.9.0 -> 5.10.0 for #294's new capability; this branch had bumped 5.9.0 -> 5.9.1 for its merge-gate.mjs export. Resolved to 5.10.1 — main's minor stands, and this branch's workflow/lib change still carries a bump above it, so the plugin cache key moves for both.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpqKoZPiBkxF32cJB
Both were dead on main, and the move into actions.mjs surfaced them. The reviewer chose B on the thread that asked.

archiveCurrent is constructed by no plan, so apply.mjs's arm for it was unreachable rather than latent: plans are built per event and never replayed. Its arm goes with it. decide.mjs's _internal seam has no importer — decide.test.mjs imports gather.mjs's — and a test seam nobody tests through only tells a reader the wrong thing about what is covered.

Git history keeps archiveCurrent's behaviour if someone wires the capability up.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpqKoZPiBkxF32cJB
The reviewer chose B on the membership thread: predicates.mjs holds the whole small, pure family, not only the members the cycle forced out. A rule drawn where a cycle happened to fall cannot place the next helper — the same objection this branch already used to split actions.mjs off.

stackedPr and isRoadmap move to predicates.mjs. loopMayNotMerge goes to approvals.mjs instead, as the reviewer's thread asked: it is merge policy, so mergePolicy's $comment in loop-config.json now names one file. needsAddressReview stays in decide.mjs — its dependency tail is decide.mjs's own.

status.mjs reads each from its new home, so decide.mjs is down to one export it asks for. Both module headers now state the membership rule they apply. 399 dispatcher tests pass, no cycle in the 22 modules.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjWpqKoZPiBkxF32cJB
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both answers built, one commit each, on a base merge that had one conflict.

Your three requirements are now criteria on #291.

Nothing rebutted. Both threads resolved, and none is open. 399 dispatcher and 156 lib tests pass, no cycle in the 22 modules. 48,988 differential comparisons against origin/main, 0 differences, reaching armAutoMerge 324 times — the path that reads both moved predicates. Second security review: no findings. Body refreshed.

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


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 21, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 21, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 22, 2026
Conflict: workflow/.claude-plugin/plugin.json version. main bumped 5.10.0 -> 5.11.0 for #302's new workflow/lib/contract-paths.mjs; this branch stood at 5.10.1 for its merge-gate.mjs export. Resolved to 5.11.1 — main's minor stands, and this branch's workflow/lib change still carries a bump above it, so the plugin cache key moves for both.

Nothing else conflicted, and nothing incoming touches the moved modules: #302 and #297 changed only workflow/lib, the audit-contracts skill, docs/why.md, loop-config.json's WeMeditateWeb contract paths, and two dispatcher tests that import gather.mjs and fire.mjs, neither of which this branch moved a symbol out of.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjVAr3C2hHbsKE6d9bg
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged origin/main in at 91bb968. One conflict, workflow/.claude-plugin/plugin.json: main bumped version to 5.11.0 for #302, this branch stood at 5.10.1. Resolved to 5.11.1, so the plugin cache key moves for both changes.

Nothing incoming touches the moved modules. Lean gate passes, 161 lib tests and 399 dispatcher tests pass, dispatcher/index.mjs still imports.

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


Generated by Claude Code

@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 22, 2026
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 22, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 22, 2026
Merged via the queue into main with commit 673b716 Nov 22, 2026
14 of 15 checks passed
@sydevs-bot
sydevs-bot deleted the claude/refactor-291-approvals-module branch November 22, 2026 18:30
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 22, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
main reached 5.11.1 through #295 while this branch was at 5.11.2, so
`workflow/.claude-plugin/plugin.json` was the one conflicted file and
the version line the one conflicted hunk.

Kept 5.11.2. It is strictly above main's 5.11.1, so merging this PR
still moves the string an installed plugin's cache is keyed by
(docs/why.md#an-installed-plugin-does-not-track-main). Taking main's
5.11.1 would have left this branch's skill change arriving under a
version already published, which is the one thing that keeps a cached
plugin on the old prose.

Nothing else overlapped: this branch touches docs/why.md and
workflow/skills/start-run/SKILL.md, and #295 touches dispatcher/,
loop-config.json and workflow/lib/merge-gate.mjs.

Lean gate green after the merge: `claude plugin validate ./workflow
--strict` passes and `node --test workflow/lib/*.test.mjs` is 161/161,
run from this .claude/worktrees worktree. The dispatcher suite that
owns the merged code is 399/399, and both JSON manifests parse.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYqS6P2jFN36nkXuEY
sydevs-bot pushed a commit that referenced this pull request Nov 22, 2026
#295 moved the login predicates out of decide.mjs into predicates.mjs and
approvals.mjs; this branch rewrote them in place. Both sides are kept: the
new module layout, with this branch's behaviour inside it.

- predicates.mjs takes isLogin's list form, restLogin and dispatcherLogins,
  and isBot reads the list. decide.mjs keeps main's deletion. Putting them
  back in decide.mjs would have re-added the apply -> decide and
  reconcile -> decide edges #295 removed, and predicates.mjs imports
  nothing, so nothing new is reachable from it.
- apply, deps, gather, reconcile and sweep import each name from its new
  home. apply.mjs keeps main's inlined isReviewer and its imported lower;
  deps.mjs keeps both sides' imports.
- contracts.mjs and test/record.test.mjs were not textual conflicts: this
  branch added import lines naming decide.mjs, which still parsed and still
  resolved to a module that no longer exports those names. Both now name
  predicates.mjs.
- version goes to 5.11.2. Both sides bumped to 5.11.1 independently, and
  #295 merged first, so this branch's workflow/lib/payload.mjs change would
  have shipped under a cache key an installed plugin already holds.
  (why: docs/why.md#an-installed-plugin-does-not-track-main)

Lean gate green (plugin validate, 162 lib tests), 425 dispatcher tests, and
the root marketplace manifest validates.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjZehhisSFVGHJpSzTf
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(dispatcher): hold approval accounting in its own module

3 participants