Files
multica/server/migrations/150_agent_task_coalesced_comments.up.sql
Multica Eve 6a72f248a1 fix: unblock release migrations (#5162)
Co-authored-by: Eve <eve@multica-ai.local>
Co-authored-by: multica-agent <github@multica.ai>
2026-07-09 17:59:19 +08:00

21 lines
1.2 KiB
SQL

-- Guarantee at-least-once processing of user comments (MUL-4195).
--
-- Historically a new comment that arrived while an agent already had a
-- queued/dispatched task for the same (issue, agent) was silently DROPPED by
-- the HasPendingTaskForIssueAndAgent dedup: only the first comment's
-- trigger_comment_id survived, and the follow-up instruction was lost with no
-- visible trace. That is a correctness bug for comments, which — unlike chat —
-- are deliberate, addressed, persisted user input that must never vanish.
--
-- coalesced_comment_ids records the comments that were FOLDED INTO a
-- not-yet-started task instead of being dropped. The task's trigger_comment_id
-- is repointed to the newest comment (so the injected prompt shows the latest
-- deliberate instruction) while this array preserves every earlier comment the
-- single run must still address. It is also surfaced on the task API so the UI
-- can show exactly which comments a run covered.
--
-- Default '{}' (empty array, never NULL) so existing rows and every non-merge
-- enqueue path keep working untouched.
ALTER TABLE agent_task_queue
ADD COLUMN IF NOT EXISTS coalesced_comment_ids UUID[] NOT NULL DEFAULT '{}';