fix(archied): post each reportable status a chat task reaches, recorded by status not by flag

This commit is contained in:
sam committed 2026-10-25 02:42:31 +11:00
1 parent 1a386dae7e
commit 4e2edc911f
13 files changed
+85 -51

No files matched your search

@@ -105,14 +105,15 @@ ORDER BY id;
-- Chat tasks that finished, wait for approval or have a pull request open,
-- whose state has not reached their conversation yet.
SELECT * FROM tasks
WHERE origin <> '' AND NOT outcome_posted
WHERE origin <> '' AND outcome_posted_status <> status
AND status IN ('merged', 'rejected', 'dead', 'closed_wont_do', 'completed', 'waiting_approval', 'pr_open')
AND (sqlc.narg(scope_org)::text IS NULL OR org_id = sqlc.narg(scope_org))
ORDER BY id
LIMIT 50;
-- name: MarkOutcomePosted :exec
UPDATE tasks SET outcome_posted = true WHERE id = $1;
-- Records the status whose state reached the task's conversation.
UPDATE tasks SET outcome_posted_status = $2 WHERE id = $1;
-- name: StampTaskBinding :exec
-- The capture's signature result is spelled as the access context spells it.
@@ -152,11 +153,8 @@ SELECT status FROM tasks WHERE id = $1 FOR UPDATE;
-- name: TransitionTask :execrows
-- Arriving at 'parked' also records why. The class is normalized by the
-- caller, so an unknown value persists as needs_human rather than as itself.
-- Leaving a state the conversation was told about (an approval request, an
-- open pull request) clears outcome_posted, so the next state is posted too.
UPDATE tasks
SET status = $2,
outcome_posted = CASE WHEN status IN ('waiting_approval', 'pr_open') THEN false ELSE outcome_posted END,
park_reason = CASE WHEN $2 = 'parked' THEN $3 ELSE park_reason END,
park_class = CASE WHEN $2 = 'parked' THEN $4 ELSE park_class END,
park_blocker = CASE WHEN $2 = 'parked' THEN '' ELSE park_blocker END,
@@ -210,7 +208,7 @@ RETURNING *;
-- A remediation must continue the branch its pull request lives on, so it
-- records that dispatch mode explicitly (taskstate.RetryContinuePushedWork)
-- rather than leaving prepareWorkspace to infer it from the workflow.
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, outcome_posted = false, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '', park_class = 'needs_human', review_payload = $2, retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}', updated_at = now()
WHERE id = $1 AND status = 'pr_open';
-- name: AppendPendingReview :execrows
@@ -231,7 +229,7 @@ WHERE id = $1 AND status IN ('queued', 'running') AND workflow = 'remediate';
-- waiting: the oldest becomes the active payload and the task is queued
-- again, so it is remediated after the run that just finished.
UPDATE tasks SET status = 'queued', workflow = 'remediate', park_reason = '',
park_class = 'needs_human', outcome_posted = false,
park_class = 'needs_human',
review_payload = pending_reviews->>0, pending_reviews = pending_reviews - 0,
retry_mode = 'continue_pushed_work', resume_from = '', resume_results = '{}',
updated_at = now()