KB-1582

Law Extraction Plan — Điều XX Application Process / Workflow / Task Infrastructure (DRAFT, 2026-05-27)

15 min read Revision 1
law-extractiondesigndieu-xxframework-lawapplication-platformdraft2026-05-27no-double-ownership

Law Extraction Plan — "Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc"

Path: knowledge/dev/design/law-extraction-plan-application-process-workflow-task.md Status: DRAFT — extraction plan, NOT a law. Codifies what should become law once requirements + design + implementation reach maturity. Date: 2026-05-27 Companion: requirements brief + master design + implementation roadmap.


1. Why a new law is needed later

The current law set covers:

  • Hiến pháp v4.6.3 — 13 NT, foundation.
  • Điều 28 (display), 29 (classification), 30 (regression), 31 (integrity), 32 (approval), 33 (PostgreSQL), 35 (DOT governance), 37 (governance org), 38 (Text-as-Code / IU), 39 (knowledge graph), 41 (...), 43 (...).
  • Điều 45 v1.0 BAN HÀNH 2026-05-26 — PG-native queue & task orchestration law (core queue/event substrate + executor boundary + MOT-not-executor clause + work_state_machine §6.7 + event_vs_job §6.6 + forward-compat §13).
  • Điều 34 v1.0 DRAFT — workflow law, still draft.

Gap: there is no enacted law that governs:

  • The application layer (4 Mothers MOW/MOT/MOIT/MOUT).
  • The workflow/task factory (config-driven generation in minutes).
  • The proposal/Kaizen governance lifecycle for workflow & form & field & task type.
  • The application usage of events (not the core — Điều 45 already owns that).
  • The no-double-ownership invariants between IU laws, queue/event law, and the new application layer.

Filling this gap with a new framework law prevents:

  • A future drift where MOW or MOT redefines queue semantics owned by Điều 45.
  • A future drift where MOIT/MOUT bypasses field/form governance.
  • A future drift where Nuxt or Directus picks up business logic in violation of Hiến pháp NT13 / Điều 28 / Điều 33.
  • A future drift where executor classes proliferate without registry.

2. Proposed law

Name (provisional):

Điều XX — Luật Hạ tầng Ứng dụng Quy trình và Công việc (Application Process & Task Infrastructure Law)

Type: Framework law (luật khung). Not detailed implementation specification.

Style: Like Điều 45 — invariants + boundaries + forward-compat clauses. Not function bodies, not table DDL. Implementation lives in the design packs under knowledge/dev/design/ and knowledge/dev/implementation/.

Number: TBD — must be assigned by Council at enactment. Candidates: Điều 46 (next sequential), or a higher number if a vacancy exists.

3. What the new law WILL govern

3.1 MOW boundary

  • MOW owns the workflow definition + runtime model: workflow_registry, workflow_step_def, workflows, workflow_steps, workflow_step_relations.
  • MOW owns the orchestration loop (advance, branch, parallel, sub-workflow).
  • MOW owns the proposal/Kaizen lifecycle for workflow change (workflow_change_requests).
  • MOW MUST orchestrate; MUST NOT execute business work directly.

3.2 MOT boundary

  • MOT owns task definition + runtime model: task_def, tasks, task_checkpoints, task_comments.
  • MOT owns the 4-vùng layout contract (header / input via MOIT / reference via MOUT / instruction via IU).
  • MOT owns the executor_class field; MUST NOT itself execute.
  • MOT MUST link every task to a workflow_run (or be standalone for ad-hoc).

3.3 MOIT boundary

  • MOIT owns field_registry, input_form_registry, validation engine assembly contract.
  • MOIT MUST refuse any form that references unapproved field.
  • MOIT MUST support 2 channels (direct / queue) by config flag.
  • Nuxt component MUST be a zero-logic render shell.

3.4 MOUT boundary

  • MOUT owns output_table_registry, dot_function_registry.
  • MOUT MUST refuse any output that bypasses the registry.
  • MOUT MUST not allow ad-hoc query from Nuxt.
  • MOUT MUST honor permission filter at backend.

3.5 Application workflow/task platform invariants

  • Workflow/task/form/output/event_type/executor_class — all must follow the governance lifecycle: propose → review → approve (Điều 32 quorum if material) → register → use → deprecate → archive.
  • Birth gate Điều 0-G applies.
  • One UI per role tier — backend permission filter; no role-specific UI fork.
  • Long-running workflow MUST be resume-safe (snapshot + checkpoint).
  • Proposal mode is the ONLY user-facing path to mutate registry; direct DB mutation by tools is reserved for governance ops with audit.

3.6 Proposal mode governance

  • All proposals MUST land in a *_change_requests / *_proposal table.
  • All proposals MUST carry submitter, reason, impact preview, target version.
  • All proposals MUST be approvable, rejectable, or deferrable through governance UI.
  • Material proposals (affecting ≥N consumers) MUST go through Điều 32 approval.

