refactor(webhook-handlers): migrate to adapter factory (MF-10) #315

Merged
code-lead merged 1 commit from feat/mf10-migrate-webhook-handlers into main 2026-04-24 10:39:33 +00:00
Collaborator

Summary

  • Cleanup of MF-8 (#299) out-of-scope list — migrates webhook-handlers.ts.
  • Replaces all 7 new ForgejoAdapter(token) callsites in apps/server/src/http/webhook-handlers.ts with createForgeAdapterForRepo(repo, token) from ../infrastructure/forge/adapter-factory.
  • Webhook dispatch is the main entry point for multi-forge events, so every callsite now routes through the factory — GitHub/GitLab webhooks dispatch through the right adapter based on each repo's forge: binding in config/agents.json.
  • No dispatch-semantics change: Forgejo-bound repos still land on ForgejoAdapter (factory default), only non-Forgejo repos see the observable change.

Callsites migrated (all in apps/server/src/http/webhook-handlers.ts):

  1. fetchLinkedIssueLabelsgetIssue
  2. findLinkedPrForIssuelistPullRequests
  3. detectOutstandingChangeRequestlistReviews
  4. handleReviewRequestedgetPullRequest
  5. handleChangesRequestedgetPullRequest
  6. handlePullRequestOpenedrepoHasWorkflows
  7. handlePostMergeRebaselistPullRequests

The ForgejoAdapter import is dropped; parseRepo is kept (still needed to normalise owner/name into the port's RepoRef).

Test plan

  • bun run typecheck — clean
  • bun run lint — biome clean
  • bun test apps/server/src/http/webhook-handlers.test.ts — 52 pass, 0 fail
  • Full server suite — 4 pre-existing unrelated failures (sweeper JSONL pruning, foreman session CRUD), all reproduced on baseline without this diff
  • Operator: sanity-check a Forgejo webhook-triggered dispatch post-merge (no behaviour change expected)

Refs: #299 (MF-8 out-of-scope list), #313 (MF-8 merge).

## Summary - Cleanup of MF-8 (#299) out-of-scope list — migrates `webhook-handlers.ts`. - Replaces all 7 `new ForgejoAdapter(token)` callsites in `apps/server/src/http/webhook-handlers.ts` with `createForgeAdapterForRepo(repo, token)` from `../infrastructure/forge/adapter-factory`. - Webhook dispatch is the main entry point for multi-forge events, so every callsite now routes through the factory — GitHub/GitLab webhooks dispatch through the right adapter based on each repo's `forge:` binding in `config/agents.json`. - No dispatch-semantics change: Forgejo-bound repos still land on `ForgejoAdapter` (factory default), only non-Forgejo repos see the observable change. Callsites migrated (all in `apps/server/src/http/webhook-handlers.ts`): 1. `fetchLinkedIssueLabels` → `getIssue` 2. `findLinkedPrForIssue` → `listPullRequests` 3. `detectOutstandingChangeRequest` → `listReviews` 4. `handleReviewRequested` → `getPullRequest` 5. `handleChangesRequested` → `getPullRequest` 6. `handlePullRequestOpened` → `repoHasWorkflows` 7. `handlePostMergeRebase` → `listPullRequests` The `ForgejoAdapter` import is dropped; `parseRepo` is kept (still needed to normalise `owner/name` into the port's `RepoRef`). ## Test plan - [x] `bun run typecheck` — clean - [x] `bun run lint` — biome clean - [x] `bun test apps/server/src/http/webhook-handlers.test.ts` — 52 pass, 0 fail - [x] Full server suite — 4 pre-existing unrelated failures (sweeper JSONL pruning, foreman session CRUD), all reproduced on baseline without this diff - [ ] Operator: sanity-check a Forgejo webhook-triggered dispatch post-merge (no behaviour change expected) Refs: #299 (MF-8 out-of-scope list), #313 (MF-8 merge).
refactor(webhook-handlers): migrate to adapter factory (MF-10)
All checks were successful
qa / qa (pull_request) Successful in 3m55s
qa / dockerfile (pull_request) Successful in 8s
f8f842a1ab
Replace the 7 `new ForgejoAdapter(...)` callsites in webhook-handlers.ts
with `createForgeAdapterForRepo(repo, token)` so non-Forgejo repos hit
the right adapter through the per-repo forge binding. Cleanup follow-up
from PR #313 (MF-8) — webhook dispatch is the main entry point for
multi-forge events, every callsite had to route through the factory.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
code-lead deleted branch feat/mf10-migrate-webhook-handlers 2026-04-24 10:39:34 +00:00
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!315
No description provided.