KB-38EC

12000x · 06 — Phase G · Event runtime emission proof (4 events emitted in-TX, all dry_run, rolled back to zero)</title> <parameter name="tags">["iu-core","v0.6","12000x","phase-g","piece-event-runtime","fn_iu_piece_emit_event","trigger","dry-run","pass"]

5 min read Revision 1

12000x · 06 — Phase G · Event runtime emission proof (gated)

Goal

Exercise the 11000x Piece Event Runtime substrate end-to-end: open piece_event_runtime.emit_enabled inside a transaction, drive both emit paths (direct call + lifecycle-log trigger), confirm rows land in v_piece_event_outbox, confirm migration 030's event_outbox.event_domain CHECK += 'piece' actually accepts inserts, then ROLLBACK and assert ZERO durable state changed.

11000x built the substrate (bounded BEGIN/ROLLBACK). 12000x is the INDEPENDENT re-proof that the substrate is re-exercisable.

SQL

BEGIN;
UPDATE dot_config SET value='true' WHERE key='iu_core.composer_enabled';
UPDATE dot_config SET value='true' WHERE key='piece_event_runtime.emit_enabled';

-- G.A direct emit
SELECT public.fn_iu_piece_emit_event(
  'split', 'iu_core/12000x/dryrun/direct-emit',
  (SELECT id FROM information_unit LIMIT 1),
  'iu-core-12000x',
  jsonb_build_object('proof','12000x','via','direct_fn'));

-- G.B/C/D trigger emit via 3 lifecycle_log INSERTs (split/merge/supersede)
INSERT INTO iu_lifecycle_log(unit_id, canonical_address, from_status, to_status, transition_type, performed_by, metadata)
SELECT id, canonical_address, 'enacted','enacted','split','iu-core-12000x', jsonb_build_object('proof','12000x','via','trigger')
FROM information_unit LIMIT 1;
-- same pattern with transition_type='merge', then 'supersede'.

ROLLBACK;

In-tx state after UPDATEs

piece_event_runtime.dry_run_only = true   ← kept true on purpose
piece_event_runtime.emit_enabled = true   ← gate opened in-tx

Pre-emit healthcheck (8th surface)

{"ok": true, "surface": "piece_event_runtime", "gate_keys": 2,
 "view_exists": true, "dry_run_only": "true", "emit_enabled": "true",
 "fn_trg_exists": true, "fn_emit_exists": true, "trigger_exists": true,
 "piece_event_types_active": 6}

G.A — Direct fn_iu_piece_emit_event call returned a UUID

emitted_event_id = 3a33ff62-832c-4c0b-a1a0-3f08b15ccaf5

Non-NULL return means the fn passed all four guards (fn_iu_core_routes_enabled() master, runtime gate, event-type registered+active, payload classification) and wrote a row to event_outbox.

G.B/C/D — Trigger emission

Three INSERTs into iu_lifecycle_log with transition_type ∈ {split, merge, supersede} fired trg_iu_lifecycle_log_emit_piece_event AFTER INSERT. Trigger mapping:

input transition_type output event_type
split split
merge merged
supersede superseded

Matches the trigger's CASE block exactly — verified live.

G.E — v_piece_event_outbox accumulated 4 rows in-tx

event_type payload_classification count
merged safe_metadata 1
split safe_metadata 2 (1 direct + 1 trigger)
superseded safe_metadata 1

All rows have payload_classification='safe_metadata' (no PII surface).

G.F — event_outbox accepted event_domain='piece' (mig 030 verified by live INSERT)

event_type emit_mode count
merged dry_run 1
split dry_run 2
superseded dry_run 1

emit_mode='dry_run' confirms piece_event_runtime.dry_run_only=true honored even when emit is enabled — safety property for staged rollouts.

The 10000x defect (event_outbox CHECK vs event_type_registry drift — see feedback_event_outbox_check_vs_registry_drift) is now re-verified GREEN by a live INSERT round-trip, not just inspection.

G.G — Healthcheck still ok=true after emission

{"ok": true, "surface": "piece_event_runtime", "emit_enabled":"true", "dry_run_only":"true", "piece_event_types_active": 6, …}

ROLLBACK + durability check

event_outbox_piece_post      = 0
v_piece_event_outbox_post    = 0
iu_lifecycle_log_12000x_post = 0
composer_gate                = false
piece_emit_enabled           = false
piece_dry_run_only           = true

All piece-event surfaces back to zero. All gates back to false. ZERO durable mutation.

Pass criteria

  • In-tx gate-toggle worked; healthcheck reflected new gate state
  • Direct fn_iu_piece_emit_event returned non-NULL UUID
  • Trigger fired on 3 lifecycle-log INSERTs and mapped transitions correctly
  • v_piece_event_outbox showed 4 expected rows
  • event_outbox.event_domain='piece' accepted (mig 030 round-trip)
  • All rows carried emit_mode='dry_run' (dry_run_only honored)
  • Healthcheck stayed ok=true throughout
  • Post-rollback: ZERO rows, gates restored

PHASE G PASS — Piece Event Runtime substrate is execution-proven, not just installed.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-12000x-product-factory-execution-event-proof-open-goal/06-phase-G-event-runtime-emission-proof.md