- Extract TaskService (server/internal/service/task.go) for task lifecycle: enqueue with context snapshot, claim, start, complete, fail, progress - Add daemon protocol endpoints under /api/daemon/: register, heartbeat, claim task, start/progress/complete/fail task - Task ↔ Issue status sync: running→in_progress, completed→in_review, failed→blocked - Agent status auto-management: reconcile idle/working based on running tasks - Enforce max_concurrent_tasks on task claiming (FOR UPDATE SKIP LOCKED) - Add UpdateIssueStatus query (fixes bug where UpdateIssue nulls assignee) - Extract shared pgx utils to server/internal/util/ to avoid circular imports - Migration 003: add context JSONB to agent_task_queue, daemon unique constraint Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
12 lines
506 B
SQL
12 lines
506 B
SQL
-- Add context snapshot to agent tasks so daemons have everything needed to execute
|
|
ALTER TABLE agent_task_queue
|
|
ADD COLUMN context JSONB;
|
|
|
|
-- Partial index for efficient daemon polling of pending tasks
|
|
CREATE INDEX idx_agent_task_queue_pending
|
|
ON agent_task_queue(agent_id, priority DESC, created_at ASC)
|
|
WHERE status IN ('queued', 'dispatched');
|
|
|
|
-- Unique constraint for daemon connection upsert
|
|
ALTER TABLE daemon_connection
|
|
ADD CONSTRAINT uq_daemon_agent UNIQUE (agent_id, daemon_id);
|