KB-45F5 rev 2

IU-Centered 4 Mothers + Event Foundation — Requirement Brief Rev2 (MP1–MP6 patched, DOC-ONLY, 2026-05-27)

45 min read Revision 2
requirementsrev2rev2-mp1-6iu-centered4-mothersmowmotmoitmoutevent-foundationevent-5-layer9-state-uitraffic-lightwaiting-sublabelsa11ywcag-2-1-aaworkflow-status-rollupevidence-levelcandidate-registriesold-infra-coverage-matrixconstitution-matrixpg-maximization-maposs-7-labelsdieu-34-decision-pathfinal-approval-gatedoc-only2026-05-27

IU-Centered 4 Mothers + Event Foundation — Requirement Brief Rev2

Path: knowledge/dev/requirements/v0.6-iu-4mothers-event-foundation-rev2/00-requirement-brief-rev2.md Status: DRAFT Rev2 (MP1–MP6 patched) — đầu bài chính thức, DOCUMENT ONLY. Chờ user duyệt trước khi soạn Master Design Rev2. Date: 2026-05-27 (revision 2; MP1–MP6 applied after GPT Council review iu-4mothers-event-requirement-rev2-gpt-review-2026-05-27.md) Supersedes: knowledge/dev/requirements/iu-mow-mot-event-foundation-requirements.md (rev1). MP log: MP1 evidence_level column + 4 candidate registry rows (§12); MP2 raw-source wording (header + §17); MP3 waiting sublabels (§7.3.6); MP4 a11y traffic-light (§7.3.7); MP5 workflow roll-up principle (§7.2.6); MP6 final approval gate (§21). Patches encoded: knowledge/dev/requirements/iu-centered-4mothers-event-design-patch-instruction-2026-05-27.md, knowledge/dev/reports/architecture/iu-4mothers-event-foundation-council-review-gpt-2026-05-27.md, knowledge/dev/reports/architecture/iu-4mothers-event-foundation-council-review-gpt-addendum-2026-05-27.md, knowledge/dev/reports/architecture/iu-4mothers-event-foundation-gpt-recheck-after-drive-upload-2026-05-27.md. Uploaded sources reconciled: 4 mẹ mở rộng.txt, Bắt sự kiện của PG(3).docx. Raw source đã có qua uploaded files trong phiên rev1; Rev2 dùng iu-4mothers-event-foundation-gpt-recheck-after-drive-upload-2026-05-27.md (GPT recheck report) làm accessible consolidation source. Nếu Council cần direct raw-source audit, raw files sẽ được upload vào KB ở vòng document-only riêng. KHÔNG claim raw source tuyệt đối không truy cập được. NOT A LAW. Requirement brief duy nhất; mature binding rules sẽ được trích sang Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc ở law-extraction-plan riêng (rev1 vẫn còn hiệu lực).


§0. User Approval Gate (mandatory front section)

This brief is DOCUMENT ONLY. Until the user explicitly accepts Rev2:

  • KHÔNG Master Design Rev2.
  • KHÔNG implementation macro.
  • KHÔNG law drafting/enactment.
  • KHÔNG final OSS tool selection.
  • KHÔNG PG / Directus / Qdrant / vector mutation.
  • KHÔNG migration / DOT command run / law enactment.

Design content, if mentioned at all, appears only as "design implications" to support requirement framing — never as design decisions.

The brief becomes baseline for Master Design Rev2 after explicit user approval.


§1. Why Rev2 exists — gap of Rev1 in one sentence

Rev1 declared "workflow/task tham chiếu IU" nhưng để IU ở vai trò registry tham chiếu. Rev2 nâng IU thành đơn vị lắp ráp tái sử dụng mà mọi step / task / form / output / event / governance đều lắp quanh. 4 Mothers chuyển từ "hệ thống riêng có pointer sang IU" → "khuôn đúc đúc quy trình quanh IU".


§2. IU-Centered Doctrine (binding, non-negotiable)

D2.1 Đơn vị thông tin là trung tâm kiến trúc. Mọi quy trình, dù 2 bước hay 500 bước, bắt buộc được lắp từ IU-backed steps hoặc IU bundles. Không có "workflow artifact riêng tách rời IU".

D2.2 Build-once, reuse-many. Một IU mô tả nội dung/chính sách/hợp đồng IO chỉ tồn tại đúng một bản nguồn; mọi step/task/form/output/notification chỉ render hoặc bind tới IU đó, không sao chép thân nội dung.

D2.3 No duplicate text invariant. Bất kỳ nơi nào trong runtime hiển thị/đẩy instruction, input contract, output contract, policy text — phải đi qua IU reference + render layer. Cấm copy thân instruction vào tasks.body, vào workflow_step_def.description_text v.v.

D2.4 4 Mothers là khuôn đúc, không phải hệ thống riêng. MOW/MOT/MOIT/MOUT chỉ định hình luồng/giao diện/contract IO quanh IU; không sở hữu nội dung IU, không sở hữu queue/event core.

D2.5 Uniform assembly primitive. 2-step workflow và 500-step workflow phải dùng cùng một primitive lắp ráp (IU-backed step brick + bundle). Không tạo schema riêng cho workflow dài.

D2.6 Editing IU propagates by version policy. Sửa instruction trong IU một lần — task/workflow tương lai dùng version mới theo policy; workflow đang chạy pin version cũ; không cần đi sửa rải rác trong nhiều bảng.


§3. Information Unit as Process Brick (requirement fields)

Mỗi IU khi tham gia 4 Mothers phải lộ ra (qua registry/binding) các trường tối thiểu sau (binding requirement; design định nghĩa schema):

Field Mục đích
iu_unit_id Brick id ổn định
iu_version_id Version pin để workflow ổn định
iu_role_in_process instruction | decision_gate | input_contract | output_contract | policy | checklist | SOP | validation_rule | event_hook | report_context
assembly_slot MOW step slot / MOT region (header/input/reference/instruction) / MOIT field group / MOUT block
precondition_config Trigger/guard rules by config
postcondition_config Emitted events, output contracts, next-step signal
io_contract_refs Link tới MOIT/MOUT schemas
executor_class_ref DOT / SQL / AI / human / external / notification / render
event_contract_ref Event type(s) produced/consumed (đã register-before-emit)
kg_edge_refs Semantic deps / related IU / required context pack (Điều 39)
governance_state proposed | approved | active | deprecated | archived

