Design baseline · 28 SEP 2026 · 03 / 23
Domain & state machines
Mô hình nghiệp vụ đích: Process Definition → Workflow có một Role owner → Task graph.
DESIGN DIAGRAMS · TARGET ARCHITECTURE 2.0
01 · Task state machine
Chỉ chuyển SUCCEEDED sau validation. Mọi nonterminal state có thể nhận CANCEL; retry hữu hạn. Follow-up của task terminal là task mới.
02 · Delivery state: timeout chưa phải thất bại
ACK durable chỉ xác nhận command đã nhận. SENT cần provider receipt. UNKNOWN phải đối soát trước khi quyết định tiếp theo.
| Entity | Ý nghĩa / vòng đời |
|---|---|
| RoleDefinition / RoleVersion | Trách nhiệm logistics, phạm vi dữ liệu, policy, capability allowlist, context profile và human owner; không chứa model/provider cố định. |
| TaskDefinition / TaskInstance | Task thuộc Workflow Instance và kế thừa Role owner của Workflow; khai báo schema, executor kind, retry, timeout, evidence, idempotency. |
| SkillDefinition / SkillVersion | Input/output schema, executor CODE/AI/HYBRID, required tools, timeout và retry policy. |
| ProcessDefinition / ProcessDefinitionVersion | Mẫu nghiệp vụ end-to-end; tham chiếu Workflow con, điều kiện start/handoff/completion và policy; version độc lập. |
| WorkflowDefinition / WorkflowDefinitionVersion | Một quy trình con có đúng một Role owner và task graph; version độc lập với Process Definition. |
| BusinessCase / ProcessInstance | Business Case định danh booking/lô hàng; Process Instance là một lần chạy Process Definition và chứa nhiều Workflow Instances. |
| WorkflowInstance | Một lần chạy Workflow trong Process Instance, pin Workflow + Role version và graph state. |
| Execution | Một lần thử chạy node/skill; lease, attempt, input/output hash và error. |
| Result / Review | Output có evidence + validation; quyết định con người giữ actor, reason và expectedVersion. |
| ChannelBinding / Integration | Kết nối channel/session/group và tên hiển thị; workflow version xác định nhóm nguồn/đích. Credential chỉ lưu secret reference. |
Task state
RECEIVED → ROUTED → PLANNED → RUNNING → SUCCEEDED
↘ WAITING_INPUT → RUNNING
↘ WAITING_REVIEW → RUNNING
↘ RETRY_WAIT → RUNNING
↘ FAILED
Nonterminal → CANCELLED (explicit command + audit)
SUCCEEDED chỉ khi kết quả task đã được Validator chấp nhận theo task schema. Business review và delivery là task/state riêng: extraction hoàn tất không đồng nghĩa report đã gửi. Retry vượt maxAttempts → FAILED và ghi alert/audit. Không tự mở lại task terminal; tạo follow-up task với parentTaskId.
Process / Workflow state
Process Instance giữ lifecycle nghiệp vụ end-to-end; mỗi Workflow Instance có lifecycle riêng và pin Workflow/Role version. Workflow node graph hỗ trợ branch, parallel fork/join, wait và review; join policy, timeout, retry/failure path phải khai báo rõ. Không dùng một graph duy nhất thay Process Definition và các Workflow con.
Dispatch decision
IGNORE giữ reason và event; ASSIGN tạo một/nhiều task; ATTACH gắn event bổ sung vào một task nonterminal cùng tenant/session/thread sau kiểm tra correlation. Sự kiện không chọn được workflow hợp lệ được ghi IGNORE, không tạo hàng đợi làm rõ riêng. Mọi decision có phiên bản policy, model metadata nếu dùng AI, và audit.
Album và shipment
Một album = một submission dự kiến cho một container. Dùng provider album ID khi có; fallback gom cùng sender/thread trong cửa sổ cấu hình. Ảnh đến muộn tạo event bổ sung và nối submission sau kiểm tra. Nhận diện nhiều container hoặc mâu thuẫn → review; không âm thầm tách hay ghi đè. ShipmentId được phép null đến khi resolve đủ bằng chứng.