@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
@@ -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,223 @@
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
16
  ],
17
17
  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 组合多个检查",
18
+ "Identity check: context(Signer) + logic_equal (single address) / vec_contains_address (whitelist)",
19
+ "Membership validation: query EntityRegistrar(0xaab) + logic_and combination",
20
+ "Time limit: context(Clock) + logic_as_u256_greater_or_equal",
21
+ "Multi-condition: logic_and combining multiple checks",
22
22
  ],
23
23
  mutable_after_publish: true,
24
24
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R9"],
25
25
  },
26
26
  {
27
27
  id: "service_order_allocators_guard",
28
- name: "分账策略选择验证(order_allocators[].guard",
28
+ name: "Allocation strategy selection validation (order_allocators[].guard)",
29
29
  host_object: "Service",
30
30
  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 状态自动派生(无需客户显式提交)",
31
+ validation_scene: "When an order is completed or allocation conditions are met, the system evaluates each Allocator's Guard in order_allocators order. " +
32
+ "The first Allocator whose Guard passes executes the allocation",
33
+ pass_result: "Execute that Allocator's allocation strategy (distribute funds by ratio/condition)",
34
+ fail_result: "Skip this Allocator and try the next (first-match-wins). If all Allocators fail, funds are not distributed",
35
+ submission_source: "System auto-derives from Progress state (no explicit customer submission needed)",
36
36
  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 值作为分账比例)",
37
+ "order_allocators is order-sensitive: the first Allocator whose Guard passes executes allocation",
38
+ "order_allocators cannot be modified after Service is published (immutable)",
39
+ "Guard usually queries Order/Progress state to determine allocation conditions",
40
+ "Common queries: order.amount, progress.current_node, order.completed, etc.",
41
+ "GuardIdentifier can be used for dynamic amounts (extract u64 value from table as allocation ratio)",
42
42
  ],
43
43
  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] 提取分账比例",
44
+ "Node state check: query(Progress.current_node) + logic_equal('Completed')",
45
+ "Amount threshold: query(Order.amount) + logic_as_u256_greater_or_equal(threshold)",
46
+ "Multi-condition combination: logic_and (node state + amount + time)",
47
+ "GuardIdentifier dynamic ratio: table[u64] extracts allocation ratio",
48
48
  ],
49
49
  mutable_after_publish: false,
50
50
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
51
51
  },
52
52
  {
53
53
  id: "machine_forward_guard",
54
- name: "工作流节点推进验证(Forward.guard",
54
+ name: "Workflow node advancement validation (Forward.guard)",
55
55
  host_object: "Machine",
56
56
  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 配置)",
57
+ 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",
58
+ pass_result: "Progress advances to next_node; session accumulates weight",
59
+ fail_result: "Forward is blocked; Progress stays at the current node. Optional retained_submission retains audit data",
60
+ submission_source: "The party executing Forward (Customer or Provider, depending on Forward configuration)",
61
61
  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",
62
+ "Forward.guard cannot be modified after Machine is published (a new Machine must be created)",
63
+ "Optional retained_submission: stores submission data in Progress for later audit",
64
+ "retained_submission indices must correspond to the Guard table",
65
+ "Common queries: progress.current_node, progress.session_forward, order.service, etc.",
66
+ "Time lock: context(Clock) + calc_number_add(progress.entry_time, duration) tested with 1000ms",
67
67
  ],
68
68
  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",
69
+ "Identity check: context(Signer) + logic_equal (only specific parties can advance)",
70
+ "Time lock: context(Clock) + calc_number_add + logic_as_u256_greater_or_equal",
71
+ "Prior Forward completion: query_progress_history_find + logic_equal(accomplished=true)",
72
+ "Submission data validation: identifier(submission) + logic_equal(expected_value)",
73
+ "Cross-object query: convert_witness=TypeOrderProgress(100) queries Progress from Order",
74
74
  ],
75
75
  mutable_after_publish: false,
76
76
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
77
77
  },