Boundary: IU không sở hữu execute logic. IU lưu tri thức ổn định + typed relations + contracts + governance metadata. Runtime execution vẫn ở MOW/MOT/executors/queue/event core.


§4. IU Bundle / Step Pack (avoid over-merge, support typed composition)

R4.1 Khi một step cần nhiều IU members, không ép merge IU; thay vào đó định nghĩa IU Bundle (a.k.a. Step Pack): N IU members + ordered slots + typed roles, version + governance riêng, lắp ráp qua PG registry — không hardcode.

R4.2 Bundle có thể đại diện cho: 1 workflow step / 1 task instruction pack / 1 form context / 1 output-report context.

R4.3 KG (Điều 39) khuyến nghị tạo bundle thay vì merge khi co-usage đủ mạnh nhưng semantics còn tách biệt.

R4.4 Bundle là first-class brick: workflow_step_def có thể bind tới (a) 1 IU, (b) 1 IU bundle, (c) typed IU assembly view, (d) task template IU-backed.


§5. 4 Mothers (patched around IU)

§5.1 MOW — IU Assembly Orchestrator

  • MOW không duplicate IU content; chỉ sở hữu graph assembly trên IU-backed step bricks.
  • MOW chọn next step bằng event/trigger/condition; payload step là IU/IU-bundle reference + config.
  • MOW hỗ trợ uniformly: 2-step và 500-step là cùng một phép lắp graph.
  • Proposal mode đổi graph/bundle bindings, không copy text.
  • Long-running (giờ → năm) phải resume-safe, snapshot, replay; pin IU version theo policy.
  • KHÔNG sở hữu queue core (Điều 45), KHÔNG sở hữu IU internals (Điều 38/39), KHÔNG sở hữu approval (Điều 32).

§5.2 MOT — IU-Backed Task Envelope

  • Task là envelope vận hành quanh IU-backed instruction/context/IO contracts.
  • 4 vùng UI render từ ref, không copy:
    • Header = task runtime metadata (id, PIC, deadline, status).
    • Input = MOIT contract referenced (IU-context-aware).
    • Reference = MOUT contract referenced (IU-context-aware).
    • Instruction = IU hoặc IU bundle (text/video/audio/sơ đồ, format declared in config).
  • Automated task dùng cùng IU-backed contract, không UI.
  • MOT KHÔNG executor (Điều 45 §11.5); MOT gọi executor class.
  • MOT KHÔNG sở hữu approval logic.

§5.3 MOIT — IU-Context-Aware Input

  • field_registry + input_form_registry vẫn là SoT cho field/form.
  • Mỗi field entry có thể link tới IU mô tả ý nghĩa/policy/validation.
  • Form không là đảo: bound vào IU-backed task/step context.
  • Direct vs staging/approval là config policy gắn vào form/field/task context.
  • DOT assembly: registry → kiểm tra field → ghép form structure + validation.
  • Nuxt <MOITForm formId /> zero logic.

§5.4 MOUT — IU-Backed Output Views

  • Output/reference/report blocks là IU-backed views của state PG/Directus.
  • Report khai báo iu_id source + SQL/DOT function link; computed fields qua generated columns / materialized views / DOT functions.
  • 2 dạng: inline (trong MOT vùng 3, context-aware từ task IU) + matrix độc lập (route riêng).
  • Realtime qua governed gateway, không trực tiếp queue.
  • Nuxt <MOUTTable tableId contextId /> zero logic.
  • Permission filter ở backend (không Nuxt-side).

§6. Event 5-Layer (reconciled với Bắt sự kiện của PG(3).docx)

Tham chiếu Điều 45 cho core; không redefine.

§6.1 Layer 1 — Event Producers

  • Producers chỉ emit events; không chứa business execution logic.
  • Sources: PG DML trigger → outbox; IU axis refresh/compose/structure_op; DOT command lifecycle; cut pipeline transitions; workflow/task state changes; proposal submissions (Kaizen); human decisions; agent outputs; external APIs qua approved adapter.
  • Register-before-emit: event type bắt buộc nằm trong event_type_registry trước khi producer emit.
  • Schema JSON versioned (semver) trong PG.
  • "Capture by config": thêm event type = INSERT vocab + register, không deploy code.

§6.2 Layer 2 — Broker / Event Bus

  • Tách bạch event bus (pub/sub, fanout) vs job queue (durable, lease, retry, DLQ). Queue không thay vai trò event bus.
  • Queue carry signal/ref, không body nặng (Điều 45 §13.5).
  • Topic / routing key / priority.
  • Multiple consumers fan-out.
  • Substrate hiện tại: PG-native (event_outbox + job_queue). Wrap thêm broker chỉ khi profile chứng minh (NATS/Redis Streams) — không tự ý đổi.
  • Queue không tự chạy script. Queue chỉ schedule/route; chỉ worker mới execute.

§6.3 Layer 3 — Consumers / Workers / Executors

  • Executor class registry (Điều 45 §11.5): DOT / SQL/function / AI agent / Human-review / External API / Notification / Render/rebuild.
  • ACK / NACK / retry với exponential backoff / timeout / idempotency key bắt buộc / replay.
  • Poison message isolation → job_dead_letter.
  • Lease + heartbeat (Điều 45 §15.5) — mọi worker mới phải emit heartbeat ngay từ ngày bật.
  • trace_id (W3C shape) + correlation_id + parent_span_id luôn carry trên event/job.
  • MOT KHÔNG executor. MOW orchestrates; executor executes.

§6.4 Layer 4 — Realtime Gateway

  • Nuxt KHÔNG kết nối trực tiếp core queue / event_outbox / NOTIFY channels.
  • Backend realtime gateway (WebSocket/SSE) đứng giữa; filter permission + relevance backend-side trước khi event rời vùng tin cậy.
  • Governance UI nhận summary/delta/red-flag/progress, không raw event noise.
  • SSE shell trong Nuxt server route (nếu dùng) chỉ là shell: gọi backend gateway abstraction, KHÔNG đọc trực tiếp outbox tail / LISTEN-NOTIFY (sửa lại từ rev1).

