S7-09 · 进阶 · 概念实验 S7-09 · Advanced · Concept Lab

状态机 · 当前在哪一步,决定下一步能做什么 State Machine · Current State Determines What Can Happen Next

state + event + guard condition → allowed transition or explicit rejection

状态机(State Machine)用有限状态及明确转移条件描述流程当前所处阶段和允许动作。它把自由循环收紧为可审计路径,并为责任人、超时与例外留下确定位置。 A state machine uses finite states and explicit transition conditions to describe where a process is and what actions are allowed. It constrains open loops into auditable paths with owners, timeouts, and exceptions.

01 · 先从日常问题开始 01 · Start with an everyday question

订单还没审核,就有人直接点“已发货”——系统该照做,还是先问这条路是否存在? An order has not been reviewed, yet someone clicks “shipped.” Should the system comply or first check whether that transition exists?

02 点击事件推进;不在表里的跳转会被拒绝 Trigger Events; Jumps Outside the Table Are Rejected

事件是唯一主动作 events are the main action
当前状态 Current state
DRAFT
external state
合法转移 Legal transitions
0
accepted events
拒绝跳转 Rejected jumps
0
audited rejects

03 一条可审计转移包含四件事 An Auditable Transition Has Four Parts

把变化映射到零件 Map change to parts
01 · STATE

有限状态 Finite state

草稿、审核、工具执行、完成是明确枚举,不靠自然语言猜测。 Draft, review, tool execution, and done are explicit enums, not inferred from prose.

02 · EVENT

触发事件 Event

提交、批准、工具成功等事件请求一次状态变化。 Submit, approve, and tool-success events request a state change.

03 · GUARD

转移条件 Guard condition

只有当前状态、权限和证据同时满足,边才可通过。 An edge opens only when current state, authority, and evidence all satisfy its guard.

04 · OWNER

责任与超时 Owner and timeout

每条边写明谁处理、多久未完成会进入异常路径。 Each edge states who owns it and when delay enters an exception path.

04 最小规则:只执行转移表里允许的边 Minimal Rule: Execute Only Edges in the Transition Table

δ(state, event) → next or reject
δ(state, event) = next state
otherwise → reject
当前状态与事件共同决定下一状态。没有定义的“草稿→完成”不会因为模型说得合理就自动出现。 Current state and event jointly determine the next state. An undefined draft-to-done jump does not appear because a model sounds persuasive.
读取当前状态 Read current state 外部记录是事实 external record is fact
匹配事件与条件 Match event and guard 查转移表 consult transition table
写入新状态 Write next state 拒绝也留下记录 rejection is recorded

05 边界实验:从草稿直跳工具执行 Boundary Test: Jump from Draft Straight to Tool Execution

主动制造失败 Create a failure

跳过提交与审核两道边 Skip both submit and review edges

重置到草稿后请求“直接执行工具”。转移表没有这条边,因此动作被拒绝,当前状态不能变化。 Reset to draft and request “run tool now.” The transition table has no such edge, so the action is rejected and state cannot change.

尚未执行。先操作上方主交互。 Not run yet. Use the main interaction above first.
流程图画了箭头就一定能执行。 A drawn arrow is automatically executable. → ✓ 边必须有事件、条件、责任人与超时。 Edges need events, guards, owners, and timeouts.
模型说“已完成”就更新状态。 Update state when the model says “done.” → ✓ 只用真实事件与校验结果触发转移。 Use real events and verified outcomes to transition.
非法跳转可以静默忽略。 Illegal jumps can be silently ignored. → ✓ 拒绝原因与当前状态都要可观察。 Expose rejection reason and current state.
06 · 一句话带走 06 · One line to keep

状态机把流程收紧为有限状态与有条件的边:事件只有在当前状态和转移条件匹配时才改变状态,非法跳转必须拒绝并留痕。 A state machine constrains a process to finite states and guarded edges. Events change state only when the current state and transition conditions match; illegal jumps are rejected and recorded.