@wowok/agent-mcp 2.3.18 → 2.4.1

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 (65) 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/knowledge/acquisition-flywheel.js +64 -64
  12. package/dist/knowledge/arbitration-trust.js +10 -10
  13. package/dist/knowledge/demand-matching.js +8 -8
  14. package/dist/knowledge/dynamic-pricing.js +18 -18
  15. package/dist/knowledge/flywheel-loop.js +11 -11
  16. package/dist/knowledge/glossary.js +22 -22
  17. package/dist/knowledge/guard-ledger.d.ts +1 -1
  18. package/dist/knowledge/guard-ledger.js +131 -104
  19. package/dist/knowledge/guard-lint.d.ts +76 -0
  20. package/dist/knowledge/guard-lint.js +590 -0
  21. package/dist/knowledge/guard-puzzle.d.ts +109 -14
  22. package/dist/knowledge/guard-puzzle.js +627 -101
  23. package/dist/knowledge/guard-risk.d.ts +8 -1
  24. package/dist/knowledge/guard-risk.js +868 -296
  25. package/dist/knowledge/guard-templates.d.ts +37 -0
  26. package/dist/knowledge/guard-templates.js +329 -0
  27. package/dist/knowledge/guard-translation.d.ts +14 -2
  28. package/dist/knowledge/guard-translation.js +825 -194
  29. package/dist/knowledge/index.d.ts +8 -4
  30. package/dist/knowledge/index.js +9 -5
  31. package/dist/knowledge/industry-evolution.js +29 -29
  32. package/dist/knowledge/industry-generalizer.js +52 -52
  33. package/dist/knowledge/industry-registry.js +20 -33
  34. package/dist/knowledge/intent-metrics.js +67 -67
  35. package/dist/knowledge/process-model.js +80 -80
  36. package/dist/knowledge/reputation-rules.js +9 -9
  37. package/dist/knowledge/reward-templates.js +51 -51
  38. package/dist/knowledge/safety-rules.js +3 -3
  39. package/dist/knowledge/tool-constraints.js +20 -4
  40. package/dist/knowledge/trust-metrics.js +26 -26
  41. package/dist/schema/call/base.js +16 -16
  42. package/dist/schema/call/bridge.d.ts +32 -32
  43. package/dist/schema/call/demand.d.ts +84 -84
  44. package/dist/schema/call/guard.d.ts +153 -0
  45. package/dist/schema/call/guard.js +50 -0
  46. package/dist/schema/call/permission.d.ts +78 -78
  47. package/dist/schema/call/repository.d.ts +22 -22
  48. package/dist/schema/call/semantic.js +228 -24
  49. package/dist/schema/local/wip.d.ts +39 -19
  50. package/dist/schema/local/wip.js +5 -5
  51. package/dist/schema/messenger/index.d.ts +26 -26
  52. package/dist/schema/messenger/index.js +2 -2
  53. package/dist/schema/operations.d.ts +222 -144
  54. package/dist/schema/query/index.d.ts +38 -38
  55. package/dist/schema/trust/index.d.ts +4 -4
  56. package/dist/schema/utils/guard-parser.js +4 -4
  57. package/dist/schema/utils/node-parser.js +14 -14
  58. package/dist/schemas/bridge_operation.output.json +14 -14
  59. package/dist/schemas/index.json +1 -1
  60. package/dist/schemas/messenger_operation.output.json +17 -15
  61. package/dist/schemas/onchain_events.output.json +14 -14
  62. package/dist/schemas/onchain_operations.output.json +14 -14
  63. package/dist/schemas/onchain_table_data.output.json +14 -14
  64. package/dist/schemas/wip_file.output.json +24 -1
  65. package/package.json +2 -2
@@ -1,20 +1,59 @@
1
1
  export const SEMANTIC_TO_SCHEMA_RULES = [
2
2
  {
3
- id: "A01_identity_single",
4
- pattern_name: "身份检查(单地址)",
5
- semantic_intent: "只有地址 X 能执行此操作",
6
- match_keywords: ["只有", "允许", "授权", "身份", "指定地址", "签名者"],
3
+ id: "P02",
4
+ pattern_name: "Query published object + system context",
5
+ data_source_combination: "Type1 + Type4",
6
+ semantic_intent: "Query published on-chain object fields and compare with system context",
7
+ match_keywords: ["paused", "published", "service status", "machine status", "paused", "published"],
8
+ schema_elements: {
9
+ root_type: "logic_equal / logic_and",
10
+ table_entries: [
11
+ { value_type: "Address", b_submission: false, purpose: "Published object address constant (Type1)" },
12
+ ],
13
+ context_nodes: [
14
+ { context_type: "Signer", purpose: "Optional: identity validation" },
15
+ ],
16
+ tree_structure: "logic_equal(query(<instruction>, object: { identifier: 0 }), identifier[1] or context(Signer))",
17
+ },
18
+ constraints: [
19
+ "The object_type of table[0] must match the target object type of the query instruction",
20
+ "The query return type must be compatible with the comparison object",
21
+ "The object must be published (published=true) to ensure fields are immutable",
22
+ ],
23
+ example: {
24
+ root: {
25
+ type: "logic_equal",
26
+ nodes: [
27
+ { type: "query", query: "service.paused", object: { identifier: 0 }, parameters: [] },
28
+ { type: "identifier", identifier: 1 },
29
+ ],
30
+ },
31
+ table: [
32
+ { identifier: 0, b_submission: false, value_type: "Address", value: "0xSERVICE", name: "Service object address" },
33
+ { identifier: 1, b_submission: false, value_type: "Bool", value: false, name: "Expected paused state (false=not paused)" },
34
+ ],
35
+ },
36
+ },
37
+ {
38
+ id: "P03",
39
+ pattern_name: "Identity check (single address)",
40
+ data_source_combination: "Type4 + Type1 constant",
41
+ semantic_intent: "Only a specific address can perform the operation",
42
+ match_keywords: ["only", "allow", "authorize", "identity", "specified address", "signer"],
7
43
  schema_elements: {
8
44
  root_type: "logic_equal",
9
45
  table_entries: [
10
- { value_type: "Address", b_submission: false, purpose: "授权地址常量" },
46
+ { value_type: "Address", b_submission: false, purpose: "Authorized address constant (Type1 constant)" },
47
+ ],
48
+ context_nodes: [
49
+ { context_type: "Signer", purpose: "Current transaction signer (Type4)" },
11
50
  ],
12
51
  tree_structure: "logic_equal(context(Signer), identifier[0])",
13
52
  },
14
53
  constraints: [
15
- "root 必须 logic_equal(返回 Bool",
16
- "table[0] 必须 Address 类型,b_submission=false",
17
- "context(Signer) 返回当前交易签名者地址",
54
+ "root must be logic_equal (returns Bool)",
55
+ "table[0] must be Address type, b_submission=false",
56
+ "context(Signer) returns the current transaction signer address",
18
57
  ],
19
58
  example: {
20
59
  root: {
@@ -25,26 +64,30 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
25
64
  ],
26
65
  },
27
66
  table: [
28
- { identifier: 0, b_submission: false, value_type: "Address", value: "0xabc...", name: "授权操作者地址" },
67
+ { identifier: 0, b_submission: false, value_type: "Address", value: "0xabc...", name: "Authorized operator address" },
29
68
  ],
30
69
  },
31
70
  },
32
71
  {
33
- id: "A02_identity_allowlist",
34
- pattern_name: "身份检查(白名单)",
35
- semantic_intent: "白名单中的地址可以执行此操作",
36
- match_keywords: ["白名单", "多个地址", "列表", "允许列表", "名单"],
72
+ id: "P04",
73
+ pattern_name: "Identity check (whitelist)",
74
+ data_source_combination: "Type4 + Type1 constant (VecAddress)",
75
+ semantic_intent: "Addresses in the whitelist can perform this operation",
76
+ match_keywords: ["whitelist", "multiple addresses", "list", "allowlist", "roster"],
37
77
  schema_elements: {
38
78
  root_type: "vec_contains_address",
39
79
  table_entries: [
40
- { value_type: "VecAddress", b_submission: false, purpose: "授权地址列表" },
80
+ { value_type: "VecAddress", b_submission: false, purpose: "Authorized address list (Type1 constant)" },
81
+ ],
82
+ context_nodes: [
83
+ { context_type: "Signer", purpose: "Signer being looked up (Type4)" },
41
84
  ],
42
85
  tree_structure: "vec_contains_address(identifier[0], context(Signer))",
43
86
  },
44
87
  constraints: [
45
- "root vec_contains_address 返回 Bool",
46
- "table[0] 必须 VecAddress 类型",
47
- "context(Signer) 作为被查找的元素",
88
+ "root vec_contains_address returns Bool",
89
+ "table[0] must be VecAddress type",
90
+ "context(Signer) is the element being looked up",
48
91
  ],
49
92
  example: {
50
93
  root: {
@@ -55,31 +98,36 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
55
98
  ],
56
99
  },
57
100
  table: [
58
- { identifier: 0, b_submission: false, value_type: "VecAddress", value: ["0xabc...", "0xdef..."], name: "授权地址白名单" },
101
+ { identifier: 0, b_submission: false, value_type: "VecAddress", value: ["0xabc...", "0xdef..."], name: "Authorized address whitelist" },
59
102
  ],
60
103
  },
61
104
  },