§6.5 Layer 5 — DLQ / Recovery / Governance

  • job_dead_letter đã có → retry policy / replay policy / poison isolation.
  • Idempotency registry (PG).
  • dlq_replay_request ledger (governance-approved replay).
  • Schema registry compatibility (forward + backward where contract allows).
  • Audit timeline view (đi qua MOUT).
  • Governance UI (xem §7.4): problems-only, aggregate counts, AI/worker concise status, drill-down, DLQ replay với approval.

§6.6 Reconcile checklist với Bắt sự kiện của PG(3).docx

Lesson Embedded ở mục Trạng thái
Producers chỉ produce, không execute §6.1 bắt buộc
Event bus ≠ job queue §6.2 bắt buộc
Workers consume + execute; queue không tự chạy §6.2/§6.3 bắt buộc
Nuxt không connect trực tiếp core queue §6.4 bắt buộc
Realtime gateway bắt buộc §6.4 bắt buộc
DLQ / retry / replay / poison isolation §6.5 bắt buộc
ACK/NACK / timeout / idempotency / replay là part of consumption §6.3 bắt buộc
Schema Registry + distributed tracing là governance primitives §6.1/§6.3 bắt buộc
Governance UI shows problems / summary / drill-down §7.4 bắt buộc

§7. Workflow & Task UI Requirements (process-facing)

§7.1 Standard Process View

  • Hiển thị định nghĩa quy trình: graph các step (IU-backed brick / IU bundle), trigger, branching condition, parallel branches, sub-workflow boundaries.
  • Render từ workflow_registry (config); zero hardcode.
  • Có thể switch sang Proposal mode: add/edit/delete step → đẩy vào workflow_change_requests (table đã có); KHÔNG ghi thẳng workflow_registry.
  • Một UI duy nhất cho mọi role; permission filter backend.
  • Hỗ trợ workflow 2 step lẫn 500 step bằng cùng layout (zoom/pan, collapse subgraph).

§7.2 Runtime Progress View

  • Hiển thị runtime instance của một workflow đang chạy: từng step có trạng thái riêng, deadline, người PIC, output đã có.
  • Drill-down từ step → task instance → IU content + IO actual.
  • Resume-safe: refresh không mất context.
  • Long-running workflow phải hiển thị timeline + milestone view.
  • Realtime cập nhật qua gateway (§6.4), không poll DB từ Nuxt.

R7.2.6 Workflow status roll-up principle (MP5, requirement-level). Workflow tổng có summary status được roll-up từ step states theo các nguyên tắc binding sau:

  • Red overrides yellow overrides green. Nếu có ít nhất 1 mandatory active step ở Red (failed / overdue / cannot_complete) → workflow status KHÔNG được hiển thị Green. Nếu có Yellow (waiting / blocked) mà không có Red → Yellow là tối đa.
  • Workflow KHÔNG green nếu có mandatory active step Red. Đây là invariant cứng.
  • Skipped / not_applicable không tính incomplete. Step bị skip theo branching condition / not_applicable (vd nhánh else) KHÔNG kéo workflow xuống Yellow/Red — chỉ tính step active (đã enter graph branch).
  • Optional vs mandatory. Step có flag optional=true (config) không kéo workflow status; chỉ mandatory step roll-up.
  • Roll-up rules là config-driven — declare trong PG registry (workflow_registry hoặc tương đương); KHÔNG hardcode Nuxt-side.
  • Transition matrix + per-state weight + edge cases (vd workflow có 0 mandatory active step, workflow có cycle, sub-workflow roll-up vào parent) → defer sang Master Design Rev2.

§7.3 Step / Task State Model (9 states, traffic-light, icon/text)

Brief này định nghĩa 9 trạng thái + semantics + traffic-light + icon/text; transition matrix (who/when/why) deferred sang Master Design Rev2.

# State Semantics Traffic-light Icon hint Text label (vi)
1 not_started Đã tạo nhưng chưa đến lượt (precondition chưa thoả) Gray Chưa tới lượt
2 ready Precondition thoả, sẵn sàng nhận PIC/executor Green (pale) Sẵn sàng
3 in_progress Đang được thực thi (human hoặc executor) Green Đang làm
4 waiting Đang chờ phụ thuộc bên ngoài (input của user khác, external API, time gate) Yellow Đang chờ
5 blocked Có vật cản nội bộ rõ ràng (thiếu IU, thiếu approval, lỗi config) Yellow (dark) Bị chặn
6 overdue Quá deadline nhưng vẫn còn cứu được Red (pale) Trễ hạn
7 failed Đã chạy và thất bại (transient hoặc permanent đến quyết định retry) Red Thất bại
8 cannot_complete Worker/PIC tuyên bố không hoàn thành được trong phạm vi step (escalate) Red (dark) Không thể hoàn tất
9 completed Đã hoàn thành đúng output contract; sẵn sàng phát postcondition events Green (deep) Hoàn thành

R7.3.1 Traffic-light first. Mọi step/task hiển thị màu chính (green/yellow/red/gray) trước, icon + text label theo sau. Giảm đào tạo; non-technical user nhìn màu là hiểu.

R7.3.2 Mỗi step/task có trạng thái riêng — không gộp dồn vào trạng thái workflow tổng. Workflow status là roll-up từ step states (rules sang Master Design).

R7.3.3 State machine 9 trạng thái là minimum. Master Design có thể bổ sung trạng thái phái sinh (paused/retrying/escalated/cancelled) nhưng phải justify; brief này chỉ chốt floor.

R7.3.4 Mỗi state phải có: machine-readable code + semantic short message + UI label (i18n-able) + traffic-light token + icon ref. Tất cả declare-by-config trong registry.

R7.3.5 Design implication (không phải thiết kế): state machine và transition phải sống trong PG (state_machine_registry hoặc tương tự); Nuxt zero logic; transition validation backend-side.

R7.3.6 Waiting sublabels / facets (MP3, không phải core state mới). Khi step ở core state waiting, UI bắt buộc gắn 1 sublabel/facet từ danh sách sau để user biết "chờ cái gì":

