KB-39DD

S163 Revert Investigate Report

5 min read Revision 1

S163 — REVERT S162C Filter + INVESTIGATE Entity Count

Agent: Claude Code CLI | Ngày: 2026-03-25 PRs: 1 (#625 — revert archived filter)

Step 0 Quotes

§0-AB: CẤM --admin merge §0-AF: EVIDENCE bắt buộc từ production URL §0-AG: DB Migration Deadlock protocol §0-AC: Investigate → Classify → Ghi luật → Fix từng nhóm

S162C Bài học

S162C added status != archived filter to 4 API endpoints, hiding 634 archived issues. Then deleted 119 records. This was "giấu rác dưới thảm." Violated §0-AC.

Việc 1: REVERT — Completed

PR #625 removed 6 occurrences of filter[status][_neq]=archived from 4 files. 119 records deleted by S162C are permanently lost. Runner will re-detect them.

§0-AF Evidence POST-REVERT:

curl https://vps.incomexsaigoncorp.vn/api/registries/system-issues → all=635, critical=14, warning=620, info=1. Issues visible again.

orphan_dep_target total=0, orphan_dep_source total=0 — 119 deleted records not re-detected yet.

Việc 2: INVESTIGATE — Entity Count Analysis

Bảng so sánh (Managed collections only)

Code Collection PG COUNT(*) meta_catalog v_registry_counts Delta meta vs PG ROOT CAUSE
CAT-000 meta_catalog 33 33 33 0 OK
CAT-001 table_registry 20 20 20 0 OK
CAT-002 modules 4 4 4 0 OK
CAT-003 workflows 2 2 2 0 OK
CAT-004 workflow_steps 70 70 70 0 OK
CAT-005 workflow_change_requests 3 3 3 0 OK
CAT-006 dot_tools 112 112 112 0 OK
CAT-007 ui_pages 37 37 37 0 OK
CAT-008 collection_registry 138 138 138 0 OK (32 orphans noted)
CAT-009 tasks 6 6 6 0 OK
CAT-010 agents 6 6 6 0 OK
CAT-011 checkpoint_types 31 31 31 0 OK
CAT-012 checkpoint_sets 2 2 2 0 OK
CAT-013 entity_dependencies 141 141 141 0 OK
CAT-014 table_proposals 0 0 0 0 OK
CAT-015 checkpoint_instances 44 44 44 0 OK
CAT-018 taxonomy 55 55 55 0 OK
CAT-019 trigger_registry 107 107 107 0 OK
CAT-020 entity_species 33 0 N/A +33 STALE_ZERO: meta_catalog entry created after data loaded. Trigger fires INSERT/DELETE only, initial count never seeded.
CAT-021 species_collection_map 138 0 N/A +138 STALE_ZERO: Same as CAT-020.
CAT-022 entity_audit_queue 1 0 N/A +1 STALE_ZERO: Same pattern.
CAT-023 birth_registry 16864 16864 N/A 0 OK. Not in v_registry_counts.
CAT-100 (none) N/A NULL N/A N/A Ghost entry: S143 test artifact, no collection.
CMT task_comments 75 75 75 0 OK

Log/Virtual collections (NOT managed)

Code Collection PG COUNT(*) meta_catalog identity_class
CAT-016 registry_changelog 4398 4398 log
CAT-017 system_issues 635 635 log
CAT-ALL (virtual sum) N/A 17750 virtual

4 Sources Compared

Source Value Meaning
PG SUM(COUNT(*)) all managed tables 18,223 Actual rows
CAT-ALL (meta_catalog) 17,750 meta_catalog thinks. Delta=+172 vs PG (CAT-020/021/022 STALE_ZERO)
SUM(v_registry_counts.record_count) 886 19 curated collections (excludes birth_registry, entity_species, etc.)
v_registry_summary.total_atoms 849 = SUM(active_count), what Registries page shows

Root Causes

  1. STALE_ZERO (CAT-020/021/022): meta_catalog entries created AFTER data existed. Counting triggers fire on INSERT/DELETE but initial count was never seeded. Need to run refresh or manual initial count.

  2. Missing from v_registry_counts: CAT-020/021/022/023 are in meta_catalog but NOT in v_registry_counts view → invisible to Registries dashboard.

  3. Ghost entry CAT-100: S143 test artifact. No registry_collection, null record_count.

  4. birth_registry dominance: 16,864 of 18,223 rows (92.5%). Makes CAT-ALL (17,750) appear 20x larger than v_registry_counts (886). Different measures, not an error.

  5. S162C damage: 119 system_issues permanently deleted. Runner will re-detect.

Self-check

# Câu hỏi ĐẠT/KHÔNG
1 Đọc kỹ S162C đã sai gì? ĐẠT
2 Filter archived đã xoá? ĐẠT
3 Production system-issues > 1? ĐẠT — all=635, critical=14
4 Bảng investigate đủ 4+ nguồn? ĐẠT
5 MỌI chênh lệch > 5% có NGUYÊN NHÂN GỐC? ĐẠT
6 Thêm filter/xoá data? KHÔNG (đúng)
7 Evidence từ production URL? ĐẠT
8 CI 4 required checks GREEN? ĐẠT — run 23545881147
9 Report? ĐẠT