62
105
  {
63
- id: "A03_time_lock",
64
- pattern_name: "时间锁",
65
- semantic_intent: "等待 N 毫秒后才能执行此操作",
66
- match_keywords: ["等待", "时间", "锁定", "延迟", "小时", "天", "毫秒"],
106
+ id: "P05",
107
+ pattern_name: "Time lock",
108
+ data_source_combination: "Type2 + Type4 + Type1 constant",
109
+ semantic_intent: "This operation can only be executed after waiting N milliseconds",
110
+ match_keywords: ["wait", "time", "lock", "delay", "hours", "days", "milliseconds"],
67
111
  schema_elements: {
68
112
  root_type: "logic_as_u256_greater_or_equal",
69
113
  table_entries: [
70
- { value_type: "Address", b_submission: true, purpose: "目标对象地址(如 Order" },
71
- { value_type: "U64", b_submission: false, purpose: "锁定时长(毫秒,测试用 1000" },
114
+ { value_type: "Address", b_submission: true, purpose: "Source object address (e.g. Order, Type3) or constant (Type1)" },
115
+ { value_type: "U64", b_submission: false, purpose: "Lock duration (in milliseconds, 1000 for tests, Type1 constant)" },
72
116
  ],
73
117
  query_nodes: [
74
- { query_name: "progress.session.time", object_type: "Progress", convert_witness: 100 },
118
+ { query_name: "progress.current_time", object_type: "Progress", convert_witness: 100 },
119
+ ],
120
+ context_nodes: [
121
+ { context_type: "Clock", purpose: "Current on-chain timestamp (Type4)" },
75
122
  ],
76
- tree_structure: "logic_as_u256_greater_or_equal(context(Clock), calc_number_add(query(progress.time, witness=100), identifier[1]))",
123
+ tree_structure: "logic_as_u256_greater_or_equal(context(Clock), calc_number_add(query(1272: progress.current_time, witness=100, identifier[0]), identifier[1]))",
77
124
  },
78
125
  constraints: [
79
- "时间单位为毫秒,测试时用 1000ms,生产环境再调整",
80
- "convert_witness=100 (TypeOrderProgress) Order 转换到 Progress",
81
- "table[0] object_type 必须匹配 witness source type (Order)",
82
- "calc_number_add 返回 U256context(Clock) 返回 U64,自动宽展",
126
+ "Time unit is milliseconds; use 1000ms for tests and adjust in production",
127
+ "convert_witness=100 (TypeOrderProgress) converts from Order to Progress",
128
+ "The object_type of table[0] must match the witness source type (Order)",
129
+ "calc_number_add returns U256, context(Clock) returns U64, auto-widened",
130
+ "Key: use progress.current_time(1272) rather than progress.session.forward.time(1271); the latter querying an unforwarded session returns 0 and disables the time lock",
83
131
  ],
84
132
  example: {
85
133
  root: {
@@ -91,7 +139,7 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
91
139
  nodes: [
92
140
  {
93
141
  type: "query",
94
- query: "progress.session.time",
142
+ query: "progress.current_time",
95
143
  object: { identifier: 0, convert_witness: 100 },
96
144
  parameters: [],
97
145
  },
@@ -101,32 +149,34 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
101
149
  ],
102
150
  },
103
151
  table: [
104
- { identifier: 0, b_submission: true, value_type: "Address", name: "目标 Order 地址", object_type: "Order" },
105
- { identifier: 1, b_submission: false, value_type: "U64", value: 1000, name: "锁定时长(毫秒)" },
152
+ { identifier: 0, b_submission: true, value_type: "Address", name: "Target Order address", object_type: "Order" },
153
+ { identifier: 1, b_submission: false, value_type: "U64", value: 1000, name: "Lock duration (milliseconds)" },
106
154
  ],
107
155
  },
108
156
  },
109
157
  {
110
- id: "A04_progress_state",
111
- pattern_name: "进度状态检查",
112
- semantic_intent: "订单进度达到指定节点才能执行此操作",
113
- match_keywords: ["进度", "节点", "状态", "完成", "到达", "当前节点"],
158
+ id: "P06",
159
+ pattern_name: "Progress state check",
160
+ data_source_combination: "Type2 + Type1 constant",
161
+ semantic_intent: "The order progress must reach the specified node before this operation can be executed",
162
+ match_keywords: ["progress", "node", "state", "completed", "reach", "current node"],
114
163
  schema_elements: {
115
164
  root_type: "logic_equal",
116
165
  table_entries: [
117
- { value_type: "Address", b_submission: true, purpose: "目标 Order 地址" },
118
- { value_type: "String", b_submission: false, purpose: "期望的节点名称" },
166
+ { value_type: "Address", b_submission: true, purpose: "Source Order address (Type3, witness source)" },
167
+ { value_type: "String", b_submission: false, purpose: "Expected node name (Type1 constant)" },
119
168
  ],
120
169
  query_nodes: [
121
- { query_name: "progress.current_node_name", object_type: "Progress", convert_witness: 100 },
170
+ { query_name: "progress.current", object_type: "Progress", convert_witness: 100 },
122
171
  ],
123
- tree_structure: "logic_equal(query(progress.node, witness=100, identifier[0]), identifier[1])",
172
+ tree_structure: "logic_equal(query(1253: progress.current, witness=100, identifier[0]), identifier[1])",
124
173
  },
125
174
  constraints: [
126
- "query 返回 Stringidentifier[1] 必须 String 类型",
127
- "logic_equal 比较 String 时大小写敏感",
128
- "如需大小写不敏感,使用 logic_string_nocase_equal",
129
- "convert_witness=100 (TypeOrderProgress) Order 转换",
175
+ "query returns String; identifier[1] must be String type",
176
+ "logic_equal comparison on String is case-sensitive",
177
+ "For case-insensitive comparison, use logic_string_nocase_equal",
178
+ "convert_witness=100 (TypeOrderProgress) converts from Order",
179
+ "Type2 stacks on Type3: the source object Order is submitted (b_submission=true)",
130
180
  ],
131
181
  example: {
132
182
  root: {
@@ -134,7 +184,7 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
134
184
  nodes: [
135
185
  {
136
186
  type: "query",
137
- query: "progress.current_node_name",
187
+ query: "progress.current",
138
188
  object: { identifier: 0, convert_witness: 100 },
139
189
  parameters: [],
140
190
  },
@@ -142,31 +192,33 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
142
192
  ],
143
193
  },
144
194
  table: [
145
- { identifier: 0, b_submission: true, value_type: "Address", name: "目标 Order 地址", object_type: "Order" },
146
- { identifier: 1, b_submission: false, value_type: "String", value: "Completed", name: "期望的进度节点名" },
195
+ { identifier: 0, b_submission: true, value_type: "Address", name: "Target Order address", object_type: "Order" },
196
+ { identifier: 1, b_submission: false, value_type: "String", value: "Completed", name: "Expected progress node name" },
147
197
  ],
148
198
  },
149
199
  },
150
200
  {
151
- id: "A05_one_time_claim",
152
- pattern_name: "一次性领取检查",
153
- semantic_intent: "用户只能领取一次奖励",
154
- match_keywords: ["一次", "领取", "重复", "已领", "领取过"],
201
+ id: "P07",
202
+ pattern_name: "One-time claim check",
203
+ data_source_combination: "Type3 + Type1 constant",
204
+ semantic_intent: "Users can only claim the reward once",
205
+ match_keywords: ["once", "claim", "duplicate", "already claimed", "claimed before"],
155
206
  schema_elements: {
156
207
  root_type: "logic_equal",
157
208
  table_entries: [
158
- { value_type: "Address", b_submission: true, purpose: "Reward 对象地址" },
159
- { value_type: "Address", b_submission: false, purpose: "领取者地址(从 context 派生)" },
209
+ { value_type: "Address", b_submission: true, purpose: "Reward object address (Type3, submitted)" },
210
+ { value_type: "U64", b_submission: false, purpose: "Expected historical claim count 0 (Type1 constant)" },
160
211
  ],
161
212
  query_nodes: [
162
213
  { query_name: "reward.record.count", object_type: "Reward" },
163
214
  ],
164
- tree_structure: "logic_equal(query_reward_record_count(identifier[0], identifier[1]), constant(0))",
215
+ tree_structure: "logic_equal(query_reward_record_count(object: { identifier: 0 }, recipient: context(Signer)), identifier[1])",
165
216
  },
166
217
  constraints: [
167
- "query_reward_record_count 返回 U64",
168
- "比较 count == 0 表示无历史记录(可领取)",
169
- "identifier[1] 可用 context(Signer) 替代",
218
+ "query_reward_record_count returns U64",
219
+ "Comparing count == 0 means no history record (can claim)",
220
+ "recipient defaults to context(Signer) to ensure the claimer's identity is bound",
221
+ "Type3 submitted objects must have constraint rules (here the constraint is count==0 and recipient=Signer)",
170
222
  ],
171
223
  example: {
172
224
  root: {
@@ -175,31 +227,116 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
175
227
  {
176
228
  type: "query_reward_record_count",
177
229
  object: { identifier: 0 },
178
- recipient: { type: "context", context: "Signer" },
179
230
  },
180
231
  { type: "identifier", identifier: 1 },
181
232
  ],
182
233
  },
183
234
  table: [
184
- { identifier: 0, b_submission: true, value_type: "Address", name: "Reward 对象地址", object_type: "Reward" },
185
- { identifier: 1, b_submission: false, value_type: "U64", value: 0, name: "期望的历史领取数(0" },
235
+ { identifier: 0, b_submission: true, value_type: "Address", name: "Reward object address", object_type: "Reward" },
236
+ { identifier: 1, b_submission: false, value_type: "U64", value: 0, name: "Expected historical claim count (0)" },
186
237
  ],
187
238
  },
188
239
  },
