GPT Review — 23-P3A Execution Result and P3B Directive
GPT Review — 23-P3A Execution Result and P3B Directive
Date: 2026-05-07
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed:knowledge/dev/laws/dieu44-trien-khai/reports/23-p3a-iu-gateway-allow-list-patch-report.mdrev1
Related:knowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-23-p3a-execution-result-2026-05-07.md
Verdict
23-P3A PASS. No supplemental Agent action needed.
Agent executed the approved prompt correctly. Opus review is accurate.
P3A is closed. Proceed to P3B schema-only prompt design, not immediate execution.
Evidence accepted
phase_status=PASSp3b_readiness=READYpatch_status=OK- 11/11 tests PASS
- Source hash changed as expected:
- before:
68928bcdd86325955f817b03a41b4b4f - after:
6907fa4e5e46b5617d7dfecbd86326d7
- before:
fn_iu_createreal pilot succeeded via named params.- direct IU INSERT blocked.
- direct UV INSERT blocked by gateway.
- direct UV UPDATE blocked by gateway.
- future marker
fn_iu_apply_edit_draftaccepted in rollback test. - unknown marker blocked.
- row-leak count = 0.
- PUBLIC EXECUTE not broadened.
- owner/SECURITY DEFINER/search_path preserved.
- hard boundaries honored.
Runtime state after P3A
- Gateway now allows explicit markers:
fn_iu_createfn_iu_apply_edit_draft
fn_iu_apply_edit_draftdoes not exist yet.- IU/UV counts increased 5 → 6 due to retained P3A pilot. This is expected and accepted.
- No schema edit tables exist yet.
- P3B is unblocked.
Important process note
The Agent log says it received “tiếp tục P3B schema-only”, but P3B should not be executed until the P3B prompt is created, reviewed, and approved.
Correct next step: Opus creates P3B schema-only prompt and stops for GPT/User review.
Directive to Opus — P3B schema-only prompt design
Create prompt, do not dispatch:
knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3b-iu-edit-draft-schema-prompt.md
Report path:
knowledge/dev/laws/dieu44-trien-khai/reports/23-p3b-iu-edit-draft-schema-report.md
P3B objective
Add only the schema needed for the editorial edit layer:
unit_edit_draftunit_edit_commentinformation_unit.sort_order- any minimal
dot_configpolicy keys needed for schema semantics
No functions yet. No gateway changes. No triggers unless absolutely required and explicitly justified.
Hard boundaries
- No edit/apply/comment functions.
- No changes to
fn_iu_create,fn_iu_gateway_write_guard, or Pack 22 functions. - No trigger create/drop/enable/disable unless explicitly justified in prompt and reviewed.
- No IU/UV row rewrite.
- No cleanup of pilot rows.
- No vector mutation.
- No Pack 2C.
- DDL must be additive only.
Required prompt structure
§0. Scope / pre-read
Agent must read:
knowledge/dev/laws/dieu44-trien-khai/design/23-p3-iu-proposal-merge-implementation-design.mdrev5knowledge/dev/laws/dieu44-trien-khai/reports/23-p3a-iu-gateway-allow-list-patch-report.mdknowledge/dev/laws/dieu44-trien-khai/reports/23-p2-iu-edit-merge-runtime-inspection-report.md
§1. Preflight hard gates
Include §15 compatibility/no-duplicate checks from 23-P3 rev5.
Must inspect and STOP if:
- table
unit_edit_draftalready exists; - table
unit_edit_commentalready exists; - similar tables exist (
%edit%draft%,%proposal%,%comment%) and need reconciliation; information_unit.sort_orderalready exists with incompatible type;information_unit.sort_orderalready exists with compatible type, in which case do not re-add it;information_unitandunit_versionschema changed unexpectedly from P3-P2 evidence;dot_config.keyunique semantics missing;- current role/owner/grant pattern cannot be determined.
Also capture baseline counts:
- IU count;
- UV count;
- table list;
- existing columns on IU;
- existing constraints/indexes related to new objects if any.
§2. Proposed schema DDL — design requirements
P3B prompt should propose exact DDL, transaction-wrapped, for:
unit_edit_draft
Recommended columns:
id uuid PRIMARY KEY DEFAULT gen_random_uuid()unit_id uuid NOT NULL REFERENCES information_unit(id)canonical_address text NOT NULLbase_version_ref uuid NOT NULL REFERENCES unit_version(id)base_version_seq integer NOT NULLbase_content_hash text NOT NULLdraft_title text NULLdraft_body text NOT NULLdraft_content_hash text NOT NULLdraft_status text NOT NULL DEFAULT 'open'created_by text NOT NULLcreated_at timestamptz NOT NULL DEFAULT now()applied_by text NULLapplied_at timestamptz NULLapplied_version_ref uuid NULL REFERENCES unit_version(id)stale_at timestamptz NULLreason text NULLmetadata jsonb NOT NULL DEFAULT '{}'::jsonb
Design constraints/checks:
draft_status IN ('open','applied','stale_base','withdrawn')btrim(created_by) <> ''btrim(draft_body) <> ''draft_title IS NULL OR btrim(draft_title) <> ''canonical_addressnon-empty- optional check: status/timestamp consistency if simple and safe
Indexes:
(unit_id, draft_status, created_at DESC)(canonical_address, draft_status, created_at DESC)(base_version_ref)(applied_version_ref)partial/normal as appropriate
unit_edit_comment
Recommended columns:
id uuid PRIMARY KEY DEFAULT gen_random_uuid()draft_id uuid NOT NULL REFERENCES unit_edit_draft(id)unit_id uuid NOT NULL REFERENCES information_unit(id)author_ref text NOT NULLauthor_type text NOT NULLcomment_body text NOT NULLcomment_kind text NOT NULL DEFAULT 'general'created_at timestamptz NOT NULL DEFAULT now()resolved_at timestamptz NULLresolved_by text NULLparent_comment_id uuid NULL REFERENCES unit_edit_comment(id)target_path text NULLmetadata jsonb NOT NULL DEFAULT '{}'::jsonb
Design constraints/checks:
author_type IN ('user','agent','system')comment_kind IN ('general','review','change_request','approval','system')btrim(author_ref) <> ''btrim(comment_body) <> ''resolved_by IS NULL OR btrim(resolved_by) <> ''
Indexes:
(draft_id, created_at)(unit_id, created_at)(comment_kind, created_at)if justified- parent comment index if threading is expected later
information_unit.sort_order
Recommended:
ALTER TABLE information_unit ADD COLUMN sort_order integer NULL;- no immediate NOT NULL;
- no immediate unique constraint;
- add index only if justified for render hot path now.
GPT recommendation for P3B prompt: add the column, but defer index unless Agent can justify it cheaply. If adding index, use normal btree on (parent_or_container_ref, sort_order) if this matches runtime type.
§3. Ownership / permissions
P3B must preserve Directus/Pack 22 pattern:
- identify table owner pattern first;
- new tables should be owned by the same operational owner, likely
directus, but do not hardcode without preflight; - no PUBLIC table privileges unless existing convention demands it;
- Agent should report grants.
If directus owns current IU/UV and execution role is directus, note owner/grant state in report.
§4. dot_config policy keys
Only seed minimal keys if useful and non-conflicting. Candidate keys:
iu_edit.policy.default_mode = auto_applyiu_edit.schema.version = p3b-v1iu_edit.comment.append_only = trueiu_edit.draft.status_values = open,applied,stale_base,withdrawn
Do not over-seed. If uncertain, leave to P3C functions.
§5. Transaction and rollback
Prompt must run DDL in a transaction where possible.
If failure occurs:
- transaction rollback should leave no partial schema;
- report must say whether tables/columns exist after failure;
- no retry/improvise.
§6. Post-DDL verification tests
Required:
unit_edit_draftexists with expected columns/types;unit_edit_commentexists with expected columns/types;sort_orderexists with expected type or compatible pre-existing status;- constraints/checks exist;
- indexes exist if created;
- FK references resolve;
- JSONB defaults are
'{}'::jsonb; - no IU/UV count change;
- P3A gateway allow-list still present;
fn_iu_createstill exists and was not touched;- no new functions created.
§7. Report requirements
Report must include:
- phase_status PASS/FAIL/CRITICAL;
- p3c_readiness READY/BLOCKED;
- preflight result;
- DDL applied list;
- table/column/constraint/index verification;
- owner/grants;
- IU/UV count before/after;
- boundaries honored;
- whether any objects were skipped because already existed.
P3B design cautions for Opus
- Keep P3B schema-only. Do not sneak in helper functions.
- Do not create triggers on draft/comment tables in Phase 1 unless absolutely justified.
- Do not add strict NOT NULL/unique constraints beyond what Phase 1 functions can satisfy.
- Keep schema extensible with JSONB metadata but core hot fields as columns.
- Draft/comment direct writes are discouraged by policy; permission hardening can be Phase 2 unless P3B can do it safely.
Expected Opus response
Opus should create the P3B schema-only prompt and stop for GPT/User review.
Do not dispatch.
Summary
P3A is complete. The gateway now has the future keyhole for fn_iu_apply_edit_draft. P3B should add only the editorial schema layer, carefully and additively, without touching the verified create/gateway infrastructure.