KB-4961

IU Core MVP — 08 Tests + Static Validation

3 min read Revision 1
dieu44iu-core-mvptestsstatic-validationv0.62026-05-21

IU Core MVP — 08 Tests + Static Validation

Date: 2026-05-21 · tests/test_iu_core_ddl.py — stdlib unittest, Python 3.12.

Commands + results

$ python3 -m unittest tests.test_iu_core_ddl
Ran 33 tests ... OK

$ python3 -m unittest discover -s tests
Ran 519 tests in 0.298s ... OK

Baseline before this macro was 486 tests (per prior O10 closeout). New count 519 = 486 + 33 new IU-core tests. Zero regressions.

Coverage of test_iu_core_ddl.py (33 tests)

Package presence — all 5 forward files exist; every forward file has a matching rollback/*.rollback.sql; README exists.

Forward content — expected tables created idempotently; every created table uses the iu_ namespace prefix; no active CREATE TRIGGER (comment lines stripped before the check, so the SANDBOX-ONLY block passes); no ON DELETE CASCADE (no-hard-delete contract); route tables default enabled=false / dry_run=true / fail_closed=true + both named safety CHECKs present; metadata columns default '{}' jsonb; idempotency UNIQUEs present on link/operation/attempt; every table carries an audit timestamp; CHECK constraints present in 001–004.

Rollback content — every table rollback contains the REFUSED row-loss guard; rollback 005 drops the authored functions.

Idempotency helpers — keys deterministic; row_pk changes the key; structure_operation_key is source-id-order-invariant; inbound/outbound keys use distinct namespaces.

Tree helperscompute_path, is_descendant, cycle detection (clean + dirty graph), reparent self/descendant blocked, reparent-to-root and reparent-to-sibling-subtree allowed.

Structure-ops contract — Python OPERATION_TYPES / RELATION_TYPES / OBJECT_KINDS each verified to match the SQL CHECK constraints (drift guard); status-machine accepts legal and rejects illegal transitions; terminal-status detection; events_for_operation values all within IU_EVENT_VOCABULARY.

SQL static validation

No live DB parser was used (no execution permitted). Static checks performed:

  • Structural review of all 10 SQL files: balanced BEGIN/COMMIT, balanced $$ function bodies, every CREATE TABLE is IF NOT EXISTS.
  • The contract tests above assert object names, defaults, constraints and the no-trigger / no-cascade safety rules directly against the SQL text.
  • A live psql parse/EXPLAIN against a sandbox is deferred to the sandbox macro (forbidden here — no DDL execution).

Non-critical skips

None. All 519 tests pass. No skipped tests introduced by this macro.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-mvp-pg-native-parent-child-structure-ops-authoring/08-tests-static-validation.md