Read executionStatus from incremental checkpoint blobs

Gates the GraphQL executionStatus read on Workflow#reconstruct_from_blobs_for_graphql?, reconstructing the status channel from incremental checkpoint blobs when on (scalar/replace fold to the latest value) and reading the checkpoint header otherwise. Mirrors the duoMessages/lastDuoMessage migration in the same presenter. Reuses the per-consumer dw_read_blobs_graphql flag plus the duo_workflow_read_incremental_checkpoints kill switch — no new flag.

Part of the graphql read consumer. Issue: #607000 (closed)

Database review

New query shape: Workflow#reconstructed_channel narrows accumulated_blobs_for by a single channel (status). Raw SQL:

SELECT "p_duo_workflows_checkpoint_blobs".*
FROM "p_duo_workflows_checkpoint_blobs"
WHERE "p_duo_workflows_checkpoint_blobs"."workflow_id" = 1
  AND "p_duo_workflows_checkpoint_blobs"."workflow_created_at" = '2026-08-06 00:00:00'
  AND "p_duo_workflows_checkpoint_blobs"."project_id" = 1
  AND "p_duo_workflows_checkpoint_blobs"."current_thread" = 0
  AND "p_duo_workflows_checkpoint_blobs"."thread_ts" IN ('ts-1','ts-2')
  AND "p_duo_workflows_checkpoint_blobs"."channel" = 'status'
ORDER BY "p_duo_workflows_checkpoint_blobs"."id" ASC;

workflow_id and workflow_created_at come from the checkpoint_blobs association scope; project_id, current_thread, thread_ts, and channel come from accumulated_blobs_for plus the .where(channel:) narrowing.

The channel filter lands on idx_duo_wf_checkpoint_blobs_dedup (project_id, workflow_id, thread_ts, channel, version, step_action, workflow_created_at): project_id, workflow_id, thread_ts, and channel are the four leading columns, all bound (thread_ts as an IN/= ANY). workflow_created_at prunes to a single daily partition first.

Plan (local DB is empty, so SET enable_seqscan = off to reveal the index the planner uses at scale):

 Sort  (cost=2.19..2.19 rows=1 width=252)
   Sort Key: p_duo_workflows_checkpoint_blobs.id
   ->  Index Scan using p_duo_workflows_checkpoint_b_project_id_workflow_id_threa_idx57 on p_duo_workflows_checkpoint_blobs_20260806
         Index Cond: ((project_id = 1) AND (workflow_id = 1) AND (thread_ts = ANY ('{ts-1,ts-2}'::text[])) AND (channel = 'status'::text) AND (workflow_created_at = '2026-08-06 00:00:00+00'::timestamp with time zone))
         Filter: (current_thread = 0)

The plan prunes to one daily partition and uses that partition's copy of idx_duo_wf_checkpoint_blobs_dedup, with channel in the Index Cond. current_thread is a residual Filter.

Edited by Eduardo Bonet

Merge request reports

Loading
Loading