Sublabel Nghĩa
waiting_dependency Chờ output của step/task upstream trong cùng workflow (chưa completed).
waiting_human Chờ user khác submit input/decision (không cùng PIC step hiện tại).
waiting_external Chờ external API / callback / webhook / partner system.
waiting_time_gate Chờ cron / scheduled time / business calendar / SLA window.

R7.3.6.a Sublabel là facet hiển thị, không phải state mới — state machine vẫn 9 trạng thái floor. Master Design Rev2 quyết định lưu sublabel ở step_instance.waiting_facet (hoặc tương tự) — chưa chốt schema.

R7.3.6.b Mỗi sublabel có icon/text riêng nhưng vẫn share traffic-light Yellow của state waiting.

R7.3.6.c Nếu wait điều kiện hỗn hợp (vd chờ vừa human vừa external) → UI hiển thị primary sublabel + chips secondary; rule chọn primary để Master Design.

R7.3.7 Accessibility cho traffic-light UI (MP4, mandatory):

  • Không dựa vào màu đơn độc. Mọi state UI bắt buộc kèm icon + text label.
  • Tooltip / short reason — hover/long-press hiển thị 1-2 dòng giải thích trạng thái cụ thể (vd "Đang chờ duyệt từ KT" cho waiting_human).
  • Color contrast — pair foreground/background phải đạt WCAG 2.1 AA tối thiểu (contrast ratio ≥ 4.5:1 cho text, ≥ 3:1 cho icon/large text).
  • Color-blind safe palette — không dùng red/green đơn thuần là disambiguator; bổ sung shape/icon/pattern. Test với simulator (Deuteranopia/Protanopia/Tritanopia).
  • High-contrast mode — UI phải hoạt động khi user bật high-contrast/dark theme; không lose state-distinguishability.
  • Screen reader — mỗi state cell có aria-label rõ ràng (machine-readable state code + human label).
  • Design implication: palette token + icon token phải declare trong design-system registry (cùng nguồn config trong PG hoặc Directus content registry — không hardcode Nuxt-side).

§7.4 Governance UI (problem-first, drill-down)

R7.4.1 Chỉ show vấn đề. Default view = problems-only: failed steps, overdue tasks, DLQ messages, silent workers, schema violations, integrity warnings, event lag.

R7.4.2 Aggregate counts mỗi category 1 dòng (vd: "DLQ: 23 / silent_workers: 2 / overdue: 41"). Không list raw rows.

R7.4.3 Concise AI/worker-generated status — mỗi worker/agent có summary text ngắn do AI sinh, không hiển thị log thô. Drill-down để xem log.

R7.4.4 Drill-down on demand — click category → list → click row → full audit + correlation + trace_id.

R7.4.5 DLQ replay/rescue interface — yêu cầu approval (Điều 32); ghi vào dlq_replay_request ledger; idempotent.

R7.4.6 Heartbeat / silent worker monitor — bất kỳ worker không emit heartbeat trong N giây → hiển thị silent state; tránh false-heal (Điều 45 §15.5; xem feedback memory pattern).

R7.4.7 Event lag monitor — đo p50/p95/p99 lag từ emit → consume; hiển thị traffic-light theo threshold config.

R7.4.8 No raw event stream surface — UI không bao giờ hiển thị raw event noise; chỉ summary + red-flag + progress.

R7.4.9 Cùng layout cho mọi role; permission filter backend.


§8. IU Event Contract

R8.1 IU có thể produce events khi: born / edited / split / merged / deprecated / linked / rendered / validated / used in workflow/task.

R8.2 Workflow/task events bắt buộc carry references, không heavy body:

Field Bắt buộc
iu_unit_id
iu_version_id
workflow_run_id nếu phát từ MOW
task_run_id nếu phát từ MOT
event_type
trace_id (W3C)
correlation_id
parent_span_id

R8.3 Event payload không copy large IU body; consumer fetch detail by ref.

R8.4 Event type register-before-emit; JSON schema trong PG event_type_registry; semver versioning.

R8.5 Worker đọc PG/Directus/DOT để lấy body — never inline.


§9. KG Feedback Loop (Điều 39, mandatory)

KG không chỉ phục vụ search; KG phải chủ động đề xuất:

  • propose workflow step order (từ semantic dependency).
  • detect missing dependency giữa các step.
  • suggest typed edge thay vì merge IU.
  • detect over-coupled step units (đề xuất split).
  • detect orphan workflow step (IU không có downstream/upstream).
  • impact analysis khi sửa IU đang được active workflow dùng (list workflow/task affected, version policy).
  • suggest split / merge / rebundle / re-parent sau khi có usage evidence (§10).

Output dạng đề xuất governance (qua proposal queue); KHÔNG tự sửa registry.


§10. Usage Evidence Registry

Hệ thống phải ghi nhận và phân tích các tín hiệu sau (registry/concept; design định nghĩa schema):

  • co-used-in-workflow (cùng workflow_run).
  • co-triggered (cùng trigger event).
  • co-edited (cùng change-request).
  • co-retrieved (cùng search session/context-pack).
  • failure correlation (cùng failed run window).
  • repeated escalation (cùng step type).
  • repeated human correction (human override pattern).
  • event lag / DLQ correlation (per producer-consumer pair).

Evidence feeds → KG feedback (§9) → governance decision (add edge / create bundle / split IU / merge IU / reparent / change task template / change workflow graph / no action).


§11. No-Double-Ownership / Boundary Matrix

Concern Owner law New requirement chỉ được làm gì
Queue/event core, executor boundary, work_state_machine, heartbeat caller obligation Điều 45 v1.0 BAN HÀNH Tham chiếu + tuân thủ; KHÔNG redefine
IU axis / compose / split / merge / SQL link / structure ops Điều 38 + Điều 39 Tham chiếu + reuse; KHÔNG redefine
Approval quorum Điều 32 Gọi qua API/event; KHÔNG copy logic
DOT lifecycle Điều 35 v5.2 DOT-pair cho mọi mutation
Display tech (Nuxt = render shell) Điều 28 / S178 Zero business logic Nuxt-side
4-DB / 3-layer (PG → Directus → Nuxt) Điều 33 v2.1 Không direct PG from Nuxt
Birth registry (governance before use) Điều 0-G Field/form/workflow/task/event/schema sinh → duyệt → registry
Governance org Điều 37 v3.3 Boundary tổ chức không vi phạm
Regression protection Điều 30 Reversible by default
Integrity / audit Điều 31 v1.2 Evidence-first
Assembly First Điều 7 OSS tools = adapter, không owner
4 Mothers application layer Điều XX (future framework law) Only NEW concern — chỉ định nghĩa MOW/MOT/MOIT/MOUT là khuôn đúc quanh IU
Workflow law Điều 34 DRAFT Decision path only, xem §16

