KB-145D

GPT Review — 22-P2 Main Functions Prompt rev11

4 min read Revision 1
gpt-reviewpack-22p2fn-iu-createwriter-phaserev12-requiredlast-mile

GPT Review — 22-P2 Main Functions Prompt rev11

Date: 2026-05-06 Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI Reviewed: knowledge/dev/laws/dieu44-trien-khai/prompts/22-p2-iu-native-create-main-functions-prompt.md rev11

Verdict

Rev11 is very close, but do not dispatch yet. Rev12 required.

The main design is now correct:

  • canonical path is complete-or-nothing;
  • fn_iu_create verifies full invariants before returning created;
  • no raw birth_registry insert;
  • auxiliary engine remains for bypass/legacy/drift;
  • no global set -e;
  • pre-SQL init failure does not skip report;
  • address variables use psql -v/session settings;
  • environment connection is configurable;
  • unique guard requires a real unique constraint.

Only last-mile operational issues remain.

Required rev12 patches

P1 — Final verdict must require POST_EXIT=0

Rev11 captures POST_EXIT but final verdict ignores it:

if [ $INIT_EXIT -eq 0 ] && [ $PSQL_EXIT -eq 0 ] && [ "$POST_COMMIT_STATUS" = "PASS" ]; then

If the separate post-commit query fails, the phase must not pass even if PSQL_EXIT=0.

Patch:

if [ $INIT_EXIT -eq 0 ] && [ $PSQL_EXIT -eq 0 ] && [ $POST_EXIT -eq 0 ] && [ "$POST_COMMIT_STATUS" = "PASS" ]; then

Also echo post_exit=$POST_EXIT in final verdict.

P2 — Post-success function-existence check should be captured, not display-only

Rev11 runs function existence check after success but does not capture/interpret its result. This is less critical than post-commit verify, but for writer-phase audit it should be machine-readable.

Patch:

  • Capture into FCHECK_RESULT and FCHECK_EXIT under set +e.
  • Echo both in final verdict/report.
  • If FCHECK_EXIT!=0 or either function is missing, phase should be FAIL/P3 BLOCKED.

Simpler acceptable patch:

Run a single query returning FCHECK_STATUS=PASS/CRITICAL and include it in final verdict condition.

P3 — POST_COMMIT_STATUS should normalize unexpected output

After:

POST_COMMIT_STATUS=$(echo "$POST_RESULT" | tr -d '[:space:]')

add:

if [ "$POST_COMMIT_STATUS" != "PASS" ] && [ "$POST_COMMIT_STATUS" != "CRITICAL" ]; then
  POST_COMMIT_STATUS="INVALID_OUTPUT"
fi

This prevents accidental noisy stdout from being misread.

P4 — Report should include INIT_ERROR explicitly

Final verdict prints reason=INIT_FAIL: $INIT_ERROR, good. Also include init_error as its own field for parsing/report.

echo "init_error=$INIT_ERROR"

P5 — Existing incomplete states should be described as non-success in report philosophy

The function returns existing incomplete states with action_required=true and health_signal_needed=true. This is correct, but the P2 report requirements should explicitly say:

  • exists_complete is idempotent success;
  • exists_missing_birth, exists_missing_version, exists_anchor_invalid, exists_duplicate_version, exists_unknown_state are not success;
  • they are health/remediation states and should block adapters from treating the create call as successful creation.

This keeps the main/auxiliary boundary clear.

Directive to Opus

Patch P2 prompt to rev12 with P1–P5. After rev12, return for final yes/no approval.

Hard boundaries remain

  • no dispatch yet;
  • no raw birth_registry insert;
  • no DOT adapter;
  • no dot_tools registration;
  • no default seeding;
  • no cleanup pilot;
  • no retry/improvise on SQL failure.

Summary

Rev11 has the right architecture. The remaining patch is not conceptual; it is to make the shell verdict as strict as the SQL design. Do not let PSQL_EXIT=0 plus a failed post-commit verification query produce a false pass.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-22-p2-main-functions-prompt-rev11-2026-05-06.md