feat(triggers): TriggerEvent union + webhook-normalize converters (NF-1) #342

Closed
code-lead wants to merge 1 commit from boss/322 into main
Collaborator

Add a closed 20-variant TriggerEvent discriminated union mirroring specs/node-flows.md § Trigger catalog (v1) so the future Node Flows executor (NF-2) has a uniform input.

Test plan

  • bun x turbo run typecheck — clean across all 4 packages
  • bun x biome check . — clean across 299 files
  • bun test src/http/webhook-normalize.test.ts — 56 pass (24 new round-trip fixtures, one per catalog row)
  • bun x turbo run test — full server suite (1,419 pass, 0 fail)
  • No existing handler is rewired; the union is additive — webhook-handlers.ts, webhook-ci.ts, webhook.ts dispatch paths unchanged
  • Coverage test asserts every TRIGGER_KINDS entry has a matching fixture; new catalog rows without fixtures will trip it

Closes #322

Add a closed 20-variant `TriggerEvent` discriminated union mirroring `specs/node-flows.md` § Trigger catalog (v1) so the future Node Flows executor (NF-2) has a uniform input. ## Test plan - [x] `bun x turbo run typecheck` — clean across all 4 packages - [x] `bun x biome check .` — clean across 299 files - [x] `bun test src/http/webhook-normalize.test.ts` — 56 pass (24 new round-trip fixtures, one per catalog row) - [x] `bun x turbo run test` — full server suite (1,419 pass, 0 fail) - [x] No existing handler is rewired; the union is additive — `webhook-handlers.ts`, `webhook-ci.ts`, `webhook.ts` dispatch paths unchanged - [x] Coverage test asserts every `TRIGGER_KINDS` entry has a matching fixture; new catalog rows without fixtures will trip it Closes #322
feat(triggers): add TriggerEvent union + webhook-normalize converters (NF-1)
All checks were successful
qa / qa (pull_request) Successful in 4m28s
qa / dockerfile (pull_request) Successful in 8s
dbb6de195a
Closed 20-variant `TriggerEvent` discriminated union in
@claude-hooks/shared mirroring `specs/node-flows.md` § Trigger catalog
(v1). Per-trigger pure converters land in webhook-normalize.ts plus an
umbrella `forgeEventToTriggerEvents` dispatcher; non-webhook triggers
(`cron.tick`, `task.*`, `manual`) get builder constructors. ForgeEvent
extended additively with `issues.opened`, `issues.unassigned`,
`issues.unlabeled`, and `pull_request.ready_for_review` so the catalog
covers every entry-point row. Risk-free — no existing handler is
rewired; the union is emitted purely for the future executor (NF-2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Author
Collaborator

Rebase aborted — superseded by merged #341.

Both PRs implement NF-1 with an identical 20-variant TriggerEvent union (same kind strings: issue.opened/closed/assigned/unassigned/labeled/unlabeled, issue_comment.created/slash_command, pull_request.opened/closed/ready_for_review/synchronize, pull_request_review.review_requested/submitted, check_suite.completed, cron.tick, task.completed/failed/cost_capped, manual). Main already carries #341's packages/shared/src/trigger-event.ts + apps/server/src/http/webhook-normalize.{ts,test.ts}; this branch adds trigger-events.ts (plural) plus overlapping normalize files. Nothing net-new to rescue.

Closing recommended — no force-push.

Rebase aborted — superseded by merged #341. Both PRs implement NF-1 with an identical 20-variant `TriggerEvent` union (same `kind` strings: `issue.opened/closed/assigned/unassigned/labeled/unlabeled`, `issue_comment.created/slash_command`, `pull_request.opened/closed/ready_for_review/synchronize`, `pull_request_review.review_requested/submitted`, `check_suite.completed`, `cron.tick`, `task.completed/failed/cost_capped`, `manual`). Main already carries #341's `packages/shared/src/trigger-event.ts` + `apps/server/src/http/webhook-normalize.{ts,test.ts}`; this branch adds `trigger-events.ts` (plural) plus overlapping normalize files. Nothing net-new to rescue. Closing recommended — no force-push.
Author
Collaborator

Rebase aborted — design invalidated by main.

NF-1 already landed via PR #341 (commit 173305c): packages/shared/src/trigger-event.ts (singular), webhook-normalize.ts converter, and the full TRIGGER_KINDS export set. The merged implementation covers the same 20 catalog rows this branch introduces, and does so without extending ForgeEvent — it builds the extra trigger arms (issues.opened, issues.unassigned, issues.unlabeled, pull_request.ready_for_review) directly from raw webhook payloads in the normaliser.

Three-way conflict on packages/shared/src/index.ts, apps/server/src/http/webhook-normalize.ts, and apps/server/src/http/webhook-normalize.test.ts — both sides create overlapping but structurally different surfaces. Forcing a resolution would either (a) duplicate the union under two file names or (b) delete one implementation wholesale, and neither is what this PR was scoped to do.

Recommend closing this PR. If the ForgeEvent extension is still wanted as a separate concern, it can ship on top of the merged NF-1 as a follow-up.

Rebase aborted — design invalidated by main. NF-1 already landed via PR #341 (commit `173305c`): `packages/shared/src/trigger-event.ts` (singular), `webhook-normalize.ts` converter, and the full `TRIGGER_KINDS` export set. The merged implementation covers the same 20 catalog rows this branch introduces, and does so without extending `ForgeEvent` — it builds the extra trigger arms (`issues.opened`, `issues.unassigned`, `issues.unlabeled`, `pull_request.ready_for_review`) directly from raw webhook payloads in the normaliser. Three-way conflict on `packages/shared/src/index.ts`, `apps/server/src/http/webhook-normalize.ts`, and `apps/server/src/http/webhook-normalize.test.ts` — both sides create overlapping but structurally different surfaces. Forcing a resolution would either (a) duplicate the union under two file names or (b) delete one implementation wholesale, and neither is what this PR was scoped to do. Recommend closing this PR. If the `ForgeEvent` extension is still wanted as a separate concern, it can ship on top of the merged NF-1 as a follow-up.
Author
Collaborator

Closing as superseded by #341 which landed NF-1 first and is already on main. Thanks for the parallel attempt — the ticket is closed and the implementation that merged is the canonical one. Closing this branch to keep the PR list clean.

Closing as superseded by #341 which landed NF-1 first and is already on main. Thanks for the parallel attempt — the ticket is closed and the implementation that merged is the canonical one. Closing this branch to keep the PR list clean.
code-lead closed this pull request 2026-04-24 14:08:38 +00:00
All checks were successful
qa / qa (pull_request) Successful in 4m28s
Required
Details
qa / dockerfile (pull_request) Successful in 8s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!342
No description provided.