§12. Old Infrastructure Coverage Matrix

Phạm vi: hệ thống cũ trong rev1 + 4 mẹ mở rộng.txt + dấu vết trong codebase/KB (cho phép suy luận thêm từ source code/migration history).

Evidence-level taxonomy (mandatory cho mỗi dòng — không overclaim cái chưa verify):

Level Nghĩa
verified_live Có bằng chứng PG live (rev1 §1 survey hoặc memory live snapshot 2026-05-27); hiện trạng vận hành xác nhận.
KB_reported KB doc / memory đã mô tả nhưng KHÔNG có read PG snapshot mới trong Rev2; treat as report, không phải live verification.
legacy_trace Hệ thống cũ tồn tại (Directus flow / pg_cron / signal cũ) — không phải target use; ghi nhận để boundary, không reuse vào MOW/MOT.
candidate_requires_survey Suy luận từ schema/codebase/KB references; cần survey trong Master Design Rev2 trước khi reuse.
known_gap Đã được flagged là missing; nằm trong §19 Open Decisions.
# Old infra Hiện trạng Evidence Rev2 đối xử
1 information_unit + axes (source/domain/tree) live, PASS verified_live (rev1 §1 + memory) Reuse; bind IU brick fields trong §3
2 IU compose ops (create/add/reorder/remove/render/validate) live, PASS verified_live (memory IU Core 120x PASS) Reuse cho MOW step assembly
3 IU split/merge PARTIAL — thiếu review_decision_id known_gap (G1) Rev2 phụ thuộc Phase 0 đóng gap; KG feedback (§9) chỉ đề xuất khi gap closed
4 IU trigger in/out model live, PASS verified_live (memory) Reuse làm precondition/postcondition cho IU brick
5 IU SQL link (iu_sql_link) live verified_live (rev1 §1) Reuse cho MOUT output binding
6 fn_iu_post_cut_axis_materialize exists, registered, chưa auto-wired vào fn_cut_complete verified_live (exists) + known_gap (G2 autowire) Phase 0 macro phải wire (theo memory + roadmap rev1)
7 iu_metadata_tag + iu_metadata_tag_registry live verified_live (rev1 §1) Reuse cho domain governance
8 iu_lifecycle_log live verified_live (rev1 §1) Audit ledger cho IU governance state
9 event_outbox live, ~140k+ rows (dominant: issue_opened) verified_live (rev1 §1 counts) SoT event ledger §6
10 event_type_registry live (lưu ý: không có cột source) verified_live (rev1 §1 + memory KB quirk) SoT cho event types §6.1
11 event_pending / event_read / event_subscription live verified_live (rev1 §1) Reuse §6.2/§6.3
12 job_queue / job_dead_letter / queue_heartbeat live verified_live (rev1 §1 + memory gates) Reuse §6.2/§6.3/§6.5
13 cut_request + cut_request_transition live verified_live (memory cut pipeline) Cut pipeline producer §6.1
14 dot_iu_command_catalog (cột mutating, không is_mutating) live verified_live (memory KB quirk) DOT-pair executor §6.3
15 dot_config (runtime gates) live; many gates currently false; composer_enabled flipped true 2026-05-27 verified_live (rev1 §1 + same-day mig 057 memory) Gate respect; brief khẳng định no-mutation
16 workflows / workflow_steps / workflow_step_relations live verified_live (rev1 §1) Reuse làm MOW substrate
17 workflow_change_requests live verified_live (rev1 §1) Reuse cho Proposal mode (§7.1); KHÔNG tạo bảng mới
18 workflow_categories live verified_live (rev1 §1) Reuse classification
19 tasks / task_checkpoints / task_comments live verified_live (rev1 §1) Reuse, mở rộng schema theo MOT §5.2
20 DOT command run audit (dot_iu_command_run) live verified_live (memory) Audit ledger §6.5
21 iu_route_* + iu_qdrant_collection_registry + iu_vector_sync_point live; vector_sync_enabled=false verified_live (rev1 §1 + gates) Vector projection only; KHÔNG cross-IU pollution
22 iu_notification_event live verified_live (rev1 §1) Notification executor §6.3
23 Directus collections + flows (legacy) tồn tại nhưng có legacy flows legacy_trace Boundary: Directus = API/admin/staging only; KHÔNG executor; không dùng Directus realtime làm app event plane
24 pg_cron legacy tồn tại trên VPS legacy_trace Reuse cho scheduled triggers; không thay role queue
25 signal/event_outbox legacy (non-IU signals dominant: issue_opened 140 580 rows) counts từ rev1 §1; nội dung legacy chưa được re-survey trong Rev2 KB_reported (counts từ rev1) + legacy_trace (semantics) Re-categorize sang event_type_registry; register-before-emit
26 iu_piece_collection / iu_piece_membership / iu_collection_template_* live verified_live (rev1 §1) Cơ sở cho IU bundle (§4); design ánh xạ
27 iu_three_axis_envelope live verified_live (rev1 §1) Source cho assembly_slot resolution
28 field_registry rev1 §6.3 mô tả là SoT cho MOIT; chưa survey live trong rev1/Rev2 candidate_requires_survey Confirm live tồn tại + cấu trúc trong Master Design Rev2 trước khi reuse
29 input_form_registry rev1 §6.3 mô tả là SoT cho form; chưa survey live candidate_requires_survey Confirm trong Master Design Rev2
30 output_table_registry rev1 §6.4 mô tả là SoT cho MOUT; chưa survey live candidate_requires_survey Confirm trong Master Design Rev2
31 dot_function_registry rev1 §6.4 nhắc DOT function registry cho aggregation; chưa survey live candidate_requires_survey Confirm trong Master Design Rev2 + ownership boundary với Điều 45 (§19 OD13)

