IU / 4-Mothers / Event Foundation — Requirement + Design Macro Report (2026-05-27)
IU / 4-Mothers / Event 5-Layer Foundation — Requirement + Design Macro Report
Path:
knowledge/dev/reports/architecture/iu-4mothers-event-foundation-requirement-design-2026-05-27.mdMacro:IU_4MOTHERS_EVENT_APPLICATION_REQUIREMENT_AND_DESIGN_6000XDate: 2026-05-27 (today's date per environment). Effort: high. Target runtime: 45–60 min. Outcome:IU_4MOTHERS_EVENT_FOUNDATION_REQUIREMENT_DESIGN_PASS(with limited write channel — see §10). Production mutation: NONE. DDL: NONE. DML: NONE. Qdrant: NONE.
1. CHANNEL_AND_SOURCE_PROOF
1.1 Drive files read
Folder: https://drive.google.com/drive/folders/1bOPTt0VSurdMde_xHYi77Je-q3W_RUrd — 11 files listed.
| File | id | Read |
|---|---|---|
| _STATUS (2026-05-25) | 1pZ5ROB4faFDzWlTkyKnjUkHRttiPAMTFrosyICTrWn4 |
✓ |
| step1-user-requirements-draft (v3 large 256 KB, 2026-05-25 07:42) | 1gHkpoShfH23tjc_jxmW8fTBY4I4X690Lo442V_L0qGM |
✓ — primary source |
| step1-user-requirements-draft (latest small 6.8 KB, 2026-05-25 14:18) | 1zjKwW3kBiROKOD9O03Sa7xaxNMF6I2qOmErPUkYBMto |
✓ |
| PHU-LUC-A_giao-dien-MOW-source-code (HTML/JS, 21 KB) | 1uy16CJ3lmH6llDroV18Gy5ZbAyH6cJaB |
✓ — UI ground truth |
| PHU-LUC-B_UI-quy-trinh-dong-goi (1.6 KB) | 1AQMEPrp9r6kdI5QpAKjDKFjXYayVjuDCA1cZALrS9Pc |
✓ |
| PHU-LUC-C_proposal-flow-source-code (HTML/JS, 14 KB) | 1soZ26oicp6-I4Omb6spmQCO691BhVnOQ |
✓ |
Not found in Drive search: Bắt sự kiện của PG(1).docx — title contains 'Bắt sự kiện' returned no rows. Event 5-layer requirements built from Điều 45 v1.0 + standard pattern; user invited to re-upload for reconciliation.
1.2 KB documents read
knowledge/dev/laws/constitution.md(v4.6.3 BAN HÀNH, rev 44).knowledge/dev/laws/dieu45-pg-native-queue-and-task-orchestration-law.md(v1.0 BAN HÀNH 2026-05-26, rev 21).knowledge/dev/laws/dieu34-workflow-law.md(DRAFT v1.0).knowledge/dev/laws/prompt-muc-tieu-mo-for-claude-code.md(v1.2).- KB index sampled (200 docs listed in
knowledge/dev/laws/andknowledge/dev/). - KB semantic searches:
Điều 45 queue event law enacted,prompt mục tiêu mở,IU foundation 6000x axis compose trigger sql dot,IU foundation post-CUT autowire split merge.
1.3 Live read-only PG survey
Channel proof: local zsh → ssh → docker exec postgres → psql.
current_database()=directus.current_user=context_pack_readonly(read-only role; write channel not available in this session — see §10).version()=PostgreSQL 16.13 (Debian 16.13-1.pgdg13+1).
Surveys executed (all read-only, statement_timeout 5 s, LIMIT enforced):
- 61 tables matching IU/event/queue/workflow/task/cut/dot/review patterns.
dot_configrows for queue/iu_core/runtime/composer/heartbeat namespaces.event_outboxper-type counts.- (event_type_registry: column
sourcenot present — query refused with clear error.) - (dot_iu_command_catalog: column
is_mutatingnot present — actual column ismutating. Noted.)
2. KB_STRUCTURE_DECISION
| Lifecycle | Path |
|---|---|
| Requirement / đầu bài | knowledge/dev/requirements/ |
| Design (master + critique + law plan) | knowledge/dev/design/ |
| Law (only after preconditions §12 of law plan met) | knowledge/dev/laws/ |
| Implementation (roadmap, migration packs, DOT packs) | knowledge/dev/implementation/ |
| Reports (macro, proof, acceptance) | knowledge/dev/reports/ |
This macro respects the decision.
3. CREATED_OR_UPDATED_DOCUMENTS
| # | Path | Status | Summary |
|---|---|---|---|
| 1 | knowledge/dev/requirements/iu-mow-mot-event-foundation-requirements.md |
created, rev 1 | Requirement brief: sources, current state, strategic goal, scope, non-negotiable constraints (20), 4 Mothers, Event 5-layer, IU compatibility, governance, scale, acceptance, open questions. |
| 2 | knowledge/dev/design/iu-mow-mot-event-foundation-design.md |
created, rev 1 | Master design: 6-tier architecture, responsibility boundaries, no-double-ownership matrix, 4-Mothers design, event 5-layer master design, governance lifecycle, data/event flows, reuse matrix, technology decision matrix, scale model, governance UI, layer diagram, packs needed next. |
| 3 | knowledge/dev/design/law-extraction-plan-application-process-workflow-task.md |
created, rev 1 | Law extraction plan: why a framework law is needed later, proposed name "Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc", what it governs, what it must not duplicate, relationship to Constitution + IU laws + Điều 45/34/28/33, candidate §1–§22 clauses, preconditions for drafting, drafting playbook, risks. |
| 4 | knowledge/dev/implementation/iu-4mothers-event-foundation-roadmap.md |
created, rev 1 | Implementation roadmap: 7 phases (0–6), parallel law-drafting track, operational readiness track, agent enablement track, risk register, next-macro recommendation. |
| 5 | knowledge/dev/design/assembly-first-open-source-integration-critique.md |
created, rev 1 | Critique of user's Assembly-First Open-Source Integration candidate strategy: 31-row critique matrix, cross-cutting critique, final recommended architecture, re-evaluation triggers, "decisions NOT yet made" list. |
| 6 | knowledge/dev/reports/architecture/iu-4mothers-event-foundation-requirement-design-2026-05-27.md |
this file | Macro report. |
4. LAW_BOUNDARY_DECISION
- New future law name: "Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc" (Application Process & Task Infrastructure Law).
- Law type: Framework law (luật khung). Like Điều 45 — invariants + boundaries, not table DDL.
- Governs: MOW boundary, MOT boundary, MOIT boundary, MOUT boundary, application workflow/task platform, workflow/task/config governance lifecycle, IU↔application relationship, application-level event use, proposal/Kaizen governance, no-double-ownership rules, application use of executor classes, one UI per role tier, long-running workflow resume-safe rule, governance UI surface principle.
- Does NOT govern: event_outbox/job_queue schemas + lifecycle (Điều 45); heartbeat caller obligation (Điều 45 §15.5); event_vs_job distinction (Điều 45 §6.6); work_state_machine invariant (Điều 45 §6.7); executor boundary clause (Điều 45 §11.5); cut pipeline (cut laws + Điều 45 §6 extensions); IU axis A/B/C and compose/split/merge (Điều 38 + Điều 39); approval quorum (Điều 32); display tech (Điều 28); 4-DB / 3-layer / NT3 exception (Điều 33); DOT lifecycle (Điều 35); birth registry (Điều 0-G); regression protection (Điều 30); system integrity (Điều 31); governance org (Điều 37); text-as-code / IU (Điều 38).
- Relationship to existing laws: References (does not redefine) Điều 45 for queue/event substrate; layers above Điều 34 (DRAFT) — recommended path: promote Điều 34 to enacted as workflow law nền, then layer Điều XX as application factory above; respects Hiến pháp v4.6.3 13 NT.
- Preconditions before drafting: §12 of law extraction plan — requirement + design stable, Phase 0–2 closed, Council Round 1 review of candidate clauses.
5. KEY_ARCHITECTURE_DECISIONS
| Concern | Role |
|---|---|
| IU | Smart knowledge brick. Axis A (source) + B (domain) + C (tree). Compose/split/merge/render/validate. Owned by IU laws (Điều 38 + Điều 39). Workflow step / task / form / output all reference iu_unit_id. |
| Task | Operational brick. 4-vùng layout (header / input via MOIT / reference via MOUT / instruction via IU). State machine. Two branches (automated / human). executor_class discriminator. Not an executor itself (Điều 45 §11.5). |
| Workflow | Ordered/conditional/parallel/sub graph of tasks + events. Owned by MOW; state machine in PG; resume-safe via snapshot + checkpoint. Proposal mode for change governance. |
| Event | Bus + job queue, owned by Điều 45 core. Application-level event types register in event_type_registry; schema versioned; trace_id propagated. |
| Queue / job | PG-native (event_outbox + job_queue + DLQ). Lease + heartbeat + retry + idempotency. Owned by Điều 45 — application uses it, never redefines. |
| Executor | Class registry: dot, sql, ai_agent, human, external_api, notification, render. Workers consume job_queue with class filter. Heartbeat mandatory. |
| Directus | API/admin layer only; not business owner. |
| Nuxt | Render shell only; never connects directly to queue/broker. Realtime via backend gateway. |
| Gateway | Separate concern (Nuxt server-route SSE to start, WS/Centrifugo later if profile demands). Filters by permission, emits summaries not raw events. |
6. EXISTING_INFRA_REUSE_MATRIX
(Full matrix in master design §12. Summary here.)
| Decision | Items |
|---|---|
| Keep + use as-is | event_outbox, event_pending, event_read, event_subscription, event_type_registry, job_queue, job_dead_letter, queue_heartbeat, cut_request*, dot_iu_command_catalog/run/runtime_lease, dot_operations/tools/domains/domain_rules, dot_config, iu_tree_path, iu_three_axis_envelope, iu_metadata_tag(registry), iu_sql_link, iu_piece_collection/membership, iu_relation, iu_lifecycle_log, iu_route, iu_qdrant_, iu_vector_sync_point, iu_notification_, iu_collection_template_, workflow_categories, iu_outbound_route. |
| Keep + EXTEND | workflows, workflow_steps, workflow_step_relations, workflow_change_requests, tasks, task_checkpoints, task_comments — extend with metadata columns and new sibling tables. |
| Keep + autowire (Phase 0) | fn_iu_post_cut_axis_materialize — wire from fn_cut_complete. |
| Create new | workflow_registry, workflow_step_def, task_def, field_registry, input_form_registry, output_table_registry, dot_function_registry, executor_class_registry, dlq_replay_request, input_form_proposal (or generic proposal), review_decision (if absent — survey Phase 0). |
| Deprecate later | None identified in this macro. |
Gaps (still open after this macro):
- post-CUT axis materialize not auto-wired into fn_cut_complete (memory note — to verify via Phase 0).
- split/merge live proof blocked on
review_decision_id(table existence not surveyed in this macro — schedule for Phase 0 entry). - queue.job_substrate.enabled=false; queue.worker.enabled=false; queue.notify.enabled=false; queue.dlq.replay_enabled=false → all gates need staged turn-on under governance.
Bắt sự kiện của PG(1).docxnot located in Drive search.- Workflow law (Điều 34) still DRAFT — needs Council decision (promote vs merge into new framework law).
7. IMPLEMENTATION_SEQUENCE (Phase 0 → 6)
| Phase | Macro name | Scope summary | Exit gate condensed |
|---|---|---|---|
| 0 | IU_POST_CUT_AUTOWIRE_SPLIT_MERGE_AND_EVENT_FOUNDATION_PHASE0_6000X |
autowire fn_iu_post_cut_axis_materialize; introduce review_decision; close split/merge gap; healthcheck row | post-CUT auto on cut_complete; split/merge end-to-end with review_decision_id; no regressions |
| 1 | EVENT_FOUNDATION_UPGRADE_PHASE1_6000X |
event_type_registry hardening, schema validator, executor_class_registry, dlq_replay_request, trace_id W3C, heartbeat caller template | producers refuse unregistered types at validated boundaries; 2 executor classes catalogued; replay flow with audit |
| 2 | MOT_MINIMUM_PHASE2_6000X |
task_def, tasks schema extension, MOT state machine, executor pool for dot + human, idempotency proof | MOT-not-executor proven; lease + heartbeat operational for 2 classes |
| 3 | MOW_CORE_PHASE3_6000X |
workflow_registry, workflow_step_def, state machine, advance loop, triggers 1/2/3 + composite, proposal mode, pilot Tuyển sinh 6-step + 1 nested | config-only workflow creation; proposal end-to-end; resume tested |
| 4 | MOIT_MOUT_FACTORY_PHASE4_6000X |
field_registry, input_form_registry, output_table_registry, dot_function_registry, validation engine, Nuxt zero-logic components | new field/form/output added by config; field governance refuses unregistered; permission filter live |
| 5 | GOVERNANCE_UI_PROBLEM_SURFACE_PHASE5_6000X |
Nuxt server-route SSE gateway, governance UI panels, summary aggregator, DLQ rescue, heartbeat panel | summary-first UI; DLQ replay via UI with audit; §15.5 violations surfaced |
| 6 | SCALE_HARDENING_PHASE6_6000X |
partitioning, indexes, retention, OTel SDK on workers, perf soak | p95 task pickup under target; archive automation; bounded DLQ |
Parallel track L (law drafting) per law extraction plan §13: survey at end of Phase 1, v0.1 at end of Phase 2, Council Round 1 mid-Phase 3, v0.2 end of Phase 3, Round 2 mid-Phase 4, enactment end of Phase 4.
8. OPEN_GAPS
Real gaps only — listed for visibility, not buried:
- post-CUT autowire —
fn_iu_post_cut_axis_materializeexists + catalogued but not invoked fromfn_cut_complete. Live verification needs Phase 0 channel (workflow_admin write). - split / merge with review_decision —
fn_iu_piece_split/fn_iu_piece_mergeexist but live proof needsreview_decision_id; table existence not surveyed (read-only role limited). Phase 0 will survey + create if absent. - Drive doc missing —
Bắt sự kiện của PG(1).docxnot findable. Event 5-layer drafted from Điều 45 + standard pattern. event_type_registrycolumn shape — read-only query failed on assumedsourcecolumn; will survey columns in Phase 1 entry.dot_iu_command_catalogcolumn shape — actual column ismutating, notis_mutating. Noted.- Workflow Law Điều 34 still DRAFT — Council decision required before law drafting (path A vs B in law extraction plan §8).
- Realtime gateway tech — not finalised (Nuxt server-route SSE default; revisit Phase 5).
- Long-running orchestrator — MOW native primary; Temporal evaluation deferred to post-Phase 6 with explicit triggers.
- Proposal table shape — generic vs per-domain. Default generic with discriminator; survey existing
workflow_change_requestsschema in Phase 3 entry. - KB write channel acceptance — 6 new docs uploaded via
mcp__claude_ai_Incomex_KB__upload_document(rev 1 each). PG/Directus mutation NOT performed (read-only role; production gate per macro spec).
Cleanly classified — every gap has a phase and a next action.
9. NEXT_RECOMMENDED_MACRO
→ IU_POST_CUT_AUTOWIRE_SPLIT_MERGE_AND_EVENT_FOUNDATION_PHASE0_6000X
Why this is next:
- Closes the IU gaps carried over from
IU_FOUNDATION_6000X_AXIS_COMPOSE_TRIGGER_SQL_DOT— without these, MOW/MOT cannot rely on IU as a stable knowledge brick. - Starts event foundation work in the same macro by setting up the trace_id W3C shape on
event_outbox+job_queue+ new run/task rows — this unlocks Phase 1. - Operational scope is bounded and verifiable — wire 1 function, create 1 table (review_decision if absent), add 1 healthcheck row, prove end-to-end with BEGIN/ROLLBACK regression. Fits the 6000x runtime envelope.
- Returns to closing current IU workstream FIRST as required by the macro balance rule (Section "BALANCE RULE" of the prompt) — does not skip ahead into MOW/MOT prematurely.
- Compatible with all enacted laws — uses Điều 35 DOT-pair, respects Điều 45 substrate, preserves Điều 38 IU contract.
After Phase 0 PASS → EVENT_FOUNDATION_UPGRADE_PHASE1_6000X (schema validator + executor_class_registry + DLQ replay + heartbeat caller template + trace_id contract finalised).
10. SAFETY + ACCEPTANCE NOTES
- No production mutation. Live PG access in this session is read-only (
context_pack_readonlyrole); PG/Directus/Qdrant left untouched. Future phases will use theworkflow_adminwrite channel per memory's proven SSH/docker-exec/psql stdin-pipe pattern. - 6 KB documents uploaded via the Incomex KB MCP tool — equivalent to the agreed lifecycle paths under
knowledge/dev/. KB documents are advisory; no law is now active by their existence. - 15/15 forbiddens preserved (no DDL/DML/Qdrant write, no alias touch, no PG write, no production gate flip, no migration applied, no DOT command run, no broker service deployed, no schema change, no force push, no destructive op, no cron job, no Nuxt deploy, no Directus mutation, no secret read, no test bypass).
- PASS verdict by macro spec acceptance criteria: requirement brief ✓, master design ✓, law extraction plan ✓, implementation roadmap ✓, macro report ✓, KB placement follows agreed structure ✓, framework-law boundary explicit ✓, Constitution + 14 NT + Điều 45/35/33/28/37/38/39 mapped ✓, no production mutation ✓, gaps explicit ✓.
End macro report.