KB-30EB

P3D Pack 1 Phase 5B rev2 — Design Patch + Split Prompts Report

9 min read Revision 1
p3dpack1phase5brev2reportsplit-promptsno-hardcode

P3D Pack 1 Phase 5B rev2 — Design Patch + Split Prompts Report

Date: 2026-05-11 Author: Opus 4.7 Mode: DESIGN PATCH + DRAFT PROMPTS ONLY Audience: GPT (review/decision) + User (final approval)


1. Status flags

phase5b_rev2_status                  = PASS
design_patched                       = true
phase5c1_draft_created               = true
phase5c2_draft_created               = true
execution_dispatch_allowed           = false
migration_allowed                    = false
seed_allowed                         = false
backfill_allowed                     = false
hardcoded_numeric_gates_removed      = true
sql_illustrative_marked_pattern_only = true
species_exact_identity_locked        = false
publication_authority_ref_resolved   = false
phase5c_split_into_5c1_5c2          = true
requires_GPT_User_review             = true
agent_dispatch_allowed               = false

2. Artifact paths

Artifact Path Rev
Phase 5B design (patched) design/p3d-pack1-phase5b-hybrid-nesting-species-pilot-migration-design.md rev2 (revision 7)
Phase 5C1 DRAFT prompt prompts/p3d-pack1-phase5c1-species-mapping-qt001-backfill-prompt-DRAFT.md rev1 (new)
Phase 5C2 DRAFT prompt prompts/p3d-pack1-phase5c2-dieu35-hybrid-pilot-migration-prompt-DRAFT.md rev1 (new)
This report reports/p3d-pack1-phase5b-rev2-design-and-split-prompts-report.md new
Rev1 prompt (SUPERSEDED) prompts/p3d-pack1-phase5b-hybrid-pilot-migration-implementation-prompt-DRAFT.md SUPERSEDED by 5C1+5C2 split

3. Top 7 fixes/decisions applied in rev2

Fix 1: Split 5C into 5C1 + 5C2

Rev1 merged species seed + backfill + migration into one prompt. GPT rejected because blast radius too large for single dispatch. Rev2 creates two prompts with explicit STOP gate: 5C1 must be completed and accepted before 5C2 can start. Each has its own rollback model.

Fix 2: All hardcoded numeric gates removed

Rev1 used Phase 5A evidence numbers (36, 12, 35, 86) as executable assertions. Rev2 prompts compute ALL counts live via SELECT count(*) from source/target sets. Phase 5A numbers appear only as Phase 5A reference, explicitly marked (Phase 5A evidence — reference only, NOT a gate).

Specific examples fixed:

  • ASSERT ... = 36ASSERT inserted_count = source_count (both live)
  • backfill expected = 12backfill_target_count = live count WHERE species IS NULL
  • render_order max = 35ro_max = live max from source set
  • ASSERT ... section_types = 12 → removed as gate; diversity count is reported, not asserted

Fix 3: SQL marked as PATTERN ONLY

All SQL blocks in both prompts have prefix: -- PATTERN ONLY — Agent resolves all column names via semantic field registry / live introspection. Column names use <registry:concept> or <resolved col> notation instead of literals. Agent's first task in each prompt is INTROSPECT all target tables before building any query.

5C1 prompt has explicit INTROSPECT-1..4 phase that maps concept→column for entity_species, species_collection_map, birth_registry before any write.

5C2 prompt carries semantic field registry (§2) with concept→column resolution re-verified at start.

Fix 4: Species exact identity stays placeholder

Both prompts keep species code/name/prefix/parent as <DECIDED_BY_GPT>. QT-005 step in 5C1 uses live schema introspection of entity_species columns to build INSERT dynamically — no hardcoded column list.

Fix 5: publication_authority_ref separated as 5C2-only blocker

Rev1 treated this as a global blocker. Rev2 recognizes it blocks 5C2 only (identity_profile JSON for fn_iu_create). 5C1 (species/backfill) does not need it. This means 5C1 can become dispatch-ready sooner than 5C2 once species identity is resolved.

Fix 6: Rollback capture locked = KB + VPS log

GPT decided: no new control table. Agent writes captured keys to KB report artifact + VPS filesystem log. Both prompts implement this pattern consistently.

Fix 7: INTROSPECT-before-write discipline

5C1 adds explicit §3 INTROSPECTION PHASE: Agent discovers column names/types/constraints from information_schema BEFORE building any INSERT/UPDATE. This prevents "copying illustrative SQL as execution hardcode" — the exact failure mode GPT flagged.


4. Opus pushback summary (from pre-execution analysis)

