Workflows and compliance
How on-site checks work with workflows: create from a template, photograph, review, remediate, recheck.
Source docs/en/site/mech-workflow-compliance.md
Document version: 2.0 Status: Compliance-template runtime (the process must first have a definition created in Workflows) Voice: For product, operations, and integrators; implementation terms: Implementation mapping.
Related:
- 工作流.md (template → definition → publish → instance)
- 产品规格.md §4.2.4 (platform plugins — heavy compliance SaaS may live outside)
- 工作区应用.md (lightweight register; no process)
- 服务通知.md (to-do reach, P2)
- Sample plugin:
examples/henry-iway-compliance/(IWay and similar brands may hang a platform-plugin UI)
1. Up front
Cadau core provides a workflow runtime; on-site compliance inspection is one platform template (compliance_inspection). Users create a process definition in the Workflows module then use it — it is not a built-in fixed app.
- From government / customer / IWay or workspace knowledge, generate a compliance checklist by department;
- Inspectors take photos on site;
- The platform judges automatically from images;
- Non-compliant → remediate → recheck until everything passes.
Reimbursement and similar multi-level approval is a second class kind=approval, sharing the engine with compliance; iterate later.
2. Two kinds of workflow (shared engine)
| kind | Name | Pilot | Step semantics |
|---|---|---|---|
orchestration | Task orchestration | Compliance inspection (this page) | Done → hand to the next step |
approval | Conditional approval | Reimbursement (planned) | Pass / reject / return |
3. Compliance-inspection user flow
flowchart TD A[Pick a standards framework and departments] --> B[Generate checklists per department] B --> C[On-site photo, item by item] C --> D[AI vision auto-judgment] D -->|all pass| E[Inspection complete] D -->|non-compliant exists| F[Issue remediation tasks] F --> G[Remediation notes and extra photos] G --> C
3.1 Standards frameworks (built-in MVP)
| framework_id | User-visible name | Note |
|---|---|---|
iway | IWay customer standards | Common warehouse/EHS items |
gov_fire_safety | Government fire safety | Aisles, fire equipment, electrical |
gov_electrical | Government electrical safety | Distribution, cables, grounding |
customer_generic | Customer generic standards | 5S, labels, aisles |
from_knowledge | Workspace compliance standards (knowledge documents) | Generated from the workspace knowledge tree |
Per-workspace JSON config can extend this (P2).
3.2 Knowledge-driven checklists
The workspace maintains knowledge/compliance/ under the knowledge base (recommended), uploads government/customer/IWay and similar Markdown, and rebuilds the index on the knowledge page.
| Mode | Behavior |
|---|---|
| Pick a built-in framework + tick “combine workspace compliance knowledge” | Built-in checklist is primary; the LLM adds extra items from knowledge excerpts |
Pick from_knowledge | Checklist is generated entirely from knowledge documents + LLM (a language model must be configured) |
Knowledge retrieval: internal/compliance/knowledge.go prefers compliance/index.json, else falls back to the workspace-root knowledge/index.json, and if there is still no index, reads Markdown excerpts under compliance directly.
Knowledge-status API: GET .../workflows/compliance/knowledge-status returns whether the directory exists, whether it is indexed, and hint copy.
3.3 Check items and vision
Each item includes: department, category, inspection requirement, legal-basis summary, vision_hints (risks for the model to look at, e.g. “messy cables”, “escape aisle blocked”).
Judgment: pass | fail | inconclusive (needs human review).
4. HTTP API
Path prefix: /api/v1/workspaces/{id}/workflows; workspace member required.
| Method | Path | Note |
|---|---|---|
| GET | /frameworks | List available compliance frameworks (including knowledge-ready status) |
| GET | /compliance/knowledge-status | Workspace compliance knowledge-directory status |
| GET | /instances | This workspace’s compliance instance list |
| POST | /definitions/{defId}/start | Start a compliance inspection (must have a process definition first) |
| GET | /instances/{instanceId} | Detail + checklist + judgment |
| GET | /tasks/mine | My to-dos |
| POST | /tasks/{taskId}/complete | Complete the current task (submit photos / remediation) |
Start request body example:
{
"framework_id": "iway",
"site_name": "A 仓 3 区",
"departments": ["仓储", "行政", "生产"],
"title": "2026-Q2 IWay 例行检查",
"use_knowledge": true
}
use_knowledge: overlay knowledge extras on a built-in framework; when framework_id=from_knowledge, ignore the built-in table and generate from knowledge only.
Complete an inspection task (submit photos):
{
"action": "submit_inspection",
"item_photos": {
"iway-storage-cable-1": "upload-uuid",
"iway-storage-aisle-1": "upload-uuid"
}
}
Complete a remediation task:
{
"action": "submit_remediation",
"items": [
{ "item_id": "iway-storage-cable-1", "note": "已重新捆扎并标识", "photo_upload_id": "upload-uuid" }
]
}
5. Data model (mindlink.db)
| Table | Note |
|---|---|
workflow_instances | Process instance, current step, payload (checklist, judgment, rounds) |
workflow_tasks | To-dos (on-site inspection, remediation) |
Business detail lives in payload_json; no extra wide business tables (MVP).
6. Relation to the IWay plugin
| Layer | Duty |
|---|---|
| Cadau core | Workflow engine, to-dos, vision judgment, generic nodes (form/upload/approval/score/branch and similar), Web process panel |
plugins/compliance | Official compliance: questionnaire → check items → declare a “load inspection standard” workflow node; inspection ledger calls core workflow APIs. IWAY is a sample standard; laws/management policies can replace it |
Who specifies the check scheme: an inspection plan must fix one set (what this round inspects); process settings may also fill a “default check scheme” (used when starting from Workflows). When starting from Compliance, that plan’s scheme is written into instance variables; the load node prefers it and does not overwrite process settings. | Workspace standards library | Law/policy body source of truth (separate from the check-item list) | | henry-iway-compliance sample | Brand-shell sketch; official capability is plugins/compliance |
MVP: core engine + official plugin ledger closed loop; brand customers may wrap another UI layer. The product goal is that this enterprise’s sites meet the rules, not external factory audits.
7. Implementation mapping
| User concept | Implementation |
|---|---|
| Workflow engine | internal/workflow/ |
| Compliance frameworks and vision | internal/compliance/ (including knowledge.go, generate.go) |
| Storage | internal/store/workflow.go |
| API | handlers/workflows.go |
| Workflow app catalog | See 工作流.md |
| Web | WorkflowPanel + ComplianceWorkflowPanel (bound to definition_id) |
8. Later (P3)
- [x] Service notices: to-do assignment (
workflow.task.assigned) - [x] Conversation tools:
workflow_list/workflow_create/workflow_start - [x] Approval-flow kind (simple approval template)
- [ ] To-do due reminders
- [ ] Workspace custom framework JSON
- [ ] Register with the henry-iway plugin manifest