189
240
  {
190
- id: "A06_multi_condition_and",
191
- pattern_name: "多条件组合(AND)",
192
- semantic_intent: "多个条件必须同时满足",
193
- match_keywords: ["并且", "同时", "都满足", "AND", "且", "还需要"],
241
+ id: "P08",
242
+ pattern_name: "Submitted object identity validation",
243
+ data_source_combination: "Type3 + Type4",
244
+ semantic_intent: "Verify that the owner of the submitted object matches the signer",
245
+ match_keywords: ["ownership", "belonging", "customer", "submitted object", "order.customer"],
194
246
  schema_elements: {
195
- root_type: "logic_and",
247
+ root_type: "logic_equal",
248
+ table_entries: [
249
+ { value_type: "Address", b_submission: true, purpose: "Submitted Order address (Type3)" },
250
+ ],
251
+ context_nodes: [
252
+ { context_type: "Signer", purpose: "Current signer (Type4), compared with order.customer" },
253
+ ],
254
+ query_nodes: [
255
+ { query_name: "order.customer", object_type: "Order" },
256
+ ],
257
+ tree_structure: "logic_equal(query(1550: order.customer, object: { identifier: 0 }), context(Signer))",
258
+ },
259
+ constraints: [
260
+ "query returns Address, context(Signer) returns Address, types compatible",
261
+ "Type3 submitted object constraint: indirectly binds submitter identity via order.customer == Signer",
262
+ "Ensures callers cannot submit other users' Order addresses",
263
+ ],
264
+ example: {
265
+ root: {
266
+ type: "logic_equal",
267
+ nodes: [
268
+ {
269
+ type: "query",
270
+ query: "order.customer",
271
+ object: { identifier: 0 },
272
+ parameters: [],
273
+ },
274
+ { type: "context", context: "Signer" },
275
+ ],
276
+ },
277
+ table: [
278
+ { identifier: 0, b_submission: true, value_type: "Address", name: "User-submitted Order address", object_type: "Order" },
279
+ ],
280
+ },
281
+ },
282
+ {
283
+ id: "P09",
284
+ pattern_name: "Submitted object + witness derivation query",
285
+ data_source_combination: "Type3 + Type2 (source is Type3)",
286
+ semantic_intent: "User submits an Order and queries the Progress state via witness",
287
+ match_keywords: ["submit", "derive", "witness", "order to progress", "convert"],
288
+ schema_elements: {
289
+ root_type: "logic_equal / logic_and",
290
+ table_entries: [
291
+ { value_type: "Address", b_submission: true, purpose: "Submitted Order address (Type3, witness source)" },
292
+ { value_type: "String", b_submission: false, purpose: "Expected node name (Type1 constant)" },
293
+ ],
294
+ query_nodes: [
295
+ { query_name: "progress.current", object_type: "Progress", convert_witness: 100 },
296
+ ],
297
+ tree_structure: "logic_equal(query(1253: progress.current, object: { identifier: 0, convert_witness: 100 }), identifier[1])",
298
+ },
299
+ constraints: [
300
+ "Type2 stacks on Type3: the source object Order has b_submission=true",
301
+ "witness=100 (TypeOrderProgress) derives Progress from the submitted Order",
302
+ "query returns String; identifier[1] must be String type",
303
+ "Key: Type2 can stack on Type1 or Type3, depending on the source object's b_submission",
304
+ ],
305
+ example: {
306
+ root: {
307
+ type: "logic_equal",
308
+ nodes: [
309
+ {
310
+ type: "query",
311
+ query: "progress.current",
312
+ object: { identifier: 0, convert_witness: 100 },
313
+ parameters: [],
314
+ },
315
+ { type: "identifier", identifier: 1 },
316
+ ],
317
+ },
318
+ table: [
319
+ { identifier: 0, b_submission: true, value_type: "Address", name: "User-submitted Order address", object_type: "Order" },
320
+ { identifier: 1, b_submission: false, value_type: "String", value: "Inspecting", name: "Expected progress node name" },
321
+ ],
322
+ },
323
+ },
324
+ {
325
+ id: "P10",
326
+ pattern_name: "Multi-condition combination (AND/OR)",
327
+ data_source_combination: "Type1 + Type2 + Type3 + Type4 (combination)",
328
+ semantic_intent: "Multiple conditions must all be satisfied (AND) or any one is satisfied (OR)",
329
+ match_keywords: ["and", "simultaneously", "all satisfied", "AND", "and also", "also need", "or", "any", "OR", "or", "one of"],
330
+ schema_elements: {
331
+ root_type: "logic_and / logic_or",
196
332
  table_entries: [],
197
- tree_structure: "logic_and([condition1, condition2, ...])",
333
+ tree_structure: "logic_and/logic_or([condition1, condition2, ...]) — each condition can be any combination of P03-P09",
198
334
  },
199
335
  constraints: [
200
- "logic_and 所有子节点必须返回 Bool",
201
- "子节点数量 2-8MAX_MULTI_OPERANDS",
202
- "每个子条件可以是任何返回 Bool 的节点",
336
+ "All subnodes of logic_and/logic_or must return Bool",
337
+ "Subnode count 2-8 (MAX_MULTI_OPERANDS)",
338
+ "Each subcondition can be any node that returns Bool",
339
+ "Multi-condition combination is a container for other Patterns and does not stand alone",
203
340
  ],
204
341
  example: {
205
342
  root: {
@@ -212,252 +349,734 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
212
349
  },
213
350
  },
214
351
  {
215
- id: "A07_multi_condition_or",
216
- pattern_name: "多条件组合(OR)",
217
- semantic_intent: "任一条件满足即可",
218
- match_keywords: ["或者", "任一", "OR", "或", "之一"],
352
+ id: "P11",
353
+ pattern_name: "Entity registration check",
354
+ data_source_combination: "Type1 system address + Type3",
355
+ semantic_intent: "Verify that the user is registered in the entity registrar",
356
+ match_keywords: ["register", "entity", "EntityRegistrar", "member", "certify"],
219
357
  schema_elements: {
220
- root_type: "logic_or",
221
- table_entries: [],
222
- tree_structure: "logic_or([condition1, condition2, ...])",
358
+ root_type: "logic_and",
359
+ table_entries: [
360
+ { value_type: "Address", b_submission: false, purpose: "EntityRegistrar system address 0xaab (Type1 system address)" },
361
+ { value_type: "Address", b_submission: true, purpose: "User address (Type3, submitted)" },
362
+ ],
363
+ query_nodes: [
364
+ { query_name: "entity.registrar.records", object_type: "EntityRegistrar" },
365
+ ],
366
+ tree_structure: "logic_and(query(1760: entity.registrar.records, object: { identifier: 0 }, parameters: [identifier[1]]), ...)",
223
367
  },
224
368
  constraints: [
225
- "logic_or 所有子节点必须返回 Bool",
226
- "子节点数量 2-8",
227
- "等价于 rely.logic_or=true(如果使用 rely 组合)",
369
+ "EntityRegistrar address is fixed at 0xaab (system address)",
370
+ "EntityLinker address is fixed at 0xaaa",
371
+ "table[0] has is_system_address=true",
372
+ "query parameters must match the instruction definition",
228
373
  ],
229
374
  example: {
230
375
  root: {
231
- type: "logic_or",
376
+ type: "logic_and",
377
+ nodes: [
378
+ {
379
+ type: "query",
380
+ query: "entity.registrar.records",
381
+ object: { identifier: 0 },
382
+ parameters: [{ type: "identifier", identifier: 1 }],
383
+ },
384
+ ],
385
+ },
386
+ table: [
387
+ { identifier: 0, b_submission: false, value_type: "Address", value: "0xaab", name: "EntityRegistrar system address" },
388
+ { identifier: 1, b_submission: true, value_type: "Address", name: "User address (submitted)" },
389
+ ],
390
+ },
391
+ },
392
+ {
393
+ id: "P12",
394
+ pattern_name: "Dynamic voting weight",
395
+ data_source_combination: "Type3 + Type4 + Type1 constant",
396
+ semantic_intent: "Voting weight equals the reputation score (extracted from submitted data)",
397
+ match_keywords: ["weight", "vote", "reputation", "score", "voting", "weight"],
398
+ schema_elements: {
399
+ root_type: "logic_and",
400
+ table_entries: [
401
+ { value_type: "Address", b_submission: true, purpose: "Voter address (Type3)" },
402
+ { value_type: "U64", b_submission: true, purpose: "Voter weight (Type3, extracted by GuardIdentifier)" },
403
+ ],
404
+ context_nodes: [
405
+ { context_type: "Signer", purpose: "Validate voter identity (Type4)" },
406
+ ],
407
+ query_nodes: [
408
+ { query_name: "entity.registrar.records", object_type: "EntityRegistrar" },
409
+ ],
410
+ tree_structure: "logic_and(identity check: logic_equal(context(Signer), identifier[0]), weight comparison: GuardIdentifier extracts identifier[1])",
411
+ },
412
+ constraints: [
413
+ "The table entry referenced by GuardIdentifier must be numeric (U8-U256)",
414
+ "b_submission must be true (weight is submitted at runtime by the voter)",
415
+ "Non-numeric types cause E_GUARD_IDENTIFIER_NOT_NUMBER error",
416
+ "Weight value is cast to u32",
417
+ "voting_guard scene special constraint: GuardIdentifier numeric",
418
+ ],
419
+ example: {
420
+ root: {
421
+ type: "logic_and",
232
422
  nodes: [
233
423
  {},
234
424
  {},
235
425
  ],
236
426
  },
427
+ table: [
428
+ { identifier: 0, b_submission: true, value_type: "Address", name: "Voter address" },
429
+ { identifier: 1, b_submission: true, value_type: "U64", name: "Voter weight (extracted from reputation score)" },
430
+ ],
237
431
  },
238
432
  },
239
433
  {
240
- id: "A08_dynamic_weight",
241
- pattern_name: "动态投票权重",
242
- semantic_intent: "投票权重等于用户声誉分(从提交数据提取)",
243
- match_keywords: ["权重", "投票", "声誉", "分数", "voting", "weight"],
434
+ id: "P13",
435
+ pattern_name: "Repository data query",
436
+ data_source_combination: "Type1 + Type2",
437
+ semantic_intent: "Query Repository data and validate",
438
+ match_keywords: ["Repository", "storage", "data source", "weather", "external data", "oracle"],
244
439
  schema_elements: {
245
440
  root_type: "logic_and",
246
441
  table_entries: [
247
- { value_type: "Address", b_submission: true, purpose: "投票者地址" },
248
- { value_type: "U64", b_submission: true, purpose: "投票者权重(GuardIdentifier 提取)" },
442
+ { value_type: "Address", b_submission: false, purpose: "Repository address (Type1 constant)" },
249
443
  ],
250
444
  query_nodes: [
251
- { query_name: "entity.records.value", object_type: "EntityRegistrar" },
445
+ { query_name: "repository.data", object_type: "Repository" },
252
446
  ],
253
- tree_structure: "logic_and(资格检查, GuardIdentifier 提取权重[1])",
447
+ tree_structure: "logic_and(query(1167: repository.data, object: { identifier: 0 }, parameters: [...]), [data validation condition])",
254
448
  },
255
449
  constraints: [
256
- "GuardIdentifier 引用的 table 条目必须 numeric (U8-U256)",
257
- "b_submission 必须 true(权重由 voter 运行时提交)",
258
- " numeric 类型导致 E_GUARD_IDENTIFIER_NOT_NUMBER 错误",
259
- "权重值 cast u32",
450
+ "The quote_guard authentication of query 1167 always has empty impack_list during the verify phase",
451
+ "Repository queries with quote_guard fail with IMPACK_GUARD_NOT_FOUND in the gen_passport flow",
452
+ "Only passes when quote_guard==None",
453
+ "rep semantics: repository.data query does not depend on runtime submission, so rep=true",
260
454
  ],
261
455
  example: {
262
456
  root: {
263
457
  type: "logic_and",
264
458
  nodes: [
265
- {},
459
+ {
460
+ type: "query",
461
+ query: "repository.data",
462
+ object: { identifier: 0 },
463
+ parameters: [{ type: "identifier", identifier: 1 }],
464
+ },
266
465
  {},
267
466
  ],
268
467
  },
269
468
  table: [
270
- { identifier: 0, b_submission: true, value_type: "Address", name: "投票者地址" },
271
- { identifier: 1, b_submission: true, value_type: "U64", name: "投票者权重(从声誉分提取)" },
469
+ { identifier: 0, b_submission: false, value_type: "Address", value: "0xREPO", name: "Repository address" },
470
+ ],
471
+ },
472
+ },
473
+ {
474
+ id: "P14",
475
+ pattern_name: "Pure dependency combination",
476
+ data_source_combination: "None (rely only)",
477
+ semantic_intent: "Does not compute itself; fully depends on the results of other Guards",
478
+ match_keywords: ["depend", "combine", "reuse", "rely", "delegate"],
479
+ schema_elements: {
480
+ root_type: "logic_and / logic_or (minimized tautology)",
481
+ table_entries: [],
482
+ tree_structure: "root: minimized (e.g. context(Clock) >= 0, tautology) + rely: { guards: [...], logic_or: false }",
483
+ },
484
+ constraints: [
485
+ "Depended-on Guards must have rep=true (repository.data query does not depend on runtime submission)",
486
+ "rely.guards supports at most 4 (MAX_DEPENDED_COUNT)",
487
+ "Self-reference is forbidden",
488
+ "AND logic: all dependencies must pass; OR logic: any one passing is sufficient",
489
+ ],
490
+ example: {
491
+ root: {
492
+ type: "logic_as_u256_greater_or_equal",
493
+ nodes: [
494
+ { type: "context", context: "Clock" },
495
+ { type: "identifier", identifier: 0 },
496
+ ],
497
+ },
498
+ table: [
499
+ { identifier: 0, b_submission: false, value_type: "U64", value: 0, name: "Tautology baseline value (0)" },
500
+ ],
501
+ rely: { guards: ["guard_a", "guard_b"], logic_or: false },
502
+ },
503
+ },
504
+ {
505
+ id: "P15",
506
+ pattern_name: "Submission data retention pattern (retained_submission)",
507
+ data_source_combination: "Type3 + Type4 (submission + system context binding)",
508
+ semantic_intent: "Guard accepts runtime-submitted data but ensures it is trustworthy via Signer binding and type checking",
509
+ match_keywords: ["submit", "retain", "retained", "submission", "bind signer", "submission check"],
510
+ schema_elements: {
511
+ root_type: "logic_and",
512
+ table_entries: [
513
+ { value_type: "Address", b_submission: true, purpose: "Submitted object address (Type3, requires Signer binding)" },
514
+ { value_type: "U256", b_submission: true, purpose: "Submitted numeric value (e.g. amount, weight, requires range check)" },
515
+ ],
516
+ context_nodes: [
517
+ { context_type: "Signer", purpose: "Validate submitter identity to ensure submission data ownership" },
518
+ ],
519
+ tree_structure: "logic_and(logic_equal(context(Signer), query(..., signer_field)), logic_as_u256_greater_or_equal(identifier[1], identifier[2]))",
520
+ },
521
+ constraints: [
522
+ "The name of each b_submission=true entry must be a complete natural-language description (not a technical identifier)",
523
+ "The submitted object address should be bound to Signer (query the signer/owner field of the submitted object to validate ownership)",
524
+ "Submitted numeric values should have range checks (>= min, <= max)",
525
+ "Total table size must not exceed 40000 bytes",
526
+ "Total submission bytes must not exceed 256",
527
+ ],
528
+ example: {
529
+ root: {
530
+ type: "logic_and",
531
+ nodes: [
532
+ {
533
+ type: "logic_equal",
534
+ nodes: [
535
+ { type: "context", context: "Signer" },
536
+ {
537
+ type: "query",
538
+ query: 1237,
539
+ object: { identifier: 0 },
540
+ parameters: [],
541
+ },
542
+ ],
543
+ },
544
+ {
545
+ type: "logic_as_u256_greater_or_equal",
546
+ nodes: [
547
+ { type: "identifier", identifier: 1 },
548
+ { type: "identifier", identifier: 2 },
549
+ ],
550
+ },
551
+ ],
552
+ },
553
+ table: [
554
+ { identifier: 0, b_submission: true, value_type: "Address", name: "Submitted Order object address; must belong to the current signer" },
555
+ { identifier: 1, b_submission: true, value_type: "U256", name: "Submitted amount (unit: MIST); must be >= minimum amount" },
556
+ { identifier: 2, b_submission: false, value_type: "U256", value: 1000000, name: "Minimum amount constant (1 MIST)" },
557
+ ],
558
+ },
559
+ },
560
+ {
561
+ id: "P16",
562
+ pattern_name: "Circular reference pattern (Guard references the host object itself)",
563
+ data_source_combination: "Type1 (host object as constant, using name instead of address)",
564
+ semantic_intent: "Guard binds to a Host Object while querying the Host Object's own fields; uses name reference to achieve circular binding",
565
+ match_keywords: ["circular reference", "self", "host", "host", "circular", "self-reference"],
566
+ schema_elements: {
567
+ root_type: "logic_equal / logic_and",
568
+ table_entries: [
569
+ { value_type: "Address", b_submission: false, purpose: "Host object name (SDK resolves to address at binding time)" },
570
+ ],
571
+ query_nodes: [
572
+ { query_name: "query_service_* / query_machine_*", object_type: "Service / Machine" },
573
+ ],
574
+ tree_structure: "logic_equal(query(<host_field_query>, object: { identifier: 0 }), identifier[1] or context(Signer))",
575
+ },
576
+ constraints: [
577
+ "The Host Object must not be published (bPublished=false) when creating and binding the Guard",
578
+ "Use the Host Object name (not address) in the table; the SDK resolves it at binding time",
579
+ "The Host Object can only be published after the Guard is bound",
580
+ "Guard verification only runs normally after the Host Object is published",
581
+ "Use guard2file to export Guard backups for easy rebuilding",
582
+ ],
583
+ example: {
584
+ root: {
585
+ type: "logic_equal",
586
+ nodes: [
587
+ {
588
+ type: "query",
589
+ query: 1231,
590
+ object: { identifier: 0 },
591
+ parameters: [],
592
+ },
593
+ { type: "identifier", identifier: 1 },
594
+ ],
595
+ },
596
+ table: [
597
+ { identifier: 0, b_submission: false, value_type: "Address", value: "my_service", name: "Host Service name (circular reference, resolved by SDK at binding time)" },
598
+ { identifier: 1, b_submission: false, value_type: "Bool", value: false, name: "Expected Service paused state (false=not paused)" },
599
+ ],
600
+ },
601
+ },
602
+ {
603
+ id: "P17",
604
+ pattern_name: "Query parameter translation pattern (type conversion node combination)",
605
+ data_source_combination: "Type1/2 + type conversion (query parameter type translation)",
606
+ semantic_intent: "Guard queries parameters that require type conversion (e.g. Address → U64 timestamp key); uses convert_* nodes to translate",
607
+ match_keywords: ["type conversion", "translate", "convert", "timestamp key", "parameter translation", "address to u64"],
608
+ schema_elements: {
609
+ root_type: "logic_equal / logic_as_u256_greater_or_equal",
610
+ table_entries: [
611
+ { value_type: "Address", b_submission: false, purpose: "Query target object address (Type1/2)" },
612
+ { value_type: "U64", b_submission: false, purpose: "Comparison baseline value (e.g. timestamp threshold)" },
613
+ ],
614
+ query_nodes: [
615
+ { query_name: "query_repository_data / query_progress_history_*", object_type: "Repository / Progress" },
616
+ ],
617
+ tree_structure: "logic_as_u256_greater_or_equal(query(<query_with_converted_param>, object: { identifier: 0 }, parameters: [convert_number_address(identifier[1])]), identifier[2])",
618
+ },
619
+ constraints: [
620
+ "The query parameter type must match the parameters type defined in GUARDQUERY",
621
+ "If the table declares Address but the query requires U64, convert_number_address must be used to translate",
622
+ "The input type of convert_* nodes must be compatible with the child node's return type",
623
+ "The translated type must match the parameters definition of the query instruction",
624
+ "Use wowok_buildin_info info='guard instructions' to verify parameter types",
625
+ ],
626
+ example: {
627
+ root: {
628
+ type: "logic_as_u256_greater_or_equal",
629
+ nodes: [
630
+ {
631
+ type: "query",
632
+ query: 1167,
633
+ object: { identifier: 0 },
634
+ parameters: [
635
+ {
636
+ type: "convert_number_address",
637
+ nodes: [
638
+ { type: "identifier", identifier: 1 },
639
+ ],
640
+ },
641
+ ],
642
+ },
643
+ { type: "identifier", identifier: 2 },
644
+ ],
645
+ },
646
+ table: [
647
+ { identifier: 0, b_submission: false, value_type: "Address", value: "0xrepo", name: "Repository address constant" },
648
+ { identifier: 1, b_submission: false, value_type: "U64", value: 1700000000000, name: "Timestamp key (U64, needs to be converted to Address for Repository query)" },
649
+ { identifier: 2, b_submission: false, value_type: "U256", value: 100, name: "Expected Repository data value" },
272
650
  ],
273
651
  },
274
652
  },
275
653
  ];
