@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.
- package/dist/customer/industry-risks.js +31 -31
- package/dist/customer/order-monitor.js +57 -57
- package/dist/customer/order-strategy.js +89 -89
- package/dist/customer/post-purchase.js +97 -97
- package/dist/customer/reminder-system.js +26 -26
- package/dist/customer/risk-assessment.js +46 -46
- package/dist/customer/types.d.ts +4 -4
- package/dist/customer/types.js +4 -4
- package/dist/customer/user-preferences.js +50 -50
- package/dist/experience/intent-distill.js +6 -6
- package/dist/knowledge/acquisition-flywheel.js +64 -64
- package/dist/knowledge/arbitration-trust.js +10 -10
- package/dist/knowledge/demand-matching.js +8 -8
- package/dist/knowledge/dynamic-pricing.js +18 -18
- package/dist/knowledge/flywheel-loop.js +11 -11
- package/dist/knowledge/glossary.js +22 -22
- package/dist/knowledge/guard-ledger.d.ts +1 -1
- package/dist/knowledge/guard-ledger.js +131 -104
- package/dist/knowledge/guard-lint.d.ts +76 -0
- package/dist/knowledge/guard-lint.js +590 -0
- package/dist/knowledge/guard-puzzle.d.ts +109 -14
- package/dist/knowledge/guard-puzzle.js +627 -101
- package/dist/knowledge/guard-risk.d.ts +8 -1
- package/dist/knowledge/guard-risk.js +868 -296
- package/dist/knowledge/guard-templates.d.ts +37 -0
- package/dist/knowledge/guard-templates.js +329 -0
- package/dist/knowledge/guard-translation.d.ts +14 -2
- package/dist/knowledge/guard-translation.js +825 -194
- package/dist/knowledge/index.d.ts +8 -4
- package/dist/knowledge/index.js +9 -5
- package/dist/knowledge/industry-evolution.js +29 -29
- package/dist/knowledge/industry-generalizer.js +52 -52
- package/dist/knowledge/industry-registry.js +20 -33
- package/dist/knowledge/intent-metrics.js +67 -67
- package/dist/knowledge/process-model.js +80 -80
- package/dist/knowledge/reputation-rules.js +9 -9
- package/dist/knowledge/reward-templates.js +51 -51
- package/dist/knowledge/safety-rules.js +3 -3
- package/dist/knowledge/tool-constraints.js +20 -4
- package/dist/knowledge/trust-metrics.js +26 -26
- package/dist/schema/call/base.js +16 -16
- package/dist/schema/call/bridge.d.ts +32 -32
- package/dist/schema/call/demand.d.ts +84 -84
- package/dist/schema/call/guard.d.ts +153 -0
- package/dist/schema/call/guard.js +50 -0
- package/dist/schema/call/permission.d.ts +78 -78
- package/dist/schema/call/repository.d.ts +22 -22
- package/dist/schema/call/semantic.js +228 -24
- package/dist/schema/local/wip.d.ts +39 -19
- package/dist/schema/local/wip.js +5 -5
- package/dist/schema/messenger/index.d.ts +26 -26
- package/dist/schema/messenger/index.js +2 -2
- package/dist/schema/operations.d.ts +222 -144
- package/dist/schema/query/index.d.ts +38 -38
- package/dist/schema/trust/index.d.ts +4 -4
- package/dist/schema/utils/guard-parser.js +4 -4
- package/dist/schema/utils/node-parser.js +14 -14
- package/dist/schemas/bridge_operation.output.json +14 -14
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +17 -15
- package/dist/schemas/onchain_events.output.json +14 -14
- package/dist/schemas/onchain_operations.output.json +14 -14
- package/dist/schemas/onchain_table_data.output.json +14 -14
- package/dist/schemas/wip_file.output.json +24 -1
- 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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: ["
|
|
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: "
|
|
4
|
+
name: "Service purchase validation (buy_guard)",
|
|
5
5
|
host_object: "Service",
|
|
6
6
|
binding_field: "buy_guard",
|
|
7
|
-
validation_scene: "
|
|
8
|
-
pass_result: "
|
|
9
|
-
fail_result: "
|
|
10
|
-
submission_source: "Customer
|
|
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
|
|
14
|
-
"
|
|
15
|
-
"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
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
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: "
|
|
28
|
+
name: "Allocation strategy selection validation (order_allocators[].guard)",
|
|
29
29
|
host_object: "Service",
|
|
30
30
|
binding_field: "order_allocators",
|
|
31
|
-
validation_scene: "
|
|
32
|
-
"
|
|
33
|
-
pass_result: "
|
|
34
|
-
fail_result: "
|
|
35
|
-
submission_source: "System
|
|
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
|
|
38
|
-
"Service
|
|
39
|
-
"Guard
|
|
40
|
-
"
|
|
41
|
-
"GuardIdentifier
|
|
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
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"GuardIdentifier
|
|
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: "
|
|
54
|
+
name: "Workflow node advancement validation (Forward.guard)",
|
|
55
55
|
host_object: "Machine",
|
|
56
56
|
binding_field: "Forward.guard",
|
|
57
|
-
validation_scene: "
|
|
58
|
-
pass_result: "Progress
|
|
59
|
-
fail_result: "Forward
|
|
60
|
-
submission_source: "
|
|
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
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"retained_submission
|
|
65
|
-
"
|
|
66
|
-
"
|
|
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
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
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
|
|
80
|
+
name: "Progress submission data validation (submission guard)",
|
|
81
81
|
host_object: "Progress",
|
|
82
82
|
binding_field: "submission",
|
|
83
|
-
validation_scene: "Forward
|
|
84
|
-
pass_result: "Forward
|
|
85
|
-
fail_result: "Forward
|
|
86
|
-
submission_source: "
|
|
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
|
-
"
|
|
89
|
-
"retained_submission
|
|
90
|
-
"
|
|
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
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
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: "
|
|
102
|
+
name: "Reward claim validation (Reward.guard)",
|
|
103
103
|
host_object: "Reward",
|
|
104
104
|
binding_field: "guard",
|
|
105
|
-
validation_scene: "
|
|
106
|
-
pass_result: "
|
|
107
|
-
fail_result: "
|
|
108
|
-
submission_source: "Claimant
|
|
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
|
-
"
|
|
111
|
-
"Guard
|
|
112
|
-
"
|
|
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
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
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: "
|
|
125
|
+
name: "Repository write validation (write_guard)",
|
|
126
126
|
host_object: "Repository",
|
|
127
127
|
binding_field: "write_guard",
|
|
128
|
-
validation_scene: "
|
|
129
|
-
pass_result: "
|
|
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
|
|
134
|
-
"data_from_submission
|
|
135
|
-
"
|
|
136
|
-
"
|
|
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
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"ID
|
|
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: "
|
|
148
|
+
name: "Dispute initiation validation (usage_guard)",
|
|
149
149
|
host_object: "Arbitration",
|
|
150
150
|
binding_field: "usage_guard",
|
|
151
|
-
validation_scene: "
|
|
152
|
-
pass_result: "
|
|
153
|
-
fail_result: "
|
|
154
|
-
submission_source: "Customer
|
|
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
|
|
157
|
-
"
|
|
158
|
-
"
|
|
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
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"
|
|
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: "
|
|
172
|
+
name: "Arbitration voting weight validation (voting_guard[])",
|
|
173
173
|
host_object: "Arbitration",
|
|
174
174
|
binding_field: "voting_guard",
|
|
175
|
-
validation_scene: "
|
|
176
|
-
pass_result: "
|
|
177
|
-
fail_result: "
|
|
178
|
-
submission_source: "Voter
|
|
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
|
|
181
|
-
"
|
|
182
|
-
"b_submission
|
|
183
|
-
"
|
|
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
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
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;
|