KB-2232 rev 2

23-P3D4C0Y — Universal Phase 2 PoC Scope Plan Prompt (rev2)

9 min read Revision 2
p3d4c0ypromptuniversalpocscopephase2eventdesignrev2

23-P3D4C0Y — Universal Phase 2 PoC Scope Plan Prompt (rev2)

Date: 2026-05-08 Status: PROMPT rev2 — chờ GPT/User final review. CHƯA dispatch. Design: knowledge/dev/laws/dieu44-trien-khai/design/23-p3d4c0y-universal-phase2-poc-scope-plan.md Report: knowledge/dev/laws/dieu44-trien-khai/reports/23-p3d4c0y-universal-phase2-poc-scope-plan-report.md Scope: PoC scope/design review only. NO implementation. NO mutation. Rev1→Rev2: PG inventory for PoC domain, dot_config reuse, registry enforcement, pending strategy, IU compat locked, payload safety schema, task/review rule, Đ43 gate, rollback design.


Quyết định đã khóa

  • UNIVERSAL_WITH_IU_COMPAT (Option C) approved
  • IU runtime: KHÔNG touch (fn_iu_*, tables, triggers bất biến)
  • P3D4C1: ABSORBED, không resume
  • event_type_registry: BẮT BUỘC
  • LISTEN/NOTIFY: defer Phase 3
  • Đ45: defer sau Phase 2 PoC

Hard Boundaries

  • ❌ KHÔNG implement / mutate PG / Directus / Nuxt
  • ❌ KHÔNG Hermes / Codex
  • ❌ KHÔNG touch iu_notification_* runtime
  • ❌ KHÔNG resume P3D4C1
  • ❌ KHÔNG expose body/vector/secret
  • ❌ KHÔNG activity log
  • ❌ KHÔNG tạo event_config nếu dot_config phù hợp
  • ❌ KHÔNG dual-write IU triggers
  • ❌ KHÔNG migrate IU rows trong Phase 2
  • ✅ KB document create only
  • ✅ PG read-only inventory

Step 0: Pre-Read

  1. P3D4C0X design note (38KB)
  2. P3D4C0X report (8 answers)
  3. GPT review + P3D4C0Y directive
  4. P3D4C1 rev3 (lessons to absorb)
  5. Constitution + relevant laws

Step 1: PoC Domain Selection (PG inventory-backed)

Agent KHÔNG chọn domain theo cảm giác. PHẢI inventory PG read-only:

-- For each candidate: check table exists, columns, lifecycle states, actors, correlation keys
\d system_issues
\d dot_tools  -- or equivalent DOT execution table
\d birth_registry_entries  -- or equivalent
Candidate Check What to verify
system_issues (Đ22) Table exists? Lifecycle columns? Actor/owner? Severity? Resolution state? Simplest lifecycle → preferred
dot_execution (Đ35) DOT execution log exists? Paired DOT (exec/verify)? Result state? Medium complexity
birth_registry (Đ0-G) Birth tables? Species? Conformance? Medium complexity

Agent must report actual PG findings, then choose with justification.

If preferred candidate doesn't have sufficient schema → choose next, or report poc_domain=NONE_SUITABLE and explain.


Step 2: Universal Core Schema (non-executable sketches)

2A. event_outbox (durable)

Based on P3D4C0X envelope. 18+ columns. Clearly fenced NON-EXECUTABLE.

2B. event_read (per-actor)

Generalize iu_notification_read. Universal constraint: UNIQUE (event_id, actor_ref).

2C. event_subscription (routing config)

Per-domain, per-actor. Minimal Phase 2.

2D. event_type_registry (MANDATORY — chống free-form)

event_domain text NOT NULL
event_type text NOT NULL
event_stream text NOT NULL
description text
active boolean NOT NULL DEFAULT true
PRIMARY KEY (event_domain, event_type)

Enforcement mechanism — agent must choose 1 and justify:

Option Mechanism Pros Cons
A Compound FK from event_outbox → event_type_registry(event_domain, event_type) Strong integrity, PG-native FK on text pairs, slight insert overhead
B BEFORE INSERT trigger on event_outbox validates against registry Flexible, custom error messages Trigger overhead (should be small)
C Static CHECK generated from registry (rebuild on registry change) Zero runtime cost Requires re-generation, stale risk
D Registry table only (no enforcement) for PoC, production adds A or B Fastest PoC No runtime protection

PG CHECK constraint CANNOT lookup another table dynamically — option C requires DDL regeneration. Agent must not claim "CHECK-backed by registry" without specifying the mechanism.

2E. event_pending (staging)

Agent must decide strategy:

Option Approach
UNIVERSAL 1 table event_pending with event_domain column
PER_DOMAIN {domain}_event_pending per domain
HYBRID Universal table, per-domain partial indexes

Evaluate: index efficiency, permission isolation, maintenance. Recommend with justification.

2F. Worker log

Generalize P3D4C1 pattern. Per-domain or universal.

2G. Config — REUSE dot_config

KHÔNG tạo event_config. Ưu tiên reuse dot_config với namespaced keys:

event.{domain}.debounce_seconds
event.{domain}.batch_piece_threshold
event.global.debounce_seconds (fallback)