78
78
  {
79
79
  id: "progress_submission_guard",
80
- name: "Progress 提交数据验证(submission guard",
80
+ name: "Progress submission data validation (submission guard)",
81
81
  host_object: "Progress",
82
82
  binding_field: "submission",
83
- validation_scene: "Forward 执行时提交的数据(如签名、凭证、确认)是否满足 Guard 条件",
84
- pass_result: "Forward 完成,session 累计权重达到阈值后推进节点",
85
- fail_result: "Forward 不完成,等待重新提交或满足条件",
86
- submission_source: "提交数据的一方(Customer Provider",
83
+ validation_scene: "Whether the data (e.g. signature, credential, confirmation) submitted during Forward execution satisfies the Guard condition",
84
+ pass_result: "Forward completes; node advances after session accumulates weight to threshold",
85
+ fail_result: "Forward does not complete; waits for resubmission or condition satisfaction",
86
+ submission_source: "The party submitting data (Customer or Provider)",
87
87
  special_constraints: [
88
- " Forward.guard 协同:Forward.guard 验证资格,submission guard 验证数据",
89
- "retained_submission 将提交数据存入 Progress session 供审计",
90
- "常用 query: progress.session_forward, progress.session_weight ",
88
+ "Works in concert with Forward.guard: Forward.guard validates eligibility, submission guard validates data",
89
+ "retained_submission stores submission data in Progress session for audit",
90
+ "Common queries: progress.session_forward, progress.session_weight, etc.",
91
91
  ],
92
92
  common_patterns: [
93
- "签名验证:identifier(signature_submission) + logic_equal(expected)",
94
- "凭证验证:query(Repository.data) + logic_equal(submission_proof)",
95
- "确认验证:identifier(confirm_submission) + logic_equal(true)",
93
+ "Signature validation: identifier(signature_submission) + logic_equal(expected)",
94
+ "Credential validation: query(Repository.data) + logic_equal(submission_proof)",
95
+ "Confirmation validation: identifier(confirm_submission) + logic_equal(true)",
96
96
  ],
97
97
  mutable_after_publish: false,
98
98
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R8"],
99
99
  },
100
100
  {
101
101
  id: "reward_guard",
102
- name: "奖励领取验证(Reward.guard",
102
+ name: "Reward claim validation (Reward.guard)",
103
103
  host_object: "Reward",
104
104
  binding_field: "guard",
105
- validation_scene: "用户领取奖励池时,Guard 验证是否有资格领取",
106
- pass_result: "奖励发放给 Claimant,记录到 reward_record",
107
- fail_result: "领取拒绝,奖励不发",
108
- submission_source: "ClaimantaddresscredentialsPassport",
105
+ validation_scene: "When a user claims from a reward pool, the Guard validates eligibility to claim",
106
+ pass_result: "Reward is distributed to the Claimant and recorded in reward_record",
107
+ fail_result: "Claim rejected; reward is not distributed",
108
+ submission_source: "Claimant (address, credentials, Passport)",
109
109
  special_constraints: [
110
- "常用 query_reward_record_count 防重复领取(one-time claim",
111
- "Guard 通常查询历史记录 + 时间条件 + 身份验证",
112
- "如果 Reward 引用 Service,使用循环引用模式",
110
+ "Common query_reward_record_count prevents duplicate claims (one-time claim)",
111
+ "Guard usually queries history records + time conditions + identity validation",
112
+ "If the Reward references a Service, use the circular reference pattern",
113
113
  ],
114
114
  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(身份 + 时间 + 未领取过)",
115
+ "One-time claim: query_reward_record_count(recipient) + logic_equal(0)",
116
+ "Time window: context(Clock) + logic_as_u256_greater_or_equal(start_time)",
117
+ "Identity validation: context(Signer) + vec_contains_address(allowlist)",
118
+ "Multi-condition: logic_and (identity + time + not claimed before)",
119
119
  ],
120
120
  mutable_after_publish: true,
121
121
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
122
122
  },
123
123
  {
124
124
  id: "repository_write_guard",
125
- name: "存储写入验证(write_guard",
125
+ name: "Repository write validation (write_guard)",
126
126
  host_object: "Repository",
127
127
  binding_field: "write_guard",
128
- validation_scene: "写入链上存储时,Guard 验证写入资格并可选提取数据",
129
- pass_result: "写入成功;可选 id_from_submission 提取 entity IDdata_from_submission 提取数据值",
130
- fail_result: "写入拒绝",
128
+ validation_scene: "When writing to on-chain storage, the Guard validates write eligibility and optionally extracts data",
129
+ pass_result: "Write succeeds; optional id_from_submission extracts the entity ID, data_from_submission extracts the data value",
130
+ fail_result: "Write rejected",
131
131
  submission_source: "Writer/Reader",
132
132
  special_constraints: [
133
- "id_from_submission 引用的 table 条目必须是 Address 类型",
134
- "data_from_submission 引用的 table 条目必须匹配 Repository value_type",
135
- "类型不匹配导致写入失败或数据损坏",
136
- "常用于 oracle 数据写入、第三方凭证存证等场景",
133
+ "The table entry referenced by id_from_submission must be of Address type",
134
+ "The table entry referenced by data_from_submission must match the Repository's value_type",
135
+ "Type mismatch leads to write failure or data corruption",
136
+ "Commonly used for oracle data writes, third-party credential attestation, etc.",
137
137
  ],
138
138
  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 组合",
139
+ "Authorized writer: context(Signer) + vec_contains_address(authorized_writers)",
140
+ "Data format validation: identifier(data_submission) + logic_string_contains(expected_prefix)",
141
+ "ID extraction: id_from_submission + data_from_submission combination",
142
142
  ],
