refactor(foreman-handler): migrate to adapter factory (MF-10) #314

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

Summary

  • Migrates 7 of 8 new ForgejoAdapter(token) callsites in apps/server/src/http/handlers/foreman.ts to createForgeAdapterForRepo(repo, token) from adapter-factory.ts, so the foreman's multi-repo edits (spec reads/writes, breakdown preview, batch issue creation, tracking-issue comments) route through each repo's forge: binding instead of silently hitting Forgejo.
  • Keeps the one remaining direct ForgejoAdapter in handleForemanRepos (listAccessibleRepos()): it's the operator-hosted account-discovery path, has no repo scope to feed the factory, and is intentionally Forgejo-specific. Marked inline as an intentional exception.
  • Cleanup of MF-8 (#299) out-of-scope list — migrates foreman.ts handler.

Test plan

  • just qa — typecheck clean, biome check/format clean
  • bun test src/http/handlers/foreman.test.ts — 36/37 pass; the one remaining failure (listSessions returns newest-first) is a pre-existing Date.now() ordering flake on origin/main unrelated to this change
  • Manual spot-check once merged: /foreman/breakdown-preview on a GitHub-bound repo should route through GitHubAdapter rather than silently 404ing against forge.jacquin.app

Callsites migrated (line numbers post-patch):

  • 271 listDir (handleForemanFilesList)
  • 362 readFile (handleForemanFileContent)
  • 417 writeFile setup (handleForemanSpecSave)
  • 493 readFile (handleForemanBreakdownPreview — remote spec fetch)
  • 506 listIssues (handleForemanBreakdownPreview — dedup)
  • 574 createIssue (handleForemanCreateIssues)
  • 602 createComment (handleForemanCreateIssues — tracking summary)

Exception kept: 205 listAccessibleRepos (handleForemanRepos).

## Summary - Migrates 7 of 8 `new ForgejoAdapter(token)` callsites in `apps/server/src/http/handlers/foreman.ts` to `createForgeAdapterForRepo(repo, token)` from `adapter-factory.ts`, so the foreman's multi-repo edits (spec reads/writes, breakdown preview, batch issue creation, tracking-issue comments) route through each repo's `forge:` binding instead of silently hitting Forgejo. - Keeps the one remaining direct `ForgejoAdapter` in `handleForemanRepos` (`listAccessibleRepos()`): it's the operator-hosted account-discovery path, has no repo scope to feed the factory, and is intentionally Forgejo-specific. Marked inline as an intentional exception. - Cleanup of MF-8 (#299) out-of-scope list — migrates foreman.ts handler. ## Test plan - [x] `just qa` — typecheck clean, biome check/format clean - [x] `bun test src/http/handlers/foreman.test.ts` — 36/37 pass; the one remaining failure (`listSessions returns newest-first`) is a pre-existing `Date.now()` ordering flake on `origin/main` unrelated to this change - [ ] Manual spot-check once merged: `/foreman/breakdown-preview` on a GitHub-bound repo should route through `GitHubAdapter` rather than silently 404ing against `forge.jacquin.app` Callsites migrated (line numbers post-patch): - 271 `listDir` (handleForemanFilesList) - 362 `readFile` (handleForemanFileContent) - 417 `writeFile` setup (handleForemanSpecSave) - 493 `readFile` (handleForemanBreakdownPreview — remote spec fetch) - 506 `listIssues` (handleForemanBreakdownPreview — dedup) - 574 `createIssue` (handleForemanCreateIssues) - 602 `createComment` (handleForemanCreateIssues — tracking summary) Exception kept: 205 `listAccessibleRepos` (handleForemanRepos).
refactor(foreman-handler): migrate to adapter factory (MF-10)
All checks were successful
qa / qa (pull_request) Successful in 3m57s
qa / dockerfile (pull_request) Successful in 9s
5c2bf6d235
Cleanup of MF-8 (#299) out-of-scope list — migrates foreman.ts handler
from direct `new ForgejoAdapter(token)` to `createForgeAdapterForRepo`,
so foreman's multi-repo edits pick the right forge (Forgejo / GitHub /
GitLab) based on each repo's `forge:` binding in `config/agents.json`.

7 of 8 callsites migrated. The one exception — `listAccessibleRepos()`
in `handleForemanRepos` — stays on `ForgejoAdapter` because it's the
operator-hosted account-discovery path; it has no repo scope to feed
the factory. Inline comment marks it as an intentional exception.

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