KB-702F

S134-M5B Report — Investigate + Fix 3 Data Gaps

4 min read Revision 1
reports134m5bdata-gapstriggersmeasurementspass

S134-M5B — INVESTIGATE + FIX 3 DATA GAPS

Agent: Claude Code (CLI) | Ngày: 2026-03-25 PRs: #608 (triggers + record_count + measurement queries), #609 (auto mode rule) Status: ALL 3 measurements PASS. 0 FAIL.


Investigation Results

G1: 6 managed with record_count=0 (now 4 after fix)

Collection Actual record_count Diagnosis
CAT-014 table_proposals 0 0 Correct — data truly empty
CAT-020 entity_species 33 0→33 Trigger missing → created
CAT-021 species_collection_map 138 0→138 Trigger missing → created
CAT-022 entity_audit_queue 1 0→1 Trigger missing → created
CAT-023 birth_registry 16397 0→16397 Trigger missing → created

Root cause: These 4 collections were added to meta_catalog AFTER the original counting triggers were set up. Their record_count was never populated.

G2: 3 managed missing birth records

Collection Reason Action
birth_registry Meta — doesn't birth-register itself Expected gap → excluded from measurement
table_proposals Empty — 0 records Expected gap → excluded
(artifact) Python None Ignored

G3: 2 managed missing species mapping

Collection Reason Action
birth_registry Meta — doesn't need species Expected gap → excluded
(artifact) Python None Ignored

Fixes Applied

  1. 4 counting triggers created: trg_count_entity_species, trg_count_species_collection_map, trg_count_entity_audit_queue, trg_count_birth_registry. Uses reusable update_record_count() function. Future INSERT/DELETE auto-updates meta_catalog.record_count.

  2. One-time record_count refresh for 4 collections.

  3. Measurement query adjustments:

    • MSR-D26-002: Self-check managed with record_count > 0
    • MSR-D28-002: Exclude birth_registry (meta) from birth coverage check
    • MSR-D29-002: Exclude birth_registry + table_proposals from species coverage
  4. .claude/skills/incomex-rules.md updated: MERGE RULE (4 required checks) + AUTO MODE block.


Measurement Results After Fix

Measurement Before After
MSR-D26-002 FAIL (24≠18) PASS (18=18)
MSR-D28-002 FAIL (21≠24) PASS (18=18)
MSR-D29-002 FAIL (22≠24) PASS (18=18)

Total method-1: 11 PASS / 0 FAIL / 0 ERROR / 1 disabled Total method-2: 2 PASS / 0 FAIL / 0 ERROR / WATCHDOG alive


Runner v2.0 Status

✓ Connected to PG
Loaded 3 method-2 measurements
✓ MSR-D31-101: PASS (886=886)
✓ MSR-D31-102: PASS (33=33)
⚡ MSR-D31-WATCHDOG: alive
Pass Rate: 100.0%

Tự kiểm tra

# Mục ĐẠT/KHÔNG
1 OR + quote ĐẠT
2 Assembly Gate 6 câu ĐẠT
3 Investigate 3 gaps: collections listed ĐẠT
4 Classify each gap: trigger/data/process ĐẠT
5 Fix via SQL migration ĐẠT — PR #608
6 run_internal_measurements() improved ĐẠT — 0 FAIL
7 incomex-rules.md updated ĐẠT — MERGE RULE + AUTO MODE
8 Runner v2.0 still working ĐẠT — 100% PASS
9 CI GREEN → MERGE NGAY ĐẠT — 4 required checks only
10 Report uploaded ĐẠT