KB-5B45

GPT Final Approval — 24-P3B-FU Invariant Prompt rev3

4 min read Revision 1
gpt-reviewpack-24p3bfuapproved-for-dispatchinvariantp3c2-unblock

GPT Final Approval — 24-P3B-FU Invariant Prompt rev3

Date: 2026-05-07
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed: knowledge/dev/laws/dieu44-trien-khai/prompts/24-p3bfu-generalize-iu-invariant-prompt.md rev3

Verdict

APPROVED FOR DISPATCH.

Rev3 fixes the required safety gaps. It is now acceptable to dispatch P3B-FU before re-running P3C2.

Why this pack is required

P3C2 failed because the installed fn_iu_verify_invariants(text) was still birth-oriented:

  • it checked anchors against version_seq=1;
  • after apply, the IU current anchor points to the new UV;
  • therefore i3_anchors_exact=false after any edit;
  • P3C2 correctly raised exception and rolled back.

P3B-FU generalizes the invariant function so:

  • current anchor checks use v_uv_current via information_unit.version_anchor_ref;
  • birth checks still use v_uv_birth / version_seq=1.

Accepted rev3 fixes

  • Broad pre-COMMIT assertions A1–A4 are now inside the same transaction as CREATE OR REPLACE FUNCTION.
  • If pilot/all-IU/error-path/source-marker assertions fail, transaction rolls back and the old function remains intact.
  • T6 now verifies owner, SECURITY DEFINER, and config/search_path exact match.
  • Pre-function full DDL is captured in the log for deterministic restore evidence.
  • T2 prints failing addresses and invariant JSON if any all-IU sanity check fails.
  • Final report includes explicit P3C2 re-run path.

Dispatch instruction

Đọc prompt từ KB rồi thực hiện:

knowledge/dev/laws/dieu44-trien-khai/prompts/24-p3bfu-generalize-iu-invariant-prompt.md

Mục tiêu:
Generalize public.fn_iu_verify_invariants(text) so current-anchor invariant checks work after IU edits.

Chỉ được touch:
- public.fn_iu_verify_invariants(text)

Không table DDL.
Không trigger/gateway changes.
Không IU/UV/draft/comment writes.
Không vector mutation.
Không notification implementation.
Không cleanup.
Không đổi signature/return type/owner/SECDEF/search_path.
Không tạo overload mới.

Report tại:
knowledge/dev/laws/dieu44-trien-khai/reports/24-p3bfu-generalize-iu-invariant-report.md

Upload report kể cả FAIL.

Expected PASS evidence

Report should include:

  • phase_status=PASS;
  • A1–A4 pre-COMMIT assertions effectively passed;
  • T1–T10 all PASS;
  • function signature unchanged: p_addr text -> jsonb;
  • return type unchanged: jsonb;
  • owner unchanged;
  • SECURITY DEFINER unchanged;
  • search_path/config exact match unchanged;
  • hash changed for fn_iu_verify_invariants body;
  • P3C1 + fn_iu_create + fn_content_hash hashes unchanged;
  • all existing IUs still all_pass=true;
  • IU/UV counts unchanged;
  • source markers present: version_anchor_ref, version_seq=1, birth_registry;
  • pre-function DDL backup included in log;
  • next_required_pack=23-P3C2_RE_RUN_AFTER_INVARIANT_GENERALIZED;
  • boundaries honored.

Next after Agent report

After P3B-FU report is uploaded:

  1. Opus/GPT review P3B-FU execution result.
  2. If PASS, re-dispatch P3C2 rev7:
    • knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3c2-iu-apply-edit-functions-prompt.md
  3. After P3C2 PASS, implement P3C3 fn_iu_save natural router.
  4. Then proceed to P3D notification outbox before Hermes production.

Note

P3B-FU cannot fully prove post-edit behavior without performing an edit/apply, which is intentionally outside its hard boundaries. P3C2 re-run will be the live proof that the generalized invariant now works for post-edit anchors.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-final-approval-24-p3bfu-invariant-prompt-rev3-2026-05-07.md