GPT Review — P3D Pack1 Phase4 DRAFT v4 Not Approved
GPT Review — P3D Pack 1 Phase 4 Implementation DRAFT v4 Not Approved
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.mdrevision 4knowledge/dev/laws/dieu44-trien-khai/reports/p3d-pack1-phase4-implementation-draft-v4-patch-report.md
Verdict
DRAFT v4 is NOT approved for dispatch.
It is much closer philosophically, but still not certainly correct. Therefore, it is wrong for production execution.
What v4 fixed well
- Scope is now correctly narrowed: vocab prep only as executable candidate.
- Species mapping is read-only candidate reporting only.
- No species INSERT.
law_unitis labelled as Pack 1 EVOLVE contract-required, not TAC-discovered.- The no-hardcode philosophy is explicitly stated.
- Run marker is passed to psql with
-v run_marker=....
Remaining blockers
1. Temp tables are created in one psql session and used in another
v4 creates _delta_section_type, _delta_pub_type, _delta_unit_kind in one psql invocation, then attempts to use them in a later psql invocation.
Postgres temp tables are session-scoped. They will not exist in the second session.
This is a production execution blocker.
2. GATE 0 only prints unique constraints; it does not enforce them
The prompt says “STOP if no unique constraint/index on key”, but the bash/SQL does not actually compute and enforce a boolean gate. This leaves execution to agent judgment.
For production, STOP gates must be executable, not prose only.
3. GATE 1 only prints existing tables; it does not verify completeness
The prompt prints table names but does not count/compare expected required objects. It must fail if required source/target objects are missing.
4. Schema adaptation is still too vague
“Agent MUST adapt INSERT columns to match GATE 0 schema” is too open-ended. A production prompt should either:
- require exact compatible schema and STOP otherwise; or
- include deterministic branching for supported schemas.
Given current discovery, require exact compatible dot_config(key,value,description,updated_at) and STOP otherwise.
5. Rollback after COMMIT is available but not the preferred safety model
Rollback by description = run_marker is acceptable only if description is a confirmed marker field and only exact current-run rows are inserted. Better: perform insert + verification in one transaction, and commit only after verification passes. If verification fails, ROLLBACK before commit.
6. Dry-run subjective STOP remains unclear
“Agent: review dry-run preview. If unexpected value appears, STOP” is useful, but production cannot rely on subjective review alone. The prompt should print preview and then proceed only with deterministic rules. Unexpected values should be handled by explicit deny patterns or by requiring GPT review if agent is uncertain.
Required v5 direction
DRAFT v5 must be executable-safe and no-hardcode:
- Use one SQL transaction/session for delta computation, dry-run preview, INSERT, verification, and COMMIT/ROLLBACK.
- Make STOP gates executable booleans.
- Require exact
dot_configschema compatibility or STOP. - Require unique key/primary key on
dot_config.keyor STOP. - Generate deltas in CTEs or temp tables inside the same session that inserts.
- Use
ON CONFLICT (key) DO NOTHINGonly after verifying unique key exists. - Record exact inserted keys via
RETURNINGinto a temp table within the same transaction. - Verify
fn_iu_create_plan(p_unit_kind:='law_unit')does not returnunresolved_vocabbefore COMMIT. - If verification fails, ROLLBACK before commit.
- Keep species mapping read-only candidate only.
- Keep hash provenance document-only.
No-hardcode philosophy remains binding
If not certainly right, it is wrong.
Not hardcoded does not mean “wrapped in a temp table”; it means every value is derived from a declared authoritative source at execution time, and the prompt states why that source is authoritative.
Status
phase4_draft_v4=REJECTED_FOR_DISPATCH
reason=temp_table_session_bug_and_non_executable_gates
vocab_prep_candidate=ALLOWED_FOR_DRAFT_V5_ONLY
species_mapping_executable=false
migration_allowed=false
seed_allowed=false_until_DRAFT_v5_GPT_REVIEW
next_action=PATCH_DRAFT_V5_SINGLE_SESSION_EXECUTABLE_GATES