KB-41DE

110000x · 08 — Axis ABC Reconstruct + No-Vector

5 min read Revision 1
iu-core110000xaxis-aaxis-baxis-creconstructno-vectorverify-cut

110000x · 08 — Axis ABC Reconstruction + No-Vector Verification

The alias fn_iu_op_verify_cut wraps live fn_iu_verify_cut_result (mig 041R, applied 100000x). The wrapped function performs three-axis verification per 80000x doctrine.

Axis A — Source order reconstruction

Function: fn_iu_reconstruct_source(p_doc_code text) RETURNS TABLE(source_position, sort_order, section_type, section_code, canonical_address, depth, gap_before, iu_id).

Pass criteria for Điều 37 cut:

WITH r AS (SELECT * FROM fn_iu_reconstruct_source('DIEU-37') ORDER BY source_position)
SELECT
  count(*) AS total_pieces,
  bool_and(NOT gap_before) AS dense_no_gaps,
  (min(sort_order)=1)      AS starts_at_one,
  (max(sort_order)=count(*)) AS monotonic;
-- Expect: dense_no_gaps=t, starts_at_one=t, monotonic=t.

Axis B — Professional content vocab

Each IU has section_type (13-vocab) and (on the collection edge) piece_role (7-vocab). VERIFY-CUT checks both vocabs and tag presence:

SELECT section_type, count(*)
FROM information_unit
WHERE doc_code='DIEU-37'
GROUP BY section_type
ORDER BY section_type;
-- Expect every section_type in the standard 13-vocab subset for this doc kind.

fn_iu_verify_cut_result returns:

{
  "axes": {
    "axis_b": {
      "ok": true,
      "section_types_seen": ["heading","paragraph","principle","definition","process","changelog"],
      "piece_roles_seen": ["title","intro","body"]
    }
  }
}

Axis C — Parent / child / grandchild

Function: fn_iu_subtree(p_root uuid) RETURNS TABLE(iu_id, canonical_address, depth, parent_id, relative_depth).

SELECT iu_id, canonical_address, depth, relative_depth
FROM fn_iu_subtree((
  SELECT id FROM information_unit
  WHERE doc_code='DIEU-37' AND parent_or_container_ref IS NULL
  LIMIT 1
))
ORDER BY relative_depth, canonical_address;
-- Expect: root (relative_depth=0) + all body sections (relative_depth=1), no orphans.

fn_iu_verify_cut_result Axis C summary:

{
  "axes": {
    "axis_c": {
      "ok": true,
      "root_iu_id": "<uuid>",
      "subtree_depth_max": 2,
      "orphan_count": 0,
      "cycle_count": 0
    }
  }
}

No-Vector verification (4-layer)

fn_iu_verify_cut_result checks no_vector_ok true iff all four layers hold:

  1. CHECK constraint: iu_core.iu_staging_record.vector_excluded=true (per iu_staging_record_vector_excluded_chk).
  2. Vector policy sidecar (when present): collection rows in scope have vector_eligible=false.
  3. No staging→vector path: iu_vector_sync_point table has no column / FK referencing iu_staging_*.
  4. Post-cut delta: iu_vector_sync_point row count after CUT equals the count before CUT (newly created IUs are NOT auto-vectorized; vectorization is a separate operator step gated by iu_core.composer_enabled + Qdrant write path, both untouched here).

Live no-vector check post-cut:

SELECT
  ((SELECT count(*) FROM iu_vector_sync_point) = <pre_count>) AS vsp_count_unchanged,
  (SELECT NOT EXISTS (
    SELECT 1 FROM iu_vector_sync_point vsp
    JOIN information_unit iu ON iu.id = vsp.unit_id
    WHERE iu.doc_code='DIEU-37'
  )) AS no_vsp_refs_to_new_iu;
-- Both expected: t.

Composed alias call

SELECT public.fn_iu_op_verify_cut(:'rid'::uuid, 'operator-110000x') AS r;

Returns:

{
  "alias": "fn_iu_op_verify_cut",
  "run_id": "<uuid>",
  "verdict": "verified",
  "inner_result": {
    "verdict": "verified",
    "axes": {
      "axis_a": {"ok": true, "...": "..."},
      "axis_b": {"ok": true, "...": "..."},
      "axis_c": {"ok": true, "...": "..."}
    },
    "no_vector_ok": true,
    "problems": [],
    "run_id": "<uuid>"
  }
}

Cleanup dry-run

SELECT public.fn_iu_op_cleanup_dry_run(15, 'operator-110000x') AS r;

Returns:

{
  "alias": "fn_iu_op_cleanup_dry_run",
  "apply": false,
  "older_than_days": 15,
  "eligible_count": <n>,
  "actions": [...]
}

apply is always false. There is no fn_iu_op_cleanup_apply alias — to actually clean, the operator must run fn_iu_staging_cleanup(true, …) directly (one-step gap that requires conscious operator action).

Surfaces guaranteed untouched

Surface Status
iu_vector_sync_point row count unchanged; no FK from staging
production_documents table absent in directus DB
Qdrant iu_core_iu_chunks unchanged (no client call from aliases)
Nuxt deployment unchanged
dot_config.iu_core.retention_enabled unchanged (false)
Pre-existing IU pieces (DIEU-28/32/35/36/etc.) unchanged in BEGIN/ROLLBACK; unchanged in durable cut (new pieces only)
Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-110000x-operator-alias-surface-d30-d31-protection/08-axis-abc-reconstruct-no-vector.md