← Archive
lm-004713 · 2026-10

PSMR Workflow Runtime Specification v0.1

下載 MD 檔 ⬇

PSMR Workflow Runtime Specification v0.1

版本: v0.1
日期: 2026-09-15

作者: Neo.K
機構: EveMissLab/一言諾科技有限公司


0. 目的

Workflow Runtime 負責將 Operator 組成可執行、可暫停、可恢復、可驗證的 DAG。

它不是單純 Agent log。

其工作流本身是一級語義物件。


一、Workflow Definition

Π=(VO,EO,K,P)\Pi = ( V_O, E_O, K, P )

其中:

  • VOV_O:Operator invocations;
  • EOE_O:dependency;
  • KK:workflow constraints;
  • PP:policy。

二、Workflow Schema

{
  "workflow_id": "wf_...",
  "schema": "psmr-workflow-0.1",
  "inputs": [],
  "nodes": [],
  "edges": [],
  "policies": [],
  "outputs": []
}

三、Node

{
  "node_id": "n1",
  "operator": "pbsio.impact",
  "parameters": {},
  "capabilities": [],
  "retry_policy": null
}

四、Edge

{
  "from": "n1",
  "to": "n2",
  "condition": "completed"
}

五、Execution State

Workflow Run:

created
running
paused
blocked
completed
failed
cancelled

六、Checkpoint

每個完成 node 可產生 checkpoint:

CPi=(Wi,Oi,Yi,Ei)CP_i = ( W_i, O_i, Y_i, E_i )

七、Resume

若 workflow 中斷,Runtime 從最近合法 checkpoint 恢復。

已完成 pure Operator 不應重跑。


八、Effect Barrier

Effectful Operator 前應建立:

Effect Barrier\boxed{ \text{Effect Barrier} }

檢查:

  • capability;
  • human approval;
  • policy;
  • idempotence;
  • rollback。

九、Human Approval Node

人類批准是一種正式 Operator:

human.approve

輸出:

approved
rejected
modified

十、AI Planning

AI 可以產生:

Πproposal\Pi_{\mathrm{proposal}}

但 workflow plan 預設 authority 為:

ai_proposal

Runtime 仍需驗證 Operator type / capability compatibility。


十一、Dynamic Workflow Expansion

某 Operator 可產生新的 workflow fragment:

Π→Π′\Pi \rightarrow \Pi'

但 expansion 必須記錄:

generated_by
reason
added_nodes
added_edges

十二、Retry

Retry policy:

{
  "max_attempts": 3,
  "backoff": "exponential",
  "only_if": ["TRANSIENT_ERROR"]
}

十三、Cache

對 cacheable Operator:

KOK_O

命中時可直接回用 result。

但 cache hit 必須成為 workflow event:

operator_skipped_by_cache

不能讓 provenance 斷裂。


十四、Branch

Workflow 可以有條件:

if validation failed
→ repair
else
→ finish

十五、Loop

Loop 必須有 boundary:

max_iterations
convergence_condition
stop_condition

禁止無限制 Agent 自循環。


十六、Workflow Provenance

每個 run 應能回答:

Who initiated?
What inputs?
Which operators?
Which versions?
Which cache hits?
Which capabilities?
Which external effects?
Which outputs?
Which unresolved items?

十七、Modification Workflow

建議標準工作流:

Intent
→ Locate Semantic Region
→ Impact
→ Load Contracts
→ Propose Semantic Delta
→ Validate Delta
→ Project Patch
→ Run Tests
→ Rebuild Workspace
→ Semantic Diff
→ Verify
→ Human Approval

十八、Understanding Workflow

Input
→ Observe
→ Build Workspace
→ Slice
→ Retrieve Evidence
→ Explain

十九、PR Review Workflow

Base
+
Head
→ Build / Reuse CISG
→ Semantic Diff
→ Impact
→ New Findings
→ Review Fingerprint
→ Human Review

二十、Runtime Reconciliation Workflow

未來:

Static Graph
+
Runtime Trace
→ Runtime Graph
→ Reconcile
→ Drift
→ New Unknowns / Conflicts

二十一、Workflow Validation

執行前驗證:

Valid⁡(Π)\operatorname{Valid}(\Pi)

至少檢查:

  • type compatibility;
  • cycle;
  • missing capability;
  • impossible dependency;
  • missing effect barrier。

二十二、Failure Isolation

單一 Operator failure 不應污染整個 Workspace。

結果應:

failed node
preserved prior checkpoint
typed failure
partial outputs if safe

二十三、Workflow Identity

定義:

ID⁡(Π)=H(N(Π))\operatorname{ID}(\Pi) = H( N(\Pi) )

可用於:

  • cache;
  • audit;
  • reproducibility;
  • comparison。

二十四、Workflow Diff

可比較:

Π1→Π2\Pi_1 \rightarrow \Pi_2

回答:

AI 的做事方式改了什麼?

這也是 AI-native system 的重要可觀測性。


二十五、結論

Workflow Runtime 把「Agent 做事過程」從不可重現的 conversational trace,提升成:

Typed+Executable+Checkpointable+Auditable+Verifiable\boxed{ \text{Typed} + \text{Executable} + \text{Checkpointable} + \text{Auditable} + \text{Verifiable} }

的 Semantic Workflow Graph。

這是 PSMR 從 analyzer 升級成真正 runtime 的核心。