KB-3115

GPT Review — 23-P3C2 Prompt rev5

4 min read Revision 1
gpt-reviewpack-23p3c2rev6-small-patchapply-wrappernear-final

GPT Review — 23-P3C2 Prompt rev5

Date: 2026-05-07
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed: knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3c2-iu-apply-edit-functions-prompt.md rev5

Verdict

Rev5 is very close, but do not dispatch yet. Rev6 small patch required.

Opus correctly applied the seven rev5 fixes. The T16 || true blocker is gone, DRAFT_B is required, final variables are initialized, input validation exists, and security/report fields were added.

Two small but real hardening issues remain before running the official write path.

Accepted rev5 fixes

  • T16 apply source check now parses exact fields and can fail.
  • T16 requires marker, UV insert, IU update, no delete.
  • Preflight requires both DRAFT_A and DRAFT_B.
  • Final variables initialized.
  • UUID/address validation added.
  • Security metadata report added.
  • P3D roadmap fields preserved.

Required rev6 fixes

P1 — DRAFT_B must be tied to the same IU/base as DRAFT_A

Rev5 requires DRAFT_B but selects it as any second open draft:

SELECT id FROM unit_edit_draft WHERE draft_status='open' AND id!='$DRAFT_A_ID' ORDER BY created_at LIMIT 1;

T6 expects B to become stale_base after applying A. That only happens if B is on the same IU affected by A. In the current P3C1 retained pilots this is probably true, but the prompt should not depend on global ordering.

Patch DRAFT_B selection to require same unit/base as A:

DRAFT_A_ID=$("${PSQL[@]}" -t -A -c "
  SELECT id
  FROM unit_edit_draft
  WHERE draft_status='open'
  ORDER BY created_at
  LIMIT 1;")

DRAFT_B_ID=$("${PSQL[@]}" -t -A -c "
  WITH a AS (
    SELECT unit_id, base_version_ref
    FROM unit_edit_draft
    WHERE id='$DRAFT_A_ID'
  )
  SELECT d.id
  FROM unit_edit_draft d, a
  WHERE d.draft_status='open'
    AND d.id != '$DRAFT_A_ID'
    AND d.unit_id = a.unit_id
    AND d.base_version_ref = a.base_version_ref
  ORDER BY d.created_at
  LIMIT 1;")

Keep the existing validation after selection. If B is missing, preflight FAIL remains correct.

P2 — T16 regex should use PostgreSQL-safe whitespace classes

Rev5 regex uses patterns like:

'insert\s+into\s+(public\.)?unit_version'

Depending on PostgreSQL regex/string handling, \s can be fragile. Use POSIX character class instead, which is PG-native and clear:

'insert[[:space:]]+into[[:space:]]+(public\.)?unit_version'
'update[[:space:]]+(public\.)?information_unit'
'delete[[:space:]]+from[[:space:]]+(public\.)?(information_unit|unit_version)'

Patch both apply and wrapper source checks. Preserve case-insensitive ~*.

Expected logic unchanged:

  • apply: marker=true, uv_insert=true, iu_update=true, delete=false;
  • wrapper: no marker and no direct IU/UV write/delete.

Directive to Opus

Patch P3C2 prompt to rev6 with P1–P2 only.

Path:

knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3c2-iu-apply-edit-functions-prompt.md

Do not dispatch after patch. Return for GPT/User final review.

Hard boundaries remain

  • No dispatch.
  • No table DDL.
  • No trigger/gateway changes.
  • No vector mutation.
  • No cleanup.
  • No notification log implementation in P3C2.
  • No Pack 2C.

Summary

Rev5 is almost dispatch-ready. Rev6 should only make stale-base test deterministic by selecting B from the same IU/base as A, and make T16 source regex robust using PostgreSQL-native [[:space:]]+ classes.