GAP đã biết (đưa vào Open Decisions §19):

  • G1 review_decision_id schema cho split/merge.
  • G2 fn_iu_post_cut_axis_materialize autowire vào fn_cut_complete.
  • G3 executor_class_registry ownership boundary (Điều XX vs Điều 45 cross-ref).
  • G4 dlq_replay_request ledger schema.
  • G5 idempotency_registry schema.
  • G6 Step state machine registry placement (PG schema TBD).
  • G7 4 candidate registries (field/input_form/output_table/dot_function) — survey trong Master Design Rev2.

§13. Constitution / Law Clause Matrix

Source Binding requirement Rev2 thoả ở mục Risk còn lại Sentinel test (gợi ý)
Hiến pháp v4.6.3 NT13 PG-first §11, §14 Adapter có thể tạo SoT thứ hai "Mọi external tool row có ref về PG registry row"
NT2/NT4 Native/config-driven §3, §5, §7.3.4 Hardcode Nuxt-side "Nuxt component zero business logic"
NT12 / Điều 35 v5.2 DOT-pair mutation §6.3, §11 Raw SQL vận hành "0 raw SQL run ngoài DOT"
Điều 7 Assembly First OSS = adapter §15 Tool nuốt SoT "External tool point back PG registry"
Điều 28 / S178 Nuxt render shell §5.3/§5.4, §7 SSE direct outbox §6.4 sửa rồi
Điều 30 Reversible by default §1, §11 Implementation phase Rollback test mỗi mig
Điều 31 v1.2 Integrity / audit §6.5, §10 Audit gap Audit timeline test
Điều 32 Approval quorum §5.2 (MOT không own), §7.4.5 MOT/MOW chiếm approval "Approval call → Điều 32 only"
Điều 33 v2.1 4-DB / 3-layer §5.3/§5.4, §6.4 Direct PG from Nuxt "Nuxt fetch qua Directus/gateway only"
Điều 34 DRAFT Workflow law §16 Promote vs merge chưa quyết Council decision path §16
Điều 37 v3.3 Governance org boundary §7.4 UI cross-role "Same UI, backend filter"
Điều 38 + Điều 39 IU + KG §3, §4, §9 KG passive KG feedback proof §9
Điều 45 v1.0 §6.6 Event ≠ job §6.2 Lẫn lộn "Event bus ≠ job queue trong design"
Điều 45 §6.7 Work_state_machine ≥9 §7.3 Vendor state vocab OSS adoption gate (state-vocab fit)
Điều 45 §11.5 Executor boundary §5.2, §6.3 MOT thành executor "MOT calls executor class only"
Điều 45 §15.5 Heartbeat caller §6.3, §7.4.6 False-heal feedback memory pattern
Điều 0-G Birth Sinh → duyệt → registry §6.1, §7.1 Bypass form/event "Register-before-emit" test
Vector law No cross-IU pollution §12 row 21 Adapter ingest cross "1 IU = ≥1 point, không trộn"

§14. PG Maximization Map

Rev2 yêu cầu các artifacts sau bắt buộc nằm trong PG (SoT). External tools chỉ là projection/adapter và phải point back PG row.

Artifact Live? Ghi chú
event_outbox (canonical event ledger) Reuse
event_type_registry + JSON schema Reuse; thêm semver compatibility mode
trace_id / correlation_id / parent_span_id shape partial Adopt W3C trace_id NOW (memory feedback)
Idempotency registry GAP G5 Schema sang design
Retry policy registry partial (per job_queue config) Tách registry rõ ràng
job_dead_letter (DLQ) Reuse
DLQ replay ledger (dlq_replay_request) GAP G4 Schema sang design
Governance state / proposal state ✓ (workflow_change_requests) Reuse; mở rộng cho IU/MOT/MOIT/MOUT proposals
workflow_registry / workflow_step_def / workflows / workflow_steps partial Extend cho IU-backed binding
task_def / tasks / task_checkpoints partial Extend cho MOT 4-region binding
field_registry / input_form_registry TBD live status (rev1 inferred) Confirm trong design
output_table_registry / dot_function_registry TBD Confirm trong design
executor_class_registry GAP G3 Ownership boundary
DOT catalog (dot_iu_command_catalog, dot_iu_command_run) Reuse
Runtime gates (dot_config) Reuse; respect gates
Audit evidence (iu_lifecycle_log, audit timelines) Reuse
Healthcheck rows (heartbeat) ✓ (queue_heartbeat) Reuse; new worker phải emit
State machine registry (step/task) GAP G6 Tránh hardcode
Usage evidence registry (§10) GAP Schema sang design
IU bundle registry (§4) partial (iu_piece_collection/iu_collection_template_*) Map sang design

§15. OSS Candidate Strategy (labels only, NO final tool selection)

Rev2 chốt bộ nhãn; tool decision cuối chưa chốt; mỗi adoption phải qua 2 cổng:

Gate A — state-vocab fit: OSS tool có làm rách Điều 45 §6.7 ≥9-state work_state_machine không? Nếu tool áp đặt vocab riêng → fail.

Gate B — config-first fit: Workflow/task/event definition có sống trong PG/registry hay trong tool's code/yaml? Nếu logic ở code-side của tool → fail.

Pass cả 2 → A candidate. Pass 1 → M (borrow patterns natively hoặc bounded adapter). Fail cả 2 → R.

# Label Nghĩa
L1 confirmed_invariant Đã invariant; KHÔNG đổi
L2 reject_as_core_owner Không cho tool sở hữu core (queue/event/workflow/IU)
L3 reject_as_primary_substrate_now Không làm substrate chính hiện tại; xét lại theo profile trigger
L4 defer_until_profile_trigger Hoãn cho tới khi metric/scale chứng minh; ghi rõ trigger
L5 future_adapter_slot_preserved Giữ slot adapter tương lai (read-only / bounded)
L6 sandbox/reference_only Đọc pattern, không production
L7 not_a_second_SoT Bắt buộc point back PG registry; không tạo SoT thứ hai

