KB-4853

Agent Prompt — Phase 5C2-R0 Read-Only Mapping Artifact — DIEU-35 TAC→IU — 2026-05-14

8 min read Revision 1
agentphase5c2r0readonlymapping-artifactdieu35tac-to-iuno-mutation2026-05-14

Agent Prompt — Phase 5C2-R0 Read-Only Mapping Artifact — DIEU-35 TAC→IU — 2026-05-14

Mission

Generate the Phase 5C2-R0 read-only mapping artifact for TAC→information_unit migration of DIEU-35.

This task emits a mapping artifact only. It is not a migration. It must not create, update, delete, or mutate anything in PG/code/UI/vector.

Governing reviews

Read first:

  1. GPT approval of R0 design: knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-phase5c2-r0-resume-plan-design-approve-next-readonly-mapping-2026-05-14.md

  2. R0 design: knowledge/dev/laws/dieu44-trien-khai/design/p3d-phase5c2-resume-tac-to-information-unit-migration-plan.md

  3. R0 design report: knowledge/dev/laws/dieu44-trien-khai/reports/p3d-phase5c2-resume-plan-report.md

  4. Opus review: knowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-phase5c2-r0-resume-plan-design-2026-05-14.md

  5. Agent current-position investigation: knowledge/dev/laws/dieu44-trien-khai/reports/agent-readonly-investigation-iu-current-position-before-next-design-2026-05-14.md

Hard boundaries

Absolutely forbidden:

No DB writes.
No DDL.
No DML: no INSERT/UPDATE/DELETE/TRUNCATE/MERGE.
No temp tables if they require CREATE TEMP TABLE.
No mutating function execution.
No fn_iu_create.
No fn_iu_create_plan.
No fn_iu_save.
No fn_iu_apply_edit_draft.
No fn_iu_edit.
No fn_iu_verify_invariants.
No fn_birth_onboarding_full_scan_hc execution.
No TAC writes.
No IU migration rows.
No bulk migration.
No UI cutover.
No code/Nuxt/Directus config changes.
No schema mutation.
No trigger/function patch.
No birth-system change.
No vector/Qdrant mutation or reindex.
No old rev4 prompt execution.
No rollback execution.

Allowed:

Read KB.
Run SELECT-only SQL.
Read PG catalogs/information_schema.
Read live data from TAC/IU tables.
Create KB report/artifact only.

If unsure whether a query mutates, do not run it. If a desired check requires mutation, report BLOCKED_BY_NO_MUTATION_BOUNDARY.

Required live SELECT checks

A. G0 gate checks

Re-run read-only gates and report PASS/FAIL/UNKNOWN:

  1. TAC tables exist: tac_publication, tac_logical_unit, tac_unit_version, tac_publication_member.
  2. DIEU-35 exists.
  3. DIEU-35 member count.
  4. render_order min/max/count/distinct and contiguity.
  5. owner NULL count = 0.
  6. Existing IU collision count with DIEU-35 canonical addresses = 0.
  7. information_unit and unit_version tables exist.
  8. fn_iu_create signature exists but do not execute it.
  9. Gateway mode = enforced.
  10. iu_edit.policy.default_mode=require_review.
  11. trg_birth_information_unit exists.
  12. species_collection_map has primary information_unit mapping.
  13. Vocab keys exist: vocab.publication_authority.incomex_council, vocab.publication_type.law, vocab.unit_kind.law_unit.
  14. All distinct DIEU-35 section types have vocab.section_type.<value> keys.
  15. Existing IU pilot/test rows are classified and excluded.

B. Generate 36-row mapping artifact

Run one SELECT-only source query for DIEU-35, joined through:

tac_publication → tac_publication_member → tac_logical_unit → tac_unit_version

For each of the 36 rows, produce a mapping row containing at least:

