KB-4230
S136C Rule Engine Report
3 min read Revision 1
reports136carchitecture-v3rules-engine
S136C Rule Engine Report — Architecture v3.0 Phase 1B
Session: S136C | Date: 2026-03-19 | Status: COMPLETE
Assembly Gate
Cau 0: YES — Toan bo = PG views + functions. Khong viet code Nuxt/Vue/TS.
Severity Fix
Rule 3 (Classification) + Rule 8 (Liveness): severity error, is_blocking=true.
7 Rule Views Created (Functions + Views)
| View | Rule | Violations | Description |
|---|---|---|---|
| v_rule_identity_violations | 1 | 7 | Entity thieu code hoac code sai format |
| v_rule_classification_violations | 3 | 199 | Entity khong co label nao |
| v_rule_connectivity_violations | 4 | 730 | Entity khong co edge nao (expected - chua backfill) |
| v_rule_birth_violations | 6 | 6 | Entity thieu _dot_origin hoac date_created |
| v_rule_liveness_violations | 8 | 730 | Entity chua co lifecycle_log (expected - moi tao) |
| v_rule_uniqueness_violations | 9 | 0 | Trung code trong cung collection |
| v_rule_traceability_violations | 10 | 1 | Thieu _dot_origin hoac edges thieu source_info |
Rule 2 (Registry) + Rule 5 (Countability): dung existing functions (check_registry_coverage, verify_counts). Rule 7 (Visibility): dot_contract, return -1 (external check).
fn_run_all_rules() Engine
- Creates run record in universal_rule_runs
- Loops through rules by execution_order
- UPSERT violations (dedupe by md5 hash)
- Auto-close resolved violations
- Records run_results per rule
- First run: 1673 total violations (expected high - Phase 1 baseline)
Gate Functions
fn_pre_birth_check(collection, code, name, dot_origin)
5 checks: collection valid, dot_origin present, code format, name unique, code unique. Test valid: 5/5 passed. Test invalid: 3/5 failed (correct behavior).
fn_retire_gate_check(collection, entity_id)
Dual-source: FK_NATIVE (hard blockers) + EDGE_MIRROR (soft blockers).
v_liveness_self_check
All 10 rules have measurement_exists = true.
Verification
| # | Check | Result |
|---|---|---|
| 1 | Severity fix (3+8 = error) | PASS |
| 2 | 7 violation views exist | PASS |
| 3 | fn_run_all_rules returns 10 rows | PASS |
| 4 | Run history completed | PASS (run #3, 1673 violations) |
| 5 | Violations populated | PASS (6 rules with open violations) |
| 6 | v_liveness_self_check = 0 missing | PASS |
| 7 | fn_pre_birth_check works | PASS (valid + invalid cases) |
| 8 | fn_retire_gate_check works | PASS (0 blockers for dot_tools.1) |
| 9 | Smoke test | PASS (17/17) |
| 10 | verify_counts 0 mismatch | PASS (19/19 OK) |
| 11 | Health Check GREEN | PASS |