GPT Review — 23-P3D2 Notification Triggers Prompt rev3
GPT Review — 23-P3D2 Notification Triggers Prompt rev3
Date: 2026-05-08
Reviewer: GPT-5.5 Thinking / Incomex Hội đồng AI
Reviewed:knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d2-notification-triggers-prompt.mdrev3
Verdict
Rev3 is close, but do not dispatch yet. Rev4 required.
Opus applied most fixes correctly and incorporated the User’s implicit self-read requirement. However, rev3 still leaves execution-time adaptation inside the CREATE section, and Variant B is incomplete. That is not acceptable for a production trigger deployment prompt.
Accepted rev3 improvements
- Creator/self implicit read is correctly added to board semantics:
- own events are treated as read for the creator;
unread_for_actor=falsefor own events.
- Board function includes
unread_for_actor. - Static quoted heredoc direction is mostly adopted.
- Partial unique event index is now checked through
pg_index. - Owner assignment uses
set_config+format('%I', owner). - PUBLIC revocation is applied to all four functions.
- Source safety is broader.
- Cleanup captures event ids before deleting events.
- Final report includes board/read-state status and next context update pack.
Required rev4 fixes
P1 — BLOCKER: Variant B must be fully written, not “copy from Variant A”
Rev3 Variant B contains comments:
-- fn_iu_notif_comment and fn_iu_notif_draft: identical to Variant A
-- (Agent: copy exact bodies from Variant A above)
-- fn_iu_notification_board: identical to Variant A
-- (Agent: copy exact body from Variant A above)
-- Triggers, REVOKE, owner DO block: identical to Variant A
This violates the no-adaptation rule. A runnable execution prompt must contain complete SQL for both variants, or it must choose one variant by preflight and generate a complete block.
Patch:
- Expand Variant B fully.
- No “copy from above” instructions inside executable section.
- Agent should select exactly one complete block and run it.
P2 — BLOCKER: author_type branch still asks Agent to adapt CREATE body
Rev3 says:
If HAS_AUTHOR_TYPE=1, adapt fn_iu_notif_comment suppress condition to...
This reintroduces execution-time editing inside the CREATE section.
Patch one of two ways:
Option A — Require author_type exists and hard-code:
IF NEW.comment_kind='system' OR NEW.author_type='system' THEN RETURN NEW; END IF;
Option B — Provide complete Variant C/D for comment trigger with/without author_type.
GPT preference: Option A if runtime P3C1/P3C2 reports confirm author_type exists. P3D2 preflight can require it. If it does not exist, STOP and return for review rather than silently weakening suppression.
P3 — P3D1 read unique index check still incomplete
Rev3 checks uq_notif_event_type_ref, chk_notif_event_type_stream, and fk_notif_read_event, but it no longer verifies uq_notif_read_event_actor.
Patch preflight to verify uq_notif_read_event_actor exists and is unique via pg_index/pg_class.
P4 — Board function should include read_status_source for implicit self-read
To avoid future confusion, board JSON should distinguish explicit read rows from implicit creator-read.
Add:
read_status_source = explicit_read | implicit_self | unread | not_applicable
Rules:
p_actor IS NULL→not_applicable;e.actor_ref=p_actor→implicit_self;- read row exists →
explicit_read; - else →
unread.
This directly addresses the User’s point: if Opus created it, Opus is treated as having read it even without a read row.
P5 — T16 must verify unread_for_actor=false and read_status_source=implicit_self
Rev3 T16 only verifies is_read_for_actor=true for self. Add assertions:
- self event:
unread_for_actor=false; - self event:
read_status_source=implicit_self; - GPT after mark_read:
read_status_source=explicit_readfor at least one event.
P6 — T15 PUBLIC revoke check can miss overloaded function signatures
proname IN (...) is acceptable if no overloads exist, but this prompt creates a board with signature (text,text,integer). Add exact signature verification for the board:
to_regprocedure('public.fn_iu_notification_board(text,text,integer)')
Also verify the three trigger functions as zero-arg regprocedures:
public.fn_iu_notif_comment()
public.fn_iu_notif_draft()
public.fn_iu_notif_version()
P7 — T14 should require insert into event table, not only forbid bad inserts
Rev3 forbids bad INSERT targets but does not assert each trigger function actually inserts into iu_notification_event.
Patch T14:
- for each of the three trigger functions, require source matches:
insert into public.iu_notification_eventorinsert into iu_notification_event;
- board function should not insert anywhere.
P8 — Cleanup with TEST_EVT_IDS can fail if array is NULL
If no test events exist due to earlier failure but cleanup path runs, ANY(NULL::uuid[]) behavior may not be intended.
Patch:
- if
TEST_EVT_IDSis empty/null, set cleanup event id array to'{}'::uuid[]; - report
test_event_ids_count.
P9 — Fail cleanup should also run when FN_STATUS=FAIL after partial create and verify exact objects removed
Rev3 has a partial cleanup branch, but it does not verify exact remaining trigger/function count after the partial cleanup. Add the same exact verification used in the FAIL cleanup branch. If anything remains, PHASE_STATUS=CRITICAL.
P10 — Final report should include trigger/function creation variant and author_type suppression mode
Add report fields:
version_actor_variant=A_created_by|B_draft_applied_by_fallback
comment_suppression=comment_kind_and_author_type|comment_kind_only
self_read_policy=implicit_self_read
board_read_status_source=ACTIVE
If rev4 chooses to require author_type, then comment_suppression=comment_kind_and_author_type should be expected.
Directive to Opus
Patch P3D2 prompt to rev4 with P1–P10.
Path:
knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d2-notification-triggers-prompt.md
Do not dispatch after patch. Return for GPT/User final review.
Hard boundaries remain
- No dispatch.
- No Pack 23 function changes.
- No P3D1 table changes.
- No gateway/birth trigger changes.
- No vector mutation.
- No LISTEN/NOTIFY.
- No retention/archival.
- No external queue.
- No global read flag.
- No Hermes production start.
Summary
Rev3 mostly solves the core issues but still has incomplete executable SQL and a lingering “Agent adapt” instruction. Rev4 should make all CREATE paths complete and static, encode implicit self-read explicitly in the board output, and tighten final verification. After rev4, P3D2 may be ready for final approval.