143
143
  mutable_after_publish: true,
144
144
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
145
145
  },
146
146
  {
147
147
  id: "arbitration_usage_guard",
148
- name: "争议发起验证(usage_guard",
148
+ name: "Dispute initiation validation (usage_guard)",
149
149
  host_object: "Arbitration",
150
150
  binding_field: "usage_guard",
151
- validation_scene: "客户对订单发起争议时,Guard 验证客户是否有资格发起争议",
152
- pass_result: "创建 Arb 案件,进入仲裁流程",
153
- fail_result: "争议拒绝,Arb 不创建",
154
- submission_source: "CustomerPassport credential",
151
+ validation_scene: "When a customer initiates a dispute against an order, the Guard validates whether the customer is eligible to initiate the dispute",
152
+ pass_result: "Create an Arb case and enter the arbitration flow",
153
+ fail_result: "Dispute rejected; Arb is not created",
154
+ submission_source: "Customer (Passport credential)",
155
155
  special_constraints: [
156
- "Arbitration bPaused=true 时优先阻塞(先于 Guard 检查)",
157
- "客户需先生成 Passportgen_passport 通过 usage_guard",
158
- "常用 query: order.completed, order.service, entity.has ",
159
- "Guard 验证客户身份 + 订单状态 + 争议资格",
156
+ "When Arbitration bPaused=true, it blocks first (before the Guard check)",
157
+ "The customer must first generate a Passport (gen_passport passes usage_guard)",
158
+ "Common queries: order.completed, order.service, entity.has, etc.",
159
+ "Guard validates customer identity + order status + dispute eligibility",
160
160
  ],
161
161
  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)",
162
+ "Order status validation: query(Order.status) + logic_equal('completed')",
163
+ "Membership validation: query(EntityRegistrar) + logic_and",
164
+ "Time window: query(Order.time) + calc_number_add + context(Clock)",
165
+ "Passport credential: identifier(passport_submission) + context(Signer)",
166
166
  ],
167
167
  mutable_after_publish: true,
168
168
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
169
169
  },
170
170
  {
171
171
  id: "arbitration_voting_guard",
172
- name: "仲裁投票权重验证(voting_guard[]",
172
+ name: "Arbitration voting weight validation (voting_guard[])",
173
173
  host_object: "Arbitration",
174
174
  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",
175
+ validation_scene: "When an arbitrator votes, the Guard validates voting eligibility and extracts the voting weight (u32) from GuardIdentifier",
176
+ pass_result: "Vote is counted; weight is the value extracted by GuardIdentifier",
177
+ fail_result: "Vote rejected",
178
+ submission_source: "Voter (Passport credential with weight data)",
179
179
  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 时阻塞投票",
180
+ "The table entry referenced by GuardIdentifier must be of a numeric type (U8-U256), cast to u32",
181
+ "Non-numeric types cause E_GUARD_IDENTIFIER_NOT_NUMBER error",
182
+ "b_submission must be true (weight is submitted at runtime by the voter)",
183
+ "Multiple voting_guards can be configured, each corresponding to a different voter group",
184
+ "When Arbitration bPaused=true, voting is blocked",
185
185
  ],
186
186
  common_patterns: [
187
- "声誉分权重:query(EntityRegistrar.records[reputation]) + GuardIdentifier(u64)",
188
- "固定权重:identifier(constant_weight) + GuardIdentifier",
189
- "多级投票:不同 voting_guard 对应不同权重等级",
190
- "资格 + 权重:logic_and(资格检查 + GuardIdentifier 提取权重)",
187
+ "Reputation score weight: query(EntityRegistrar.records[reputation]) + GuardIdentifier(u64)",
188
+ "Fixed weight: identifier(constant_weight) + GuardIdentifier",
189
+ "Multi-tier voting: different voting_guards correspond to different weight tiers",
190
+ "Eligibility + weight: logic_and (eligibility check + GuardIdentifier extracts weight)",
191
191
  ],
192
192
  mutable_after_publish: true,
193
193
  r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
194
194
  },