Áp dụng cụ thể (binding labels — KHÔNG phải tool selection):

Tool / pattern Labels
pg-boss / Graphile Worker L2 (reject_as_core_owner), L5 (future_adapter_slot_preserved nếu map về Điều 45 lifecycle), L7
Temporal L2, L3, L4 (re-evaluate post-Phase 6 nếu native MOW saturate / multi-host / >100k active long-running)
Camunda L2 (approval = Điều 32), L6 (sandbox reference for BPMN patterns)
Airflow L2, L6 (batch/data workflow, KHÔNG MOW core)
Benthos / Redpanda Connect L3, L5 (bounded external mirror), L7 (register-before-emit)
NATS L4 (multi-host/fanout profile), L7 (transport, không SoT)
Redis Streams L4, L7 (chỉ khi Redis đã ops or indep justification)
Hasura subscriptions L2 (core owner), L6
Directus realtime L2 (boundary violation app plane), L6 (admin diagnostics nếu approved)
Watermill L3, L6
Centrifugo L4 (>1k concurrent realtime clients), L5 (gateway adapter slot)
W3C trace_id shape L1 (confirmed_invariant — adopt now để OTel attach sau)
OpenTelemetry collector L4 (sau khi trace_id phổ cập)

Forbidden trong rev2: không chọn tool cuối, không pin version, không đưa CI step nào. Chỉ labels.


§16. Điều 34 Workflow Law DRAFT — decision path

Section ngắn, KHÔNG soạn requirement chi tiết cho Điều 34. KHÔNG enact. KHÔNG merge vào Điều 45 hay Điều 32.

S16.1 Hiện trạng. Điều 34 v1.0 vẫn là DRAFT, chưa được dùng như luật enacted; chưa được dùng làm authority cho implementation.

S16.2 Rev2 không quyết. Rev2 chỉ liệt kê 3 nhánh quyết định để Council xử lý sau:

  1. Promote Điều 34 thành workflow grammar law nền (workflow vocab + state machine + step kind taxonomy), MOW là implementation.
  2. Merge / archive Điều 34 vào future framework law Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc (nếu Council xác định không cần lớp law riêng cho workflow grammar).
  3. Giữ DRAFT. Không dùng làm authority cho implementation; Phase 0 vẫn tiến hành trên Điều 45 + IU laws + Điều XX khi enacted.

S16.3 Tiêu chí chọn (binding):

  • No double ownership với Điều 45 (queue/event/state_machine core), Điều 32 (approval), Điều 38/39 (IU + KG).
  • Không duplicate vocabulary của các luật đã ban hành.
  • Nếu merge → phải bảo toàn DRAFT history như evidence trail.
  • Nếu promote → phải qua Council Round 1 (Điều 37) + check trùng vocab.

S16.4 Rev2 không sửa luật, không enact, không draft law mới.


§17. Acceptance Criteria (cho Rev2 brief)

Rev2 PASS nếu:

  1. IU-centered doctrine §2 hiện diện và binding.
  2. IU brick fields §3 + IU bundle §4 đủ định nghĩa requirement.
  3. 4 Mothers §5 đã được re-frame quanh IU (KHÔNG copy text).
  4. Event 5-layer §6 reconciled với Bắt sự kiện của PG(3).docx (checklist §6.6 PASS).
  5. UI §7 có Standard Process View + Runtime Progress View + 9-state model + Governance UI.
  6. IU Event Contract §8 + KG feedback §9 + Usage Evidence §10 đủ requirement.
  7. No-double-ownership matrix §11 + Constitution matrix §13 đầy đủ.
  8. Old Infra Coverage Matrix §12 cover ≥27 hệ thống cũ (đã có).
  9. PG Maximization Map §14 lock SoT.
  10. OSS labels §15 dùng đúng 7 nhãn; không tool selection.
  11. Điều 34 §16 chỉ decision path; KHÔNG enact / merge / draft.
  12. Forbidden §20 nguyên vẹn.
  13. Acceptance criteria khẳng định 500-step workflow lắp được từ IU brick/bundle mà không cần schema riêng.
  14. MP1 applied — §12 có cột evidence_level + 5-level taxonomy + 4 candidate registry rows (28-31) với candidate_requires_survey.
  15. MP2 applied — wording raw-source được sửa: raw đã có qua uploaded files trong phiên rev1; Rev2 dùng GPT recheck làm consolidation source; raw upload deferred theo Council request.
  16. MP3 applied — §7.3.6 có 4 waiting sublabels như facet (KHÔNG phải state mới); 9-state floor giữ nguyên.
  17. MP4 applied — §7.3.7 có accessibility: không color-alone, icon+text+tooltip, WCAG 2.1 AA, color-blind safe palette, screen reader aria.
  18. MP5 applied — §7.2.6 có workflow roll-up principle (red>yellow>green, workflow không green nếu mandatory active step red, skipped không incomplete, config-driven).
  19. MP6 applied — §21 có dòng final approval gate.

PARTIAL_WITH_EXACT_GAP nếu:

  • Council yêu cầu direct raw-source audit 4 mẹ mở rộng.txt / Bắt sự kiện của PG(3).docx thay vì dùng GPT recheck consolidation — Rev2 hiện reconcile qua recheck report; raw upload sẽ được làm ở vòng document-only riêng nếu cần.
  • 4 candidate registries (field_registry / input_form_registry / output_table_registry / dot_function_registry) live status chưa được survey trong rev1/Rev2 (evidence_level = candidate_requires_survey §12 rows 28-31) — đẩy sang Master Design Rev2 survey.

§18. Agreed Details Completeness Checklist

