3.6 KiB
3.6 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec |
|---|---|---|---|---|---|---|
| 01-backend-duplicate-endpoint | Add the backend profile duplicate endpoint | done | 1 | plan.md | ../../specs/agents/requirements/profile-duplicate.md |
Task 01: Backend profile duplicate endpoint
Acceptance
POST /api/v1/agent-profiles/:id/duplicate(interlock-protected) creates a new profile named<source name> Copywith a distinct ID anduser_modified: true, copying model, fallback model, auto-fallback, mode, config options, allow-indexing, auto-approve, CLI passthrough, CLI flags, env vars (secret refs included), command prefix, enabled state, and the source's MCP config row (enabled + servers + meta) when one exists.- Runtime state is not copied: the copy is idle, no pause reason, no last-run timestamp, zero consecutive failures.
- A disabled source produces a disabled copy; an enabled source produces an enabled copy.
- The copy is committed atomically (row + MCP config in one repository transaction, inserted with the source's enabled state): a failure leaves no partial profile and a disabled source never becomes briefly selectable.
- Unknown or soft-deleted source ID →
ErrAgentProfileNotFound→ HTTP 404, and nothing is created. - An office-scoped source (non-empty
workspace_id) →ErrAgentProfileNotFound→ HTTP 404 (existence hidden), rejected before MCP config is read or any row is written, with zero broadcasts on any channel (global or workspace-scoped). - Success returns the new
AgentProfileDTOand broadcasts theagent.profile.createdWS notification with{"profile": <dto>}. - The route is added to the interlock 403 route list.
Verification
- RED/GREEN controller:
cd apps/backend && go test -run 'TestDuplicateProfile' ./internal/agent/settings/controller - Interlock list:
cd apps/backend && go test -run 'TestRegisterRoutesProtectsEveryStateChangingAgentSettingsRoute' ./internal/agent/settings/handlers - Full package after refactor:
cd apps/backend && go test ./internal/agent/settings/...
Files likely touched
apps/backend/internal/agent/settings/controller/profile_crud.goapps/backend/internal/agent/settings/controller/profile_duplicate_test.go(new)apps/backend/internal/agent/settings/controller/reconciler_test.go(extend sharedfakeStorewith MCP config methods +DuplicateAgentProfile, additively)apps/backend/internal/agent/settings/store/store.go(addDuplicateAgentProfileto the repository interface)apps/backend/internal/agent/settings/store/sqlite.go(atomicDuplicateAgentProfilein one transaction; shared insert/upsert helpers)apps/backend/internal/agent/settings/store/sqlite_duplicate_test.go(new)apps/backend/internal/agent/settings/handlers/handlers.goapps/backend/internal/agent/settings/handlers/interim_settings_interlock_test.go- Optional:
apps/backend/internal/agent/settings/handlers/profile_duplicate_handlers_test.go
Dependencies
None.
Parallelism
Sequential by default; file-disjoint from Tasks 02–03 and may run in parallel only with explicit user authorization.
Inputs
- Spec duplicate scenarios
profile_crud.goexistingDeleteProfilenot-found mapping andCreateProfilefield list;store.Repositoryinterface; sqliteCreateAgentProfile/GetAgentProfileMcpConfig/UpsertAgentProfileMcpConfig;ws.ActionAgentProfileCreatedbroadcast pattern fromhttpCreateProfile.
Output contract
Report RED and GREEN results, the response/error contract, changed files, the
enabled-state and MCP-copy behavior, and update this task plus plan.md
status.