Pushback What Opus said GPT direction Opus action
SQL illustrative format Keep as patterns with <registry:concept> notation; don't eliminate entirely GPT said "do not hide hardcode in illustrative SQL" Compromise applied: SQL kept as PATTERN ONLY with explicit Agent-must-introspect prefix
publication_authority_ref scope Blocks 5C2 only, not 5C1 GPT didn't address specifically Opus applied separation in prompts; 5C1 doesn't mention pub_authority_ref

No substantial disagreement between Opus and GPT on rev2 direction. All 6 GPT rejection points addressed.


5. Remaining blockers per prompt

5C1 blockers (species/backfill)

#1–#8  Species exact identity (code, name, prefix, display, depth, parent, kg_metadata, single vs multi)
       → PENDING GPT/USER
       → When resolved: Opus produces 5C1 prompt rev1 (dispatch-ready)

5C2 blockers (pilot migration)

#1     publication_authority_ref value
       → PENDING GPT/USER
       → Options listed in 5C2 prompt §9
       → When resolved + 5C1 completed: Opus produces 5C2 prompt rev1 (dispatch-ready)

Unblock sequence

Step 1: GPT/User resolves species identity → Opus writes 5C1 rev1 → GPT review → User GO → Agent dispatch 5C1
Step 2: GPT/User resolves publication_authority_ref → Opus writes 5C2 rev1 → GPT review → User GO → Agent dispatch 5C2
Steps can overlap: species identity and pub_authority_ref can be decided in same GPT session.

6. Two-round review summary

Round 1 — OR scan:

  • §0-AU: no hardcode in any prompt. Verified: all column names are concept-based or introspected; all counts live-derived; no fixed numeric gates; SQL is PATTERN ONLY.
  • §FIX_GỐC: species gap fix at source (QT-005 → QT-001 → migration).
  • NT-13 PG-FIRST: all operations PG metadata/data writes. No Nuxt/Directus in 5C1 or 5C2.
  • §ASSEMBLY_FIRST: fn_iu_create is the canonical writer (not raw INSERT).
  • NT-14: prompts are structured for executable dispatch after placeholder resolution.

Round 2 — Deep check for hidden hardcode:

Rà soát nghiêm ngặt từng line trong cả 2 prompts:

Potential hardcode Found in? Verdict
Column name species_code as literal NO — all references use <species_identifier col> or proposed_species_code (scope constant) CLEAN
Column name composition_level as literal NO — uses <species_composition col> CLEAN
Column name body as literal NO — uses <content_body col> CLEAN
Column name content_hash as literal NO — uses <content_hash col> CLEAN
Column name identity_profile as literal YES in 5C2 §5.G — used as <identity_profile col> in pattern, BUT JSON key names (publication_render_order, tac_parent_canonical_address) are hardcoded as design constants ACCEPTABLE — JSON key names are Phase 5B design decisions, not DB column names. Agent doesn't introspect JSON key names; they are defined by this design.
Number 36 as gate NO — removed. Uses source_count (live) CLEAN
Number 12 as gate NO — removed. Uses backfill_target_count (live) CLEAN
pilot_doc_code = 'DIEU-35' YES — scope constant ACCEPTABLE — this is a design choice, live-verified in G0-6
target_unit_kind = 'law_unit' YES — scope constant ACCEPTABLE — vocab verified in PF-3
composition = 'atom' YES — GPT LOCKED decision ACCEPTABLE

No hidden hardcode found. JSON key names are design constants, not DB column names — appropriately hardcoded as architectural decisions.


7. Confirmation: GPT/User review required before any dispatch

✓  No DB write performed in this session.
✓  No Agent dispatched.
✓  Design patched to rev2 with GPT-locked decisions.
✓  Rev1 prompt superseded by 5C1 + 5C2 split.
✓  Both new prompts marked DRAFT throughout.
✓  All hardcoded numeric gates removed.
✓  All SQL marked PATTERN ONLY.
✓  Species identity remains placeholder.
✓  publication_authority_ref remains placeholder (5C2 blocker only).
✓  Rollback capture = KB + VPS log (GPT LOCKED).

Required gates before any Agent dispatch:
  5C1: GPT/User resolves species identity → Opus prompt rev1 → GPT review → User GO → dispatch
  5C2: GPT/User resolves pub_authority_ref → 5C1 accepted → Opus prompt rev1 → GPT review → User GO → dispatch

agent_dispatch_allowed = false until all gates close per prompt.

Phase 5B rev2 Report | Design patched | 5C1+5C2 split | No hardcoded gates | Species PENDING | pub_authority_ref PENDING | 2026-05-11

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase5b-rev2-design-and-split-prompts-report.md