KB-45BB rev 3

Pack 21 — Birth Runtime Truth Doc Fix Execution Prompt (rev3.1)

7 min read Revision 3
birth-pipelinedoc-fixpack-21executionpromptrev3.1no-hardcode

Pack 21 — Birth Runtime Truth Doc Fix Execution Prompt (rev3.1)

Date: 2026-05-05 | Status: PROMPT — sẵn sàng dispatch Controlling: Pack 21 rev3 + GPT final check (5 patches applied) Scope: Patch KB docs only. Không runtime/PG/DOT mutation. Nguyên tắc: (1) query source-of-truth, (2) snapshot date + observed value, (3) re-verify instruction. Không hardcode numbers.


§0. Mission

Sửa 3-5 KB docs stale về birth pipeline. Dùng query-path language.


§1. Pre-read

Đọc từ KB:

  1. knowledge/dev/laws/dieu44-trien-khai/design/21-birth-runtime-truth-doc-fix-pack.md (rev3)
  2. knowledge/dev/laws/dieu44-trien-khai/reports/p2b-inv-birth-pipeline-inventory-report.md

§2. Execute patches

E1: knowledge/dev/architecture/birth-registry-law.md

  1. get_document_for_rewrite
  2. Trigger coverage: Tìm section mention trigger count.
    • Không xóa context hữu ích. Giữ mô tả trigger mechanism nếu đúng.
    • Thêm runtime-truth note với query:
      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_countFROM pg_triggerWHERE NOT tgisinternal  AND (tgname LIKE 'trg_birth_%' OR tgname LIKE 'birth_trigger_%')GROUP BY 1;
      
    • Snapshot: "P2B-INV (2026-05-05) observed 162: 31 dot119_v2 + 131 legacy"
    • Chỉ remove/replace con số cứng nếu sai — không xóa mô tả đúng
  3. Schema: Tìm column list section.
    • Giữ schema details nếu không sai. Thêm runtime-truth note:

      PG catalog là source of truth cho birth_registry 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.

    • Chỉ xóa/sửa explicit stale field count (e.g. "18 columns") nếu có
  4. Phase B/C tools: Append "(Planned — verify: ls /opt/incomex/dot/bin/dot-inspect-*)"
  5. fn_birth_first(): Append "(Planned — verify: SELECT proname FROM pg_proc WHERE proname='fn_birth_first')"
  6. update_document

E2: knowledge/dev/architecture/birth-procedures.md

  1. get_document_for_rewrite
  2. QT-002: Thêm runtime-truth note (giữ mô tả process nếu đúng):
    • Query birth triggers + birth-related DOT tools
    • DOT tools query (schema-tolerant):
      -- Verify dot_tools columns firstSELECT column_name FROM information_schema.columnsWHERE table_name='dot_tools' ORDER BY ordinal_position;-- Then query (adjust columns if schema differs):SELECT code, name, status, operation, file_pathFROM dot_toolsWHERE code ILIKE '%BIRTH%' OR name ILIKE '%birth%'   OR operation ILIKE '%birth%' OR file_path ILIKE '%birth%'ORDER BY code;-- Note: if operation/file_path columns absent, re-check schema first
      
    • Snapshot: "P2B-INV (2026-05-05): no QT-002 wrapper binary. Enforcement = PG triggers/gates."
  3. QT-001: Thêm runtime-truth note:
    • Verify commands: ls -la /opt/incomex/dot/bin/dot-birth-backfill + crontab -l | grep birth
    • Snapshot: "P2B-INV (2026-05-05): binary present, manual, no cron."
  4. update_document

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

  1. get_document_for_rewrite
  2. Idempotency check: Tìm marker Historical context note (Pack 21. Nếu đã có → SKIP, không append trùng.
  3. KHÔNG sửa nội dung gốc. Append ở cuối:

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

    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).

  4. update_document hoặc SKIP

E4: registries/meta_catalog/CAT-023

  1. Tìm doc: get_document_for_rewrite(path="registries/meta_catalog/CAT-023")
  2. Nếu doc không tìm thấy: search KB cho "CAT-023" một lần. Nếu vẫn không thấy → SKIP, ghi "CAT-023 not found — skipped."
  3. Nếu status field đã có → SKIP
  4. Nếu thiếu → thêm field entry + "Source of truth = PG catalog. Snapshot P2B-INV (2026-05-05)."
  5. Không ghi "total N fields"
  6. update_document hoặc SKIP

E5: knowledge/dev/laws/law-04-birth-process.md

  1. Tìm doc. Nếu path không tìm thấy → search KB cho "Đ4 birth process" một lần. Nếu vẫn không thấy → SKIP.
  2. Scan cho hardcode trigger count, schema count, "QT-002 tool" wording
  3. Nếu factual error → patch tối thiểu với query-path language
  4. Nếu không stale → SKIP
  5. Không over-patch enacted law

§3. Quality checks

Per-doc check (trước mỗi update_document):

  • Có con số nào viết như timeless truth? → phải kèm query + snapshot date
  • Có query source-of-truth? → phải có
  • Có "re-verify" instruction? → phải có
  • Có rewrite nội dung historical? → không được
  • Có xóa mô tả đúng? → không được (chỉ xóa/sửa stale facts)

Anti-hardcode self-check (cuối cùng, trước upload report):

  • Naked dynamic runtime constants introduced? → phải NO
  • Each dynamic count has query/path? → phải YES
  • Each snapshot has date/evidence? → phải YES

§4. Report

Upload tại: knowledge/dev/laws/dieu44-trien-khai/reports/21-birth-runtime-truth-doc-fix-report.md

# Pack 21 — Birth Runtime Truth Doc Fix Report

## Patches applied

| Doc | Patched? | Query-path compliant? | Changes summary |
|---|---|---|---|
| birth-registry-law.md | yes/skip | yes/no | [list] |
| birth-procedures.md | yes/skip | yes/no | [list] |
| S145 report | yes/skip (idempotent) | yes/no | [appended / already present] |
| CAT-023 | yes/skip/not-found | yes/no | [status added / current / not found] |
| Đ4 law-04 | yes/skip/not-found | yes/no | [minimal fix / not stale / not found] |

## Anti-hardcode self-check
- Naked dynamic runtime constants introduced: yes/no
- Each dynamic count has query/path: yes/no
- Each snapshot has date/evidence: yes/no

## TDs logged (KB only)
TD-A through TD-H

## Verdict
PASS / PARTIAL

## Next
Pack 22 — dot-iu-create wrapper design

§5. Hard Boundaries

  • ❌ Không PG/runtime mutation
  • ❌ Không DOT script patch
  • ❌ Không system_issues mutation
  • ❌ Không rewrite historical content
  • ❌ Không over-patch enacted laws
  • ❌ Không hardcode numbers as timeless truth
  • ❌ Không tự tạo doc path mới nếu target missing

Pack 21 Execution Prompt rev3.1 | 2026-05-05 | Query-path language. 5 GPT patches applied. Sẵn sàng dispatch.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/21-birth-runtime-truth-doc-fix-execution-prompt.md