KB-27C1

GPT Final Approval — 23-P3D1 Notification Schema Functions Prompt rev3

4 min read Revision 1
gpt-reviewpack-23p3d1approved-for-dispatchnotificationschema

GPT Final Approval — 23-P3D1 Notification Schema Functions Prompt rev3

Date: 2026-05-07
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed: knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d1-notification-schema-functions-prompt.md rev3

Verdict

APPROVED FOR DISPATCH.

P3D1 rev3 resolves the major runtime-safety issues from rev2. It may now be executed.

Accepted rev3 fixes

  • Preflight is read-only.
  • Dedicated pilot IU/draft is created only after DDL + P3D1 functions are created.
  • Pilot unit id is queried by canonical address instead of assuming fn_iu_save returns unit_id.
  • UUID arrays for fn_iu_mark_read tests are built inside SQL, not passed through shell literals.
  • Duplicate input handling is explicitly tested: requested=4, distinct=3.
  • fn_iu_mark_read uses a clearer two-step count-then-insert flow.
  • Manual event table count is asserted before unread/self-exclusion tests.
  • Manual notification cleanup on PASS is verified.
  • Final report uses MANUAL_EVENTS_CLEANUP instead of hardcoded true.
  • Preflight requires iu_edit.policy.default_mode=require_review.
  • DDL/FN/test failure cleanup drops P3D1 objects.
  • idempotency_mode=strict_fail_if_exists is reported.
  • Source safety includes DELETE checks.
  • p3d2_readiness is reported.

Dispatch instruction

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

knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d1-notification-schema-functions-prompt.md

Mục tiêu:
Tạo P3D1 notification scaffold:

1. iu_notification_event table
2. iu_notification_read table
3. indexes + constraints theo design rev3
4. fn_iu_unread(text,text,boolean,integer)
5. fn_iu_mark_read(uuid[],text)

Không tạo triggers trong P3D1.

Report tại:
knowledge/dev/laws/dieu44-trien-khai/reports/23-p3d1-notification-schema-functions-report.md

Upload report kể cả FAIL/CRITICAL.

Hard boundaries for Agent

  • No triggers.
  • No Pack 23 function changes.
  • No gateway/birth trigger changes.
  • No vector mutation.
  • No LISTEN/NOTIFY.
  • No retention/archival subsystem.
  • No external queue.
  • No global read flag.
  • Only P3D1 notification tables/functions may be created.

Expected PASS evidence

Report should include:

  • phase_status=PASS;
  • ddl=OK;
  • fn=OK;
  • test_fail=0;
  • T1–T16 PASS;
  • iu_notification_event and iu_notification_read created;
  • named CHECK constraints exist;
  • named FK constraints exist;
  • fk_notif_read_event delete rule is CASCADE;
  • exact six indexes exist;
  • uq_notif_event_type_ref is partial;
  • fn_iu_unread(text,text,boolean,integer) created;
  • fn_iu_mark_read(uuid[],text) created;
  • SECURITY DEFINER + search_path verified;
  • PUBLIC execute revoked;
  • grantees can execute;
  • fn_iu_unread empty before manual events;
  • manual test events exercise stream filter, self-exclude/include-self, limit;
  • fn_iu_mark_read returns correct requested/distinct/newly/already/unknown counts;
  • second mark_read is idempotent;
  • Pack 23 protected function hashes unchanged;
  • no trg%iu_notif% triggers created;
  • source safety check passes;
  • manual notification rows cleaned on PASS;
  • pilot IU/draft retained and reported;
  • idempotency_mode=strict_fail_if_exists;
  • p3d2_readiness=READY;
  • hard boundaries honored.

One execution caution

If DDL fails mid-transaction, PostgreSQL should roll back the DDL block. If any partial P3D1 object remains unexpectedly, Agent should report CRITICAL rather than attempting broad repair.

Next after Agent report

If P3D1 PASS:

  1. Opus/GPT review P3D1 execution report.
  2. Then create P3D2 prompt for triggers + event-generation tests.
  3. P3D2 should add trg_aa_iu_notif_comment, trg_aa_iu_notif_draft, and trg_aa_iu_notif_version only after verifying P3D1 functions and tables are stable.

Summary

P3D1 builds the durable notification schema and read/inbox API without changing runtime event behavior. It is safe to execute before P3D2 trigger activation.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-final-approval-23-p3d1-notification-schema-functions-prompt-rev3-2026-05-07.md