KB-28A7

IU Core Worker Live — 03 Delivery seam package

3 min read Revision 1
dieu44iu-core-mvpevent-workerdelivery-seamskeletonv0.62026-05-21

IU Core Worker Live — 03 Delivery seam package

What it is

cutter_agent/iu_core/delivery_seam.py — the executable contract / skeleton for the delivery dispatcher the dry_run=false macro must build. The SQL seam fn_iu_route_deliver(text,uuid,jsonb) (migration 009) is the seam of record; in the MVP it RAISES feature_not_supported. This module fixes the dispatcher shape so the dry_run=false macro has a concrete target to build against.

Surface

  • DELIVERY_TARGET_KINDS{sql_function, workflow, vector, report, directus_flow, external_endpoint}, mirrors the iu_outbound_route target_kind CHECK (migration 002).
  • DELIVERY_STATUSES{sent, failed, skipped}.
  • DeliveryRequestroute_code, event_ref, target_kind, target_ref, idempotency_key, safe_payload. Validates target_kind and requires an idempotency_key (replay safety).
  • DeliveryOutcomestatus, delivered, target_kind, detail. Enforces delivered=True ⇒ status='sent'.
  • DeliveryTarget Protocol — deliver(request) -> DeliveryOutcome.
  • UnbuiltDeliveryTarget — the fail-closed default; deliver always raises DeliveryNotImplemented (the Python mirror of the SQL RAISE).
  • DELIVERY_TARGET_REGISTRY — every kind → UnbuiltDeliveryTarget.
  • resolve_delivery_target(kind) / dispatch_delivery(request) — the dispatcher; in the MVP always raises DeliveryNotImplemented.
  • seam_is_fail_closed() — True while every target is unbuilt.

Fail-closed by construction

Pure, DB-free. No concrete DeliveryTarget exists — seam_is_fail_closed() is True and dispatch_delivery raises for all six kinds. No route, not even a (CHECK-impossible) dry_run=false one, can deliver downstream.

How the dry_run=false macro uses it

  1. Decide what "delivery" concretely means for target_kind='workflow' (a Directus flow, a workflow engine, a notification fan-out).
  2. Implement a DeliveryTarget for that kind; replace the registry entry.
  3. Re-author the SQL fn_iu_route_deliver as the matching dispatcher.
  4. The worker's deliver branch then reaches a real target instead of the feature_not_supported RAISE.

Tests: TestDeliverySeam (7) — target kinds match SQL, fail-closed, dispatch raises for every kind, request/outcome validation.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-worker-live-dryrun-structure-autocut-delivery-prep-open-goal/03-delivery-seam-package.md