﻿# An outbox connects an approved AI action to durable publication intent

Commit approval and outbox insertion together, then observe delivery separately. Examine aggregate routing, immutable events and recovery across publication crashes.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/enterprise-ai-outbox-approved-action-publication/
Language: en

## Keep an approved operation from disappearing

An assistant prepares a permitted document export. The application commits its approval record, then crashes before publishing the worker message. A different ordering can publish the message before the approval transaction fails. Neither case is solved merely by retrying an HTTP request. The design question is how the application's durable business state and its durable intent to publish work become one local transaction.

## Put the publication intent in the same transaction

The [PostgreSQL transaction tutorial](https://www.postgresql.org/docs/current/tutorial-transactions.html) describes grouping changes into an all-or-nothing operation. In this proposed design, the approval transition and an outbox insertion belong to that same database transaction. Committing makes both local records durable; rolling back preserves neither change. The broker is outside that transaction. Avoid describing a database commit as proof that a message has already reached a worker or that the external export succeeded.

## Route committed outbox changes deliberately

The [Debezium outbox event router](https://debezium.io/documentation/reference/stable/transformations/outbox-event-router.html) captures outbox-table changes and transforms them into messages. Its documented event identifier and aggregate identifier have different roles: event identity can support duplicate handling, while the aggregate key affects partition ordering. For an export, define the business object whose changes need ordering. A randomly chosen event identifier should not accidentally replace the intended aggregate routing key.

## Keep an event immutable after publication intent

The documented router expects outbox inserts, rejects updates according to configuration and filters deletes. Build the application contract around an event representing a committed transition. Do not mutate its payload later to change what a previously approved operation means. If the approval changes, create a new business transition with its own evidence. Apply the transformation selectively to intended outbox changes rather than assuming heartbeat or schema-change events have the same structure.

## Test the two crash boundaries

Use a harmless approval fixture and a test receiver. Interrupt the application before commit and after commit but before publication is observed. In the first case, neither the approval transition nor its event should exist as committed work. In the second, the committed event must remain available to the publication path after recovery. Then exercise a repeated delivered event and observe downstream duplicate handling separately. Acceptance connects durable intent with eventual observed delivery; it does not claim one global exactly-once transaction. No crash experiment was executed here.

## Report local atomicity and downstream effects separately

Retain business-operation identity, outbox event identity, aggregate key and publication observations without embedding confidential source documents in diagnostic logs. [Generation retry ledgers](/journal/provider-post-retry-idempotency-ledger/) address ambiguous request attempts, while [delegated retry identity](/journal/frontier-swarm-retry-idempotency/) distinguishes a repeated task from a new business effect. The outbox closes a different gap: a committed local transition lacking durable publication intent. Worker completion, external-service authorization and duplicate-effect prevention still need their own observed contracts. A useful recovery record can say approval committed and publication pending without inventing either a lost job or a completed export.