276
654
  export const SCHEMA_TO_SEMANTIC_RULES = [
277
- { element_type: "node", type_name: "logic_equal", semantic: "相等比较(==),返回 Bool", return_type: "Bool", child_constraints: "2 个子节点,类型必须兼容" },
278
- { element_type: "node", type_name: "logic_not", semantic: "逻辑非(!),返回 Bool", return_type: "Bool", child_constraints: "1 个子节点,必须 Bool" },
279
- { element_type: "node", type_name: "logic_and", semantic: "逻辑与(AND),所有子节点为 true true", return_type: "Bool", child_constraints: "2-8 Bool 子节点" },
280
- { element_type: "node", type_name: "logic_or", semantic: "逻辑或(OR),任一子节点为 true true", return_type: "Bool", child_constraints: "2-8 Bool 子节点" },
281
- { element_type: "node", type_name: "logic_as_u256_greater", semantic: "数值大于(>),自动宽展到 U256", return_type: "Bool", child_constraints: "2 个数值子节点" },
282
- { element_type: "node", type_name: "logic_as_u256_lesser", semantic: "数值小于(<)", return_type: "Bool", child_constraints: "2 个数值子节点" },
283
- { element_type: "node", type_name: "logic_as_u256_equal", semantic: "数值相等(==)", return_type: "Bool", child_constraints: "2 个数值子节点" },
284
- { element_type: "node", type_name: "logic_as_u256_greater_or_equal", semantic: "数值大于等于(>=)", return_type: "Bool", child_constraints: "2 个数值子节点" },
285
- { element_type: "node", type_name: "logic_as_u256_lesser_or_equal", semantic: "数值小于等于(<=)", return_type: "Bool", child_constraints: "2 个数值子节点" },
286
- { element_type: "node", type_name: "logic_string_contains", semantic: "字符串包含(大小写敏感)", return_type: "Bool", child_constraints: "2 String 子节点" },
287
- { element_type: "node", type_name: "logic_string_nocase_contains", semantic: "字符串包含(大小写不敏感)", return_type: "Bool", child_constraints: "2 String 子节点" },
288
- { element_type: "node", type_name: "logic_string_nocase_equal", semantic: "字符串相等(大小写不敏感)", return_type: "Bool", child_constraints: "2 String 子节点" },
289
- { element_type: "node", type_name: "identifier", semantic: "引用 table 条目的值", return_type: " table 条目 value_type 决定", child_constraints: "无子节点,需要 identifier 字段引用 table" },
290
- { element_type: "node", type_name: "context", semantic: "交易上下文数据(Signer 地址、Clock 时间戳、Guard 自身 ID)", return_type: "Address (Signer) / U64 (Clock) / Address (Self)", child_constraints: "无子节点" },
291
- { element_type: "node", type_name: "query", semantic: "查询链上对象数据", return_type: "由查询指令决定", child_constraints: "需要 query + object + parameters 字段", discovery_tool: "wowok_buildin_info(info='guard instructions')" },
292
- { element_type: "node", type_name: "calc_number_add", semantic: "数值加法", return_type: "U256", child_constraints: "2 个数值子节点" },
293
- { element_type: "node", type_name: "calc_number_sub", semantic: "数值减法", return_type: "U256", child_constraints: "2 个数值子节点" },
294
- { element_type: "node", type_name: "calc_number_mul", semantic: "数值乘法", return_type: "U256", child_constraints: "2 个数值子节点" },
295
- { element_type: "node", type_name: "calc_number_div", semantic: "数值除法", return_type: "U256", child_constraints: "2 个数值子节点" },
296
- { element_type: "node", type_name: "convert_string_number", semantic: "String → Number 转换", return_type: "U256", child_constraints: "1 String 子节点" },
297
- { element_type: "node", type_name: "convert_number_string", semantic: "Number → String 转换", return_type: "String", child_constraints: "1 个数值子节点" },
298
- { element_type: "node", type_name: "convert_number_address", semantic: "Number Address 转换(时间戳转地址等)", return_type: "Address", child_constraints: "1 个数值子节点" },
299
- { element_type: "node", type_name: "vec_contains_bool", semantic: "向量是否包含 Bool", return_type: "Bool", child_constraints: "2 个子节点:VecBool + Bool" },
300
- { element_type: "node", type_name: "vec_contains_address", semantic: "向量是否包含 Address(白名单检查)", return_type: "Bool", child_constraints: "2 个子节点:VecAddress + Address" },
301
- { element_type: "node", type_name: "vec_contains_string", semantic: "向量是否包含 String", return_type: "Bool", child_constraints: "2 个子节点:VecString + String" },
302
- { element_type: "node", type_name: "vec_contains_string_nocase", semantic: "向量是否包含 String(大小写不敏感)", return_type: "Bool", child_constraints: "2 个子节点:VecString + String" },
303
- { element_type: "node", type_name: "vec_contains_number", semantic: "向量是否包含数值", return_type: "Bool", child_constraints: "2 个子节点:Vec* + Number" },
304
- { element_type: "node", type_name: "query_reward_record_exists", semantic: "查询奖励领取记录是否存在(Bool)", return_type: "Bool", child_constraints: "需要 object + recipient 字段" },
305
- { element_type: "node", type_name: "query_reward_record_count", semantic: "查询奖励领取记录数(U64)", return_type: "U64", child_constraints: "需要 object + recipient 字段" },
306
- { element_type: "node", type_name: "query_progress_history_find", semantic: "查询 Progress 历史中是否存在指定 session", return_type: "Bool", child_constraints: "需要 object + historyIdx + sessionIdx" },
307
- { element_type: "node", type_name: "query_progress_history_session_forward_find", semantic: "查询 Progress session 中是否存在指定 forward", return_type: "Bool", child_constraints: "需要 object + historyIdx + sessionIdx + forwardIdx" },
308
- { element_type: "node", type_name: "query_progress_history_session_forward_retained_submission_count", semantic: "查询 Progress session forward 的保留提交数", return_type: "U64", child_constraints: "需要 object + historyIdx + sessionIdx + forwardIdx" },
309
- { element_type: "witness", type_name: "TypeOrderProgress", semantic: " Order 地址转换到 Progress(100)", discovery_tool: "wowok_buildin_info(info='guard instructions')" },
310
- { element_type: "witness", type_name: "TypeOrderMachine", semantic: " Order 地址转换到 Machine(101)" },
311
- { element_type: "witness", type_name: "TypeOrderService", semantic: " Order 地址转换到 Service(102)" },
312
- { element_type: "witness", type_name: "TypeProgressMachine", semantic: " Progress 地址转换到 Machine(103)" },
313
- { element_type: "witness", type_name: "TypeArbOrder", semantic: " Arb 地址转换到 Order(104)" },
314
- { element_type: "witness", type_name: "TypeArbArbitration", semantic: " Arb 地址转换到 Arbitration(105,父服务)" },
315
- { element_type: "witness", type_name: "TypeArbProgress", semantic: " Arb 地址转换到 Progress(106)" },
316
- { element_type: "witness", type_name: "TypeArbMachine", semantic: " Arb 地址转换到 Machine(107)" },
317
- { element_type: "witness", type_name: "TypeArbService", semantic: " Arb 地址转换到 Service(108)" },
318
- { element_type: "table_entry", type_name: "Bool", semantic: "布尔值常量或提交" },
319
- { element_type: "table_entry", type_name: "Address", semantic: "地址常量或提交" },
320
- { element_type: "table_entry", type_name: "String", semantic: "字符串常量或提交" },
321
- { element_type: "table_entry", type_name: "U8", semantic: "8 位无符号整数" },
322
- { element_type: "table_entry", type_name: "U16", semantic: "16 位无符号整数" },
323
- { element_type: "table_entry", type_name: "U32", semantic: "32 位无符号整数" },
324
- { element_type: "table_entry", type_name: "U64", semantic: "64 位无符号整数" },
325
- { element_type: "table_entry", type_name: "U128", semantic: "128 位无符号整数" },
326
- { element_type: "table_entry", type_name: "U256", semantic: "256 位无符号整数" },
327
- { element_type: "table_entry", type_name: "VecAddress", semantic: "地址向量(用于白名单)" },
328
- { element_type: "table_entry", type_name: "VecString", semantic: "字符串向量" },
329
- { element_type: "table_entry", type_name: "VecU64", semantic: "U64 向量" },
330
- { element_type: "rely", type_name: "rely_and", semantic: "依赖其他 Guard,AND 逻辑(所有必须通过)", child_constraints: "最多 4 个依赖,每个 rep=true" },
331
- { element_type: "rely", type_name: "rely_or", semantic: "依赖其他 Guard,OR 逻辑(任一通过即可)", child_constraints: "最多 4 个依赖,每个 rep=true" },
655
+ { element_type: "node", type_name: "logic_equal", semantic: "Equality comparison (==), returns Bool. Accepts any type but both operands must be type-compatible", return_type: "Bool", child_constraints: "2 child nodes, types must be compatible" },
656
+ { element_type: "node", type_name: "logic_not", semantic: "Logical NOT (!), returns Bool", return_type: "Bool", child_constraints: "1 child node, must be Bool" },
657
+ { element_type: "node", type_name: "logic_and", semantic: "Logical AND; true if all child nodes are true", return_type: "Bool", child_constraints: "2-8 Bool child nodes (MAX_MULTI_OPERANDS)" },
658
+ { element_type: "node", type_name: "logic_or", semantic: "Logical OR; true if any child node is true", return_type: "Bool", child_constraints: "2-8 Bool child nodes" },
659
+ { element_type: "node", type_name: "logic_as_u256_greater", semantic: "Numeric greater than (>), auto-widened to U256", return_type: "Bool", child_constraints: "2 numeric child nodes (U8-U256 compatible)" },
660
+ { element_type: "node", type_name: "logic_as_u256_lesser", semantic: "Numeric less than (<)", return_type: "Bool", child_constraints: "2 numeric child nodes" },
661
+ { element_type: "node", type_name: "logic_as_u256_equal", semantic: "Numeric equality (==)", return_type: "Bool", child_constraints: "2 numeric child nodes" },
662
+ { element_type: "node", type_name: "logic_as_u256_greater_or_equal", semantic: "Numeric greater than or equal (>=)", return_type: "Bool", child_constraints: "2 numeric child nodes" },
663
+ { element_type: "node", type_name: "logic_as_u256_lesser_or_equal", semantic: "Numeric less than or equal (<=)", return_type: "Bool", child_constraints: "2 numeric child nodes" },
664
+ { element_type: "node", type_name: "logic_string_contains", semantic: "String contains (case-sensitive)", return_type: "Bool", child_constraints: "2 String child nodes" },
665
+ { element_type: "node", type_name: "logic_string_nocase_contains", semantic: "String contains (case-insensitive)", return_type: "Bool", child_constraints: "2 String child nodes" },
666
+ { element_type: "node", type_name: "logic_string_nocase_equal", semantic: "String equality (case-insensitive)", return_type: "Bool", child_constraints: "2 String child nodes" },
667
+ { element_type: "node", type_name: "identifier", semantic: "References the value of a table entry. The data source type depends on b_submission: false=Type1 constant, true=Type3 submitted", return_type: "Determined by table entry value_type", child_constraints: "No child nodes; requires identifier field to reference table", data_source_class: "Type1_OnChainConstant" },
668
+ { element_type: "node", type_name: "context", semantic: "Transaction context data (Type4 SystemContext). Signer=signer address, Clock=on-chain timestamp (U64), Guard=ObjectID of the Guard currently being verified", return_type: "Address (Signer/Guard) / U64 (Clock)", child_constraints: "No child nodes", data_source_class: "Type4_SystemContext" },
669
+ { element_type: "node", type_name: "query", semantic: "Queries on-chain object data. The data source type depends on object.convert_witness: present=Type2 (witness-derived), absent+constant=Type1, absent+submitted=Type3", return_type: "Determined by the query instruction", child_constraints: "Requires query + object + parameters fields", data_source_class: "Type1_OnChainConstant", discovery_tool: "wowok_buildin_info(info='guard instructions')" },
670
+ { element_type: "node", type_name: "calc_number_add", semantic: "Numeric addition", return_type: "U256", child_constraints: "2 numeric child nodes" },
671
+ { element_type: "node", type_name: "calc_number_subtract", semantic: "Numeric subtraction", return_type: "U256", child_constraints: "2 numeric child nodes" },
672
+ { element_type: "node", type_name: "calc_number_multiply", semantic: "Numeric multiplication", return_type: "U256", child_constraints: "2 numeric child nodes" },
673
+ { element_type: "node", type_name: "calc_number_divide", semantic: "Numeric division", return_type: "U256", child_constraints: "2 numeric child nodes" },
674
+ { element_type: "node", type_name: "calc_number_mod", semantic: "Numeric modulo", return_type: "U256", child_constraints: "2 numeric child nodes" },
675
+ { element_type: "node", type_name: "calc_string_length", semantic: "String length", return_type: "U64", child_constraints: "1 String child node" },
676
+ { element_type: "node", type_name: "calc_string_contains", semantic: "String contains (returns Bool)", return_type: "Bool", child_constraints: "2 String child nodes" },
677
+ { element_type: "node", type_name: "calc_string_nocase_contains", semantic: "String contains (case-insensitive, returns Bool)", return_type: "Bool", child_constraints: "2 String child nodes" },
678
+ { element_type: "node", type_name: "calc_string_nocase_equal", semantic: "String equality (case-insensitive, returns Bool)", return_type: "Bool", child_constraints: "2 String child nodes" },
679
+ { element_type: "node", type_name: "calc_string_indexof", semantic: "String find index", return_type: "U64", child_constraints: "2 String child nodes + order" },
680
+ { element_type: "node", type_name: "calc_string_nocase_indexof", semantic: "String find index (case-insensitive)", return_type: "U64", child_constraints: "2 String child nodes + order" },
681
+ { element_type: "node", type_name: "convert_number_address", semantic: "Number → Address conversion (e.g. timestamp to address)", return_type: "Address", child_constraints: "1 numeric child node" },
682
+ { element_type: "node", type_name: "convert_address_number", semantic: "Address → Number conversion", return_type: "U256", child_constraints: "1 Address child node" },
683
+ { element_type: "node", type_name: "convert_number_string", semantic: "Number → String conversion", return_type: "String", child_constraints: "1 numeric child node" },
684
+ { element_type: "node", type_name: "convert_string_number", semantic: "String Number conversion", return_type: "U256", child_constraints: "1 String child node" },
685
+ { element_type: "node", type_name: "convert_safe_u8", semantic: "Safe conversion to U8 (errors on overflow)", return_type: "U8", child_constraints: "1 numeric child node" },
686
+ { element_type: "node", type_name: "convert_safe_u16", semantic: "Safe conversion to U16", return_type: "U16", child_constraints: "1 numeric child node" },
687
+ { element_type: "node", type_name: "convert_safe_u32", semantic: "Safe conversion to U32", return_type: "U32", child_constraints: "1 numeric child node" },
688
+ { element_type: "node", type_name: "convert_safe_u64", semantic: "Safe conversion to U64", return_type: "U64", child_constraints: "1 numeric child node" },
689
+ { element_type: "node", type_name: "convert_safe_u128", semantic: "Safe conversion to U128", return_type: "U128", child_constraints: "1 numeric child node" },
690
+ { element_type: "node", type_name: "convert_safe_u256", semantic: "Safe conversion to U256", return_type: "U256", child_constraints: "1 numeric child node" },
691
+ { element_type: "node", type_name: "value_type", semantic: "Returns the value's type identifier (U8) — used for dynamic type checking", return_type: "U8", child_constraints: "1 variable child node" },
692
+ { element_type: "node", type_name: "vec_length", semantic: "Vector length", return_type: "U64", child_constraints: "1 vec child node" },
693
+ { element_type: "node", type_name: "vec_contains_bool", semantic: "Whether the vector contains a Bool value", return_type: "Bool", child_constraints: "1 VecBool + 1 Bool" },
694
+ { element_type: "node", type_name: "vec_contains_address", semantic: "Whether the vector contains an Address (whitelist check)", return_type: "Bool", child_constraints: "1 VecAddress + 1 Address" },
695
+ { element_type: "node", type_name: "vec_contains_string", semantic: "Whether the vector contains a String", return_type: "Bool", child_constraints: "1 VecString + 1 String" },
696
+ { element_type: "node", type_name: "vec_contains_string_nocase", semantic: "Whether the vector contains a String (case-insensitive)", return_type: "Bool", child_constraints: "1 VecString + 1 String" },
697
+ { element_type: "node", type_name: "vec_contains_number", semantic: "Whether the vector contains a number", return_type: "Bool", child_constraints: "1 Vec* + 1 Number" },
698
+ { element_type: "node", type_name: "vec_indexof_bool", semantic: "Bool vector find index", return_type: "U64", child_constraints: "VecBool + Bool + order" },
699
+ { element_type: "node", type_name: "vec_indexof_address", semantic: "Address vector find index", return_type: "U64", child_constraints: "VecAddress + Address + order" },
700
+ { element_type: "node", type_name: "vec_indexof_string", semantic: "String vector find index", return_type: "U64", child_constraints: "VecString + String + order" },
701
+ { element_type: "node", type_name: "vec_indexof_string_nocase", semantic: "String vector find index (case-insensitive)", return_type: "U64", child_constraints: "VecString + String + order" },
702
+ { element_type: "node", type_name: "vec_indexof_number", semantic: "Numeric vector find index", return_type: "U64", child_constraints: "Vec* + Number + order" },
703
+ { element_type: "node", type_name: "query_reward_record_find", semantic: "Query reward claim records (returns the found record)", return_type: "Bool", child_constraints: "Requires object + recipient + where + find" },
704
+ { element_type: "node", type_name: "query_reward_record_count", semantic: "Query reward claim record count (U64)", return_type: "U64", child_constraints: "Requires object + recipient (optional)" },
705
+ { element_type: "node", type_name: "query_reward_record_exists", semantic: "Query whether a reward claim record exists (Bool)", return_type: "Bool", child_constraints: "Requires object + recipient (optional)" },
706
+ { element_type: "node", type_name: "query_progress_history_find", semantic: "Query whether a specified session exists in Progress history", return_type: "Bool", child_constraints: "Requires object + where + find" },
707
+ { element_type: "node", type_name: "query_progress_history_session_find", semantic: "Query a Progress session", return_type: "Bool", child_constraints: "Requires object + historyIdx + where + find" },
708
+ { element_type: "node", type_name: "query_progress_history_session_forward_find", semantic: "Query whether a specified forward exists in a Progress session", return_type: "Bool", child_constraints: "Requires object + historyIdx + sessionIdx + where + find" },
709
+ { element_type: "node", type_name: "query_progress_history_session_count", semantic: "Query the number of Progress sessions", return_type: "U64", child_constraints: "Requires object + historyIdx" },
710
+ { element_type: "node", type_name: "query_progress_history_session_forward_count", semantic: "Query the number of forwards in a Progress session", return_type: "U64", child_constraints: "Requires object + historyIdx + sessionIdx" },
711
+ { element_type: "node", type_name: "query_progress_history_session_forward_retained_submission_count", semantic: "Query the retained submission count of a forward in a Progress session", return_type: "U64", child_constraints: "Requires object + historyIdx + sessionIdx + forwardIdx" },
712
+ { element_type: "witness", type_name: "TypeOrderProgress", semantic: "Reads the order.progress field from an Order address to derive Progress (100, single hop)", data_source_class: "Type2_WitnessDerived", discovery_tool: "wowok_buildin_info(info='guard instructions')" },
713
+ { element_type: "witness", type_name: "TypeOrderMachine", semantic: "Reads the order.machine field from an Order address to derive Machine (101, single hop)", data_source_class: "Type2_WitnessDerived" },
714
+ { element_type: "witness", type_name: "TypeOrderService", semantic: "Reads the order.service field from an Order address to derive Service (102, single hop)", data_source_class: "Type2_WitnessDerived" },
715
+ { element_type: "witness", type_name: "TypeProgressMachine", semantic: "Reads the progress.machine field from a Progress address to derive Machine (103, single hop)", data_source_class: "Type2_WitnessDerived" },
716
+ { element_type: "witness", type_name: "TypeArbOrder", semantic: "Reads the arb.order field from an Arb address to derive Order (104, single hop)", data_source_class: "Type2_WitnessDerived" },
717
+ { element_type: "witness", type_name: "TypeArbArbitration", semantic: "Reads the arb.arbitration field from an Arb address to derive the parent Arbitration service (105, single hop)", data_source_class: "Type2_WitnessDerived" },
718
+ { element_type: "witness", type_name: "TypeArbProgress", semantic: "Derives from Arb in two hops: arb.order → order.progress (106, multi-hop)", data_source_class: "Type2_WitnessDerived" },
719
+ { element_type: "witness", type_name: "TypeArbMachine", semantic: "Derives from Arb in two hops: arb.order → order.machine (107, multi-hop)", data_source_class: "Type2_WitnessDerived" },
720
+ { element_type: "witness", type_name: "TypeArbService", semantic: "Derives from Arb in two hops: arb.order → order.service (108, multi-hop)", data_source_class: "Type2_WitnessDerived" },
721
+ { element_type: "context", type_name: "Signer", semantic: "Current transaction signer address (TransactionContext.sender())", return_type: "Address", data_source_class: "Type4_SystemContext" },
722
+ { element_type: "context", type_name: "Clock", semantic: "Current on-chain timestamp (reads timestamp_ms of WOW_CLOCK_OBJECT_ID 0x6)", return_type: "U64", data_source_class: "Type4_SystemContext" },
723
+ { element_type: "context", type_name: "Guard", semantic: "ObjectID of the Guard object currently being verified (self-reference, rare)", return_type: "Address", data_source_class: "Type4_SystemContext" },
724
+ { element_type: "table_entry", type_name: "Bool", semantic: "Boolean constant or submission" },
725
+ { element_type: "table_entry", type_name: "Address", semantic: "Address constant (Type1) or submission (Type3). Object address type" },
726
+ { element_type: "table_entry", type_name: "String", semantic: "String constant or submission" },
727
+ { element_type: "table_entry", type_name: "U8", semantic: "8-bit unsigned integer" },
728
+ { element_type: "table_entry", type_name: "U16", semantic: "16-bit unsigned integer" },
729
+ { element_type: "table_entry", type_name: "U32", semantic: "32-bit unsigned integer" },
730
+ { element_type: "table_entry", type_name: "U64", semantic: "64-bit unsigned integer (commonly used for timestamps)" },
731
+ { element_type: "table_entry", type_name: "U128", semantic: "128-bit unsigned integer" },
732
+ { element_type: "table_entry", type_name: "U256", semantic: "256-bit unsigned integer (auto-widening target for numeric operations)" },
733
+ { element_type: "table_entry", type_name: "VecAddress", semantic: "Address vector (used for whitelists, Type1 constant)" },
734
+ { element_type: "table_entry", type_name: "VecString", semantic: "String vector" },
735
+ { element_type: "table_entry", type_name: "VecU64", semantic: "U64 vector" },
736
+ { element_type: "table_entry", type_name: "VecU8", semantic: "U8 vector (raw bytes)" },
737
+ { element_type: "table_entry", type_name: "Value", semantic: "Dynamic type (19, first byte is the type identifier) — used for Repository data, EntityRegistrar records, Passport submission value" },
738
+ { element_type: "rely", type_name: "rely_and", semantic: "Depends on other Guards, AND logic (all must pass). Depended-on Guards must have rep=true", child_constraints: "At most 4 dependencies, each with rep=true (repository.data query does not depend on submission)" },
739
+ { element_type: "rely", type_name: "rely_or", semantic: "Depends on other Guards, OR logic (any one passing is sufficient). Depended-on Guards must have rep=true", child_constraints: "At most 4 dependencies, each with rep=true" },
332
740
  ];
