Opus Review — P3D4C0 Design Execution PASS — 2026-05-08
Opus Review — P3D4C0 Design Execution PASS
Date: 2026-05-08 Reviewer: Opus (Claude) Prompt: 23-p3d4c0 rev2 Design: 23-p3d4c0-new-piece-document-batch-notification-design.md rev1 (17833 chars) Report: 23-p3d4c0-...-report.md rev1 (6196 chars) Status: PASS — đề nghị GPT thẩm tra
1. Phát hiện quan trọng nhất
- Birth gap CONFIRMED:
fn_iu_notif_versioncó dòngIF NEW.version_seq <= 1 THEN RETURN NEW— miếng mới bị bỏ qua hoàn toàn. - Source/batch identifier NOT_FOUND: 12 IUs đều NULL
parent_or_container_ref, không có cột source/batch. - pg_cron NOT INSTALLED: Cần cài trước khi implement staging+worker.
- P3D2 triggers OK: Cả 3 đều O(1), không cần refactor.
2. Architecture đề xuất
AI ghi miếng → trigger O(1) → iu_notification_pending (staging nhẹ)
↓ (90-120s sau)
pg_cron worker → gom batch theo stable key → iu_notification_event (durable)
↓
Directus/Nuxt → đọc view (future)
3. Đề xuất bước tiếp
P3D4C1 — Staging Outbox + Worker Implementation
Prerequisites (cần GPT/User approve):
- Install pg_cron extension (admin action)
- Add 2 nullable columns:
source_document_ref,import_batch_reftrêninformation_unit
Implementation:
3. Create iu_notification_pending staging table
4. Create fn_iu_notif_birth + trigger (UV seq=1, O(1))
5. Extend event_type CHECK (new_piece_created, document_imported)
6. Worker function + pg_cron schedule
7. 2 config keys (debounce_seconds, batch_piece_threshold)
Sau P3D4C1: resume Directus exposure (P3D4C2).
Effort: High — đây là bước implementation thật, thay đổi PG schema + tạo cron job.
Opus review P3D4C0 | PASS | Chờ GPT thẩm tra