KB-9259
100000x · 03 — Re-author + apply 041R (VERIFY CUT result)
4 min read Revision 1
iu-core100000x041Rverify-cutaxis-a-b-cno-vectorlive-applied2026-05-26
100000x · 03 — Re-author + apply 041R
Phase: C · Status: APPLIED · Migration: 041R
Apply
ssh contabo 'docker exec -i postgres psql -U workflow_admin -d directus -v ON_ERROR_STOP=1' < /tmp/iu100000x/041R-verify-cut-result.sql
Result: BEGIN / CREATE FUNCTION / INSERT 0 1 / COMMIT. Atomic.
Smoke test (immediate)
V-not-found | {ok:false, reason:run_not_found}
CAT | dot_iu_verify_cut_result registered (1 row)
Contract
| Input | Type | Default |
|---|---|---|
p_run_id |
uuid | (required) |
p_actor |
text | 'fn_iu_verify_cut_result' |
Returns jsonb:
{ok:false, reason:'run_not_found'}or'no_pieces_in_evidence'{ok:<bool>, verdict:'verified'|'failed', pieces_count, axis_a_ok, axis_b_ok, axis_c_ok, no_vector_ok, problems:[...]}
Writes one dot_iu_command_run audit row per call with run_mode='verify', run_status ∈ {refused, verified, failed}, mutating=false, evidence carrying full result.
Axes (live-schema)
| Axis | Definition | Implementation |
|---|---|---|
| A | sort_order of created pieces is dense + monotonic from 1 (no holes; max=count) |
MIN/MAX/holes over information_unit WHERE id = ANY(pieces_created) |
| B | section_type set on every created piece (NOT NULL non-empty) |
count(*) WHERE section_type IS NULL OR btrim()=' ' |
| C | parent_or_container_ref resolves within information_unit (no orphan parents) |
count(*) WHERE parent_or_container_ref IS NOT NULL AND NOT EXISTS(SELECT 1 …) |
| no-vector | 0 rows in iu_vector_sync_point reference the new pieces |
count(*) WHERE unit_id ∈ pieces OR parent_piece_id ∈ pieces |
fn_iu_subtree and fn_iu_reconstruct_source are intentionally NOT called by 041R: subtree is implied by axis-C resolution, and fn_iu_reconstruct_source(doc_code) works at doc-scope rather than run-scope, so V-recon would not be apples-to-apples here. Operator can call them post-cut for a real Điều 37 source.
Drift patches vs 90000x mig 041
| Original (90000x) | Live | 041R fix |
|---|---|---|
iu.information_unit references |
live schema is public.information_unit |
Drop iu. prefix |
source_position for axis-A |
column is sort_order |
Use sort_order |
piece_role IS NULL OR section_type IS NULL for axis-B |
information_unit has no piece_role |
Axis-B = section_type-only |
iu_sql_link.parent_unit_id/child_unit_id for axis-C subtree roots |
iu_sql_link is IU↔SQL-object, not IU↔IU |
Use information_unit.parent_or_container_ref orphan check |
INSERT … (payload_json, status) |
columns are evidence, run_status |
Live column names + vocab |
DOT category='verify' |
vocab is {collection, piece, lifecycle, read, health} |
category='health' |
mutating=true at DOT |
verify writes 1 audit row only | mutating=false |
Algorithm
- Find audit row by
command_name='dot_iu_cut_from_manifest' AND run_status='applied' AND evidence->>'run_id'=p_run_id::text. - Extract
staging_record_idandpieces_createdarray from evidence.run_not_found/no_pieces_in_evidencerefusal paths. - Fetch the
cut_manifestpayload (for context; not currently used in axis math). - Compute v_axis_a_min / max / holes; assert min=1, holes=0, max=pieces_count.
- Count rows with NULL/empty
section_type→ axis-B. - Count rows with unresolved
parent_or_container_ref→ axis-C. - Count VSP rows referencing the pieces → no_vector.
- Aggregate
v_problems text[]; verdict =verifiedif empty elsefailed. - Audit row + return.
Rollback
BEGIN;
DELETE FROM public.dot_iu_command_catalog WHERE command_name='dot_iu_verify_cut_result';
DROP FUNCTION IF EXISTS public.fn_iu_verify_cut_result(uuid, text);
COMMIT;
No state to undo (verify writes only audit rows; safe to retain).
Cross-links
- [[feedback-iu-sql-link-is-iu-to-sql-not-parent-child-iu]]
- [[feedback-iu-vector-sync-point-has-no-staging-path]] (structural Layer 4)
- 90000x report 06.