The Research Report
Transactional Outbox and Checkpoint-Commit Ordering in Agent Pipelines
date: 2026-11-08
title: "Transactional Outbox and Checkpoint-Commit Ordering in Agent Pipelines"
author: Brian Taylor
Transactional Outbox and Checkpoint-Commit Ordering in Agent Pipelines
Why this matters
Brian’s trend-scout/content-agent/email-archive/Drive-sync pipelines cross two resources (local state and outside world) with no shared transaction. Earlier notes cover retry identity, duplicate-safe writes, and cron discipline. This adds the cross-cutting sequencing rule: a side effect becomes visible to a consumer only after the checkpoint recording intent has committed.
Transactional outbox
Write the intended side effect into the same atomic commit as local state; a separate relay performs it later.
- Sender updates local state.
- Outbox stores outgoing message/event alongside state.
- Relay reads pending rows, performs external action, records success.
- Consumer must be idempotent: relay can crash between send and acknowledge and resend.
Benefits: no 2PC across DB/provider; message sent iff local tx commits; ordering preserved. Cost: duplicate detection moves to consumer.
Checkpoint vs commit ordering
Commit the external cursor/offset after destination durable write.
- Read batch using last committed cursor.
- Stage to destination with idempotent upsert/MERGE by stable primary key.
- Commit cursor/offset after destination transaction succeeds.
- On crash before step 3, replay and MERGE again; outcome converges.
This gives exactly-once outcome from at-least-once delivery + idempotent writes; use true exactly-once (2PC/Flink barriers) only where sinks and latency needs justify it.
Side-effect types
- Idempotent by key: Drive pre-chosen IDs, email-id archive dedup, API overwrite by natural key.
- Append-only: stage then MERGE, or dedup at read time.
- Aggregations: avoid SUM/incrementing; recompute from source-of-truth.
- Non-deterministic transforms: use source event time, never NOW().
Partial batches
Track per-record success or stage whole batch and commit only when all stage; retries must not blindly replay 999 or abandon 1.
Mapping to Brian’s stack
- Trend-scout: persist fetch/analyze decisions in ledger/outbox before publishing; publisher drains pending.
- Email archive: message-id keyed writes; commit mailbox cursor after insert.
- Drive sync: choose path/ID first; verify existence; record hash; commit cursor after confirm.
- Content-agent: stable event keys; server-side heading/sources; deletes instead of duplicate regeneration.
Checklist
- External cursor committed only after destination success.
- Destination writes idempotent by a retry-surviving key.
- Outbox/relay retries recorded in local log.
- Partial failures handled deliberately (per-record or whole-batch).
- Replay tested with real duplicates before relying on it.