src_render_order
src_publication_id
src_doc_code
src_publication_version
src_logical_unit_id
src_unit_version_id
src_canonical_address
src_parent_id
src_section_type
src_section_code
src_owner
src_title
src_body_char_count
src_content_hash
planned_p_canonical_address
planned_p_title
planned_p_body_sha_or_hash_reference
planned_p_actor
planned_p_unit_kind
planned_p_section_type
planned_p_owner_ref
planned_p_publication_type
planned_p_parent_ref
planned_fn_iu_create_call_string
planned_identity_profile_patch_json
planned_content_profile_patch_json
collision_status
vocab_status
mapping_status

Do not include the full body text in any report if it makes the report too large. Use char count + hash/reference. If body is needed for exact plan, store only safe preview <= 120 chars.

C. Call string requirement

For every row, emit a string representing the future call, but do not execute it:

SELECT public.fn_iu_create(
  p_canonical_address := '<src_canonical_address>',
  p_title := '<src_title>',
  p_body := '<body omitted in R0 artifact; source=src_unit_version_id>',
  p_actor := 'agent:p3d-phase5c2-r1',
  p_unit_kind := 'law_unit',
  p_section_type := '<src_section_type>',
  p_owner_ref := '<src_owner>',
  p_publication_type := 'law',
  p_parent_ref := NULL
);

It is a string artifact only.

D. JSON patch artifact

For each row, emit planned JSON patches exactly as design §5.3 and §5.4 specify:

  • identity_profile patch with TAC provenance, hierarchy, authority, rendering.
  • content_profile patch with TAC UV provenance and original content hash.

The patch must be deterministic and JSON-valid.

E. Rollback skeleton

Include the exact-key rollback skeleton from design §8 with placeholders only. Do not execute it.

F. R1 readiness classification

Classify each row:

READY_FOR_R1
BLOCKED_MISSING_OWNER
BLOCKED_MISSING_BODY
BLOCKED_MISSING_VOCAB
BLOCKED_COLLISION
BLOCKED_UNKNOWN

Then provide summary counts.

Required deliverables

Create exactly these KB documents:

  1. Main report:
knowledge/dev/laws/dieu44-trien-khai/reports/p3d-phase5c2-r0-readonly-mapping-artifact-report.md
  1. Structured JSON artifact:
knowledge/dev/laws/dieu44-trien-khai/artifacts/p3d-phase5c2-r0-dieu35-mapping-artifact.json

If the artifact path parent does not exist in KB, create it using that path anyway; do not create PG tables or files outside KB.

Required final response fields

phase5c2_r0_mapping_status=PASS|PARTIAL|BLOCKED
no_mutation_performed=true|false
live_select_only=true|false
tac_dieu35_member_count=<N>
tac_render_order_contiguous=true|false|unknown
source_rows_mapped=<N>
rows_ready_for_r1=<N>
rows_blocked=<N>
collision_count=<N>
missing_vocab_count=<N>
missing_owner_count=<N>
missing_body_count=<N>
fn_iu_create_executed=false
fn_iu_create_plan_executed=false
fn_iu_verify_invariants_executed=false
pg_write_performed=false
bulk_migration_allowed=false
ui_cutover_allowed=false
vector_work_allowed=false
r1_execution_allowed=false
report_path=knowledge/dev/laws/dieu44-trien-khai/reports/p3d-phase5c2-r0-readonly-mapping-artifact-report.md
artifact_path=knowledge/dev/laws/dieu44-trien-khai/artifacts/p3d-phase5c2-r0-dieu35-mapping-artifact.json
next_recommended_action=GPT_OPUS_REVIEW_R0_MAPPING_ARTIFACT_THEN_DECIDE_R1_PROMPT

Quality rules

  • Do not hardcode counts as gates. Live-verify them.
  • Do not hardcode section types; derive distinct values from source and compare to vocab keys.
  • Do not rely on rev4 as executable; use the approved R0 design.
  • Prefer compact structured output over verbose prose.
  • If any live evidence conflicts with the approved design, mark PARTIAL and explain.
Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/agent-phase5c2-r0-readonly-mapping-artifact-prompt-2026-05-14.md