KB-1CEF
11 — Self-Review + Live-Evidence Appendix (SQL + Raw Results)
5 min read Revision 1
architectureself-reviewevidencesql-appendixintegrityread-onlyzero-mutation2026-05-31verified
title: 11 — Self-Review + Live-Evidence Appendix date: 2026-05-31
11 — Self-Review + Live-Evidence Appendix
Integrity statement
- Zero substrate mutation. Only
query_pg(read-only role, READ ONLY tx, 5s timeout, 500-row cap) was used againstdirectus.public. No DDL/DML, no Directus/Qdrant writes. The only writes this session are these KB documents (the deliverable channel). - No authoring ahead of results. Every number/column/function/pivot/issue-type/law named in docs 00–10 was captured from a live result in this session before it was written. One query erred (
pivot_codewrong column) and was corrected tocodeafter reading the schema — caught, not papered over. - Honest gaps surfaced, not hidden: phantom = LAW_DEFINITION_GAP; ghost detection = DEFERRED (no Qdrant read);
fn_birth_onboarding_full_scannot executed (may write); naive-SUM double-count exposed rather than silently scoped.
What was verified live (fact ledger)
pivot_definitions=37 (active 35); cols inclcode,source_object,filter_spec/group_spec/metric_spec/matrix_spec,registry_group,composition_level,species,parent_code,is_active,superseded_by.parent_codeNULL on all 37.- Pivots: PIV-001..021, PIV-101..106, PIV-201..206, PIV-207, MTX-L1-OVERVIEW, MTX-L2-ATOM, MTX-TEST(inactive), PIV-020(inactive).
pivot_count('PIV-001')→169 ·('PIV-019')→980,221 ·('PIV-007')→309 (returns[code,name,source,value]).meta_catalog=169; cols inclrecord_count, actual_count, orphan_count, baseline_count, active_count, species_count, last_scan_date, composition_level, layer, identity_class, atom_group. Nophantom_count.- Accounting rehearsal: Σrecord 3,638,356 · Σactual 3,838,798 · Σorphan 161 · net_gap +200,442 · drift_rows 10 · orphan-side 3 · phantom-side 7. (10 drift rows tabulated in doc 02.)
- Live counts:
birth_registry=980,221 ·entity_labels=718,744 ·system_issues=179,074 ·species_collection_map=164 ·taxonomy=58 ·entity_species=42 ·label_rules=38 ·taxonomy_facets=10 ·collection_groups=9. system_issuestypes (live): template_gap(172,378), thiếu_quan_hệ, thiếu_mã_định_danh, silent_fail, collection_onboarding_gap, dot_bug, kb_pg_sync_drift, hc_finding_sql/builtin/function, hardcode_violation, sai_lệch_dữ_liệu, apr_phantom_applied, verify_failed, …system_issue(singular) does not exist.- Reuse fns:
pivot_count/query/matrix,refresh_meta_catalog_from_pivot,refresh_pivot_results,check_registry_coverage,fn_refresh_orphan_col/dot/species(+trg),fn_birth_onboarding_full_scan(+_hc),fn_ensure/guard/auto_sync_*registry_counts,refresh_registry_count*. Views:v_pivot_by_level,v_pivot_species_by_level,v_pivot_dot_by_category,v_registry_counts_compat. - Laws confirmed: Đ19 (orphan scanner), Đ26 v3.9 (orphan def), Đ23 §4.2 (inverse-check), Đ24 Label Law v1.3, Đ28 (no fabricated/disguised counts), OGV-0 (ghost). No pin/favorite/watchlist table.
Live SQL used (read-only)
-- A. label/pin/taxonomy/species/orphan tables present
SELECT table_schema, table_name FROM information_schema.tables
WHERE table_type='BASE TABLE' AND (table_name ILIKE ANY (ARRAY['%label%','%tag%','%taxonom%','%pin%','%favorit%','%watch%','%classif%','%species%','%group%','%orphan%','%phantom%']));
-- B. baseline
SELECT count(*) FROM pivot_definitions; ... meta_catalog; pivot_results;
-- C. schemas of reuse anchors (information_schema.columns IN (...))
-- D. pivot rows: SELECT code,name,source_object,registry_group,composition_level,species,parent_code,is_active FROM pivot_definitions ORDER BY code;
-- E. issue taxonomy: SELECT issue_type,severity,status,count(*) FROM system_issues GROUP BY 1,2,3 ORDER BY 4 DESC;
-- F. fn/view inventory: information_schema.routines + .views filtered by pivot/orphan/coverage/registry_count/by_level
-- G. accounting rehearsal (doc 02): aggregate + 10 drift rows over meta_catalog
-- H. pivot_count('PIV-001'|'PIV-019'|'PIV-007')
Full raw results are in the session transcript; key figures are reproduced inline in docs 02 and above so the report is independently checkable.
Reviewer checklist
- Re-run query G; confirm drift_rows=10, phantom-side=7 (or note movement since 2026-05-31).
- Confirm
parent_codestill NULL on all pivots (drill gap open). - Confirm no
phantom_countcolumn and no PIV-500 (gaps open). - Confirm
registry_pinstill absent (NEW not yet built). - Confirm no KB-authored number lacks a live source above.