Agent must:

  1. Verify dot_config exists and is compatible (PG read-only)
  2. If compatible → use it
  3. If not compatible → explain why and propose minimal alternative
  4. Report: config_strategy=REUSE_DOT_CONFIG|NEW_TABLE_JUSTIFIED

Step 3: IU Compatibility C-i (LOCKED)

Rules (non-negotiable):

  • ❌ KHÔNG dual-write IU triggers (IU triggers continue writing to iu_notification_event only)
  • ❌ KHÔNG migrate IU rows to event_outbox
  • ❌ KHÔNG modify fn_iu_unread / fn_iu_mark_read / fn_iu_notification_board signature or behavior
  • ✅ Optional: v_event_unified UNION ALL for cross-domain board queries
  • ✅ Optional: fn_event_unread(p_actor, p_domain) as new universal function (does NOT replace fn_iu_*)
  • IU convergence (Phase 3) is future, not Phase 2

Step 4: P3D4C1 Lessons Absorption

Agent reads P3D4C1 rev3 and maps concepts to universal design. Report which lessons reused.


Step 5: Payload Safety (schema-level requirement)

Agent must design payload governance INTO the schema:

  • payload_classification text NOT NULL DEFAULT 'safe_metadata' — column on event_outbox
  • safe_payload jsonb — allowlist approach
  • DENYLIST enforcement: trigger or CHECK pattern cấm keys: body, content, vector, secret, token, password, ssn, personal_data
  • correlation_id, causation_id — tracing fields, NOT payload
  • Idempotency: partial unique index on (event_domain, event_type, event_subject_ref, correlation_id) or similar

Step 6: Stream Taxonomy — task vs review resolution

Agent must propose concrete rule:

Stream When to use Example
review Content needs evaluation/approval Draft needs review
task Action needs to be performed (not content evaluation) Run health check, execute DOT

If overlap is irresolvable → merge into one stream with event_type distinguishing. Report: task_review_resolved=MERGED|SEPARATED|DEFERRED


Step 7: Đ43 Alignment Gate

Agent must choose 1:

Gate Condition
ADDITIVE_ONLY Universal event can coexist with Đ43 without schema/machinery changes
NEEDS_D43_REVIEW Some Đ43 section/schema needs amendment — flag for separate review
BLOCKED Cannot proceed without Đ43 changes

Specific checks: dot_config reuse, health events overlap, context-pack registration for new tables.


Step 8: Rollback/Failure-Mode Design

Even though P3D4C0Y is scope plan only, design note must include:

  • What happens if PoC fails? (DROP new tables, no IU impact)
  • What if worker hangs? (Advisory lock timeout, manual kill)
  • What if event_outbox grows too fast? (Retention policy sketch)
  • IU regression risk assessment (should be ZERO — IU not touched)

Step 9: Output — PoC Scope Plan

Path: knowledge/dev/laws/dieu44-trien-khai/design/23-p3d4c0y-universal-phase2-poc-scope-plan.md

A-I: Same as rev1 (domain, schema, compat, lessons, routing, streams, Đ43, roadmap, risk)

J. Implementation pack recommendation

next_required_pack=P3D4C1U_UNIVERSAL_CORE_IMPLEMENTATION_PROMPT_REVIEW
poc_domain=<chosen with PG evidence>
core_tables_count=<N>
registry_enforcement=A|B|C|D
pending_strategy=UNIVERSAL|PER_DOMAIN|HYBRID
config_strategy=REUSE_DOT_CONFIG|NEW_TABLE_JUSTIFIED
iu_compat=C-i (projection only, zero IU changes)
dieu43_gate=ADDITIVE_ONLY|NEEDS_D43_REVIEW|BLOCKED
estimated_implementation_effort=<LOW|MEDIUM|HIGH>

Verification

phase_status=PASS|FAIL
poc_domain_selected=<domain>
poc_domain_pg_inventory=PASS|FAIL
core_schema_designed=PASS|FAIL
event_type_registry_included=PASS|FAIL
registry_enforcement_mechanism=A|B|C|D
pending_strategy=UNIVERSAL|PER_DOMAIN|HYBRID
config_strategy=REUSE_DOT_CONFIG|NEW_TABLE_JUSTIFIED
iu_compat_ci_locked=PASS|FAIL
iu_no_dual_write=true
iu_no_row_migration=true
iu_fn_api_unchanged=true
p3d4c1_lessons_absorbed=PASS|FAIL
payload_safety_schema=PASS|FAIL
payload_denylist_enforced=PASS|FAIL
task_review_resolved=MERGED|SEPARATED|DEFERRED
dieu43_gate=ADDITIVE_ONLY|NEEDS_D43_REVIEW|BLOCKED
rollback_design=PASS|FAIL
not_activity_log=PASS|FAIL
no_pg_mutation=true
no_directus_mutation=true
no_nuxt_code=true
no_iu_runtime_change=true
no_p3d4c1_resume=true
next_required_pack=P3D4C1U_UNIVERSAL_CORE_IMPLEMENTATION_PROMPT_REVIEW

P3D4C0Y rev2 | PoC scope plan | PG inventory-backed | Non-executable | CHƯA dispatch | Chờ GPT/User final review

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/23-p3d4c0y-universal-phase2-poc-scope-plan-prompt.md