KB-5133
23-P3D2 — Notification Triggers + Board — Execution Report
6 min read Revision 1
p3d2notificationdieu44reportpass
23-P3D2 — Notification Triggers + Board — Execution Report
Date: 2026-05-08 Prompt: knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d2-notification-triggers-prompt.md (rev7) Variant: A (unit_version.created_by EXISTS) Status: PASS VPS: 38.242.240.89, container=postgres, db=directus Log: /tmp/23-p3d2.20260508-015552.log Run TS: 20260508-015552
Final Status
| Field | Value |
|---|---|
| phase_status | PASS |
| fn | OK |
| test_fail | 0 |
| test_event_cleanup | PASS |
| fail_cleanup | NOT_RUN |
| active_object_count | 7 |
| active_object_check | PASS |
| p23_unchanged | true |
| p3d1_unchanged | true |
| version_actor_variant | A_created_by |
| comment_suppression | comment_kind_and_author_type |
| self_read_policy | implicit_self_read |
| board_scope | actionable_current_events |
| notification_runtime | ACTIVE |
| notification_board | ACTIVE |
| per_actor_read_state | ACTIVE |
| hermes_readiness | BLOCKED_PENDING_REVIEW |
| latest_readers_gpt_verified | true |
| comment_context | draft_id |
| comment_route | fn_iu_comment_with_explicit_context |
| cleanup_scope | canonical_address_only |
| pilot_rows_retained | true |
| next_required_pack | P3D3_CONTEXT_UPDATE_FOR_NOTIFICATION_COMMANDS |
Preflight
- PREFLIGHT=PASS
- Tables
iu_notification_event,iu_notification_readexist - Indexes
uq_notif_event_type_ref(partial unique),uq_notif_read_event_actorexist - Constraints
chk_notif_event_type_stream,fk_notif_read_event(CASCADE) exist - Pack 23 functions count = 10 ✓
- Target functions/triggers absent before create ✓
- All 13 column requirements present (unit_edit_comment, unit_edit_draft, unit_version)
- VERSION_HAS_ACTOR=1 → Variant A
- Policy default_mode=require_review ✓
- FN_OWNER=directus
Create (Variant A)
- 4 functions created:
fn_iu_notif_comment,fn_iu_notif_draft,fn_iu_notif_version,fn_iu_notification_board(text,text,integer) - 3 triggers created:
trg_aa_iu_notif_comment(unit_edit_comment),trg_aa_iu_notif_draft(unit_edit_draft),trg_aa_iu_notif_version(unit_version) - All AFTER INSERT FOR EACH ROW
- REVOKE PUBLIC + ALTER OWNER → directus applied
- TRIGGER-GUARD DDL warnings logged (informational; not failures)
- Single transaction commit (FN_EXIT=0)
Pilot
- TEST_ADDR=
test/p3d2/pilot-20260508-015552 - TEST_UNIT_ID=
dae168e2-15e3-4216-97ce-01c81867553c - TEST_DRAFT_ID=
f6760a02-79e8-43f7-b5a8-b86c4952f282 - Birth: created via
fn_iu_save, no version_applied event at version_seq=1
Tests
| Test | Description | Result |
|---|---|---|
| T1 | 4 function signatures resolve | PASS |
| T2 | 3 triggers attached to correct tables | PASS |
| T3 | Pack 23 hashes unchanged | PASS |
| T4 | P3D1 hashes unchanged (fn_iu_unread, fn_iu_mark_read) |
PASS |
| T5 | Comment event via fn_iu_comment (explicit draft context); ref_id resolves to existing comment |
PASS |
| T6 | System/apply comment suppression — apply did not create comment_added event | PASS |
| T7 | Draft event created (draft_created) |
PASS |
| T8 | Version applied event created on fn_iu_apply_edit_draft |
PASS |
| T9 | Birth (version_seq=1) excluded — 0 events | PASS |
| T10 | Actionable filter: applied draft hidden from fn_iu_unread('gpt','review') |
PASS |
| T11 | Per-actor read isolation: gpt cleared, agent:codex still has unread | PASS |
| T12 | Self-exclusion via board: agent:opus → read_status_source=implicit_self, unread_for_actor=false |
PASS |
| T13 | Idempotency: ON CONFLICT DO NOTHING blocks duplicate | PASS |
| T14 | Source safety: trigger fns insert only into iu_notification_event; no other writes; board fn is read-only |
PASS |
| T15 | Security: SECURITY DEFINER, search_path pinned to pg_catalog,public, owner=directus, no PUBLIC EXECUTE | PASS |
| T16 | Board latest_readers includes gpt after mark_read; codex sees unread |
PASS |
Evidence
evt_evidence: {"draft": 1, "total": 3, "comment": 1, "version": 1}
read_evidence: {"gpt_read": 2, "total_read": 2}
- 1 draft_created + 1 comment_added + 1 version_applied = 3 events
- 2 reads by
gpt(both events on test address marked read) latest_readersJSON contains"gpt"✓
Cleanup
- TEST_EVT_IDS array assembled from canonical_address scope
- DELETE FROM iu_notification_read: 2 rows
- DELETE FROM iu_notification_event: 3 rows
- Remaining = 0 → TEST_EVENT_CLEANUP=PASS
- Pilot rows (information_unit, unit_version, unit_edit_draft, unit_edit_comment) retained as designed (cleanup_scope=canonical_address_only)
- FAIL_CLEANUP not invoked (NOT_RUN)
Active Object Verification
- ACTIVE_FN=4, ACTIVE_TRG=3 → total=7 → ACTIVE_OBJ_CHECK=PASS
Hard Boundaries — Confirmed Compliant
- ✅ No Pack 23 function changes (T3 hashes match)
- ✅ No P3D1 table/function changes (T4 hashes match)
- ✅ No gateway/birth trigger changes
- ✅ No vector mutation
- ✅ No LISTEN/NOTIFY
- ✅ No retention/archival
- ✅ No external queue
- ✅ No global read flag (per-actor only)
- ✅ No Hermes production start (hermes_readiness=BLOCKED_PENDING_REVIEW)
Next Required Pack
P3D3_CONTEXT_UPDATE_FOR_NOTIFICATION_COMMANDS
Documentation surface to update:
fn_iu_unreadfn_iu_mark_readfn_iu_notification_board- implicit_self_read policy
- actionable_board_scope semantics
P3D2 rev7 executed 2026-05-08 01:55:52 UTC | Variant A | All 16 tests PASS | notification runtime ACTIVE