IU / 4-Mothers / Event 5-Layer Foundation — Requirement Brief (DRAFT, 2026-05-27)
IU / 4-Mothers / Event 5-Layer Application Foundation — Requirement Brief
Path:
knowledge/dev/requirements/iu-mow-mot-event-foundation-requirements.mdStatus: DRAFT — đề bài chính thức, chờ user duyệt trước khi sang Master Design. Date: 2026-05-27 Author scope: macroIU_4MOTHERS_EVENT_APPLICATION_REQUIREMENT_AND_DESIGN_6000X. NOT A LAW. Requirement brief; mature binding rules will later be extracted into a new framework law (xemlaw-extraction-plan-application-process-workflow-task.md).
0. Sources read
| Loại | Tài liệu | Ghi chú |
|---|---|---|
| Drive | _STATUS (2026-05-25) |
Bước 1 chờ Huyên duyệt. |
| Drive | step1-user-requirements-draft (256403B, 2026-05-25 v3 Gemini integrated) |
Nguồn chính cho 4 Mothers + JFT + Trigger + UI MOW. |
| Drive | step1-user-requirements-draft (6788B, 2026-05-25 14:18 latest) |
Phiên bản tóm gọn. |
| Drive | PHU-LUC-A_giao-dien-MOW-source-code |
HTML/JS ground-truth UI MOW normal + proposal mode. |
| Drive | PHU-LUC-B_UI-quy-trinh-dong-goi |
Đóng gói cuối UI quy trình. |
| Drive | PHU-LUC-C_proposal-flow-source-code |
HTML/JS proposal flow add/edit/delete. |
| KB | knowledge/dev/laws/constitution.md v4.6.3 (rev 44) |
13 NT, NT12 DOT-pair, NT13 PG-first, Điều 43 enacted. |
| KB | knowledge/dev/laws/dieu45-pg-native-queue-and-task-orchestration-law.md v1.0 BAN HÀNH 2026-05-26 |
Queue/Event core law — đã ban hành. Không lặp lại. |
| KB | knowledge/dev/laws/dieu34-workflow-law.md DRAFT v1.0 |
Khung workflow đã có draft — cần check trùng với MOW. |
| KB | knowledge/dev/laws/dieu38-normative-document-law.md + dieu38-trien-khai/* (text-as-code, IU) |
Nền IU đang trên D38. |
| KB | knowledge/dev/laws/dieu39-v2.1-amendment.md + agent-api-registry |
IU knowledge graph law. |
| KB | knowledge/dev/laws/dieu35-dot-governance-law.md v5.2 FINAL |
DOT lifecycle/run modes. |
| KB | knowledge/dev/laws/dieu37-governance-organization-law.md v3.3 |
Governance org boundary. |
| KB | knowledge/dev/laws/dieu33-postgresql-law.md v2.1 |
4-DB / 3-layer / NT3 exception. |
| KB | knowledge/dev/laws/prompt-muc-tieu-mo-for-claude-code.md v1.2 |
Prompt standard. |
| KB | knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-120x-three-axis-metadata-delivery-autocut-textcode-open-goal/07-final-report.md |
IU Core 120x report. |
| Memory | Latest IU foundation macro IU_FOUNDATION_6000X_AXIS_COMPOSE_TRIGGER_SQL_DOT |
Verified results (channel PASS, axis PASS, compose PASS, split/merge PARTIAL). |
Outstanding: file Bắt sự kiện của PG(1).docx not found in Drive search — its 5-layer event design is summarized from memory + standard pattern; concrete adoption will be reconciled in design step if user re-uploads.
1. Current state (live evidence, 2026-05-27)
Channel proof PASS. local zsh → ssh contabo → docker exec postgres → psql; DB=directus; user=context_pack_readonly; PG 16.13.
Live PG read-only survey:
- 61 IU/queue/task/workflow tables already exist under
public.*andiu_core.*. - Workflow substrate already present:
workflows,workflow_steps,workflow_step_relations,workflow_change_requests,workflow_categories. - Task substrate already present:
tasks,task_checkpoints,task_comments. - IU foundation present:
information_unit,iu_tree_path,iu_three_axis_envelope,iu_metadata_tag,iu_sql_link,iu_piece_collection,iu_piece_membership,iu_relation,iu_collection_template_registry,iu_collection_template_version,iu_collection_template_instance_lineage,iu_lifecycle_log,iu_route_*,iu_qdrant_collection_registry,iu_vector_sync_point,iu_notification_event, etc. - Event/queue substrate present:
event_outbox,event_pending,event_read,event_subscription,event_type_registry,job_queue,job_dead_letter,queue_heartbeat,cut_request,cut_request_transition. - DOT substrate:
dot_config,dot_iu_command_catalog,dot_iu_command_run,dot_iu_runtime_lease,dot_operations,dot_tools,dot_domains,dot_domain_rules.
Gate snapshot (dot_config):
| key | value | meaning |
|---|---|---|
iu_core.composer_enabled |
false | composer gate closed |
iu_core.auto_instantiate_enabled |
false | auto-instantiate off |
iu_core.delivery_enabled |
false | delivery off |
iu_core.three_axis_auto_refresh_enabled |
false | axis auto-refresh off |
iu_core.structure_ops_enabled |
false | split/merge runtime off |
iu_core.vector_sync_enabled |
false | Qdrant sync off |
iu_core.routes_master_enabled |
true | router master on |
iu_core.route_worker_enabled |
true | route worker on |
queue.runtime.phase |
phase2_governance |
queue in phase 2 |
queue.job_substrate.enabled |
false | DP2 substrate not selected |
queue.heartbeat.enabled |
true | heartbeat on, 300s |
queue.worker.enabled |
false | worker disabled |
queue.dlq.replay_enabled |
false | DLQ replay off |
queue.notify.enabled |
false | LISTEN/NOTIFY off |
queue.lease.reaper_enabled |
false | reaper off, dry-run only |
queue.lease.duration_sec |
300 | lease |
queue.retry.max_attempts_default |
5 | retry default |
queue.retry.backoff_base_sec |
10 | backoff base |
event_outbox row counts by type:
issue_opened140 580 (dominant — operations layer)piece_added_to_collection224structure_op_applied59collection_created44piece_reordered18structure_piece_deprecated12collection_rendered3piece_removed_from_collection1
Latest IU foundation results (from memory + IU Core 120x PASS):
- tree axis PASS, domain axis PASS, compose PASS (create/add/reorder/remove/render/validate).
- split/merge PARTIAL_WITH_EXACT_GAP — needs
review_decision_id. - trigger model PASS.
- SQL link PASS.
- post-CUT automation PARTIAL —
fn_iu_post_cut_axis_materializeexists, registered, but not auto-wired intofn_cut_complete.
2. Strategic goal
Mở rộng nền tảng IU hiện tại thành hạ tầng ứng dụng quy trình dài hạn của Incomex:
- Smart Information Unit (IU) là viên gạch tri thức.
- MOW / MOT / MOIT / MOUT là 4 nhà máy mẹ sinh ra mọi workflow / task / form / report bằng config.
- Event 5-layer là dây thần kinh kết nối tất cả.
- Sản phẩm cuối: kỹ năng "config trong vài phút" để tạo quy trình/nhiệm vụ mới — không code tay.
Quy mô đích:
- 10 000+ workflow, 100 000+ task, 1 000 000+ IU theo thời gian.
- Workflow 2-3 bước, 100+ bước; chạy giờ → ngày → tháng → năm.
- Nested/sub-workflow, human-in-the-loop, fully automated, hybrid.
- Proposal/Kaizen mode cho mọi cấp độ user.
3. Scope
In scope (đề bài lần này):
- Yêu cầu chính thức cho 4 Mothers (MOW, MOT, MOIT, MOUT).
- Yêu cầu chính thức cho Event 5-layer ứng dụng (không cướp core của Điều 45).
- Yêu cầu tương thích IU foundation + post-CUT autowire + split/merge với review decision.
- Yêu cầu governance UI (proposal mode, problem-only surface, DLQ rescue).
- Đầu vào cho law extraction plan (xem file riêng).
Out of scope (lần này):
- Triển khai code/migration thực tế.
- Mở luật mới chính thức (chỉ lập kế hoạch).
- Lựa chọn cuối cùng cho công nghệ broker (Temporal/NATS/Hasura) — chỉ frame quyết định.
- Mặt phẳng UI chi tiết MOIT/MOUT (lưới render Nuxt) — chỉ contract.
- Workflow đặc thù nghiệp vụ (sẽ thuộc Phase 3 trở đi).
4. Non-negotiable constraints (must preserve)
Bám sát Hiến pháp v4.6.3 và 13 nguyên tắc + các luật đã ban hành:
- PG-first (NT13). Mọi business state cuối cùng nằm trong PG.
- Native / config-driven (NT2/NT4). Không hardcode logic nghiệp vụ trong Nuxt/Directus.
- DOT 100% (NT12, Điều 35 v5.2). Mọi mutation đi qua DOT-pair; không raw SQL tay khi vận hành.
- Nuxt = render shell (Điều 28, S178). Không business logic.
- Directus = API/admin layer, không phải executor.
- PG → Directus → Nuxt assembly path (Điều 33 v2.1).
- No direct PG from Nuxt (NT13 + Điều 33 §3 layer boundary).
- Queue carries signal/ref, not heavy data (Điều 45 §6.6, §6.7).
- Event vs Job distinction (Điều 45 §6.6).
- Executor boundary (Điều 45 §11.5). MOT là người gọi việc, không phải executor.
- MOW = orchestrator, không thực thi business work trực tiếp.
- No cross-IU vector pollution (vector law: 1 IU = ≥1 Qdrant point, không trộn).
- 5-layer sync where applicable: PG, Directus, Nuxt, AgentData/KB, Qdrant.
- Governance before use (Điều 0-G Birth Registry, Điều 32 Approval): field/form/workflow/task/event/schema phải sinh → duyệt → registry → mới được dùng.
- Reversible by default (Điều 30 Regression Protection, Điều 31 Integrity).
- Audit / evidence first (Điều 31 v1.2, Điều 38 text-as-code).
- Old report is evidence; live state wins.
- No double ownership — Điều 45 sở hữu queue/event core; IU laws sở hữu IU internals; luật mới chỉ sở hữu lớp ứng dụng workflow/task.
- Forward-compat for customer-care/email/MOT (Điều 45 §13.4).
- Heartbeat caller obligation — bất kỳ worker mới nào phải emit heartbeat (Điều 45 §15.5).
5. Hierarchy + JFT + Trigger
5.1 Business hierarchy (6 tầng)
Field → Task → Nhiệm vụ → Chuyên môn → Phòng ban → Công ty → Lĩnh vực
(T1) (T2) (T3) (T4) (T5) (T6)
- Task = đơn vị nguyên tử, làm xong → biến mất → trigger task tiếp.
- Nhiệm vụ = workflow nhỏ (n × Task).
- Chuyên môn = tập Nhiệm vụ liên đới, kích hoạt bằng Trigger (đơn / tổ hợp).
- Phòng ban = nhiều Chuyên môn.
- Công ty = nhiều Phòng ban.
- Lĩnh vực = nhiều Công ty (≥90% quy trình giống nhau — lý do hệ thống khuôn đúc có giá trị).
5.2 JFT — Just Fix Time
JFT ≠ JIT (Toyota). JFT cho luồng công việc số:
- Đúng task, đúng người, đúng thời điểm.
- Deadline cứng, escalation tự động khi trễ.
- Hệ thống nhớ hộ — nhân sự không cần nhớ next step.
- Làm xong → biến mất → next task tự xuất hiện (trigger).
5.3 Trigger types (3 loại + tổ hợp)
- Thời gian / lịch trình (cron-like). Ví dụ: báo cáo tháng → ngày 1 hàng tháng.
- Output của Task/Nhiệm vụ trước (có thể có điều kiện). Ví dụ: QC=Đạt → trigger nhập số; QC=Không đạt → trigger trả hàng.
- Thủ công (human-pressed). Ví dụ: khiếu nại khách → nhân viên tạo task xử lý.
- Tổ hợp AND/OR — ví dụ: duyệt HĐ = (KT AND GĐ) OR (HĐ<50tr AND TP).
Config trigger lưu trong workflow_registry (PG) — KHÔNG hardcode.
6. The 4 Mothers — requirements
6.1 MOW — Mother of Workflows
Mục đích. Workflow engine sinh mọi quy trình nghiệp vụ Incomex bằng config.
Phải có:
- Workflow registry (PG) — định nghĩa graph/list các step + trigger config.
- Workflow state machine — pending → running → paused → completed → failed → archived (chi tiết trong design).
- Conditional branching, parallel steps, sub-workflows.
- Pause / resume / human approval gate / timeout / escalation / retry / audit / replay.
- IU làm nền tri thức (mô tả quy trình + mô tả từng bước).
- Task làm nền thực thi (mỗi step → ≥1 task).
- Proposal mode UI (xem
PHU-LUC-A/B/C): user thêm/sửa/xóa step → hàng đợi phê duyệt; không ghi thẳng workflow_registry. - Một UI duy nhất cho mọi role — backend filter permission.
- Long-running workflow (days → year) phải có resume-safe state, snapshot, replay.
Không được:
- MOW không thực thi business work trực tiếp; chỉ orchestrate.
- MOW không sở hữu queue core (thuộc Điều 45).
- MOW không sở hữu IU internals (thuộc IU/Điều 38/Điều 39).
6.2 MOT — Mother of Tasks
Mục đích. Task engine sinh mọi loại công việc cụ thể bằng config.
Cấu trúc 4 vùng (fixed layout, flexible content):
- HEADER — tên / mã / PIC / thời gian / status / metadata label.
- VIỆC CẦN LÀM (MOIT render) — form input từ registry.
- THÔNG TIN THAM KHẢO (MOUT render) — output từ DB, context-aware.
- HƯỚNG DẪN — text/video/audio/sơ đồ, format khai báo qua config.
Hai nhánh task:
- A. Fully automated (AI/DOT/SQL/external API executor).
- B. Human-in-the-loop (UI shell + human input).
Phải có:
- Task registry (PG) — kế thừa
taskstable hiện có, mở rộng schema. - Task state machine + deadline + escalation + retry + idempotency.
- Correlation/trace tới workflow + event stream.
- Subscriptions (trigger in) + emissions (trigger out).
- Input/output/reference field model link tới field_registry.
- 2 luồng ghi: direct vs queue/approval (config flag).
Không được:
- MOT KHÔNG phải executor (Điều 45 §11.5). MOT mô tả việc; executor là class riêng (DOT/SQL/AI/Human/External).
- MOT không sở hữu approval logic (thuộc Điều 32).
6.3 MOIT — Mother of Input Tables
Mục đích. Sinh mọi bảng/form nhập liệu bằng config.
Phải có:
field_registry(PG) — chỉ field đã duyệt mới được render.input_form_registry(PG) — mỗi form = 1 record + JSON array of field_ids + routing_channel (direct/queue) + collection_destination + staging_collection + task_type + status.- Validation rules per field (data_type, required, min/max, regex, enum, cross_field).
- DOT assembly layer: đọc registry → kiểm tra field → ghép form structure + validation.
- Nuxt component
<MOITForm formId="…" />— zero logic, chỉ fetch + render. - 2 luồng: direct ghi thẳng collection_destination, queue qua staging + MOW approval.
Không được:
- Không có form độc lập ngoài registry.
- Không hardcode validation trong Nuxt.
- Không bypass field_registry.
6.4 MOUT — Mother of Output Tables
Mục đích. Sinh mọi bảng/báo cáo hiển thị bằng config.
Phải có:
output_table_registry(PG).- DOT Function Registry — mỗi aggregation = 1 named function (fn_doanh_thu_theo_thang, fn_ton_kho_hien_tai, …).
- Computed fields layer: generated columns + materialized views + DOT functions.
- 2 loại MOUT: inline (trong MOT vùng 3, context-aware) + matrix độc lập (route riêng).
- Realtime via gateway (không trực tiếp queue).
- Permission filter at backend.
- Nuxt component
<MOUTTable tableId contextId />— zero logic.
Không được:
- Không viết query mới mỗi lần có yêu cầu báo cáo mới.
- Không direct DB from Nuxt.
7. Event 5-layer — application requirements
Tham chiếu Điều 45 cho core; KHÔNG redefine.
7.1 Layer 1 — Event Producers
Sources (qua Điều 45 §6 outbox/trigger model):
- PG changes (trigger DML → outbox).
- IU changes (axis refresh, compose, structure_op).
- DOT command lifecycle.
- Cut pipeline (cut_request_transition).
- Workflow state changes.
- Task state changes.
- Proposal submissions (Kaizen).
- Human decisions (approval).
- Agent outputs.
- External APIs (approved adapter only).
Yêu cầu:
- Event type phải đăng ký trong
event_type_registrytrước khi emit. - Schema versioned (semver).
- Producer KHÔNG chứa business execution logic.
- "Capture by config" — thêm event type mới = INSERT vocab + register, không deploy code.
7.2 Layer 2 — Event Broker / Message Bus
Tham chiếu Điều 45 §6.6 event_vs_job + §6.7 work_state_machine.
Yêu cầu:
- Phân biệt event bus (pub/sub, fanout) vs job queue (durable, lease, retry, DLQ).
- Queue carry signal/ref, not heavy payload (Điều 45 §13.5).
- Topic / routing key / priority.
- Multiple consumers fan-out.
- Substrate là PG-native trước (event_outbox + job_queue), có thể wrap thêm broker sau khi scale yêu cầu.
7.3 Layer 3 — Consumers / Workers / Executors
Executor type registry (Điều 45 §11.5):
- DOT executor (DOT command).
- SQL/function executor (PG function direct).
- AI agent executor.
- Human-review executor (queue task vào UI).
- External API executor.
- Notification executor.
- Render/rebuild executor (post-CUT axis materialize, vector reindex).
Yêu cầu chung:
- ACK / NACK / retry / timeout / idempotency / replay.
- Poison message isolation → DLQ.
- Lease + heartbeat (Điều 45 §15.5).
- Trace_id + correlation_id.
Boundary:
- MOT KHÔNG phải executor.
- MOW orchestrates; executor executes.
7.4 Layer 4 — Realtime Gateway
Yêu cầu:
- Nuxt KHÔNG kết nối trực tiếp queue/broker.
- Backend realtime gateway (WebSocket/SSE) đứng giữa.
- Filter by permission + relevance.
- Governance UI nhận SUMMARY + RED FLAG + PROGRESS, không raw event noise.
7.5 Layer 5 — DLQ / Recovery / Governance
Yêu cầu:
- DLQ (
job_dead_letterđã có) — retry policy / replay policy / poison isolation. - Idempotency keys.
- Trace_id / correlation_id.
- Schema registry compatibility (forward + backward where contract allows).
- Audit timeline view.
- Governance UI:
- chỉ show problems.
- aggregate counts (1 dòng/category).
- concise AI/worker-generated status summaries.
- drill-down on demand.
- DLQ replay / rescue interface (require approval).
8. IU compatibility requirements
IU là viên gạch tri thức. Mọi 4 Mothers phải reuse, KHÔNG duplicate:
- Source axis (A) — document/source provenance.
- Domain axis (B) — professional/section type.
- Tree axis (C) — parent-child.
- Compose ops — create / add / reorder / remove / render / validate (PASS).
- Split / Merge — cần
review_decision_id(gap còn lại). - Trigger in/out — đã có model PG-native.
- SQL link — gắn IU với SQL view/function.
- Tag / domain governance —
iu_metadata_tag+iu_metadata_tag_registry. - Event hooks — IU events emit qua event_outbox.
- Post-CUT materialization —
fn_iu_post_cut_axis_materialize(exists, not auto-wired to fn_cut_complete).
Workflow / task / form mô tả phải neo vào IU (tham chiếu unit_id) để có ngữ cảnh tri thức, không tạo bản sao mô tả.
9. Task as operational brick
Yêu cầu:
- Task có schema chuẩn (4 vùng).
- Task có state machine.
- Task có metadata link tới: workflow_id, iu_id (description), input_form_id, output_table_id, executor_class, deadline, escalation_policy, retry_policy.
- Task không sở hữu execute logic; gọi executor.
- Task emits event (created/assigned/started/completed/failed/escalated).
10. Governance model
- Field governance: field sinh → duyệt → field_registry → MOIT mới dùng.
- Form governance: form sinh → duyệt → input_form_registry → MOT mới render.
- Workflow governance: step add/edit/delete đi qua proposal mode → workflow_change_requests (table đã có) → MOW approval → workflow_registry.
- Task type governance: task_type new = đăng ký + duyệt.
- Event type governance: event_type_registry mandatory before emit.
- Schema governance: D38 birth gate (D0-G) áp dụng cho text unit + component.
- Proposal queue: mọi đề xuất Kaizen vào hàng đợi phê duyệt — UI giống nhau cho mọi role, backend filter.
11. Scale requirements
- Workflow: 10 000+ (config-driven generation).
- Task: 100 000+ concurrent (lease + heartbeat + reaper).
- IU: 1 000 000+ over time (partition iu_lifecycle_log, archive policy).
- Workflow length: 2 → 100+ step.
- Workflow duration: phút → 1 năm (resume-safe).
- Nested/sub-workflow: phải support correlation chain.
12. Acceptance criteria (cho lần này, level requirement)
PASS nếu:
- Requirement brief này tồn tại trong KB và link tới design + law plan + roadmap.
- Mọi mục [Required Content Details 1-11 của macro] có mặt.
- Live state đã được verify; gaps đã được nêu rõ.
- Constitution + 14 nguyên tắc + Điều 45/35/33/28/37/39/38 đã map.
- Đề bài cấm:
- Cấm cướp queue/event core của Điều 45.
- Cấm duplicate IU laws.
- Cấm bypass DOT-pair.
- Cấm direct PG from Nuxt.
- Cấm MOT thành executor.
- Cấm Nuxt holds business logic.
PARTIAL_WITH_EXACT_GAP nếu:
- Drive doc
Bắt sự kiện của PG(1).docxkhông tìm thấy ⇒ event 5-layer detail dùng pattern chuẩn + Điều 45 (ghi chú). - KB write channel limited; chỉ tạo được requirement + design + plan + roadmap, chưa upload macro report.
13. Open questions (cần user/Council trả lời trước khi vào implementation)
- MOW vs Điều 34 Workflow Law (DRAFT v1.0). Điều 34 đang là draft. MOW định nghĩa workflow engine. Đề xuất: nâng Điều 34 thành law nền, MOW là implementation; HOẶC merge Điều 34 vào new law. Quyết định: chờ Council.
- Realtime gateway technology — Nuxt SSE in-process? Hoặc tách microservice (Node WS, Hasura subscription, Centrifugo)?
- Long-running workflow engine — PG-native state machine đủ chưa, hay cần Temporal/Camunda? Default: PG-native + cron + outbox cho đến khi profile chứng minh không đủ.
- proposal_queue tách hay reuse workflow_change_requests? Live đã có table
workflow_change_requests— đề xuất reuse. - MOT 2 nhánh (auto/human) — chung 1 schema task hay 2 task_type khác nhau? Đề xuất: chung schema, executor_class field discriminator.
- MOUT realtime — push (gateway) hay pull (polling)? Đề xuất: push cho governance dashboard, pull cho report tĩnh.
- Field validation cross-field — chạy ở DOT assembly (PG side) hay Nuxt? Đề xuất: PG side (validate input trước khi staging).
- review_decision_id schema — đã có table chưa, hay cần tạo? Khảo sát thêm trong design.
14. Next document
→ knowledge/dev/design/iu-mow-mot-event-foundation-design.md (Master Design).
→ knowledge/dev/design/law-extraction-plan-application-process-workflow-task.md (Law extraction plan).
→ knowledge/dev/implementation/iu-4mothers-event-foundation-roadmap.md (Implementation roadmap).
→ Macro report → knowledge/dev/reports/architecture/iu-4mothers-event-foundation-requirement-design-2026-05-27.md.
End requirement brief.