KB-5394

SuperBundle — 09 Event/Queue Hardening Pack (Đ45)

5 min read Revision 1
event-queuedieu45executor-classretry-policyidempotencydlq4mothers2026-05-28

09 — Event/Queue Hardening for 4 Mothers Readiness (Branch I)

Verdict: MAP + AUTHORITY PACK — reuse Đ45 substrate, no new monolith. Live inventory shows a substantial Đ45 substrate already exists; only a few registries + event-type rows are genuinely missing.

A. Live inventory (public schema)

PRESENT (15): event_outbox, event_pending, event_read, event_subscription, event_type_registry(31), iu_auto_instantiate_event_log, iu_notification_event, iu_outbound_route, iu_route_attempt, iu_route_dead_letter, iu_route_worker_cursor, iu_sql_event_route, job_dead_letter, job_queue, queue_heartbeat. ABSENT (paper): executor_class_registry, retry_policy_registry, idempotency_key, dlq_replay_request. Gates (dot_config): routes_master=true, route_worker=true, heartbeat=true; delivery=false, job_substrate=false, dlq.replay=false, queue.worker=false, lease.reaper=false, notify=false; emit_enabled=false.

B. Needed-before-4-Mothers map

Piece Live state Action
event types 31, 0 iu./mother. SEED mother./iu. types (additive)
job queues job_queue/job_dead_letter exist reuse; job_substrate gate off
executor_class_registry ABSENT CREATE minimal (authority)
idempotency ABSENT CREATE idempotency_key (authority)
retry_policy ABSENT CREATE retry_policy_registry (authority)
DLQ replay iu_route_dead_letter + replay fn exist reuse; dlq_replay_request table optional
heartbeat queue_heartbeat + gate on reuse as-is
realtime gateway event_outbox/pending/read pipeline reuse; delivery gate off
governance problem events none typed SEED governance.problem.* types

C. Safe paper-to-live seeds (event types) — AUTHORITY-GATED

Event types are registry rows (Đ45, not Đ35). Seeding new types is additive/reversible but should accompany the producers that will emit them (no orphan event types) → deferred to event-hardening macro, spec'd here:

-- AUTHORITY-GATED (apply with producers): mother + governance event types
INSERT INTO event_type_registry (event_type, ...) VALUES
 ('mother.factory.registered', ...),
 ('mother.output.created', ...),
 ('mother.output.failed', ...),
 ('iu.kg.edge.asserted', ...),
 ('governance.problem.raised', ...);

Rollback: delete the seeded rows. Not applied here (would be orphan types until Mothers/producers exist).

D. New-registry DDL specs (reuse Đ45 patterns; authority-gated)

CREATE TABLE executor_class_registry (
  code text PRIMARY KEY, name text NOT NULL, handler_ref text NOT NULL,
  max_concurrency int DEFAULT 1, created_by_law text DEFAULT 'Dieu45',
  status text DEFAULT 'draft', created_at timestamptz DEFAULT now());
CREATE TABLE retry_policy_registry (
  code text PRIMARY KEY, max_attempts int NOT NULL DEFAULT 3,
  backoff text NOT NULL DEFAULT 'exponential', base_delay_ms int DEFAULT 1000,
  created_by_law text DEFAULT 'Dieu45', status text DEFAULT 'draft');
CREATE TABLE idempotency_key (
  key text PRIMARY KEY, scope text NOT NULL, result_ref uuid,
  created_at timestamptz DEFAULT now(), expires_at timestamptz);

Rollback: DROP TABLE executor_class_registry, retry_policy_registry, idempotency_key;

E. Reuse discipline (no new monolith)

  • DLQ uses existing iu_route_dead_letter + fn_iu_route_dead_letter_replay (gated by master routes gate, NOT dlq.replay key — see doc 04 P6). dlq_replay_request table is optional sugar, not required.
  • Job execution reuses job_queue/job_dead_letter; turning on requires queue.job_substrate.enabled + queue.worker.enabled (deliberate, gated).
  • Realtime reuses event_outbox→pending→read; delivery stays off until governed.

F. Readiness gates for 4 Mothers runtime

Before any Mother emits/consumes events at runtime: (1) seed mother.* event types + producers, (2) create executor_class + retry_policy + idempotency, (3) governed open of emit_enabled (bounded protocol), (4) DLQ runbook live (doc 03 §6). All deferred — runtime forbidden this bundle.

G. Advance vs prior state

Prior bundles noted "delivery off, no iu.* types." This doc adds: the full 15-table live inventory, the precise present/absent split, ready DDL for the 3 missing registries with Đ45 lineage, the event-type seed spec tied to producers (no orphan types), and the reuse-not-monolith rule mapped to real table/function names.

Back to Knowledge Hub knowledge/dev/reports/architecture/foundation-factory-gateway-superbundle-cr-kg-pilot-recon-4mothers-design-2026-05-28/09-event-queue-hardening-pack.md