195
+ {
196
+ id: "gen_passport_guard",
197
+ name: "Passport credential generation validation (gen_passport)",
198
+ host_object: "Standalone",
199
+ binding_field: "none",
200
+ validation_scene: "When a user calls gen_passport, the Guard validates user eligibility and generates a Passport with credentials",
201
+ pass_result: "Passport is generated, containing credentials validated by the Guard",
202
+ fail_result: "Passport generation fails; the user did not pass validation",
203
+ submission_source: "Passport applicant (signer + credentials)",
204
+ special_constraints: [
205
+ "impack_list is always empty during the verify phase (only filled after result_for_permission)",
206
+ "Therefore quote_guard (query 1167) always fails in the gen_passport flow (IMPACK_GUARD_NOT_FOUND)",
207
+ "Only Repository queries with quote_guard==None can pass in gen_passport",
208
+ "Guard can be created standalone (not bound to a specific Host Object)",
209
+ "Guard can be depended on by other Guards via rely (requires rep=true)",
210
+ "The Passport generated by gen_passport can be used as submission data for subsequent operations",
211
+ ],
212
+ common_patterns: [
213
+ "Identity validation: context(Signer) + logic_equal (single address/whitelist)",
214
+ "Membership eligibility: query(EntityRegistrar) + logic_equal",
215
+ "Reputation threshold: query(EntityRegistrar.records[reputation]) + logic_as_u256_greater_or_equal",
216
+ "Multi-condition combination: logic_and (identity + eligibility + reputation)",
217
+ ],
218
+ mutable_after_publish: false,
219
+ r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
220
+ },
195
221
  ];
196
222
  export function findScene(host_object, binding_field) {
197
223
  return GUARD_SCENES.find((s) => s.host_object === host_object &&
@@ -207,6 +233,7 @@ export function inferSceneFromAction(action) {
207
233
  dispute: "arbitration_usage_guard",
208
234
  write_repository: "repository_write_guard",
209
235
  submit_progress: "progress_submission_guard",
236
+ gen_passport: "gen_passport_guard",
210
237
  };
211
238
  const id = map[action];
212
239
  return GUARD_SCENES.find((s) => s.id === id);
@@ -0,0 +1,76 @@
1
+ import { type GuardRiskAssessment } from "./guard-risk.js";
2
+ export type DiagnosticSource = "sdk" | "lint" | "risk";
3
+ export type DiagnosticSeverity = "error" | "warning" | "info" | "hint";
4
+ export interface GuardDiagnostic {
5
+ code: string;
6
+ message: string;
7
+ severity: DiagnosticSeverity;
8
+ source: DiagnosticSource;
9
+ location: {
10
+ path: string;
11
+ };
12
+ fix?: {
13
+ description: string;
14
+ auto_fixable: boolean;
15
+ };
16
+ }
17
+ export interface GuardJsonInput {
18
+ description?: string;
19
+ table: Array<{
20
+ identifier: number;
21
+ b_submission?: boolean;
22
+ value_type?: string;
23
+ value?: unknown;
24
+ name?: string;
25
+ object_type?: string;
26
+ is_system_address?: boolean;
27
+ }>;
28
+ root: any;
29
+ rely?: {
30
+ guards: string[];
31
+ logic_or?: boolean;
32
+ };
33
+ binding_hint?: {
34
+ host_object?: string;
35
+ binding_field?: string;
36
+ action?: string;
37
+ };
38
+ }
39
+ export interface AutoFixAction {
40
+ diagnostic_code: string;
41
+ description: string;
42
+ before?: string;
43
+ after?: string;
44
+ path: string;
45
+ }
46
+ export interface GuardLintResult {
47
+ json_summary: {
48
+ table_count: number;
49
+ root_type: string;
50
+ has_rely: boolean;
51
+ rely_count: number;
52
+ has_description: boolean;
53
+ };
54
+ diagnostics: GuardDiagnostic[];
55
+ fixed_json?: GuardJsonInput;
56
+ fix_actions: AutoFixAction[];
57
+ risk_assessment?: GuardRiskAssessment;
58
+ summary: {
59
+ errors: number;
60
+ warnings: number;
61
+ infos: number;
62
+ auto_fixes_applied: number;
63
+ ready: boolean;
64
+ next_step: string;
65
+ };
66
+ }
67
+ export declare function autoFixGuard(json: GuardJsonInput): {
68
+ fixed: GuardJsonInput;
69
+ actions: AutoFixAction[];
70
+ };
71
+ export declare function lintGuard(json: GuardJsonInput, options?: {
72
+ auto_fix?: boolean;
73
+ }): Promise<GuardLintResult>;
74
+ export declare function isGuardReady(json: GuardJsonInput): Promise<boolean>;
75
+ export declare function getGuardErrors(json: GuardJsonInput): Promise<GuardDiagnostic[]>;
76
+ export declare function formatLintResult(result: GuardLintResult): string;