KB-5517

Điều 39 unit_kind Fix — Hard Gate Baseline + pg_dump (2026-05-27)

4 min read Revision 1
iu-cutdieu39hard-gate-0baselinepg-dump2026-05-27

01 — Hard Gate 0 + Baseline + Backup

Hard Gate 0 — write channel probe

Check Result
Real shell OK (interactive zsh on darwin)
SSH contabo OK
docker exec postgres OK
psql -U workflow_admin -d directus OK (current_user=workflow_admin, is_admin=t)
cut_request exists OK (146f1520-aaa2-4bda-af2c-06a8f76cd36a)
manifest staging record exists OK (9fa4685e-d35a-45d4-aee7-aa2836785ca5) in iu_core.iu_staging_record
copy staging record exists OK (365cdc10-722a-4f06-ba32-b1033de7b9a6)
fn_iu_create OK (9-arg signature)
fn_cut_mark_staged_file OK (4-arg)
fn_iu_verify_mark OK (5-arg)
fn_cut_apply OK
fn_iu_op_cut OK
fn_iu_cut_from_manifest OK

Baseline — cut_request state (Điều 39)

cut_request_id            : 146f1520-aaa2-4bda-af2c-06a8f76cd36a
source_ref                : knowledge/dev/laws/dieu39-knowledge-graph-law.md
status                    : mark_verified
copy_staging_record_id    : 365cdc10-722a-4f06-ba32-b1033de7b9a6
manifest_staging_record_id: 9fa4685e-d35a-45d4-aee7-aa2836785ca5
manifest_digest           : aded6af91fb9643fb2ea99ff024a1ede
mark_verdict              : approved
mark_verified_at          : 2026-05-27 03:36:08+00
source_hash               : a732962665691c620a050265de246050
source_bytes              : 23394
cut_run_id                : NULL  -- CUT was attempted and failed inside fn_iu_create

Baseline — manifest piece unit_kind distribution

All 16 pieces:

unit_kind = 'law_section' (count=16)
addresses = DIEU-39-v2.3#preamble, #sec-0-..., #sec-1-26-..., ..., #changelog

This is the root pathology — law_section is NOT in dot_config vocab.unit_kind.* (which only contains design_doc_section and law_unit).

Baseline — pre-fix function md5

Function md5 Role
fn_cut_mark_staged_file 67721b42a55315858e3c377654c2a5b1 TO BE CHANGED — add unit_kind gate
fn_iu_verify_mark 04e5191c430a142712bfe63089863d44 TO BE CHANGED — add Axis D
fn_iu_cut_from_manifest c5d556bc22cc2d255c0484b5a969ebc5 PINNED — must not change
fn_iu_op_cut 66b813e50205448eb01170aebec614df PINNED
fn_iu_op_mark_file ffaa47fff7a906d93060141661080cd4 PINNED
fn_iu_op_verify_mark bf20bd1929998073865808d17b1dd648 PINNED
fn_iu_op_verify_cut ac61dade6519694310cbfd75d8b549fb PINNED

Baseline — invariants

Metric Value
information_unit total 200
Điều 39 IUs 0 (no CUT)
iu_vector_sync_point 152
production_documents table absent (0)
pg_cron extension absent (0)
event_outbox total 139894

Baseline — gates

queue.job_substrate.enabled = false
iu_core.composer_enabled    = false
queue.heartbeat.enabled     = true
queue.dlq.replay_enabled    = false

runtime.phase row not present in this snapshot (was phase2_governance per prior macro memory).

Backup

$ ssh contabo "docker exec postgres pg_dump -U workflow_admin -d directus --no-owner --no-privileges -f /tmp/pre_dieu39_unit_kind_fix_20260527.sql"
$ ssh contabo "docker exec postgres bash -c 'ls -la /tmp/pre_dieu39_unit_kind_fix_20260527.sql && md5sum /tmp/pre_dieu39_unit_kind_fix_20260527.sql'"
-rw-r--r-- 1 root root 921852206 May 27 04:01 /tmp/pre_dieu39_unit_kind_fix_20260527.sql
2d21965b13a46ae32e29ccc6f48308fc  /tmp/pre_dieu39_unit_kind_fix_20260527.sql

Size 921,852,206 bytes, md5 2d21965b13a46ae32e29ccc6f48308fc. Compared to mig 054 pg_dump (84,104,933 bytes per memory), this dump is much larger because it includes the full directus runtime — both are valid for their snapshot times.

Conclusion

HARD GATE 0 PASS. All required objects exist; write channel verified; backup taken. Proceeding to PHASE B root-cause classification.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-cut-dieu39-unit-kind-root-cause-and-contract-fix/01-hard-gate-baseline-backup.md