GPT Review — 23-P3 rev5 Approval and P3A Directive
GPT Review — 23-P3 rev5 Approval and P3A Directive
Date: 2026-05-06
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed:knowledge/dev/laws/dieu44-trien-khai/design/23-p3-iu-proposal-merge-implementation-design.mdrev5
Verdict
23-P3 rev5 PASS. Design approved for next-stage execution planning.
Rev5 adds the required Existing Implementation Compatibility / No-Duplicate Rule and now gives enough protection against redoing existing IU/schema work or creating a conflicting second system.
Do not execute runtime yet. Next step is to write P3A gateway allow-list execution design/prompt for review.
Accepted design state
The following are accepted as the Pack 23 design basis:
- PG-native editorial workflow: draft → comment → apply → official version.
unit_edit_draftandunit_edit_commentas the new editorial layer.unit_versionremains official applied history only.information_unit.sort_orderas core column for structural ordering.- Address-first Agent UX.
- Parent/child = structural containment only.
- Domain/professional traceability =
universal_edgestyped relations. - Multi-axis text-as-code foundation retained as roadmap hooks.
- No-duplicate compatibility rules accepted.
- Pack 23 builds only the editorial edit layer; it reuses identity/versioning/registry/gateway/validation/graph/governance layers.
Accepted Opus additions
Preflight checklist as copyable execution pattern
Accepted. P3A/P3B/P3C prompts should include the preflight structure from §15.2, adapted to phase scope.
CREATE vs CREATE OR REPLACE distinction
Accepted:
- New objects:
CREATE, neverCREATE OR REPLACE. - Existing patch target:
CREATE OR REPLACEallowed only when patching a known existing function, with source hash before/after and rollback.
This is important for P3A because P3A will patch fn_iu_gateway_write_guard.
P3A next step
Create P3A execution design/prompt, not dispatch.
Path:
knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3a-iu-gateway-allow-list-patch-prompt.md
Report path:
knowledge/dev/laws/dieu44-trien-khai/reports/23-p3a-iu-gateway-allow-list-patch-report.md
P3A objective
Patch existing fn_iu_gateway_write_guard() from exact-marker mode to allow-list mode while preserving Pack 22 behavior.
Current accepted markers:
fn_iu_createfn_iu_apply_edit_draft
Important: fn_iu_apply_edit_draft does not exist yet. P3A should only allow its future marker value. This is OK because no runtime call uses it until P3C.
Required P3A prompt structure
§0. Scope / boundaries
- Runtime mutation allowed only for:
- dot_config key
iu_create.gateway.allowed_marker_values; - patching existing
public.fn_iu_gateway_write_guard().
- dot_config key
- No table DDL.
- No new tables.
- No new edit functions.
- No trigger changes.
- No IU/UV row mutation except canonical smoke test if explicitly needed and approved in prompt.
- No cleanup pilots.
- No Pack 2C.
§1. Preflight
Must include hard gates:
- Confirm
fn_iu_gateway_write_guard()exists exactly once. - Capture
md5(prosrc)before patch. - Confirm current guard still accepts
fn_iu_createexact marker. - Confirm gateway triggers exist and are enabled:
trg_aa_iu_gateway_write_guardtrg_aa_uv_gateway_write_guard
- Confirm dot_config table has unique key semantics / no duplicate gateway keys.
- Check whether
iu_create.gateway.allowed_marker_valuesalready exists.- If exists with exact value
fn_iu_create,fn_iu_apply_edit_draft, treat as already seeded. - If exists with incompatible value, STOP.
- If exists with exact value
- Confirm no unexpected function source patch already contains allow-list logic with different semantics.
§2. Transactional patch
Within one transaction:
- Upsert/insert dot_config key:
iu_create.gateway.allowed_marker_values = fn_iu_create,fn_iu_apply_edit_draft
- Patch
fn_iu_gateway_write_guard()withCREATE OR REPLACE FUNCTION.
Behavior requirements:
- Read
app.canonical_writerfrom session setting. - Read allow-list from dot_config.
- Split by comma and trim whitespace.
- Accept if current marker equals any allowed value.
- Fallback to old exact marker key/value if allow-list key missing.
- Otherwise raise the same gateway blocked error style with README/canonical guidance.
- Preserve SECURITY DEFINER / search_path / owner/grants as Pack 22 pattern.
§3. Tests
Use separate sessions where needed.
Required tests:
- Function source now has allow-list logic.
- Dot_config key exists and value is exact expected value.
- Existing
fn_iu_createstill works through gateway.- Prefer dry/small pilot canonical create only if prompt can create a unique pilot and retain it.
- If avoiding new IU rows, use controlled transaction rollback test to set marker and test trigger behavior without commit; but ensure no false positives.
- Direct IU INSERT without marker remains blocked.
- Direct UV INSERT/UPDATE without marker remains blocked or remains covered as in Pack 22.
- Marker
fn_iu_apply_edit_draftis accepted by guard in a safe rollback test, since the function does not exist yet. - Marker not in allow-list remains blocked.
- Gateway triggers still enabled and count unchanged.
- PUBLIC privileges / grants are not broadened.
§4. Failure behavior
- If any test fails after patch, restore original function source if feasible and reset/remove
iu_create.gateway.allowed_marker_values. - If rollback/restore fails, report
phase_status=CRITICAL. - No retry/improvisation beyond prompt.
- Always upload report and log.
§5. Report requirements
Report must include:
- phase_status: PASS / FAIL / CRITICAL;
- p3b_readiness: READY / BLOCKED;
- source_hash_before;
- source_hash_after;
- allowed_marker_values;
- tests pass/fail table;
- rollback_status if any;
- confirmation that fn_iu_create still works;
- confirmation that wrong-door blocking still works;
- boundaries honored.
GPT review requirement
Opus should create the P3A prompt and stop for GPT/User review. Do not dispatch.
Hard boundaries
- No dispatch yet.
- No P3B schema DDL.
- No edit draft/comment tables.
- No edit functions.
- No vector mutation.
- No cleanup.
- No Pack 2C.
Summary
23-P3 design is now stable and compatible with existing IU infrastructure. The next work is a small infrastructure patch: expand the gateway from one exact marker to an explicit allow-list so future apply function can write IU/UV through the canonical path without weakening wrong-door blocking.