2.9 KiB
2.9 KiB
id, title, status, wave, depends_on, plan, spec
| id | title | status | wave | depends_on | plan | spec | |
|---|---|---|---|---|---|---|---|
| 02-backend-service-handler-reorder | Backend service and WS handler reorder | done | 2 |
|
plan.md | ../../specs/ui/requirements/message-queue-reorder.md |
Task 02: Backend service and WS handler reorder
Acceptance
messagequeue.Service.ReorderEntriesvalidates input (non-empty, no duplicate ids) and delegates to the repository; drift errors surface asErrQueueChanged.- New WS action
message.queue.reorderis registered and handled:{session_id, ordered_ids}parsed, validation errors for missing session / empty / duplicate ids, session access authorized,ErrQueueChangedmapped to thequeue_changederror code, success responds{session_id, reordered: N}and publishesmessage.queue.status_changed. - Handler tests cover happy path (publish called), validation, access denied, error mapping, and a real
NewServiceMemoryround-trip; the action is added to the registration test table.
Verification
cd apps/backend && go test ./internal/orchestrator/handlers/...
cd apps/backend && go test ./internal/orchestrator/messagequeue/...
cd apps/backend && go vet ./internal/orchestrator/handlers/...
Files likely touched
apps/backend/pkg/websocket/actions.go—ActionMessageQueueReorder = "message.queue.reorder".apps/backend/internal/orchestrator/messagequeue/service.go—ReorderEntries.apps/backend/internal/orchestrator/handlers/queue_handlers.go—ReorderEntrieson theQueueServiceinterface,queueErrorCodeQueueChanged = "queue_changed"constant,wsReorder+ registration.apps/backend/internal/orchestrator/handlers/queue_handlers_reorder_test.go— new.apps/backend/internal/orchestrator/handlers/queue_handlers_test.go— addreorderrow to the table (mirror themergerow; body needs a second entry id).
Dependencies
Task 01 (repository ReorderEntries + ErrQueueChanged).
Parallelism
Sequential.
Inputs
- Spec:
## API Surface,## Permissions,## Failure Modes. - Plan:
### Service,### WebSocket action,### Handler,### Tests. - Existing patterns:
wsMergeIntoAbove+publishStatusinqueue_handlers.go, send-now error mapping,queue_handlers_send_now_test.go.
Output contract
Summary, files changed, exact test commands and outcomes, blockers, risks; update task + plan statuses in the same conversation.
Results
cd apps/backend && go test -count=1 ./internal/orchestrator/handlers/...→ok.cd apps/backend && go build ./...→ exit 0 (whole backend compiles with the newQueueService.ReorderEntries).- Files:
pkg/websocket/actions.go(ActionMessageQueueReorder),messagequeue/service.go(ReorderEntries),handlers/queue_handlers.go(interface method,queueErrorCodeQueueChanged,wsReorder+ registration,hasDuplicateIDs),handlers/queue_handlers_reorder_test.go(new),handlers/queue_handlers_test.go(auth-table row).