refactor(server): migrate deps to ForgePort #277

Merged
charles merged 1 commit from refactor/migrate-deps-to-forgeport into main 2026-04-23 21:54:11 +00:00
Collaborator

Third per-consumer Forgejo migration. Follows the pipeline (#275) and board (#276) pattern; based on main post-#276.

Scope

domain/workflow/deps.ts moves from raw forgejo-api imports to ForgejoAdapter for every call except one.

What changed

  • DependentView.comments: IssueCommentSummary[]ForgeComment[]
  • commentHistoryHolds parameter type follows
  • ListIssuesFn DI seam returns ForgeIssue[]; production default wraps new ForgejoAdapter(token).listIssues(parseRepo(repo), opts)
  • classifyBlockers / buildDependentView / buildIssueDepsGraph drop their as unknown as {state?, assignee?, labels?} casts — adapter returns properly typed ForgeIssue
  • propagateDependencyClosure's onAssignedReady callback still accepts the legacy { number, title, labels?: { name?: string }[] } shape; the propagator maps view.labels (string[]) back to [{name}] at the call site so webhook-handlers.ts::handleIssueAssigned keeps working
  • Removed the PR-row filter in the body-parsed fallback — listIssues pins type=issues server-side

The one kept raw import

getIssueBlocks from forgejo-api — kept for findDependents' cross-repo filter (#196), which reads repository.full_name to drop rows from foreign repos. The port's getBlocked returns ForgeIssueRef[] (number + state) without the source-repo attribution, so I couldn't replace this one call site cleanly. Documented inline.

Tests

  • deps.test.ts fixture helpers return ForgeIssue/ForgeComment (matches pipeline/board pattern)
  • 61/61 deps tests pass
  • Full server suite: 1007 pass / 4 pre-existing fails

Overlap with sibling PRs

Opened alongside #278 (janitor) and #277 (webhook-ci). Janitor's PR extends the port: getBlockers/getBlocked return ForgeIssueRef[] instead of number[]. Since this PR was authored against main BEFORE the janitor port change, the types the DI seam uses are still the old shape where janitor didn't touch them. If janitor merges first, a trivial fixup here will map .number out of the returned refs. If this merges first, janitor rebases instead.

Third per-consumer Forgejo migration. Follows the pipeline (#275) and board (#276) pattern; based on main post-#276. ## Scope `domain/workflow/deps.ts` moves from raw `forgejo-api` imports to `ForgejoAdapter` for every call except one. ## What changed - `DependentView.comments: IssueCommentSummary[]` → `ForgeComment[]` - `commentHistoryHolds` parameter type follows - `ListIssuesFn` DI seam returns `ForgeIssue[]`; production default wraps `new ForgejoAdapter(token).listIssues(parseRepo(repo), opts)` - `classifyBlockers` / `buildDependentView` / `buildIssueDepsGraph` drop their `as unknown as {state?, assignee?, labels?}` casts — adapter returns properly typed `ForgeIssue` - `propagateDependencyClosure`'s `onAssignedReady` callback still accepts the legacy `{ number, title, labels?: { name?: string }[] }` shape; the propagator maps `view.labels` (string[]) back to `[{name}]` at the call site so `webhook-handlers.ts::handleIssueAssigned` keeps working - Removed the PR-row filter in the body-parsed fallback — `listIssues` pins `type=issues` server-side ## The one kept raw import `getIssueBlocks` from `forgejo-api` — kept for `findDependents`' cross-repo filter (#196), which reads `repository.full_name` to drop rows from foreign repos. The port's `getBlocked` returns `ForgeIssueRef[]` (number + state) without the source-repo attribution, so I couldn't replace this one call site cleanly. Documented inline. ## Tests - `deps.test.ts` fixture helpers return `ForgeIssue`/`ForgeComment` (matches pipeline/board pattern) - 61/61 deps tests pass - Full server suite: 1007 pass / 4 pre-existing fails ## Overlap with sibling PRs Opened alongside #278 (janitor) and #277 (webhook-ci). Janitor's PR extends the port: `getBlockers`/`getBlocked` return `ForgeIssueRef[]` instead of `number[]`. Since this PR was authored against main BEFORE the janitor port change, the types the DI seam uses are still the old shape where janitor didn't touch them. If janitor merges first, a trivial fixup here will map `.number` out of the returned refs. If this merges first, janitor rebases instead.
refactor(server): migrate deps to ForgePort
All checks were successful
qa / qa (pull_request) Successful in 4m14s
qa / dockerfile (pull_request) Successful in 8s
c0442f8f6e
All Forgejo REST call sites in `domain/workflow/deps.ts` now go through
the `ForgejoAdapter` / `ForgePort` seam introduced in PR #274, matching
the pipeline (#275) and board (#276) migrations. The only raw
`forgejo-api` import kept is `getIssueBlocks` in `findDependents` — the
port strips the `repository.full_name` attribution needed for the #196
cross-repo filter. Unsafe `as unknown as {state?, assignee?, labels?}`
casts in `classifyBlockers` / `buildDependentView` / `buildIssueDepsGraph`
are gone; the adapter already returns typed domain shapes.

The `listIssuesFn` DI seam keeps its place but its type is now
`(repo, token, opts) => ForgeIssue[]` with a production default that
wraps the adapter. `DependentView.comments` moves from the raw
`IssueCommentSummary[]` to `ForgeComment[]`; `commentHistoryHolds`
follows. The PR-row defensive filter in the body-parsed fallback goes
away — `listIssues` pins `type=issues` server-side.

Tests: added `issue()` / `comment()` factories mirroring the
`pipeline.test.ts` / `board.test.ts` pattern; fixture rows now type as
`ForgeIssue[]` / `ForgeComment[]`. `findDependents` / `listReadyIssues` /
`backfillDependencies` fixtures drop the `pull_request: {}` PR-row case
which is now structurally impossible.

Webhook consumer contract preserved: `propagateDependencyClosure`'s
`onAssignedReady` still receives `{ number, title, labels?: {name}[] }`
— the propagator maps the port's `string[]` labels back to the legacy
shape at the call site so `handleIssueAssigned` in webhook-handlers.ts
keeps working unchanged.

Files touched: 2
  - apps/server/src/domain/workflow/deps.ts
  - apps/server/src/domain/workflow/deps.test.ts

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
charles deleted branch refactor/migrate-deps-to-forgeport 2026-04-23 21:54:12 +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!277
No description provided.