360 Secure SkillHub
360 安全技能中心

a2a-Market-Order-State-Machine

这是A2A交易订单编排用的初版状态机框架,核心功能包括定义订单从创建到完成/取消的全生命周期状态、合法流转守卫,集成支付与声誉触发,提供订单创建、状态流转、历史查询、超时恢复等MVP接口,支持事件发布。典型场景是实现从报价确认到支付、履约、异常处理的端到端订单编排,输入含订单ID、操作等,输出为订单状态、流转历史或事件通知。

luoqianchenguni-max
luoqianchenguni-max
热度 54.42
最近更新 2026-05-11 17:33:42
分类:开发依赖:纯提示词应用场景:代码生成 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add a2a-market-order-state-machine
Metadata
name
a2a-market-order-state-machine
description
Define order lifecycle states, transition guards, and recovery paths for A2A transactions. Use when implementing order orchestration from quote acceptance through payment, fulfillment, completion, and exception handling.

a2a-Market Order State Machine

Define the canonical order lifecycle and transition guard framework.

Current status: first-release scaffold for early protocol compatibility.

Scope

  • Model order states from creation to completion/cancelation.
  • Enforce legal transitions with guard checks and side effects.
  • Integrate payment and reputation triggers into state changes.

Suggested Project Layout

  • app/domain/order/order_state.py
  • app/domain/order/order_aggregate.py
  • app/application/usecases/transition_order.py
  • app/application/services/order_event_publisher.py

Minimum Contracts (MVP P0)

  1. create_order(intent_id, accepted_quote_id) initializes order in CREATED.
  2. transition(order_id, action, actor, payload) validates and applies state move.
  3. get_order_timeline(order_id) returns ordered transition history.
  4. recover_pending_orders(now_ts) handles timeout and stuck states.

Base States

  • CREATED
  • NEGOTIATING
  • PAYMENT_PENDING
  • PAID
  • FULFILLING
  • COMPLETED
  • CANCELED
  • FAILED

Events

  • Emit ORDER_CREATED at initialization.
  • Emit ORDER_COMPLETED when terminal success is reached.
  • Emit reputation update trigger after completion/cancel resolution.

Implementation Backlog

  • Add compensation transitions for partial fulfillment failures.
  • Add deterministic replay from event store snapshots.

Runtime Implementation

  • Status: implemented in local runtime package.
  • Primary code paths:
  • runtime/src/domain/order-state-machine.js
  • Validation: covered by runtime/tests and npm test in runtime/.