333
741
  export const GUARD_CONSTRAINT_RULES = [
334
742
  {
335
743
  id: "ROOT_01",
336
- name: "root 返回 Bool",
337
- description: "Guard root 节点必须返回 Bool 类型",
744
+ name: "root returns Bool",
745
+ description: "The Guard root node must return a Bool type",
338
746
  category: "root",
339
- validation_logic: "root.node_type 必须在 allowedTypes 列表中(logic_*, calc_string_contains, vec_contains_*, query_reward_record_exists, query[Bool返回], identifier[Bool类型])",
747
+ phase: "creation",
748
+ validation_logic: "root.node_type must be in the allowedTypes list (logic_*, calc_string_contains, vec_contains_*, query_reward_record_exists, query[Bool return], identifier[Bool type])",
340
749
  failure_message: "Guard root node must be an operation that returns Bool",
750
+ verification_location: "SDK buildNode(root, ValueType.Bool, ...)",
341
751
  pitfall_number: 7,
342
752
  },
343
753
  {
344
754
  id: "TABLE_01",
345
- name: "identifier 唯一性",
346
- description: "table 中每个 identifier 必须唯一(0-255",
755
+ name: "identifier uniqueness",
756
+ description: "Each identifier in the table must be unique (0-255)",
347
757
  category: "table",
348
- validation_logic: "table 中无重复 identifier",
758
+ phase: "creation",
759
+ validation_logic: "No duplicate identifiers in the table",
349
760
  failure_message: "Duplicate table identifier",
761
+ verification_location: "SDK lodash groupBy",
350
762
  },
351
763
  {
352
764
  id: "TABLE_02",
353
- name: "identifier 引用完整性",
354
- description: "计算树中每个 identifier 节点必须在 table 中存在",
765
+ name: "identifier referential integrity",
766
+ description: "Every identifier node in the computation tree must exist in the table",
355
767
  category: "table",
356
- validation_logic: "遍历计算树,每个 identifier 节点的 index 在 table 中存在",
768
+ phase: "creation",
769
+ validation_logic: "Traverse the computation tree; each identifier node's index exists in the table",
357
770
  failure_message: "Identifier not found in table",
771
+ verification_location: "SDK buildNode",
358
772
  pitfall_number: 1,
359
773
  },
360
774
  {
361
775
  id: "TABLE_03",
362
- name: "常量条目必须有值",
363
- description: "b_submission=false 的条目必须有 value 字段",
776
+ name: "Constant entries must have a value",
777
+ description: "Entries with b_submission=false must have a value field",
364
778
  category: "table",
365
- validation_logic: "所有 b_submission=false 的条目 value 字段非空",
779
+ phase: "creation",
780
+ validation_logic: "All entries with b_submission=false have a non-empty value field",
366
781
  failure_message: "Constant table entry must have a value",
782
+ verification_location: "SDK operate",
367
783
  },
368
784
  {
369
785
  id: "TABLE_04",
370
- name: "table 大小限制",
371
- description: "最多 256 条目,序列化后不超过 40000 字节",
786
+ name: "table size limit",
787
+ description: "At most 256 entries; serialized size must not exceed 40000 bytes",
372
788
  category: "table",
789
+ phase: "creation",
373
790
  validation_logic: "table.length <= 256 && serialize(table).length <= 40000",
374
791
  failure_message: "Table exceeds size limit (256 entries or 40000 bytes)",
792
+ verification_location: "Move guard::new",
793
+ },
794
+ {
795
+ id: "TABLE_05",
796
+ name: "submission entry value is 1 byte (type code only)",
797
+ description: "Entries with b_submission=true have a serialized value of just 1 byte (the type code)",
798
+ category: "table",
799
+ phase: "creation",
800
+ validation_logic: "When b_submission=true, bcsValue.length === 1 and bcsValue[0] === valueType",
801
+ failure_message: "Submission table entry value must be 1 byte (type code only)",
802
+ verification_location: "native deserialize_constants",
375
803
  },
376
804
  {
377
805
  id: "QUERY_01",
378
- name: "query 指令有效",
379
- description: "query 节点的 query 字段必须是有效的 GUARDQUERY ID name",
806
+ name: "query instruction valid",
807
+ description: "The query field of a query node must be a valid GUARDQUERY ID or name",
380
808
  category: "query",
381
- validation_logic: "query 字段在 GUARDQUERY 中存在(通过 isValidGuardQueryIdOrName)",
809
+ phase: "creation",
810
+ validation_logic: "The query field exists in GUARDQUERY (via isValidGuardQueryIdOrName)",
382
811
  failure_message: "Invalid Guard query instruction",
812
+ verification_location: "SDK getGuardQueryInfo",
383
813
  pitfall_number: 3,
384
814
  },
385
815
  {
386
816
  id: "QUERY_02",
387
- name: "query 参数匹配",
388
- description: "query 节点的 parameters 数量和类型必须匹配指令定义",
817
+ name: "query parameter count match",
818
+ description: "The number and types of parameters in a query node must match the instruction definition",
389
819
  category: "query",
390
- validation_logic: "parameters.length === instruction.parameters.length && 类型兼容",
820
+ phase: "creation",
821
+ validation_logic: "parameters.length === instruction.parameters.length && type-compatible",
391
822
  failure_message: "Query parameter count or type mismatch",
823
+ verification_location: "SDK buildNode",
392
824
  pitfall_number: 3,
393
825
  },
394
826
  {
395
827
  id: "QUERY_03",
396
- name: "query object 类型匹配",
397
- description: "query object object_type 必须匹配指令的 objectType",
828
+ name: "query return type compatible",
829
+ description: "The return type of a query node must be compatible with the parent node's expected type",
398
830
  category: "query",
399
- validation_logic: "table[object.identifier].object_type === instruction.objectType(考虑 witness 转换)",
400
- failure_message: "Query object type mismatch",
831
+ phase: "creation",
832
+ validation_logic: "checkType(query.return_type, parent.expected_type)",
833
+ failure_message: "Query return type incompatible with parent node",
834
+ verification_location: "SDK checkType",
835
+ },
836
+ {
837
+ id: "QUERY_04",
838
+ name: "query object identifier's value_type is Address",
839
+ description: "The table entry referenced by query node's object.identifier must have value_type of Address",
840
+ category: "query",
841
+ phase: "creation",
842
+ validation_logic: "table[object.identifier].value_type === Address",
843
+ failure_message: "Query object identifier must reference an Address-type table entry",
844
+ verification_location: "SDK buildNode L603-609",
401
845
  },
402
846
  {
403
847
  id: "WITNESS_01",
404
- name: "witness 类型有效",
405
- description: "convert_witness 必须是有效的 WitnessType (100-108)",
848
+ name: "witness type valid",
849
+ description: "convert_witness must be a valid WitnessType (100-108)",
406
850
  category: "witness",
407
- validation_logic: "witness 值在 WitnessTypeSchema 允许范围内",
851
+ phase: "creation",
852
+ validation_logic: "The witness value is within the range allowed by WitnessTypeSchema (100-108)",
408
853
  failure_message: "Invalid witness type",
854
+ verification_location: "SDK isWitnessType",
409
855
  pitfall_number: 4,
410
856
  },
411
857
  {
412
858
  id: "WITNESS_02",
413
- name: "witness source-target 匹配",
414
- description: "witness source type 必须匹配 table 条目 object_type,target type 必须匹配 query objectType",
859
+ name: "witness target matches query objectType",
860
+ description: "The witness's target type must match the query instruction's objectType",
861
+ category: "witness",
862
+ phase: "creation",
863
+ validation_logic: "witness.target_type === instruction.objectType",
864
+ failure_message: "Witness target type does not match query object type",
865
+ verification_location: "SDK buildNode L613-619",
866
+ pitfall_number: 4,
867
+ },
868
+ {
869
+ id: "WITNESS_03",
870
+ name: "witness source matches tableItem object_type",
871
+ description: "The witness's source type must match the object_type declared in the table entry (if declared)",
415
872
  category: "witness",
416
- validation_logic: "table[identifier].object_type === witness.source_type && instruction.objectType === witness.target_type",
417
- failure_message: "Witness source/target type mismatch",
873
+ phase: "creation",
874
+ validation_logic: "table[identifier].object_type === witness.source_type (if tableItem.object_type is declared)",
875
+ failure_message: "Witness source type does not match table entry object_type",
876
+ verification_location: "SDK buildNode L622-631",
418
877
  pitfall_number: 4,
419
878
  },
420
879
  {
421
880
  id: "RELY_01",
422
- name: "rely 依赖数量",
423
- description: "rely.guards 最多 4 个依赖",
881
+ name: "rely dependency count ≤ 4",
882
+ description: "rely.guards supports at most 4 dependencies (MAX_DEPENDED_COUNT)",
424
883
  category: "rely",
884
+ phase: "creation",
425
885
  validation_logic: "rely.guards.length <= 4",
426
886
  failure_message: "Rely dependencies exceed limit (4)",
887
+ verification_location: "SDK reliesAdd",
427
888
  },
428
889
  {
429
890
  id: "RELY_02",
430
- name: "rely 依赖 rep=true",
431
- description: "所有 rely 依赖的 Guard 必须 rep=true(无 Repository 依赖)",
891
+ name: "rely dependency rep=true",
892
+ description: "All rely-depended Guards must have rep=true (repository.data query does not depend on runtime submission)",
432
893
  category: "rely",
433
- validation_logic: "查询每个依赖 Guard 的 rep 字段,必须为 true",
894
+ phase: "creation",
895
+ validation_logic: "Query each depended Guard's rep field; must be true",
434
896
  failure_message: "Rely dependency has rep=false (not standalone)",
897
+ verification_location: "Move guard::relies_add",
435
898
  pitfall_number: 8,
436
899
  },
900
+ {
901
+ id: "RELY_03",
902
+ name: "rely forbids self-reference",
903
+ description: "A Guard cannot depend on itself",
904
+ category: "rely",
905
+ phase: "creation",
906
+ validation_logic: "rely.guards does not contain the current Guard's address",
907
+ failure_message: "Guard cannot rely on itself",
908
+ verification_location: "SDK reliesAdd",
909
+ },
437
910
  {
438
911
  id: "BINDING_01",
439
912
  name: "voting_guard GuardIdentifier numeric",
440
- description: "Arbitration voting_guard GuardIdentifier 引用的 table 条目必须 numeric 类型",
913
+ description: "The table entry referenced by Arbitration voting_guard's GuardIdentifier must be of a numeric type",
441
914
  category: "binding",
442
- validation_logic: "如果 binding=voting_guard,GuardIdentifier 指向的 table 条目 value_type 在 [U8,U16,U32,U64,U128,U256] 中",
915
+ phase: "creation",
916
+ validation_logic: "If binding=voting_guard, the table entry pointed to by GuardIdentifier has value_type in [U8,U16,U32,U64,U128,U256]",
443
917
  failure_message: "E_GUARD_IDENTIFIER_NOT_NUMBER: voting_guard weight must be numeric",
918
+ verification_location: "Move Arbitration",
444
919
  pitfall_number: 9,
445
920
  },
446
921
  {
447
922
  id: "BINDING_02",
448
923
  name: "Repository id_from_submission Address",
449
- description: "Repository write_guard id_from_submission 引用的 table 条目必须 Address 类型",
924
+ description: "The table entry referenced by Repository write_guard's id_from_submission must be of Address type",
450
925
  category: "binding",
451
- validation_logic: "如果 binding=write_guard 且 id_from_submission 设置,table[id_from_submission].value_type === Address",
926
+ phase: "creation",
927
+ validation_logic: "If binding=write_guard and id_from_submission is set, table[id_from_submission].value_type === Address",
452
928
  failure_message: "Repository id_from_submission must be Address type",
929
+ verification_location: "Move Repository",
453
930
  },
454
931
  {
455
932
  id: "BINDING_03",
456
- name: "Repository data_from_submission 类型匹配",
457
- description: "Repository write_guard data_from_submission 引用的 table 条目必须匹配 Repository value_type",
933
+ name: "Repository data_from_submission type match",
934
+ description: "The table entry referenced by Repository write_guard's data_from_submission must match the Repository value_type",
458
935
  category: "binding",
459
- validation_logic: "如果 binding=write_guard 且 data_from_submission 设置,table[data_from_submission].value_type === Repository.value_type",
936
+ phase: "creation",
937
+ validation_logic: "If binding=write_guard and data_from_submission is set, table[data_from_submission].value_type === Repository.value_type",
460
938
  failure_message: "Repository data_from_submission type mismatch",
939
+ verification_location: "Move Repository",
940
+ },
941
+ {
942
+ id: "INPUT_01",
943
+ name: "root byte stream non-empty",
944
+ description: "The serialized byte stream of root cannot be empty",
945
+ category: "input",
946
+ phase: "creation",
947
+ validation_logic: "input.length > 0",
948
+ failure_message: "Input cannot be empty",
949
+ verification_location: "SDK newGuard",
950
+ },
951
+ {
952
+ id: "INPUT_02",
953
+ name: "root byte stream ≤ MAX_INPUT_SIZE",
954
+ description: "The serialized byte stream of root must not exceed MAX_INPUT_SIZE",
955
+ category: "input",
956
+ phase: "creation",
957
+ validation_logic: "input.length <= MAX_INPUT_SIZE",
958
+ failure_message: "Input size exceeds maximum limit",
959
+ verification_location: "SDK newGuard",
960
+ },
961
+ {
962
+ id: "IMMUTABLE_01",
963
+ name: "Guard immutable=true after creation",
964
+ description: "After creation, a Guard cannot be modified or deleted (CREATE-only)",
965
+ category: "immutable",
966
+ phase: "creation",
967
+ validation_logic: "After guard::create, the immutable field is set to true",
968
+ failure_message: "Guard is immutable after creation",
969
+ verification_location: "Move guard::create",
970
+ },
971
+ {
972
+ id: "RUN_IMMUTABLE_01",
973
+ name: "Guard must be immutable=true to verify",
974
+ description: "At runtime verification, the Guard must be frozen (immutable=true)",
975
+ category: "immutable",
976
+ phase: "runtime",
977
+ validation_logic: "guard.immutable === true",
978
+ failure_message: "Guard must be immutable to verify",
979
+ verification_location: "native verify_guard L497-506",
980
+ },
981
+ {
982
+ id: "RUN_SUB_01",
983
+ name: "submission type byte matches table declaration",
984
+ description: "The value[0] (type byte) of submission must match the value_type declared in the table",
985
+ category: "table",
986
+ phase: "runtime",
987
+ validation_logic: "submission_value[0] === table[identifier].value_type",
988
+ failure_message: "Submission type byte does not match table declaration",
989
+ verification_location: "native parse_table_items L306",
990
+ },
991
+ {
992
+ id: "RUN_SUB_02",
993
+ name: "table entries with b_submission=true must be found in submission",
994
+ description: "All table entries declared as submitted must have corresponding submission data",
995
+ category: "table",
996
+ phase: "runtime",
997
+ validation_logic: "forall identifier in table where b_submission=true: identifier in submission_map",
998
+ failure_message: "Missing submission for declared b_submission=true table entry",
999
+ verification_location: "native parse_table_items L301-321",
1000
+ },
1001
+ {
1002
+ id: "RUN_SUB_03",
1003
+ name: "submission total bytes ≤ MAX_SUBMISSION_SIZE (256)",
1004
+ description: "The total bytes of all data submitted at runtime must not exceed 256",
1005
+ category: "table",
1006
+ phase: "runtime",
1007
+ validation_logic: "total_submission_bytes <= 256",
1008
+ failure_message: "Submission exceeds MAX_SUBMISSION_SIZE (256 bytes)",
1009
+ verification_location: "Move verify L252",
1010
+ },
1011
+ {
1012
+ id: "RUN_WITNESS_01",
1013
+ name: "witness derivation source object must have the required relation field",
1014
+ description: "When witness conversion occurs, the source object must contain the relation field needed for derivation",
1015
+ category: "witness",
1016
+ phase: "runtime",
1017
+ validation_logic: "The source object exists and contains the field required for witness derivation (e.g. order.progress field is non-empty)",
1018
+ failure_message: "Witness source object missing required field for derivation",
1019
+ verification_location: "native convert_witness",
1020
+ },
1021
+ {
1022
+ id: "RUN_WITNESS_02",
1023
+ name: "witness-derived target object must exist",
1024
+ description: "The target object derived by witness must exist on-chain",
1025
+ category: "witness",
1026
+ phase: "runtime",
1027
+ validation_logic: "The derived target object ID exists on-chain",
1028
+ failure_message: "Witness derived target object does not exist",
1029
+ verification_location: "native convert_witness",
1030
+ },
1031
+ {
1032
+ id: "RUN_QUERY_01",
1033
+ name: "query target object must exist and type match",
1034
+ description: "The target object of a query must exist on-chain and its type must match",
1035
+ category: "query",
1036
+ phase: "runtime",
1037
+ validation_logic: "Target object exists && object type matches query.objectType",
1038
+ failure_message: "Query target object does not exist or type mismatch",
1039
+ verification_location: "native process_object_query",
1040
+ },
1041
+ {
1042
+ id: "RUN_IMPACK_01",
1043
+ name: "at least one impack guard",
1044
+ description: "Passport verification requires at least one impack guard",
1045
+ category: "runtime",
1046
+ phase: "runtime",
1047
+ validation_logic: "impack_list.length >= 1 (note: impack_list is always empty during verify phase; this constraint is checked in result_for_permission phase)",
1048
+ failure_message: "No impack guard found",
1049
+ verification_location: "Move verify L281",
1050
+ },
1051
+ {
1052
+ id: "RUN_IMPACK_02",
1053
+ name: "impack guard failure fails the entire passport",
1054
+ description: "If any impack guard verification fails, the entire passport verification fails",
1055
+ category: "runtime",
1056
+ phase: "runtime",
1057
+ validation_logic: "forall guard in impack_list: guard.result === true",
1058
+ failure_message: "Impack guard verification failed",
1059
+ verification_location: "Move verify L270-275",
1060
+ },
1061
+ {
1062
+ id: "RUN_TX_01",
1063
+ name: "Passport tx_hash must match the current transaction",
1064
+ description: "The tx_hash recorded in the Passport must match the hash of the currently executing transaction",
1065
+ category: "runtime",
1066
+ phase: "runtime",
1067
+ validation_logic: "passport.tx_hash === current_tx_hash",
1068
+ failure_message: "Passport tx_hash does not match current transaction",
1069
+ verification_location: "Move verify L231",
1070
+ },
1071
+ {
1072
+ id: "RUN_RELY_01",
1073
+ name: "rely guard must have been added to passport",
1074
+ description: "Guards relied on must have been registered in the passport",
1075
+ category: "rely",
1076
+ phase: "runtime",
1077
+ validation_logic: "forall guard in rely.guards: guard in passport.relies",
1078
+ failure_message: "Rely guard not added to passport",
1079
+ verification_location: "Move calculate_relies_result",
461
1080
  },
462
1081
  ];
463
1082
  export function matchSemanticPattern(userIntent) {
@@ -482,6 +1101,18 @@ export function explainWitness(witnessType) {
482
1101
  const name = witnessMap[witnessType];
483
1102
  return SCHEMA_TO_SEMANTIC_RULES.find((r) => r.element_type === "witness" && r.type_name === name);
484
1103
  }
1104
+ export function explainContext(contextType) {
1105
+ return SCHEMA_TO_SEMANTIC_RULES.find((r) => r.element_type === "context" && r.type_name === contextType);
1106
+ }
485
1107
  export function getConstraintsByCategory(category) {
486
1108
  return GUARD_CONSTRAINT_RULES.filter((r) => r.category === category);
487
1109
  }
1110
+ export function getConstraintsByPhase(phase) {
1111
+ return GUARD_CONSTRAINT_RULES.filter((r) => r.phase === phase);
1112
+ }
1113
+ export function getPatternById(id) {
1114
+ return SEMANTIC_TO_SCHEMA_RULES.find((r) => r.id === id);
1115
+ }
1116
+ export function getDataSourceCombinations() {
1117
+ return [...new Set(SEMANTIC_TO_SCHEMA_RULES.map((r) => r.data_source_combination))];
1118
+ }