3.7 No-double-ownership rules

  • New law MUST NOT redefine queue/event core (owned by Điều 45).
  • New law MUST NOT redefine IU internals (owned by IU/Điều 38/Điều 39).
  • New law MUST NOT redefine cut pipeline (owned by cut laws / Điều 45 §6 extensions).
  • New law MUST NOT redefine Qdrant/vector policy (vector law).
  • New law MUST NOT redefine Directus/Nuxt boundary (Điều 28 / Điều 33 / S178).

3.8 Application-level event use

  • Application-level event types belong to the new law; core event/queue semantics belong to Điều 45.
  • New event types MUST register in event_type_registry.
  • Application MAY define new executor classes — must register in executor_class_registry.
  • Application MUST NOT bypass job_queue lease/heartbeat semantics.

4. What the new law WILL NOT govern (forbidden duplication)

Topic Owner law Why excluded
event_outbox / event_pending / event_read schemas Điều 45 Core substrate.
job_queue lifecycle, lease, retry, DLQ semantics Điều 45 Core substrate.
Heartbeat caller obligation (§15.5) Điều 45 Already binding.
event_vs_job distinction (§6.6) Điều 45 Already invariant.
work_state_machine invariant (§6.7) Điều 45 Already invariant.
Executor boundary clause (§11.5) Điều 45 Already binding.
Cut pipeline (cut_request, cut_request_transition, fn_cut_*) cut law family + Điều 45 §6 ext. Already owned.
IU axis A/B/C (source / domain / tree) Điều 38 + Điều 39 Already owned.
Compose/split/merge ops IU foundation Already owned.
Approval quorum mechanics Điều 32 Already owned.
Display tech template Điều 28 Already owned.
4-DB / 3-layer / NT3 exception Điều 33 Already owned.
DOT lifecycle / run modes / governance Điều 35 Already owned.
Birth registry Điều 0-G Already owned.
Regression protection / Playwright Điều 30 Already owned.
System integrity / NUXT-DB sync watchdog Điều 31 Already owned.
Governance org / NT11 Điều 37 Already owned.
Text-as-Code / IU foundation Điều 38 Already owned.

5. Relationship to Constitution

The new law derives directly from Hiến pháp v4.6.3:

  • NT2/NT4 native/config-driven → MOW/MOT/MOIT/MOUT MUST be config-driven.
  • NT12 DOT pair → mutation through DOT.
  • NT13 PG-first → state in PG.
  • NT3 exception → only explicit exceptions allowed.
  • NT11 governance org → proposal mode + role-based filter at backend.
  • 5-layer sync → application layer participates in PG ↔ Directus ↔ Nuxt ↔ KB ↔ Qdrant sync.

The new law amends the Constitution only if needed via the standard amendment process (per existing constitution-amendment-measurement). Preferred path: no Constitution change; the new law is a derivative framework law.

