@wowok/agent-mcp 2.3.18 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/customer/industry-risks.js +31 -31
  2. package/dist/customer/order-monitor.js +57 -57
  3. package/dist/customer/order-strategy.js +89 -89
  4. package/dist/customer/post-purchase.js +97 -97
  5. package/dist/customer/reminder-system.js +26 -26
  6. package/dist/customer/risk-assessment.js +46 -46
  7. package/dist/customer/types.d.ts +4 -4
  8. package/dist/customer/types.js +4 -4
  9. package/dist/customer/user-preferences.js +50 -50
  10. package/dist/experience/intent-distill.js +6 -6
  11. package/dist/index.d.ts +2 -2
  12. package/dist/index.js +11 -1624
  13. package/dist/knowledge/acquisition-flywheel.js +64 -64
  14. package/dist/knowledge/arbitration-trust.js +10 -10
  15. package/dist/knowledge/demand-matching.js +8 -8
  16. package/dist/knowledge/dynamic-pricing.js +18 -18
  17. package/dist/knowledge/flywheel-loop.js +11 -11
  18. package/dist/knowledge/glossary.js +22 -22
  19. package/dist/knowledge/guard-ledger.d.ts +1 -1
  20. package/dist/knowledge/guard-ledger.js +145 -104
  21. package/dist/knowledge/guard-lint.d.ts +77 -0
  22. package/dist/knowledge/guard-lint.js +670 -0
  23. package/dist/knowledge/guard-migration.d.ts +48 -0
  24. package/dist/knowledge/guard-migration.js +228 -0
  25. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  26. package/dist/knowledge/guard-puzzle.js +627 -101
  27. package/dist/knowledge/guard-risk.d.ts +10 -1
  28. package/dist/knowledge/guard-risk.js +1634 -292
  29. package/dist/knowledge/guard-templates.d.ts +38 -0
  30. package/dist/knowledge/guard-templates.js +605 -0
  31. package/dist/knowledge/guard-translation.d.ts +14 -2
  32. package/dist/knowledge/guard-translation.js +825 -194
  33. package/dist/knowledge/index.d.ts +8 -4
  34. package/dist/knowledge/index.js +9 -5
  35. package/dist/knowledge/industry-evolution.js +29 -29
  36. package/dist/knowledge/industry-generalizer.js +52 -52
  37. package/dist/knowledge/industry-registry.js +20 -33
  38. package/dist/knowledge/intent-metrics.js +67 -67
  39. package/dist/knowledge/process-model.js +80 -80
  40. package/dist/knowledge/reputation-rules.js +9 -9
  41. package/dist/knowledge/reward-templates.js +51 -51
  42. package/dist/knowledge/safety-rules.js +3 -3
  43. package/dist/knowledge/tool-constraints.js +20 -4
  44. package/dist/knowledge/trust-metrics.js +26 -26
  45. package/dist/project/graph.d.ts +1 -0
  46. package/dist/project/graph.js +27 -1
  47. package/dist/project/index.d.ts +1 -0
  48. package/dist/project/index.js +39 -2
  49. package/dist/project/namespace.d.ts +11 -1
  50. package/dist/project/namespace.js +27 -2
  51. package/dist/project/query.d.ts +2 -0
  52. package/dist/project/query.js +56 -15
  53. package/dist/rules.d.ts +12 -0
  54. package/dist/rules.js +9 -0
  55. package/dist/schema/call/allocation.d.ts +10 -10
  56. package/dist/schema/call/base.js +19 -19
  57. package/dist/schema/call/bridge.d.ts +32 -32
  58. package/dist/schema/call/demand.d.ts +84 -84
  59. package/dist/schema/call/guard.d.ts +153 -0
  60. package/dist/schema/call/guard.js +50 -0
  61. package/dist/schema/call/machine.d.ts +38 -38
  62. package/dist/schema/call/permission.d.ts +78 -78
  63. package/dist/schema/call/repository.d.ts +22 -22
  64. package/dist/schema/call/semantic.js +229 -25
  65. package/dist/schema/call/service.d.ts +7 -7
  66. package/dist/schema/local/wip.d.ts +39 -19
  67. package/dist/schema/local/wip.js +5 -5
  68. package/dist/schema/messenger/index.d.ts +26 -26
  69. package/dist/schema/messenger/index.js +2 -2
  70. package/dist/schema/operations.d.ts +270 -192
  71. package/dist/schema/query/index.d.ts +184 -184
  72. package/dist/schema/query/index.js +15 -9
  73. package/dist/schema/trust/index.d.ts +4 -4
  74. package/dist/schema/utils/guard-parser.js +4 -4
  75. package/dist/schema/utils/guard-query-utils.d.ts +7 -0
  76. package/dist/schema/utils/guard-query-utils.js +14 -1
  77. package/dist/schema/utils/node-parser.js +14 -14
  78. package/dist/schemas/bridge_operation.output.json +15 -15
  79. package/dist/schemas/index.json +1 -1
  80. package/dist/schemas/messenger_operation.output.json +18 -16
  81. package/dist/schemas/onchain_events.output.json +15 -15
  82. package/dist/schemas/onchain_operations.output.json +16 -16
  83. package/dist/schemas/onchain_operations.schema.json +11 -20
  84. package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
  85. package/dist/schemas/onchain_operations_machine.schema.json +2 -5
  86. package/dist/schemas/onchain_operations_service.schema.json +2 -5
  87. package/dist/schemas/onchain_table_data.output.json +20 -26
  88. package/dist/schemas/wip_file.output.json +24 -1
  89. package/dist/tools/handlers/bridge.d.ts +1 -0
  90. package/dist/tools/handlers/bridge.js +1 -0
  91. package/dist/tools/handlers/config.d.ts +2 -0
  92. package/dist/tools/handlers/config.js +71 -0
  93. package/dist/tools/handlers/file-export.d.ts +3 -0
  94. package/dist/tools/handlers/file-export.js +90 -0
  95. package/dist/tools/handlers/local.d.ts +30 -0
  96. package/dist/tools/handlers/local.js +27 -0
  97. package/dist/tools/handlers/messenger.d.ts +16 -0
  98. package/dist/tools/handlers/messenger.js +187 -0
  99. package/dist/tools/handlers/onchain.d.ts +2 -0
  100. package/dist/tools/handlers/onchain.js +246 -0
  101. package/dist/tools/handlers/project.d.ts +2 -0
  102. package/dist/tools/handlers/project.js +53 -0
  103. package/dist/tools/handlers/query.d.ts +5 -0
  104. package/dist/tools/handlers/query.js +256 -0
  105. package/dist/tools/handlers/schema-query.d.ts +2 -0
  106. package/dist/tools/handlers/schema-query.js +92 -0
  107. package/dist/tools/handlers/trust.d.ts +2 -0
  108. package/dist/tools/handlers/trust.js +194 -0
  109. package/dist/tools/handlers/wip.d.ts +2 -0
  110. package/dist/tools/handlers/wip.js +44 -0
  111. package/dist/tools/index.d.ts +13 -0
  112. package/dist/tools/index.js +479 -0
  113. package/dist/tools/rules-hook.d.ts +2 -0
  114. package/dist/tools/rules-hook.js +22 -0
  115. package/dist/tools/shared.d.ts +29 -0
  116. package/dist/tools/shared.js +130 -0
  117. package/dist/tools/types.d.ts +35 -0
  118. package/dist/tools/types.js +1 -0
  119. package/dist/tools/wrap.d.ts +6 -0
  120. package/dist/tools/wrap.js +55 -0
  121. package/package.json +19 -5