# Item Trong brief Ghi chú
C1 4 Mothers: MOW, MOT, MOIT, MOUT §5
C2 Event 5 layers §6
C3 Assembly First (Điều 7) §11, §15
C4 Business hierarchy 6 tầng (Task → Lĩnh vực) (giữ từ rev1 §5.1) Giữ nguyên
C5 JFT (right task / right person / right time / deadline / escalation) (giữ từ rev1 §5.2) + §7.3 Giữ
C6 Trigger types (time / output / manual / composite AND-OR) (giữ rev1 §5.3) Giữ
C7 MOW UI: normal + proposal + add/edit/delete + queue + permission filter + same UI §5.1, §7.1
C8 MOT layout: header + MOIT input + MOUT reference + instruction + metadata/state/deadline/escalation §5.2
C9 MOIT: approved registry / direct vs staging by config / no rogue form §5.3
C10 MOUT: read-only / live data / realtime gateway / permission filter §5.4, §6.4
C11 Governance UI: problems-only / aggregate counts / AI/worker concise / drill-down / DLQ replay/rescue §7.4
C12 Scale: 1M+ IU / 10k+ workflow / 100k+ task / 2..500 step / phút..năm / nested (giữ rev1 §11) + §5.1 Giữ
C13 IU compat: axes / compose / split-merge (review) / trigger / SQL link / event hooks / post-CUT §3, §12
C14 IU-centered doctrine (NEW) §2
C15 IU Bundle / Step Pack (NEW) §4
C16 IU Event Contract (NEW) §8
C17 KG feedback loop (NEW) §9
C18 Usage evidence (NEW) §10
C19 Step/task 9-state model + traffic-light (NEW) §7.3
C20 Standard Process View + Runtime Progress View §7.1, §7.2
C21 Old Infrastructure Coverage Matrix §12 ✓ (27 rows)
C22 Constitution / Law Clause Matrix §13
C23 PG Maximization Map §14
C24 OSS Candidate Strategy with 7 labels §15
C25 Điều 34 decision path §16
C26 User Approval Gate §0
C27 No duplicate text invariant §2 D2.3
C28 500-step assembly acceptance §17 row 13
C29 Acceptance criteria explicit §17
C30 Forbidden block §20
C31 MP1 evidence_level column + 4 candidate registries §12 ✓ (31 rows total + 5-level taxonomy)
C32 MP2 raw-source wording (raw was available; recheck = consolidation source; raw upload deferred per Council request) header + §17
C33 MP3 waiting sublabels (waiting_dependency / waiting_human / waiting_external / waiting_time_gate, facet not core state) §7.3.6
C34 MP4 accessibility (no color-alone, icon+text+tooltip, WCAG 2.1 AA contrast, color-blind safe, high-contrast mode, aria-label) §7.3.7
C35 MP5 workflow status roll-up principle (red>yellow>green; workflow not green if mandatory active step red; skipped not incomplete; config-driven) §7.2.6
C36 MP6 final approval gate line at §21 §21

§19. Open Decisions Register (Council/User-required)

# Decision Default proposal Trigger / deadline
OD1 Điều 34: promote / merge / keep-draft Council decision §16 Before Phase 1
OD2 Generic proposal table vs per-domain proposal Reuse workflow_change_requests + generic proposal table for IU/MOT/MOIT/MOUT Design Rev2
OD3 executor_class_registry ownership: Điều XX vs cross-ref Điều 45 Cross-ref; Điều XX referent, Điều 45 substrate Design Rev2
OD4 Realtime gateway: Nuxt-route SSE shell vs Node gateway vs Centrifugo later Start Nuxt-route SSE shell calling backend abstraction; preserve Centrifugo slot Phase 1
OD5 CDC threshold (Benthos/NATS adoption) Benthos sau khi PG outbox lag p95 > X / NATS sau khi multi-host worker Phase 4+
OD6 Temporal/Camunda re-evaluation trigger Sau Phase 6 nếu MOW saturate / >100k long-running active Phase 6 review
OD7 review_decision schema ownership for split/merge Phase 0 closes; Điều XX referent Phase 0
OD8 Event schema JSON SoT shape + compatibility mode (forward/backward/full) event_type_registry with semver + forward-by-default Design Rev2
OD9 Step state machine registry placement (PG schema) PG state_machine_registry table; declared-by-config Design Rev2
OD10 DLQ replay ledger schema (dlq_replay_request) Approval-gated via Điều 32 Design Rev2
OD11 Idempotency registry schema Per-executor namespace + key Design Rev2
OD12 Step states above 9 (paused/retrying/escalated/cancelled) — adopt? Defer; Master Design có thể đề xuất Design Rev2
OD13 dot_function_registry ownership and naming convention MOUT-aligned namespace Design Rev2
OD14 Governance UI category taxonomy (DLQ / silent worker / overdue / schema violation / event lag / integrity) Use §7.4 categories as v1 Design Rev2
OD15 IU version policy for active workflows (pin vs auto-upgrade vs hybrid) Pin by default + opt-in upgrade per workflow Design Rev2

§20. Forbidden (binding for Rev2 lifecycle)

  • KHÔNG PG mutation.
  • KHÔNG Directus mutation.
  • KHÔNG Qdrant / vector write hay reindex.
  • KHÔNG migration / DOT command run.
  • KHÔNG law enactment / law drafting (chỉ decision path cho Điều 34).
  • KHÔNG implementation macro.
  • KHÔNG final OSS tool selection (chỉ 7 labels §15).
  • KHÔNG UI deployment.
  • KHÔNG Master Design Rev2 — chờ user approval cho Rev2 brief trước.

§21. Next document (after user approval)

  1. knowledge/dev/design/v0.6-iu-4mothers-event-foundation-rev2/00-master-design-rev2.md (Master Design Rev2 — chỉ sau khi Rev2 brief được duyệt).
  2. knowledge/dev/design/v0.6-iu-4mothers-event-foundation-rev2/01-step-state-machine-registry.md (transition matrix cho 9 states + waiting sublabels §7.3.6 + roll-up rules §7.2.6).
  3. knowledge/dev/design/v0.6-iu-4mothers-event-foundation-rev2/02-oss-critique-rev2.md (update OSS critique theo §15 labels).
  4. Macro report sau Master Design.

Final approval gate (MP6, binding): Next macro may begin only after user explicitly approves this Requirement Rev2 or approves a minor-patch version. Until that approval, Master Design Rev2 / law drafting / implementation / OSS tool selection / PG-Directus-Qdrant mutation must not start.

End requirement brief rev2 (revision 2 — MP1–MP6 patched 2026-05-27).

Back to Knowledge Hub knowledge/dev/requirements/v0.6-iu-4mothers-event-foundation-rev2/00-requirement-brief-rev2.md