KB-3C19 rev 3

Pack 21 — Birth Runtime Truth Doc Fix (rev3)

5 min read Revision 3
birth-pipelinedoc-fixruntime-truthpack-21designrev3no-hardcode

Pack 21 — Birth Runtime Truth Doc Fix (rev3)

Date: 2026-05-05 | Status: DESIGN rev3 — chờ dispatch execution prompt rev2 Controlling: GPT hardcode objection + rev3 directive Scope: Doc corrections only. Không runtime mutation. Nguyên tắc: §0-AU — doc ghi cách lấy số + snapshot có ngày, không ghi con số như timeless truth.


§0. Nguyên tắc Pack 21

KHÔNG: "Hệ thống có 162 triggers" CÓ: "Số triggers là dynamic. Query [X] để đếm. P2B-INV (2026-05-05) observed 162."

Mọi patch trong Pack 21 phải có 3 thành phần:

  1. Source of truth — query hoặc path để lấy runtime data
  2. Snapshot evidence — ngày quan sát + con số quan sát được
  3. Re-verify instruction — "query lại trước khi quyết định"

§1. Target docs + patches

1.1 knowledge/dev/architecture/birth-registry-law.md (Đ0-G)

Trigger coverage:

Thay wording hardcode bằng:

Birth trigger coverage is dynamic — collections are added/removed over time. Current coverage must be queried:

SELECT
  CASE
    WHEN tgname LIKE 'trg_birth_%' THEN 'dot119_v2'
    WHEN tgname LIKE 'birth_trigger_%' THEN 'legacy'
    ELSE 'other'
  END AS pattern,
  count(*) AS trigger_count
FROM pg_trigger
WHERE NOT tgisinternal
  AND (tgname LIKE 'trg_birth_%' OR tgname LIKE 'birth_trigger_%')
GROUP BY 1;

Snapshot P2B-INV (2026-05-05): 162 instances — 31 trg_birth_* (DOT-119 v2) + 131 legacy birth_trigger_*.

Schema:

Thay hardcode column list bằng:

birth_registry schema is authoritative in PostgreSQL. Query current schema:

SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_schema='public' AND table_name='birth_registry'
ORDER BY ordinal_position;

Snapshot P2B-INV (2026-05-05): 19 columns, including status (default 'born') added post-v1.0.

Phase B/C tools: Đánh dấu "(Planned — chưa implement. Verify: ls /opt/incomex/dot/bin/dot-inspect-*)"

fn_birth_first(): Ghi "(Planned — verify: SELECT proname FROM pg_proc WHERE proname='fn_birth_first')"

1.2 knowledge/dev/architecture/birth-procedures.md (v3.1)

QT-002:

QT-002 is the canonical birth process name. Runtime enforcement is provided by PG triggers and gates, not a dedicated wrapper binary. Re-verify tool availability before decisions:

-- Birth-related triggers
SELECT tgname, tgrelid::regclass FROM pg_trigger
WHERE NOT tgisinternal AND tgname ~ '^(trg_birth_|birth_trigger_)';

-- Birth-related DOT tools
SELECT code, tool_name, status FROM dot_tools
WHERE tool_name ILIKE '%birth%' OR code ILIKE '%birth%';

Snapshot P2B-INV (2026-05-05): no dedicated QT-002 wrapper binary found. Enforcement = fn_birth_registry_auto (157 AFTER INSERT) + fn_birth_gate (16 BEFORE INSERT).

QT-001:

dot-birth-backfill (DOT-118) exists as backfill tool. Verify current state:

ls -la /opt/incomex/dot/bin/dot-birth-backfill
crontab -l 2>/dev/null | grep birth

Snapshot P2B-INV (2026-05-05): binary present, manual execution only, no cron found.

1.3 knowledge/current-state/reports/s145-m2-dot119-birth-triggers-report

Append only (không rewrite):


Historical context note (Pack 21, 2026-05-05): This report is historical, scoped to S145 batch. For current runtime birth trigger counts, query PostgreSQL:

SELECT count(*), CASE WHEN tgname LIKE 'trg_birth_%' THEN 'dot119_v2' ELSE 'legacy' END
FROM pg_trigger WHERE NOT tgisinternal AND tgname ~ '^(trg_birth_|birth_trigger_)' GROUP BY 2;

P2B-INV snapshot (2026-05-05): 162 total (31 + 131).

1.4 registries/meta_catalog/CAT-023

  • Verify-first: đọc current fields
  • Nếu status thiếu → thêm field entry kèm: "Source of truth = PG catalog. Snapshot P2B-INV (2026-05-05): present."
  • Không ghi "total N fields" — ghi verify query thay vào
  • Nếu đã current → SKIP

1.5 knowledge/dev/laws/law-04-birth-process.md (Đ4)

  • Check-only, patch tối thiểu nếu factual error
  • Không over-patch enacted law
  • Nếu không stale → SKIP

§2. TDs

TD Nội dung Ghi đâu
TD-A~G (giữ nguyên từ rev2) KB report section only
TD-H (mới) Tạo v_birth_pipeline_runtime_stats view/function tập trung dynamic birth facts Runtime mutation — pack riêng

§3. Hard Boundaries

  • ❌ Không runtime mutation
  • ❌ Không DOT patch
  • ❌ Không system_issues PG mutation
  • ❌ Không rewrite historical content
  • ❌ Không over-patch enacted laws
  • ❌ Không ghi con số như timeless truth

Pack 21 rev3 | 2026-05-05 | Query-path language. No hardcode numbers. Chờ execution prompt rev2.