@@ -3,7 +3,7 @@ export const CONCEPT_GLOSSARY = [
3
3
  term: "Permission",
4
4
  definition: "Organization-wide permission object. indices 0-999 builtin, 1000-65535 custom. " +
5
5
  "Shared across all Progress instances of a Service. Use for internal staff roles.",
6
- aliases: ["permission object", "权限对象"],
6
+ aliases: ["permission object"],
7
7
  category: "permission",
8
8
  },
9
9
  {
@@ -17,7 +17,7 @@ export const CONCEPT_GLOSSARY = [
17
17
  term: "OrderHolder",
18
18
  definition: "The order holder and their agents. Represented by namedOperator=\"\" (empty string) " +
19
19
  "on a Forward. Lets the customer operate their own order.",
20
- aliases: ["order owner", "orderholder", "订单持有人"],
20
+ aliases: ["order owner", "orderholder", "order holder"],
21
21
  category: "permission",
22
22
  },
23
23
  {
@@ -25,139 +25,139 @@ export const CONCEPT_GLOSSARY = [
25
25
  definition: "A state-transition edge in a Machine. Carries weight, a permission " +
26
26
  "(Permission index / NamedOperator / OrderHolder), and an optional Guard. " +
27
27
  "Every Forward MUST define at least one permission.",
28
- aliases: ["迁移", "transition"],
28
+ aliases: ["transition"],
29
29
  category: "operation",
30
30
  },
31
31
  {
32
32
  term: "Pair",
33
33
  definition: "A prev_node → next_node transition group in a Machine with a threshold. " +
34
34
  "When the cumulative weight of executed Forwards meets the threshold, the Pair fires.",
35
- aliases: ["迁移对", "transition pair"],
35
+ aliases: ["transition pair"],
36
36
  category: "operation",
37
37
  },
38
38
  {
39
39
  term: "Machine",
40
40
  definition: "Workflow blueprint (directed graph). Becomes immutable after publish. " +
41
41
  "A Progress instance is created per order from the Machine.",
42
- aliases: ["工作流模板", "machine template"],
42
+ aliases: ["machine template"],
43
43
  category: "object",
44
44
  },
45
45
  {
46
46
  term: "Progress",
47
47
  definition: "A workflow instance bound to one order. Advances via Forwards; " +
48
48
  "carries retained_submission values for Guard verification.",
49
- aliases: ["流程实例", "progress instance"],
49
+ aliases: ["progress instance"],
50
50
  category: "object",
51
51
  },
52
52
  {
53
53
  term: "Guard",
54
54
  definition: "Immutable static validation rule. Verifies submissions and on-chain object data. " +
55
55
  "Returns boolean. Cannot be mutated after creation.",
56
- aliases: ["守卫", "guard object"],
56
+ aliases: ["guard object"],
57
57
  category: "acceptance",
58
58
  },
59
59
  {
60
60
  term: "Repository",
61
61
  definition: "Mutable dynamic acceptance store. Keyed by (name, entity). " +
62
62
  "Used for data that can change over time (e.g. SLA config, review records).",
63
- aliases: ["仓库", "repository object"],
63
+ aliases: ["repository object"],
64
64
  category: "acceptance",
65
65
  },
66
66
  {
67
67
  term: "Acceptance",
68
68
  definition: "The verification standard for a process step. Composed of static Guard + " +
69
69
  "dynamic Repository. Drives whether a Forward can execute.",
70
- aliases: ["验收标准", "acceptance standard"],
70
+ aliases: ["acceptance standard"],
71
71
  category: "acceptance",
72
72
  },
73
73
  {
74
74
  term: "Service",
75
75
  definition: "A merchant's service listing. References Machine, order_allocators, arbitrations, " +
76
76
  "compensation_fund, rewards, buy_guard. machine & order_allocators lock after publish.",
77
- aliases: ["服务", "service object"],
77
+ aliases: ["service object"],
78
78
  category: "object",
79
79
  },
80
80
  {
81
81
  term: "Order",
82
82
  definition: "An order against a Service. Funds are escrowed; released via Progress + Allocation. " +
83
83
  "Arb cases attach to orders for dispute resolution.",
84
- aliases: ["订单"],
84
+ aliases: ["order instance"],
85
85
  category: "object",
86
86
  },
87
87
  {
88
88
  term: "Allocator",
89
89
  definition: "Fund distribution rules. Priority: Amount → Rate → Surplus. first-Guard-wins. " +
90
90
  "Locked on Service publish (order_allocators).",
91
- aliases: ["分账器", "allocation"],
91
+ aliases: ["allocation"],
92
92
  category: "fund",
93
93
  },
94
94
  {
95
95
  term: "Allocation",
96
96
  definition: "The act of distributing escrowed funds to recipients per an Allocator. " +
97
97
  "Executed by the order holder or Permission holder.",
98
- aliases: ["分账"],
98
+ aliases: ["allocation act"],
99
99
  category: "fund",
100
100
  },
101
101
  {
102
102
  term: "Arbitration",
103
103
  definition: "Independent arbitration service object. Configured with voting_guard, usage_guard, " +
104
104
  "fee. Generates Arb cases per dispute. Third-party preferred over self-built.",
105
- aliases: ["仲裁服务", "arb service"],
105
+ aliases: ["arb service"],
106
106
  category: "object",
107
107
  },
108
108
  {
109
109
  term: "Arb",
110
110
  definition: "A single dispute case instance of an Arbitration. Has a state machine " +
111
111
  "(dispute → confirm → vote → verdict → settle).",
112
- aliases: ["仲裁案", "arb case"],
112
+ aliases: ["arb case"],
113
113
  category: "object",
114
114
  },
115
115
  {
116
116
  term: "compensation_fund",
117
117
  definition: "A fund attached to a Service. Arbitration indemnity is drawn from it. " +
118
118
  "Adequacy is a key trust signal for customers.",
119
- aliases: ["赔偿基金", "赔偿金"],
119
+ aliases: ["compensation fund"],
120
120
  category: "fund",
121
121
  },
122
122
  {
123
123
  term: "buy_guard",
124
124
  definition: "A Guard attached to a Service that gates purchasing. Validates customer eligibility.",
125
- aliases: ["购买守卫"],
125
+ aliases: ["buy guard"],
126
126
  category: "acceptance",
127
127
  },
128
128
  {
129
129
  term: "Sub-Order",
130
130
  definition: "A child order in a cross-Machine supply chain. Introduced at a node with transparent " +
131
131
  "suppliers; verified by Guard to originate from one of the declared suppliers.",
132
- aliases: ["采购子订单", "suborder", "sub order"],
132
+ aliases: ["suborder", "sub order"],
133
133
  category: "object",
134
134
  },
135
135
  {
136
136
  term: "Reward",
137
137
  definition: "Incentive pool. claim is Guard-gated. guard_add supports Fixed or GuardU64Identifier " +
138
138
  "(dynamic). Used for marketing (first-order, cumulative, referral).",
139
- aliases: ["奖励", "reward pool"],
139
+ aliases: ["reward pool"],
140
140
  category: "fund",
141
141
  },
142
142
  {
143
143
  term: "Demand",
144
144
  definition: "A user's posted service request with optional reward. presenters submit proposals; " +
145
145
  "Guard filters them. Matches Services for personalized acquisition.",
146
- aliases: ["需求"],
146
+ aliases: ["demand request"],
147
147
  category: "object",
148
148
  },
149
149
  {
150
150
  term: "Personal",
151
151
  definition: "Permanently public on-chain identity profile. Social links, reputation (likes/dislikes), " +
152
152
  "personal info records. CRITICAL: everything here is PUBLIC forever.",
153
- aliases: ["公开身份", "personal profile"],
153
+ aliases: ["personal profile"],
154
154
  category: "object",
155
155
  },
156
156
  {
157
157
  term: "Contact",
158
158
  definition: "Bridges a Service's um (contact) and the Messenger ims (messaging). Enables " +
159
159
  "off-chain encrypted communication for pre-order negotiation & evidence.",
160
- aliases: ["联系"],
160
+ aliases: ["contact bridge"],
161
161
  category: "object",
162
162
  },
163
163
  ];
@@ -14,6 +14,6 @@ export interface GuardScene {
14
14
  }
15
15
  export declare const GUARD_SCENES: GuardScene[];
16
16
  export declare function findScene(host_object: string, binding_field: string): GuardScene | undefined;
17
- export declare function inferSceneFromAction(action: "buy" | "forward" | "allocate" | "claim_reward" | "vote" | "dispute" | "write_repository" | "submit_progress"): GuardScene | undefined;
17
+ export declare function inferSceneFromAction(action: "buy" | "forward" | "allocate" | "claim_reward" | "vote" | "dispute" | "write_repository" | "submit_progress" | "gen_passport"): GuardScene | undefined;
18
18
  export declare function getImmutableScenes(): GuardScene[];
19
19
  export declare function getNumericIdentifierScenes(): GuardScene[];
@@ -1,197 +1,237 @@
1
1
  export const GUARD_SCENES = [
2
2
  {
3
3
  id: "service_buy_guard",
4
- name: "服务购买验证(buy_guard",
4
+ name: "Service purchase validation (buy_guard)",
5
5
  host_object: "Service",
6
6
  binding_field: "buy_guard",
7
- validation_scene: "客户下单购买服务时,Guard 验证客户是否有资格购买(身份/许可/条件)",
8
- pass_result: "创建 Order 对象,客户进入支付流程",
9
- fail_result: "交易拒绝,Order 不创建,客户无法购买",
10
- submission_source: "Customersigner 地址、credentialsPassport 等)",
7
+ validation_scene: "When a customer places an order to purchase a service, the Guard validates whether the customer is eligible to purchase (identity/permission/condition)",
8
+ pass_result: "Create the Order object; the customer enters the payment flow",
9
+ fail_result: "Transaction rejected; Order is not created; the customer cannot purchase",
10
+ submission_source: "Customer (signer address, credentials, Passport, etc.)",
11
11
  special_constraints: [
12
- "Guard table 必须声明所有客户需要提交的数据",
13
- "b_submission=true 条目的 name 必须是自然语言描述(客户看到的契约)",
14
- "如果 Guard 引用 Service 本身,使用循环引用模式(CREATE Service → CREATE Guard → MODIFY Service",
15
- "Service 发布后 buy_guard 仍可修改(通过 MODIFY Service",
12
+ "The Guard table must declare all data the customer needs to submit",
13
+ "The name of b_submission=true entries must be a natural-language description (the contract the customer sees)",
14
+ "If the Guard references the Service itself, use the circular reference pattern (CREATE Service → CREATE Guard → MODIFY Service)",
15
+ "buy_guard can still be modified after Service is published (via MODIFY Service)",
16
+ "Reentrancy: LOW — Each purchase creates a fresh Order; no existing Order state is modified. Default: no reentrancy risk. IF business intent is 'limit one purchase per user' (limited-edition goods, whitelist single-buy), an anti-reentrancy check is REQUIRED but no direct GUARDQUERY primitive exists for per-user purchase history — use a Repository to record prior purchases and add `repository.data has` (query 1166) + `logic_not` to root, or revoke EntityRegistrar membership after first buy",
16
17
  ],
17
18
  common_patterns: [
18
- "身份检查:context(Signer) + logic_equal(单地址)/ vec_contains_address(白名单)",
19
- "会员验证:query EntityRegistrar(0xaab) + logic_and 组合",
20
- "时间限制:context(Clock) + logic_as_u256_greater_or_equal",
21
- "多条件:logic_and 组合多个检查",
19
+ "Identity check: context(Signer) + logic_equal (single address) / vec_contains_address (whitelist)",
20
+ "Membership validation: query EntityRegistrar(0xaab) + logic_and combination",
21
+ "Time limit: context(Clock) + logic_as_u256_greater_or_equal",
22
+ "Multi-condition: logic_and combining multiple checks",
22
23
  ],
23
24
  mutable_after_publish: true,
24
25
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R9"],
25
26
  },
26
27
  {
27
28
  id: "service_order_allocators_guard",
28
- name: "分账策略选择验证(order_allocators[].guard",
29
+ name: "Allocation strategy selection validation (order_allocators[].guard)",
29
30
  host_object: "Service",
30
31
  binding_field: "order_allocators",
31
- validation_scene: "订单完成或满足分账条件时,系统按 order_allocators 顺序评估每个 Allocator Guard," +
32
- "第一个通过的 Guard 对应的 Allocator 执行分账",
33
- pass_result: "执行该 Allocator 的分账策略(按比例/按条件分配资金)",
34
- fail_result: "跳过此 Allocator,尝试下一个(first-match-wins)。如果所有 Allocator 都失败,资金不分配",
35
- submission_source: "System Progress 状态自动派生(无需客户显式提交)",
32
+ validation_scene: "When an order is completed or allocation conditions are met, the system evaluates each Allocator's Guard in order_allocators order. " +
33
+ "The first Allocator whose Guard passes executes the allocation",
34
+ pass_result: "Execute that Allocator's allocation strategy (distribute funds by ratio/condition)",
35
+ fail_result: "Skip this Allocator and try the next (first-match-wins). If all Allocators fail, funds are not distributed",
36
+ submission_source: "System auto-derives from Progress state (no explicit customer submission needed)",
36
37
  special_constraints: [
37
- "order_allocators 顺序敏感:第一个 Guard 通过的 Allocator 执行分账",
38
- "Service 发布后 order_allocators 不可修改(immutable",
39
- "Guard 通常查询 Order/Progress 状态判断分账条件",
40
- "常用 query: order.amount, progress.current_node, order.completed ",
41
- "GuardIdentifier 可用于动态金额(从 table 提取 u64 值作为分账比例)",
38
+ "order_allocators is order-sensitive: the first Allocator whose Guard passes executes allocation",
39
+ "order_allocators cannot be modified after Service is published (immutable)",
40
+ "Guard usually queries Order/Progress state to determine allocation conditions",
41
+ "Common queries: order.amount, progress.current_node, order.completed, etc.",
42
+ "GuardIdentifier can be used for dynamic amounts (extract u64 value from table as allocation ratio)",
43
+ "Guard+sharing coupling: Guard determines IF allocation happens; sharing.who determines WHERE funds go. If sharing.who=Signer, the caller receives funds — the Guard MUST bind Signer (context(Signer)==authorized) to prevent theft. PREFERRED: use sharing.who=Entity (Treasury or fixed address) so funds always go to the legitimate recipient regardless of caller.",
44
+ "allocators require unique guard addresses: no two allocators may reference the same Guard object (create separate Guard objects with identical root/table but different descriptions if needed).",
45
+ "First-match-wins: only the first allocator whose Guard passes executes; subsequent allocators are skipped. Multiple allocators represent alternative strategies, not a simultaneous split.",
46
+ "If sharing.who=Entity references a Treasury object, verify the Treasury's permission is consistent with the Service's permission (different permissions = different permission organizations = minor risk).",
47
+ "Reentrancy: LOW — Protocol-level protection: order::on_allocation (order.move L116-119) asserts `allocation` field is None (E_ALLOCATION_ALREADY_SPECIFIED), enforcing ONE Allocation object per Order, ever. After alloc() executes, typical Rate-mode allocators (sum=10000, validated at allocation.move L162-163) and any Surplus-mode allocator drain balance to 0 via balance::withdraw_all (L254), making a second alloc() fail at `assert!(balance >= threshold)` (L193). EDGE CASE: Amount-mode-only allocators (no Surplus, total < full balance) leave remainder; a second alloc() could extract more — mitigated by preferring Rate/Surplus modes. External deposit via receive() (L291) is possible but irrational (attacker funds the Allocation they attack). Optional anti-reentrancy primitive: `order.allocation some` (query 1568) + logic_not",
42
48
  ],
43
49
  common_patterns: [
44
- "节点状态检查:query(Progress.current_node) + logic_equal('Completed')",
45
- "金额阈值:query(Order.amount) + logic_as_u256_greater_or_equal(threshold)",
46
- "多条件组合:logic_and(节点状态 + 金额 + 时间)",
47
- "GuardIdentifier 动态比例:table[u64] 提取分账比例",
50
+ "Node state check: query(Progress.current_node) + logic_equal('Completed')",
51
+ "Amount threshold: query(Order.amount) + logic_as_u256_greater_or_equal(threshold)",
52
+ "Multi-condition combination: logic_and (node state + amount + time)",
53
+ "GuardIdentifier dynamic ratio: table[u64] extracts allocation ratio",
54
+ "Treasury+personal 2-allocator pattern: 2 Guard objects (identical root/table, different descriptions) + 2 allocators (sharing.who=Entity Treasury / Entity personal) — 2 alternative merchant collection approaches; first-match-wins means only the first executes.",
48
55
  ],
49
56
  mutable_after_publish: false,
50
57
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
51
58
  },
52
59
  {
53
60
  id: "machine_forward_guard",
54
- name: "工作流节点推进验证(Forward.guard",
61
+ name: "Workflow node advancement validation (Forward.guard)",
55
62
  host_object: "Machine",
56
63
  binding_field: "Forward.guard",
57
- validation_scene: "客户或商家执行 Forward 操作推进工作流时,Guard 验证是否允许推进到下一节点",
58
- pass_result: "Progress 推进到 next_nodesession 累计权重",
59
- fail_result: "Forward 阻塞,Progress 停留在当前节点。可选 retained_submission 留存审计数据",
60
- submission_source: "执行 Forward 的一方(Customer Provider,取决于 Forward 配置)",
64
+ validation_scene: "When a customer or provider executes a Forward operation to advance the workflow, the Guard validates whether advancement to the next node is allowed",
65
+ pass_result: "Progress advances to next_node; session accumulates weight",
66
+ fail_result: "Forward is blocked; Progress stays at the current node. Optional retained_submission retains audit data",
67
+ submission_source: "The party executing Forward (Customer or Provider, depending on Forward configuration)",
61
68
  special_constraints: [
62
- "Machine 发布后 Forward.guard 不可修改(需新建 Machine",
63
- "可选 retained_submission:将提交数据存入 Progress 供后续审计",
64
- "retained_submission 索引必须与 Guard table 对应",
65
- "常用 query: progress.current_node, progress.session_forward, order.service ",
66
- "时间锁:context(Clock) + calc_number_add(progress.entry_time, duration) 测试用 1000ms",
69
+ "Forward.guard cannot be modified after Machine is published (a new Machine must be created)",
70
+ "Optional retained_submission: stores submission data in Progress for later audit",
71
+ "retained_submission indices must correspond to the Guard table",
72
+ "Common queries: progress.current_node, progress.session_forward, order.service, etc.",
73
+ "Time lock: context(Clock) + calc_number_add(progress.entry_time, duration) tested with 1000ms",
74
+ "Reentrancy: ALLOWED — By design, Forward moves progress.current_node to next_node (progress.move L443), naturally invalidating the Guard at the old node. Re-submission at the SAME node (before forward completes) is intentional: users may fix prior submission data or accumulate session weight toward threshold. No anti-reentrancy primitive needed. Optional observability queries: `progress.session_forward` (1262), `progress.history` (1273), `query_progress_history_find` (1274)",
67
75
  ],
68
76
  common_patterns: [
69
- "身份检查:context(Signer) + logic_equal(只有特定方可推进)",
70
- "时间锁:context(Clock) + calc_number_add + logic_as_u256_greater_or_equal",
71
- "前置 Forward 完成:query_progress_history_find + logic_equal(accomplished=true)",
72
- "提交数据验证:identifier(submission) + logic_equal(expected_value)",
73
- "跨对象查询:convert_witness=TypeOrderProgress(100) Order Progress",
77
+ "Identity check: context(Signer) + logic_equal (only specific parties can advance)",
78
+ "Time lock: context(Clock) + calc_number_add + logic_as_u256_greater_or_equal",
79
+ "Prior Forward completion: query_progress_history_find + logic_equal(accomplished=true)",
80
+ "Submission data validation: identifier(submission) + logic_equal(expected_value)",
81
+ "Cross-object query: convert_witness=TypeOrderProgress(100) queries Progress from Order",
74
82
  ],
75
83
  mutable_after_publish: false,
76
84
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
77
85
  },
78
86
  {
79
87
  id: "progress_submission_guard",
80
- name: "Progress 提交数据验证(submission guard",
88
+ name: "Progress submission data validation (submission guard)",
81
89
  host_object: "Progress",
82
90
  binding_field: "submission",
83
- validation_scene: "Forward 执行时提交的数据(如签名、凭证、确认)是否满足 Guard 条件",
84
- pass_result: "Forward 完成,session 累计权重达到阈值后推进节点",
85
- fail_result: "Forward 不完成,等待重新提交或满足条件",
86
- submission_source: "提交数据的一方(Customer Provider",
91
+ validation_scene: "Whether the data (e.g. signature, credential, confirmation) submitted during Forward execution satisfies the Guard condition",
92
+ pass_result: "Forward completes; node advances after session accumulates weight to threshold",
93
+ fail_result: "Forward does not complete; waits for resubmission or condition satisfaction",
94
+ submission_source: "The party submitting data (Customer or Provider)",
87
95
  special_constraints: [
88
- " Forward.guard 协同:Forward.guard 验证资格,submission guard 验证数据",
89
- "retained_submission 将提交数据存入 Progress session 供审计",
90
- "常用 query: progress.session_forward, progress.session_weight ",
96
+ "Works in concert with Forward.guard: Forward.guard validates eligibility, submission guard validates data",
97
+ "retained_submission stores submission data in Progress session for audit",
98
+ "Common queries: progress.session_forward, progress.session_weight, etc.",
99
+ "Reentrancy: ALLOWED — Multiple submissions accumulate session weight toward threshold by design (progress.move session_accomplish_imp). Re-submission is the intended mechanism for reaching threshold; no anti-reentrancy primitive needed",
91
100
  ],
92
101
  common_patterns: [
93
- "签名验证:identifier(signature_submission) + logic_equal(expected)",
94
- "凭证验证:query(Repository.data) + logic_equal(submission_proof)",
95
- "确认验证:identifier(confirm_submission) + logic_equal(true)",
102
+ "Signature validation: identifier(signature_submission) + logic_equal(expected)",
103
+ "Credential validation: query(Repository.data) + logic_equal(submission_proof)",
104
+ "Confirmation validation: identifier(confirm_submission) + logic_equal(true)",
96
105
  ],
97
106
  mutable_after_publish: false,
98
107
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R8"],
99
108
  },
100
109
  {
101
110
  id: "reward_guard",
102
- name: "奖励领取验证(Reward.guard",
111
+ name: "Reward claim validation (Reward.guard)",
103
112
  host_object: "Reward",
104
113
  binding_field: "guard",
105
- validation_scene: "用户领取奖励池时,Guard 验证是否有资格领取",
106
- pass_result: "奖励发放给 Claimant,记录到 reward_record",
107
- fail_result: "领取拒绝,奖励不发",
108
- submission_source: "ClaimantaddresscredentialsPassport",
114
+ validation_scene: "When a user claims from a reward pool, the Guard validates eligibility to claim",
115
+ pass_result: "Reward is distributed to the Claimant and recorded in reward_record",
116
+ fail_result: "Claim rejected; reward is not distributed",
117
+ submission_source: "Claimant (address, credentials, Passport)",
109
118
  special_constraints: [
110
- "常用 query_reward_record_count 防重复领取(one-time claim",
111
- "Guard 通常查询历史记录 + 时间条件 + 身份验证",
112
- "如果 Reward 引用 Service,使用循环引用模式",
119
+ "Common query_reward_record_count prevents duplicate claims (one-time claim)",
120
+ "Guard usually queries history records + time conditions + identity validation",
121
+ "If the Reward references a Service, use the circular reference pattern",
122
+ "Reentrancy: CRITICAL — Guard pass distributes reward funds to the Claimant AND creates a reward_record, but the Guard conditions (identity, time, node state) do NOT naturally invalidate after a claim. Without an explicit anti-reentrancy primitive, the same Claimant can repeatedly pass the Guard and DRAIN THE ENTIRE POOL. This is the most severe reentrancy scene. REQUIRED anti-reentrancy primitive (any one): `reward.record has` (query 1613, Bool) + `logic_not`; OR `reward.record count` (query 1612, U64) + `logic_equal(0)`; OR `reward.record.find_first` (query 1626, U64) + `logic_not`/`logic_equal(0)`. Reference template: MyShop_Advanced Guard 7 condition 4 — `logic_not(query_reward_record_exists(where.storeFromId=order_id))`",
113
123
  ],
114
124
  common_patterns: [
115
- "一次性领取:query_reward_record_count(recipient) + logic_equal(0)",
116
- "时间窗口:context(Clock) + logic_as_u256_greater_or_equal(start_time)",
117
- "身份验证:context(Signer) + vec_contains_address(allowlist)",
118
- "多条件:logic_and(身份 + 时间 + 未领取过)",
125
+ "One-time claim: query_reward_record_count(recipient) + logic_equal(0)",
126
+ "Time window: context(Clock) + logic_as_u256_greater_or_equal(start_time)",
127
+ "Identity validation: context(Signer) + vec_contains_address(allowlist)",
128
+ "Multi-condition: logic_and (identity + time + not claimed before)",
119
129
  ],
120
130
  mutable_after_publish: true,
121
131
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
122
132
  },
123
133
  {
124
134
  id: "repository_write_guard",
125
- name: "存储写入验证(write_guard",
135
+ name: "Repository write validation (write_guard)",
126
136
  host_object: "Repository",
127
137
  binding_field: "write_guard",
128
- validation_scene: "写入链上存储时,Guard 验证写入资格并可选提取数据",
129
- pass_result: "写入成功;可选 id_from_submission 提取 entity IDdata_from_submission 提取数据值",
130
- fail_result: "写入拒绝",
138
+ validation_scene: "When writing to on-chain storage, the Guard validates write eligibility and optionally extracts data",
139
+ pass_result: "Write succeeds; optional id_from_submission extracts the entity ID, data_from_submission extracts the data value",
140
+ fail_result: "Write rejected",
131
141
  submission_source: "Writer/Reader",
132
142
  special_constraints: [
133
- "id_from_submission 引用的 table 条目必须是 Address 类型",
134
- "data_from_submission 引用的 table 条目必须匹配 Repository value_type",
135
- "类型不匹配导致写入失败或数据损坏",
136
- "常用于 oracle 数据写入、第三方凭证存证等场景",
143
+ "The table entry referenced by id_from_submission must be of Address type",
144
+ "The table entry referenced by data_from_submission must match the Repository's value_type",
145
+ "Type mismatch leads to write failure or data corruption",
146
+ "Commonly used for oracle data writes, third-party credential attestation, etc.",
147
+ "Reentrancy: LOW — Default writes are idempotent (same ID overwrites, different ID appends); no fund flow. IF business intent is 'one write per ID' (e.g. voting, immutable credential, single-attestation), an anti-reentrancy check is needed. Optional primitive: `repository.data has` (query 1166, Bool) + `logic_not`",
137
148
  ],
138
149
  common_patterns: [
139
- "授权写入者:context(Signer) + vec_contains_address(authorized_writers)",
140
- "数据格式验证:identifier(data_submission) + logic_string_contains(expected_prefix)",
141
- "ID 提取:id_from_submission + data_from_submission 组合",
150
+ "Authorized writer: context(Signer) + vec_contains_address(authorized_writers)",
151
+ "Data format validation: identifier(data_submission) + logic_string_contains(expected_prefix)",
152
+ "ID extraction: id_from_submission + data_from_submission combination",
142
153
  ],
143
154
  mutable_after_publish: true,
144
155
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
145
156
  },
146
157
  {
147
158
  id: "arbitration_usage_guard",
148
- name: "争议发起验证(usage_guard",
159
+ name: "Dispute initiation validation (usage_guard)",
149
160
  host_object: "Arbitration",
150
161
  binding_field: "usage_guard",
151
- validation_scene: "客户对订单发起争议时,Guard 验证客户是否有资格发起争议",
152
- pass_result: "创建 Arb 案件,进入仲裁流程",
153
- fail_result: "争议拒绝,Arb 不创建",
154
- submission_source: "CustomerPassport credential",
162
+ validation_scene: "When a customer initiates a dispute against an order, the Guard validates whether the customer is eligible to initiate the dispute",
163
+ pass_result: "Create an Arb case and enter the arbitration flow",
164
+ fail_result: "Dispute rejected; Arb is not created",
165
+ submission_source: "Customer (Passport credential)",
155
166
  special_constraints: [
156
- "Arbitration bPaused=true 时优先阻塞(先于 Guard 检查)",
157
- "客户需先生成 Passportgen_passport 通过 usage_guard",
158
- "常用 query: order.completed, order.service, entity.has ",
159
- "Guard 验证客户身份 + 订单状态 + 争议资格",
167
+ "When Arbitration bPaused=true, it blocks first (before the Guard check)",
168
+ "The customer must first generate a Passport (gen_passport passes usage_guard)",
169
+ "Common queries: order.completed, order.service, entity.has, etc.",
170
+ "Guard validates customer identity + order status + dispute eligibility",
171
+ "Reentrancy: HIGH — Guard pass creates a new Arb case. Without anti-reentrancy, a customer can create multiple Arb cases for the SAME Order (up to MAX_DISPUTE_COUNT=10 per order.move L96), harassing the counterparty and inflating arbitration system load. Not direct fund loss, but severe system abuse. Note: order::dispute (order.move L93-99) deduplicates by Arb address but does NOT prevent multiple distinct Arbs for the same Order. REQUIRED anti-reentrancy primitive (any one): `order.dispute has` (query 1565, Bool, per-Arb check) + `logic_not`; OR `order.dispute count` (query 1564, U64) + `logic_equal(0)` (strict: block any prior dispute) or `logic_as_u256_less_or_equal(N)` (lenient: allow up to N disputes)",
160
172
  ],
161
173
  common_patterns: [
162
- "订单状态验证:query(Order.status) + logic_equal('completed')",
163
- "会员验证:query(EntityRegistrar) + logic_and",
164
- "时间窗口:query(Order.time) + calc_number_add + context(Clock)",
165
- " Passport 凭证:identifier(passport_submission) + context(Signer)",
174
+ "Order status validation: query(Order.status) + logic_equal('completed')",
175
+ "Membership validation: query(EntityRegistrar) + logic_and",
176
+ "Time window: query(Order.time) + calc_number_add + context(Clock)",
177
+ "Passport credential: identifier(passport_submission) + context(Signer)",
166
178
  ],
167
179
  mutable_after_publish: true,
168
180
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
169
181
  },
170
182
  {
171
183
  id: "arbitration_voting_guard",
172
- name: "仲裁投票权重验证(voting_guard[]",
184
+ name: "Arbitration voting weight validation (voting_guard[])",
173
185
  host_object: "Arbitration",
174
186
  binding_field: "voting_guard",
175
- validation_scene: "仲裁员投票时,Guard 验证投票资格并从 GuardIdentifier 提取投票权重(u32",
176
- pass_result: "投票计入,权重为 GuardIdentifier 提取的数值",
177
- fail_result: "投票拒绝",
178
- submission_source: "VoterPassport credential with weight data",
187
+ validation_scene: "When an arbitrator votes, the Guard validates voting eligibility and extracts the voting weight (u32) from GuardIdentifier",
188
+ pass_result: "Vote is counted; weight is the value extracted by GuardIdentifier",
189
+ fail_result: "Vote rejected",
190
+ submission_source: "Voter (Passport credential with weight data)",
179
191
  special_constraints: [
180
- "GuardIdentifier 引用的 table 条目必须是 numeric 类型(U8-U256),cast u32",
181
- "numeric 类型导致 E_GUARD_IDENTIFIER_NOT_NUMBER 错误",
182
- "b_submission 必须 true(权重由 voter 运行时提交)",
183
- "可配置多个 voting_guard,每个对应不同投票者群体",
184
- "Arbitration bPaused=true 时阻塞投票",
192
+ "The table entry referenced by GuardIdentifier must be of a numeric type (U8-U256), cast to u32",
193
+ "Non-numeric types cause E_GUARD_IDENTIFIER_NOT_NUMBER error",
194
+ "b_submission must be true (weight is submitted at runtime by the voter)",
195
+ "Multiple voting_guards can be configured, each corresponding to a different voter group",
196
+ "When Arbitration bPaused=true, voting is blocked",
197
+ "Reentrancy: CRITICAL — Guard pass counts the vote with the extracted weight. Without anti-reentrancy, the same voter can vote MULTIPLE times, multiplying their weight and skewing the arbitration result (which directly determines fund ownership via compensation). The voter's eligibility (identity, reputation) does NOT naturally invalidate after voting. REQUIRED anti-reentrancy primitive (any one): `arb.voted has` (query 1404, Bool, per-voter) + `logic_not`; OR `arb.voted.agree has` (query 1406, Bool, per-voter-per-proposition) + `logic_not`; OR `arb.voted.agree count` (query 1405, U64, per-voter) + `logic_equal(0)`. Note: `arb.voted_count` (1403) is total voter count (NOT per-voter) and does NOT serve as an anti-reentrancy primitive for individual voters",
185
198
  ],
186
199
  common_patterns: [
187
- "声誉分权重:query(EntityRegistrar.records[reputation]) + GuardIdentifier(u64)",
188
- "固定权重:identifier(constant_weight) + GuardIdentifier",
189
- "多级投票:不同 voting_guard 对应不同权重等级",
190
- "资格 + 权重:logic_and(资格检查 + GuardIdentifier 提取权重)",
200
+ "Reputation score weight: query(EntityRegistrar.records[reputation]) + GuardIdentifier(u64)",
201
+ "Fixed weight: identifier(constant_weight) + GuardIdentifier",
202
+ "Multi-tier voting: different voting_guards correspond to different weight tiers",
203
+ "Eligibility + weight: logic_and (eligibility check + GuardIdentifier extracts weight)",
191
204
  ],
192
205
  mutable_after_publish: true,
193
206
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
194
207
  },
208
+ {
209
+ id: "gen_passport_guard",
210
+ name: "Passport credential generation validation (gen_passport)",
211
+ host_object: "Standalone",
212
+ binding_field: "none",
213
+ validation_scene: "When a user calls gen_passport, the Guard validates user eligibility and generates a Passport with credentials",
214
+ pass_result: "Passport is generated, containing credentials validated by the Guard",
215
+ fail_result: "Passport generation fails; the user did not pass validation",
216
+ submission_source: "Passport applicant (signer + credentials)",
217
+ special_constraints: [
218
+ "impack_list is always empty during the verify phase (only filled after result_for_permission)",
219
+ "Therefore quote_guard (query 1167) always fails in the gen_passport flow (IMPACK_GUARD_NOT_FOUND)",
220
+ "Only Repository queries with quote_guard==None can pass in gen_passport",
221
+ "Guard can be created standalone (not bound to a specific Host Object)",
222
+ "Guard can be depended on by other Guards via rely (requires rep=true)",
223
+ "The Passport generated by gen_passport can be used as submission data for subsequent operations",
224
+ "Reentrancy: LOW — Each gen_passport call generates an independent Passport (one Passport per operation). Multiple Passports for the same user are usually valid (each serves a different subsequent operation). IF business intent is 'one active Passport per user', an anti-reentrancy check is needed but no direct GUARDQUERY primitive exists — use off-chain tracking or a Repository to record issued Passport IDs",
225
+ ],
226
+ common_patterns: [
227
+ "Identity validation: context(Signer) + logic_equal (single address/whitelist)",
228
+ "Membership eligibility: query(EntityRegistrar) + logic_equal",
229
+ "Reputation threshold: query(EntityRegistrar.records[reputation]) + logic_as_u256_greater_or_equal",
230
+ "Multi-condition combination: logic_and (identity + eligibility + reputation)",
231
+ ],
232
+ mutable_after_publish: false,
233
+ r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
234
+ },
195
235
  ];
196
236
  export function findScene(host_object, binding_field) {
197
237
  return GUARD_SCENES.find((s) => s.host_object === host_object &&
@@ -207,6 +247,7 @@ export function inferSceneFromAction(action) {
207
247
  dispute: "arbitration_usage_guard",
208
248
  write_repository: "repository_write_guard",
209
249
  submit_progress: "progress_submission_guard",
250
+ gen_passport: "gen_passport_guard",
210
251
  };
211
252
  const id = map[action];
212
253
  return GUARD_SCENES.find((s) => s.id === id);