鼎味肉市DESIGN ATELIER
← 资料目录docs/rules/state-machine.md阅读原文

State Machine Rule


rule_id: R-STATE-01 category: Architecture status: locked owner: Project Manager / Architect scope: states, flows, retry, dependency, terminal states, audit, concurrency

1. Rule

The state machine is the source of truth for lifecycle behavior.

Code must not hide undocumented states, transitions, terminal states, retry behavior, or dependency semantics.

2. Use When

Use this rule for orders, payments, files, uploads, approvals, sessions, subscriptions, async jobs, pipeline jobs, or any lifecycle entity.

3. Hard Rules

4. Required Sections

State docs must include:

5. Audit Fields

Field Meaning
entity_id entity identifier
old_state previous state
new_state next state
event triggering event
actor user or system
request_id trace id
occurred_at timestamp
metadata context

6. Gates

7. Forbidden