KB-77C6 rev 15

P3D — Birth System B3-F0 Dry-Run — Agent Prompt (DRAFT)

7 min read Revision 15
p3dbirth-systemb3fonboarding-gatedryrunpromptdraft

P3D — Birth System B3-F0 Onboarding Gate Dry-Run — Agent Prompt (DRAFT)

Date: 2026-05-12 Self-contained. Scope: read-only dry-run simulating what onboarding gate would catch. Zero enforcement. Zero writes.

Mode: READ-ONLY.


Mission

Scan ALL rows in collection_registry and report what the future onboarding gate WOULD catch. Derive governed/in-scope/birth-required/exempt/deferred subsets from live policy columns; do not assume the scan universe from a static collection list. Identify gaps in coverage policy, species mapping, physical tables, birth triggers, and known exceptions. Report only.


Scope constants

contract_function_name = fn_birth_registry_auto (resolve OID live)
sibling_function_name = fn_birth_registry_auto_id (resolve OID live)
exempt_collection = birth_registry
db_schema = DISCOVER

Hard boundaries

ZERO writes. No INSERT, UPDATE, DELETE, DDL.
No trigger creation. No function creation. No policy update.
No system_issues creation. No system_health_checks creation.
Read-only PG queries + KB report upload only.

Phase 0 — Environment + DB discovery (self-contained)


Phase 1 — Concept + function OID resolution

Resolve from live schema: collection_key, governance_role if present, coverage_status, coverage_scope_status, coverage_exemption_reason, coverage_review_owner, description_policy if present from collection_registry. Resolve species_map_collection_key from species_collection_map. If optional columns are absent, report them as absent and skip only the checks that require those optional columns; do not invent substitute columns.

Resolve function OIDs:

-- PATTERN ONLY
SELECT proname, oid FROM pg_proc
WHERE proname IN ('fn_birth_registry_auto', 'fn_birth_registry_auto_id')
  AND pronamespace = (SELECT oid FROM pg_namespace WHERE nspname = <resolved_schema>);

Phase 2 — Load approved sibling scope

First verify whether a policy/config table such as dot_config exists. If no approved policy store exists, report SIBLING_POLICY_STORE_ABSENT and sibling_policy_materialization_required=true.

If dot_config exists, check if policy artifact exists:

-- PATTERN ONLY
SELECT <config_value> FROM dot_config
WHERE <config_key> = 'policy.birth_trigger.accepted_sibling_scope';

Expected policy shape must include both function and collection scope, for example:

[{"function":"fn_birth_registry_auto_id","collections":["governance_relations","law_dot_enforcement","law_jurisdiction"]}]

If absent: do not treat any hardcoded collection list as authoritative policy. For this dry-run only, use the latest GPT-approved scoped sibling set as an expected snapshot for comparison (function=fn_birth_registry_auto_id, collections=governance_relations, law_dot_enforcement, law_jurisdiction) and report SIBLING_POLICY_NOT_IN_PG as a WARN gap requiring policy materialization before B3-F1. Do not mark sibling-policy governance as fully compliant without a PG policy artifact. Do not treat function-only policy as sufficient.


Phase 3 — Full governed collection scan

For EACH collection in collection_registry:

3A. Coverage policy check

IF coverage_status IS NULL → GAP: MISSING_COVERAGE_POLICY (CRITICAL)
IF coverage_scope_status IS NULL AND coverage_status IS NOT NULL → GAP: MISSING_SCOPE_POLICY (WARN)
IF coverage_status = 'UNCLASSIFIED_NEW' → GAP: UNCLASSIFIED_COVERAGE_POLICY (WARN)
IF coverage_status = 'BIRTH_DEFERRED_NEEDS_REVIEW' AND coverage_review_owner IS NULL → GAP: DEFERRED_WITHOUT_OWNER (WARN)
IF coverage_status = 'BIRTH_REQUIRED' AND coverage_scope_status != 'IN_SCOPE' → GAP: SCOPE_MISMATCH (WARN)

3B. Physical table check (BIRTH_REQUIRED ∩ IN_SCOPE only)

IF coverage_status='BIRTH_REQUIRED' AND coverage_scope_status='IN_SCOPE' AND no BASE TABLE in information_schema → GAP: MISSING_TABLE (CRITICAL)

3C. Species mapping check (BIRTH_REQUIRED ∩ IN_SCOPE only)

IF coverage_status='BIRTH_REQUIRED' AND coverage_scope_status='IN_SCOPE' AND no species_collection_map row → GAP: MISSING_SPECIES (CRITICAL)

3D. Birth trigger check (BIRTH_REQUIRED ∩ IN_SCOPE only)

Scan pg_trigger for this collection:
  IF trigger with contract OID → WIRED_CONTRACT (OK)
  IF trigger with sibling OID AND collection in approved scope → WIRED_SIBLING (OK)
  IF trigger with sibling OID AND collection NOT in approved scope → GAP: OUT_OF_SCOPE_SIBLING (CRITICAL)
  IF no trigger with either OID → GAP: MISSING_TRIGGER (CRITICAL)

3E. birth_registry exception check

IF collection = birth_registry AND has contract trigger → GAP: BIRTH_REGISTRY_RECURSIVE_RISK (CRITICAL)
IF collection = birth_registry AND exempt with reason → OK_EXEMPT

3F. Exempt validation

IF coverage_status = EXEMPT_* AND coverage_exemption_reason IS NULL → GAP: EXEMPT_WITHOUT_REASON (WARN)

Phase 4 — Summary statistics

total_governed = <N>
total_compliant = <N>
total_gaps = <N>
gap_missing_coverage = <N>
gap_missing_table = <N>
gap_missing_species = <N>
gap_missing_trigger = <N>
gap_out_of_scope_sibling = <N>
gap_birth_registry_risk = <N>
gap_exempt_without_reason = <N>
gap_scope_mismatch = <N>
gap_missing_scope_policy = <N>
gap_unclassified_coverage_policy = <N>
gap_deferred_without_owner = <N>
sibling_policy_in_pg = true|false
sibling_policy_fallback_used = true|false
sibling_policy_materialization_required = true|false

Phase 5 — Detailed gap list

For each GAP: collection_name, gap_type, severity, current values, recommended action.


Report path

knowledge/dev/laws/dieu44-trien-khai/reports/p3d-birth-system-b3f0-onboarding-gate-dryrun-report.md

Final response

b3f0_dryrun_status=PASS|PARTIAL|BLOCKED
total_governed=<N>
total_compliant=<N>
total_critical_gaps=<N>
total_warn_gaps=<N>
sibling_policy_in_pg=true|false
sibling_policy_fallback_used=true|false
sibling_policy_materialization_required=true|false
out_of_scope_sibling_count=<N>
missing_coverage_policy_count=<N>
missing_scope_policy_count=<N>
missing_species_mapping_count=<N>
missing_physical_table_count=<N>
missing_birth_trigger_count=<N>
unclassified_coverage_policy_count=<N>
deferred_without_owner_count=<N>
exempt_without_reason_count=<N>
description_policy_unclassified_count=<N>
duplicate_trigger_pair_count=<N>
birth_registry_recursive_risk=true|false
no_mutation_performed=true
report_path=<above>
next_recommended_action=GPT_REVIEW_DRYRUN_THEN_DECIDE_POLICY_MATERIALIZATION_OR_B3F1

B3-F0 Dry-Run | DRAFT | Read-only | 2026-05-12

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/p3d-birth-system-b3f-onboarding-gate-dryrun-prompt-DRAFT.md