refactor: extract domain logic out of agent-types-settings HTTP handler #1136

Closed
opened 2026-05-13 21:27:57 +00:00 by claude-desktop · 1 comment
Collaborator

As a developer working on agent configuration, I want the business logic for revision auditing, scope validation, and agent_type CRUD to live in the domain layer, so that the HTTP handler is a thin routing layer and the logic is testable in isolation.

Handler

  • apps/server/src/http/handlers/agent-types-settings.ts (1737 lines) currently owns: revision auditing, scope validation, agent_type table CRUD, and provider chain parsing
  • Extract into a dedicated domain module (e.g. domain/agent-type/agent-type-service.ts)
  • HTTP handler becomes: parse request → call domain → serialize response

Domain

  • New module exposes typed functions: createAgentType, updateAgentType, deleteAgentType, reorderProviderChain, etc.
  • Revision auditing logic moves into the domain module
  • Scope validation (global vs agent_type) lives in domain, not handler

Tests

  • Domain module is unit-testable without HTTP context

Out of scope

  • Changing the API contract (request/response shape stays identical)
  • Moving the route registration (stays in agent-types-settings.ts, now ~100 lines)
  • Drizzle ORM migration (separate milestone #37)

References

  • apps/server/src/http/handlers/agent-types-settings.ts (1737 lines)
  • Codebase audit 2026-05-13
As a developer working on agent configuration, I want the business logic for revision auditing, scope validation, and agent_type CRUD to live in the domain layer, so that the HTTP handler is a thin routing layer and the logic is testable in isolation. ### Handler - [ ] `apps/server/src/http/handlers/agent-types-settings.ts` (1737 lines) currently owns: revision auditing, scope validation, agent_type table CRUD, and provider chain parsing - [ ] Extract into a dedicated domain module (e.g. `domain/agent-type/agent-type-service.ts`) - [ ] HTTP handler becomes: parse request → call domain → serialize response ### Domain - [ ] New module exposes typed functions: `createAgentType`, `updateAgentType`, `deleteAgentType`, `reorderProviderChain`, etc. - [ ] Revision auditing logic moves into the domain module - [ ] Scope validation (global vs agent_type) lives in domain, not handler ### Tests - [ ] Domain module is unit-testable without HTTP context ### Out of scope - Changing the API contract (request/response shape stays identical) - Moving the route registration (stays in `agent-types-settings.ts`, now ~100 lines) - Drizzle ORM migration (separate milestone #37) ### References - `apps/server/src/http/handlers/agent-types-settings.ts` (1737 lines) - Codebase audit 2026-05-13
Collaborator

🦵 @charles kicked the queue — re-running implement on @code-lead.

🦵 @charles kicked the queue — re-running implement on @code-lead.
Sign in to join this conversation.
No milestone
No project
No assignees
2 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/agent-hooks#1136
No description provided.