KB-115D

IU-0 Pack 1 Final Execution Report

6 min read Revision 1
iu0pack1finalexecution-reportdieu44

IU-0 Pack 1 — Final Execution Report

Date: 2026-05-04 UTC Environment: VPS contabo (38.242.240.89), postgres container PG version: PostgreSQL 16.13 (Debian 16.13-1.pgdg13+1) on x86_64 gen_random_uuid() source: built-in (PG13+, no extension required)

Overall: PASS — Pack 1 DONE


Preflight (CP1)

Item Result Note
0a SSH PASS
0b PG version PASS 16.13
0c gen_random_uuid() PASS built-in
0d dot_config schema MISMATCH → CP1 FAIL → resolved via Opus correction actual cols: key, value, description, updated_at (not config_key/config_value/created_at); PRIMARY KEY on key (acts as unique)
0e Conflict vocab keys PASS 0 rows
0f information_unit exists PASS absent
0f unit_version exists PASS absent
0g Backup files PASS /opt/incomex/backups/pre-pack1-schema-20260504-113258.sql (837272 B), /opt/incomex/backups/pre-pack1-dot-config-20260504-113258.sql (6495 B)

CP1 Resolution

Verified trg_sync_cp_patterns trigger on dot_config — only fires for exact key context_pack_watched_key_patterns. Safe to seed vocab.*.

Opus approved: rewrite Step 1 INSERT and birth gate L1 to use key instead of config_key, omit created_at (use default updated_at), ON CONFLICT (key).


DDL Execution (CP2)

Step Object Result
1 Vocab seed (3 keys) PASS — INSERT 0 3
2 information_unit (15 cols, 5 indexes, trg_iu_updated_at) PASS
3 unit_version (9 cols, 3 indexes, UNIQUE(unit_id, version_seq)) + DEFERRABLE FK fk_iu_version_anchor PASS — condeferrable=t, condeferred=t
4 fn_iu_birth_gate_layer1 + BEFORE INSERT trigger PASS
5 fn_iu_birth_gate_layer2 + CONSTRAINT TRIGGER (DEFERRABLE INITIALLY DEFERRED) PASS — tgdeferrable=t, tginitdeferred=t

Audit warning observed

WARNING: [TRIGGER-GUARD] DDL detected: CREATE TRIGGER on <name> on public.information_unit — fired 3× (one per CREATE TRIGGER). Non-blocking; flagged for Opus to decide whether 3 new triggers need governance registration.


Smoke Tests (CP3) — 14/14 PASS

# Test Expected Actual error / result
T1 INSERT no title L1 block ERROR: Birth gate L1: P-id1 title required
T2 INSERT empty title L1 block ERROR: Birth gate L1: P-id1 title required
T3 INSERT empty canonical L1 block ERROR: Birth gate L1: U2 canonical_address required
T4 INSERT no pub fields (rolled back) L1 WARNING + INSERT OK 2× WARNING PILOT-ONLY + INSERT 0 1 + ROLLBACK
T5 Full transaction (iu + uv + UPDATE anchors) COMMIT SUCCESS, COMMIT
T6 New version (seq=2) OK INSERT 0 1
T7 Soft-delete UPDATE deleted_at OK UPDATE 1 (and revert)
T8 Duplicate canonical UNIQUE violation ERROR: duplicate key value violates unique constraint "information_unit_canonical_address_key"
T9 COMMIT without anchors L2 block ERROR: Birth gate L2: U5 content_anchor_ref required at COMMIT
T10 version_anchor_ref → other unit L2 block ERROR: Birth gate L2: version_anchor_ref must point to version of this unit
T11 content_anchor_ref ≠ version_anchor_ref::text L2 block ERROR: Birth gate L2: content_anchor_ref must match version_anchor_ref
T12 unit_kind="FAKE_KIND" L1 block ERROR: Birth gate L1: unit_kind "FAKE_KIND" not in vocab
T13 section_type="FAKE_SECTION" L1 block ERROR: Birth gate L1: section_type "FAKE_SECTION" not in vocab
T14 Full happy path (deferred FK) COMMIT, joined select `test.t14

Cleanup + Final verify (Giai đoạn 4)

Cleanup

DELETE 3   -- unit_version rows for test.*
DELETE 2   -- information_unit rows for test.*
SELECT count(*) FROM information_unit WHERE canonical_address LIKE 'test.%' → 0

Final state

  • information_unit table exists, 0 rows
  • unit_version table exists, 0 rows
  • Indexes (8): idx_iu_canonical, idx_iu_identity_profile, idx_iu_lifecycle, idx_iu_parent, idx_iu_unit_kind, idx_uv_content_hash, idx_uv_unit_id, uq_unit_version_seq
  • Triggers on information_unit (7 total): trg_iu_updated_at, trg_iu_birth_gate_layer1, trg_iu_birth_gate_layer2 (DEFERRED), + 4 RI_ConstraintTriggers (FK plumbing)
  • fk_iu_version_anchor: condeferrable=t, condeferred=t
  • Vocab seeds (3): vocab.unit_kind.design_doc_section, vocab.section_type.section, vocab.publication_type.design_doc — all present in dot_config

Hard boundaries

  • HB-1 không sửa tables hiện có: ✓ chỉ INSERT 3 rows vocab vào dot_config (table sẵn có, không alter)
  • HB-2 không đụng production_documents: ✓
  • HB-3 không tạo Qdrant collection: ✓
  • HB-4 không outbox: ✓
  • HB-5 không sửa 07/07b/07c/P38-XC: ✓
  • HB-6 không tạo extension: ✓ (gen_random_uuid built-in)
  • HB-7 không vi phạm: ✓
  • HB-8 schema mismatch: ✓ STOP đúng quy trình tại CP1, chờ Opus quyết định, không tự sửa

Followups for Opus

  1. [TRIGGER-GUARD] audit: xác định có cần đăng ký 3 triggers mới (trg_iu_updated_at, trg_iu_birth_gate_layer1, trg_iu_birth_gate_layer2) vào hệ thống governance hay không.
  2. Pack 2 chưa khởi động — HARD STOP theo chỉ thị.

HARD STOP

Pack 1 hoàn tất. Không Pack 2. Không outbox. Không Qdrant. Không Directus integration.