Split event-handlers.ts into topical modules and delete the file #1096

Closed
opened 2026-05-10 23:31:28 +00:00 by claude-desktop · 1 comment
Collaborator

As an operator, I want apps/server/src/domain/workflow/event-handlers.ts deleted, so that the workflow domain stops carrying a 1000+-line god-module that mixes review detection, dispatch, trust checks, and webhook routing.

Context

After issues #1092, #1093, #1094, #1095 land, the remaining exports in event-handlers.ts are pure helpers used by janitor + background tasks + ops:

Helper Used by New home
fetchPrDispatchLabels tail-pr-rebase-watchdog.ts workflow/review-detection.ts
latestVerdict (internal) workflow/review-detection.ts
detectOutstandingChangeRequest views/board.ts + detect_change_request op workflow/review-detection.ts
isTrustedUser is_trusted_user op + janitor workflow/trust.ts
dispatchIssueForAgent main.ts, views/board.ts, dispatch op workflow/dispatch.ts
dispatchPrRebase janitor.ts, handlePostMergeRebase workflow/dispatch.ts
handlePostMergeRebase janitor.ts workflow/dispatch.ts

resetTriggerBus, resetPostMergeRebaseDedup are test-only exports — delete them too.

Acceptance criteria

File moves

  • Create apps/server/src/domain/workflow/review-detection.tsfetchPrDispatchLabels, latestVerdict, detectOutstandingChangeRequest
  • Create apps/server/src/domain/workflow/dispatch.tsdispatchIssueForAgent, dispatchPrRebase, handlePostMergeRebase (+ their dedup maps)
  • Create apps/server/src/domain/workflow/trust.tsisTrustedUser
  • Update all imports across the codebase

Test moves

  • Co-locate tests with new modules (split event-handlers.test.ts into review-detection.test.ts, dispatch.test.ts, trust.test.ts)

Deletion

  • Delete apps/server/src/domain/workflow/event-handlers.ts
  • Delete apps/server/src/domain/workflow/event-handlers.test.ts
  • Delete resetTriggerBus, resetPostMergeRebaseDedup test-only exports

Verification

  • bun run qa clean (typecheck + biome + tests)
  • just qa clean
  • No grep hits for event-handlers in apps/server/src/ outside of the moved-from paths

Out of scope

  • Any behavioural changes — pure refactor
  • Op or flow changes — covered by prior tickets

Dependencies

  • Blocked by #1092 + #1093 + #1094 + #1095 — all prior tickets must merge first so this is a pure cleanup pass

References

  • Original event-handlers.ts file (1000+ LOC, mixed concerns)
  • This conversation's migration audit
As an operator, I want `apps/server/src/domain/workflow/event-handlers.ts` deleted, so that the workflow domain stops carrying a 1000+-line god-module that mixes review detection, dispatch, trust checks, and webhook routing. ## Context After issues #1092, #1093, #1094, #1095 land, the remaining exports in `event-handlers.ts` are pure helpers used by janitor + background tasks + ops: | Helper | Used by | New home | |---|---|---| | `fetchPrDispatchLabels` | `tail-pr-rebase-watchdog.ts` | `workflow/review-detection.ts` | | `latestVerdict` | (internal) | `workflow/review-detection.ts` | | `detectOutstandingChangeRequest` | `views/board.ts` + `detect_change_request` op | `workflow/review-detection.ts` | | `isTrustedUser` | `is_trusted_user` op + janitor | `workflow/trust.ts` | | `dispatchIssueForAgent` | `main.ts`, `views/board.ts`, `dispatch` op | `workflow/dispatch.ts` | | `dispatchPrRebase` | `janitor.ts`, `handlePostMergeRebase` | `workflow/dispatch.ts` | | `handlePostMergeRebase` | `janitor.ts` | `workflow/dispatch.ts` | `resetTriggerBus`, `resetPostMergeRebaseDedup` are test-only exports — delete them too. ## Acceptance criteria ### File moves - [ ] Create `apps/server/src/domain/workflow/review-detection.ts` — `fetchPrDispatchLabels`, `latestVerdict`, `detectOutstandingChangeRequest` - [ ] Create `apps/server/src/domain/workflow/dispatch.ts` — `dispatchIssueForAgent`, `dispatchPrRebase`, `handlePostMergeRebase` (+ their dedup maps) - [ ] Create `apps/server/src/domain/workflow/trust.ts` — `isTrustedUser` - [ ] Update all imports across the codebase ### Test moves - [ ] Co-locate tests with new modules (split `event-handlers.test.ts` into `review-detection.test.ts`, `dispatch.test.ts`, `trust.test.ts`) ### Deletion - [ ] Delete `apps/server/src/domain/workflow/event-handlers.ts` - [ ] Delete `apps/server/src/domain/workflow/event-handlers.test.ts` - [ ] Delete `resetTriggerBus`, `resetPostMergeRebaseDedup` test-only exports ### Verification - [ ] `bun run qa` clean (typecheck + biome + tests) - [ ] `just qa` clean - [ ] No grep hits for `event-handlers` in `apps/server/src/` outside of the moved-from paths ## Out of scope - Any behavioural changes — pure refactor - Op or flow changes — covered by prior tickets ## Dependencies - Blocked by #1092 + #1093 + #1094 + #1095 — all prior tickets must merge first so this is a pure cleanup pass ## References - Original event-handlers.ts file (1000+ LOC, mixed concerns) - This conversation's migration audit
Collaborator

🤖 Auto-assigned to code-lead (heuristic: default → code-lead (no specific label match; safer than code)). Reply /unassign to reroute.

🤖 Auto-assigned to **code-lead** (heuristic: default → code-lead (no specific label match; safer than code)). Reply `/unassign` to reroute.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#1096
No description provided.