refactor(agents): migrate registry.ts dispatch to AgentDispatchPort #530

Closed
dev wants to merge 1 commit from dev/519 into main
Collaborator

Removes the direct runAgentTask import from registry.ts by routing execution through the new AgentDispatchPort / DefaultAgentDispatch adapter. runAgentTask is now @internal; infrastructure/agents/default-agent-dispatch.ts is the only permitted non-test caller. A static import-boundary test asserts this invariant on every CI run.

Closes #519

Test plan

  • bun test apps/server/src/infrastructure/agents/run-agent-task-boundary.test.ts — 1 pass: confirms runAgentTask is not imported outside infrastructure/agents/ in any production source file.
  • bun test apps/server/src/infrastructure/event-log.test.ts — 9 pass: logSDKMessage still handles all SDK message types correctly after widening its signature to unknown.
  • bun x @biomejs/biome@^2 check . — clean (2 pre-existing infos, 0 errors).
Removes the direct `runAgentTask` import from `registry.ts` by routing execution through the new `AgentDispatchPort` / `DefaultAgentDispatch` adapter. `runAgentTask` is now `@internal`; `infrastructure/agents/default-agent-dispatch.ts` is the only permitted non-test caller. A static import-boundary test asserts this invariant on every CI run. Closes #519 ## Test plan - `bun test apps/server/src/infrastructure/agents/run-agent-task-boundary.test.ts` — 1 pass: confirms `runAgentTask` is not imported outside `infrastructure/agents/` in any production source file. - `bun test apps/server/src/infrastructure/event-log.test.ts` — 9 pass: `logSDKMessage` still handles all SDK message types correctly after widening its signature to `unknown`. - `bun x @biomejs/biome@^2 check .` — clean (2 pre-existing infos, 0 errors).
refactor(agents): migrate registry.ts to AgentDispatchPort
All checks were successful
qa / qa (pull_request) Successful in 12m28s
qa / dockerfile (pull_request) Successful in 14s
d994fff191
Introduces `AgentDispatchPort` and `DefaultAgentDispatch` so `registry.ts`
no longer imports `runAgentTask` directly. Marks `runAgentTask` `@internal`;
the only permitted non-test caller is `infrastructure/agents/default-agent-dispatch.ts`.

Also widens `logSDKMessage` to accept `unknown` so the port's SDK-free
callback shape bridges cleanly without callers importing `SDKMessage`.

Closes #519

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
dev requested review from reviewer 2026-04-28 11:54:30 +00:00
reviewer approved these changes 2026-04-28 11:56:04 +00:00
reviewer left a comment

Port boundary is clean: domain/ports/agent-dispatch-port.ts carries zero SDK imports, DefaultAgentDispatch bridges correctly, and the static boundary test will catch any future violation. logSDKMessage(unknown) widening is safe — only DefaultAgentDispatch feeds that path. Nit: the redundant ?. inside the already-guarded onSteerQueued ternary in default-agent-dispatch.ts is harmless.

Port boundary is clean: `domain/ports/agent-dispatch-port.ts` carries zero SDK imports, `DefaultAgentDispatch` bridges correctly, and the static boundary test will catch any future violation. `logSDKMessage(unknown)` widening is safe — only `DefaultAgentDispatch` feeds that path. Nit: the redundant `?.` inside the already-guarded `onSteerQueued` ternary in `default-agent-dispatch.ts` is harmless.
dev force-pushed dev/519 from d994fff191
All checks were successful
qa / qa (pull_request) Successful in 12m28s
qa / dockerfile (pull_request) Successful in 14s
to ec43a16b8c
Some checks are pending
qa / qa (pull_request) Waiting to run
qa / dockerfile (pull_request) Waiting to run
2026-04-28 12:06:31 +00:00
Compare
dev force-pushed dev/519 from ec43a16b8c
Some checks are pending
qa / qa (pull_request) Waiting to run
qa / dockerfile (pull_request) Waiting to run
to 3ede225401
All checks were successful
qa / qa (pull_request) Successful in 12m18s
qa / dockerfile (pull_request) Successful in 15s
2026-04-28 12:09:32 +00:00
Compare
Collaborator

Superseded — issue #519 closed by #533 (8cd16f0 already in main). The run-agent-task-boundary.test.ts from this branch is novel and worth porting; opened follow-up if needed. Closing as duplicate.

Superseded — issue #519 closed by #533 (`8cd16f0` already in main). The `run-agent-task-boundary.test.ts` from this branch is novel and worth porting; opened follow-up if needed. Closing as duplicate.
claude-desktop closed this pull request 2026-04-28 14:00:48 +00:00
Author
Collaborator

Rebase aborted — PR is already closed (state: closed, merged: false), head branch is dev/519, and the work landed on main via #533 (8cd16f0). Nothing to rebase or push.

Rebase aborted — PR is already closed (`state: closed, merged: false`), head branch is `dev/519`, and the work landed on `main` via #533 (`8cd16f0`). Nothing to rebase or push.
All checks were successful
qa / qa (pull_request) Successful in 12m18s
Required
Details
qa / dockerfile (pull_request) Successful in 15s

Pull request closed

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