GPT Review — P3D Pack1 Phase4 Implementation DRAFT v2 No-Hardcode Fail
GPT Review — P3D Pack 1 Phase 4 Implementation DRAFT v2 No-Hardcode Fail
Date: 2026-05-11 Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI Reviewed:
knowledge/dev/laws/dieu44-trien-khai/prompts/p3d-pack1-phase4-governance-vocab-species-prep-implementation-prompt-DRAFT.mdrev2knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase4-implementation-prep-prompt-patch-report.mdknowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase4-governance-vocab-discovery-report.md
Verdict
NOT APPROVED FOR DISPATCH.
Opus improved the prompt substantially, but DRAFT v2 still contains hardcode leakage and SQL/schema risks. Under the no-hardcode directive, this cannot be sent to Agent.
What improved
- Vocab values are now derived from live TAC data and IU vocab deltas.
- The fixed manual 14-row insert list is gone.
- Temp-table delta pattern is the right direction.
- Migration remains prohibited.
- DDL remains prohibited.
Blocking issues
1. Invalid dot_config column assumption
Discovery report says dot_config has:
key, value, description, updated_at
DRAFT v2 inserts into:
dot_config (key, value, description, created_at)
This is wrong and would fail or reveal that the prompt is not schema-driven.
2. Species mapping still hardcodes target rows
DRAFT v2 still inserts explicitly:
'information_unit'
'unit_version'
This violates the decision to derive target collections from live collection_registry. Stable table names may be used for a scoped DDL pack, but seed execution must use live-discovered target collection rows.
3. Species composition hardcode remains
DRAFT v2 inserts:
'unit_version', es.species_code, 'subordinate'
This is hardcoded composition. The previous directive explicitly said to use discovered species/composition fields and STOP if the mapping policy is not uniquely derivable.
4. Species SQL is likely invalid
This pattern is unsafe/invalid:
SELECT 'information_unit', es.species_code, es.composition_level
FROM entity_species es
...
HAVING count(*) = 1
It mixes non-aggregated selected columns with aggregate HAVING and no GROUP BY / scalar CTE. The uniqueness check should be a CTE, not a HAVING after raw rows.
5. Rollback by description prefix is unsafe
DRAFT v2 proposes:
DELETE FROM dot_config WHERE description LIKE 'Seeded from TAC live discovery%';
This can delete rows from previous legitimate runs. Rollback must delete only rows inserted by this run, identified by a unique run marker or exact captured inserted keys.
6. ON CONFLICT assumptions are not verified
The prompt assumes dot_config has a unique conflict target on key and species_collection_map has usable conflict constraints. It must introspect indexes/constraints before using ON CONFLICT.
7. STOP if delta ≠ expected is ambiguous and can reintroduce hardcode
There must be no expected count/list from report memory. The only allowed checks are schema compatibility, conflict safety, uniqueness of law species, and whether computed delta is empty/non-empty.
8. law_unit is still typed as a fixed seed value without a derivation rule
law_unit can be a required migration contract value, but the prompt must state its source: active Pack 1 migration contract requiring law units, not a discovered TAC column. It must be treated as one contract-required value, not a live table count.
Required next action
Opus must patch DRAFT v2 to DRAFT v3 or GPT may patch directly. DRAFT v3 must be split conceptually into:
- Vocab prep — likely executable after GPT review.
- Species mapping prep — either executable only if fully schema/uniqueness-safe, or deliberately deferred if not safe.
- Hash provenance contract — document JSONB contract only, no backfill.
DRAFT v3 required properties
- Introspect
dot_configcolumns and constraints before seed. - Insert only into existing columns.
- Generate a unique run marker.
- Capture inserted rows in temp tables.
- Rollback only exact rows inserted by this run.
- Compute vocab deltas from live data.
- Treat
law_unitas contract-required and clearly label it. - Do not hardcode species mapping rows.
- Do not hardcode
subordinatecomposition. - Use CTE uniqueness checks for law species.
- If species mapping cannot be derived safely, defer it rather than pretending it is safe.
- No migration, no DDL, no Directus, no Qdrant.
Status
phase4_implementation_draft_v2=REJECTED_FOR_DISPATCH
reason=NO_HARDCODE_AND_SCHEMA_SAFETY_FAILURES
migration_allowed=false
seed_allowed=false_until_DRAFT_v3_GPT_REVIEW
next_action=PATCH_DRAFT_V3_WITH_SCHEMA_INTROSPECTION_RUN_MARKER_AND_NO_HARDCODE_SPECIES_POLICY