6. Relationship to IU laws (Điều 38, Điều 39, dieu38-trien-khai/*)

  • New law REFERENCES IU as the knowledge brick.
  • workflow_step_def, task_def, form, output_table all carry iu_unit_id references for descriptive ground-truth.
  • IU compose/split/merge operations are CALLED from MOW/MOT — not redefined.
  • IU events (axis refresh, compose, structure_op_applied) are CONSUMED by MOW/MOT/MOUT — not redefined.

7. Relationship to Điều 45 (queue/event law)

  • New law USES Điều 45's substrate.
  • New law DOES NOT touch §6, §6.6, §6.7, §11, §11.5, §13, §15.
  • New law extends event_type_registry and executor_class_registry (the latter is new and MAY be claimed by the new law).
  • New law forward-compat clause to point to Điều 45 for any queue semantics.

8. Relationship to Điều 34 (Workflow Law DRAFT)

Decision required. Two paths:

  • Path A — Promote Điều 34 to enacted; new law sits above as application framework. Điều 34 becomes the workflow law nền; new law (Điều XX) sits above for MOW orchestrator + 4 Mothers + governance UI.
  • Path B — Merge Điều 34 into new law. Treat the Điều 34 draft as a precursor; new law absorbs the workflow concepts and Điều 34 is archived.

Default recommendation: Path A. Reason: Điều 34 has Council attention already; promoting + then layering keeps separation of concerns (workflow grammar vs application factory).

9. Relationship to Directus/Nuxt boundary law (Điều 28 + S178 amendments)

  • New law mandates: Nuxt = render shell; logic in PG/Directus.
  • New law mandates: realtime gateway as separate service (not in Nuxt direct broker).
  • New law DOES NOT redefine display template grammar (Điều 28).

10. Relationship to vector / no-vector law

  • New law mandates: 1 IU = ≥1 Qdrant point (no pollution).
  • Application layer (MOUT realtime, dashboards) MAY use vector reads but MUST NOT bypass the IU↔Qdrant boundary defined by vector law.

11. Candidate clauses (provisional, for drafting)

Each clause stated as an invariant — like Điều 45 style.

  • §1 Purpose. This law governs the application infrastructure for processes and tasks at Incomex.
  • §2 Scope. MOW, MOT, MOIT, MOUT, governance UI, proposal/Kaizen lifecycle.
  • §3 Out of scope. Queue/event core (Điều 45), IU internals (Điều 38/39), cut pipeline, vector boundary.
  • §4 MOW invariant — orchestrator not executor. MOW orchestrates; MOT operationalizes; executors execute.
  • §5 MOT invariant — not executor. MOT does not execute business work. Executor classes are listed in registry; MOT links a task to one.
  • §6 Field & form governance. Field and form MUST come from registry; unapproved fields are refused at MOIT assembly.
  • §7 Output governance. Output table MUST come from registry; ad-hoc query from Nuxt is forbidden.
  • §8 Proposal mode. Workflow / form / field / task type / executor class / output table changes MUST flow through a proposal table with submitter, reason, and approval.
  • §9 One UI per role tier. UI must be identical across roles; backend permission filter.
  • §10 Long-running workflow. Workflow runs MUST be resume-safe via snapshot + checkpoint.
  • §11 Nested/sub-workflow. Correlation chain MUST be preserved across nesting.
  • §12 JFT discipline. Tasks have deadline, escalation, retry; user sees only own tasks at the right time.
  • §13 Trigger types. Time, prior-output, manual, composite AND/OR. Triggers configured in registry.
  • §14 Birth gate. Every registry entry passes Điều 0-G.
  • §15 5-layer sync. Application layer participates in PG↔Directus↔Nuxt↔KB↔Qdrant.
  • §16 Realtime gateway. Nuxt MUST NOT connect to queue/broker directly; gateway in between.
  • §17 Governance UI surface. Show problems first; summaries; drill-down on demand.
  • §18 Executor class registry. New executor classes MUST register; classes: dot, sql, ai_agent, human, external_api, notification, render (forward-extensible).
  • §19 Application event types. MUST register in event_type_registry; semver schema versioned.
  • §20 No-double-ownership. New law refers to Điều 45 for queue/event; refers to IU laws for IU; does not redefine.
  • §21 Forward-compat clause. Future verticals (customer-care, email, finance pipelines) MAY plug as executor_class without amendment.
  • §22 Anti-patterns. Listed (Nuxt holds business logic; MOT becomes executor; direct PG from Nuxt; bypass field_registry; etc.).

(Final list and numbering decided at drafting.)

12. Preconditions before drafting the law

Mandatory before any "v0.1 DRAFT" attempt — same discipline that produced Điều 45:

  1. Requirement brief stable + user-approved (≥ rev 2 of iu-mow-mot-event-foundation-requirements.md).
  2. Master design stable + Council-reviewed (≥ rev 2 of iu-mow-mot-event-foundation-design.md).
  3. Phase 0 closed (post-CUT autowire + split/merge gap closed + review_decision live) — proves IU foundation is ready.
  4. Phase 1 closed (event foundation upgraded: schema registry contract, executor_class_registry, dlq_replay_request, trace_id) — proves event 5-layer is operable.
  5. Phase 2 minimum (MOT with executor_class=human + dot, lease + heartbeat) — proves MOT-not-executor in practice.
  6. Survey done for "law placement" — confirm new law is the right vessel vs amendment of existing.
  7. Council Round 1 review of candidate clauses (§4–§22) on this plan document, with at least 2 reviewers (GPT + Gemini per established pattern).

Only after all six preconditions met may a law file be born (knowledge/dev/laws/dieu-XX-…draft.md).

13. Drafting playbook (mirrors Điều 45 process)

  1. Author survey under knowledge/dev/laws/dieu44-trien-khai/...-readiness-survey/ (or equivalent placeholder).
  2. Author draft v0.1 with §1–§22 candidate clauses.
  3. Council Round 1 review (GPT + Gemini).
  4. Patch into v0.2.
  5. Council Round 2 review.
  6. Patch into v0.3.
  7. User approval → enactment at vX.0 BAN HÀNH.
  8. Move to historical archive under draft folder; amendments after enactment go through amendment process.

14. Open questions for Council before drafting

  1. Should the new law absorb Điều 34 (DRAFT) or layer above it? (Default: layer.)
  2. Does executor_class_registry belong to the new law or to Điều 45 as an extension? (Default: new law, but Điều 45 must accept the reference.)
  3. Should governance UI surface rules be in the new law, or a separate Điều 28 amendment? (Default: in new law as boundary clauses; Điều 28 keeps template grammar.)
  4. Proposal table — generic vs per-domain? (Default: generic proposal table with target_kind discriminator; per-domain views.)
  5. How material is "material proposal" (Điều 32 trigger)? (Default: ≥N consumers OR cross-department; tunable.)

15. Risks if law is delayed

  • MOW/MOT implementation drifts and starts redefining queue concepts (Điều 45 violation).
  • Field/form/output ad-hoc proliferation without registry.
  • Multiple proposal tables per domain → governance fragmentation.
  • Nuxt picks up business logic ad-hoc.

Mitigation: keep this plan visible; before any new application-layer DDL is enacted, check this plan first.

16. Risks if law is rushed

  • Premature lock of clauses that have not been validated by implementation.
  • Council noise; rework.

Mitigation: enforce Preconditions §12 strictly.

End law extraction plan.