@wowok/agent-mcp 2.3.18 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.d.ts +2 -2
- package/dist/index.js +11 -1624
- 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 +145 -104
- package/dist/knowledge/guard-lint.d.ts +77 -0
- package/dist/knowledge/guard-lint.js +670 -0
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -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 +10 -1
- package/dist/knowledge/guard-risk.js +1634 -292
- package/dist/knowledge/guard-templates.d.ts +38 -0
- package/dist/knowledge/guard-templates.js +605 -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/project/graph.d.ts +1 -0
- package/dist/project/graph.js +27 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +39 -2
- package/dist/project/namespace.d.ts +11 -1
- package/dist/project/namespace.js +27 -2
- package/dist/project/query.d.ts +2 -0
- package/dist/project/query.js +56 -15
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +10 -10
- package/dist/schema/call/base.js +19 -19
- 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/machine.d.ts +38 -38
- package/dist/schema/call/permission.d.ts +78 -78
- package/dist/schema/call/repository.d.ts +22 -22
- package/dist/schema/call/semantic.js +229 -25
- package/dist/schema/call/service.d.ts +7 -7
- 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 +270 -192
- package/dist/schema/query/index.d.ts +184 -184
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/trust/index.d.ts +4 -4
- package/dist/schema/utils/guard-parser.js +4 -4
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schema/utils/node-parser.js +14 -14
- package/dist/schemas/bridge_operation.output.json +15 -15
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/messenger_operation.output.json +18 -16
- package/dist/schemas/onchain_events.output.json +15 -15
- package/dist/schemas/onchain_operations.output.json +16 -16
- package/dist/schemas/onchain_operations.schema.json +11 -20
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -10
- package/dist/schemas/onchain_operations_machine.schema.json +2 -5
- package/dist/schemas/onchain_operations_service.schema.json +2 -5
- package/dist/schemas/onchain_table_data.output.json +20 -26
- package/dist/schemas/wip_file.output.json +24 -1
- package/dist/tools/handlers/bridge.d.ts +1 -0
- package/dist/tools/handlers/bridge.js +1 -0
- package/dist/tools/handlers/config.d.ts +2 -0
- package/dist/tools/handlers/config.js +71 -0
- package/dist/tools/handlers/file-export.d.ts +3 -0
- package/dist/tools/handlers/file-export.js +90 -0
- package/dist/tools/handlers/local.d.ts +30 -0
- package/dist/tools/handlers/local.js +27 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +187 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +246 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +53 -0
- package/dist/tools/handlers/query.d.ts +5 -0
- package/dist/tools/handlers/query.js +256 -0
- package/dist/tools/handlers/schema-query.d.ts +2 -0
- package/dist/tools/handlers/schema-query.js +92 -0
- package/dist/tools/handlers/trust.d.ts +2 -0
- package/dist/tools/handlers/trust.js +194 -0
- package/dist/tools/handlers/wip.d.ts +2 -0
- package/dist/tools/handlers/wip.js +44 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +479 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +22 -0
- package/dist/tools/shared.d.ts +29 -0
- package/dist/tools/shared.js +130 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/wrap.d.ts +6 -0
- package/dist/tools/wrap.js +55 -0
- package/package.json +19 -5
|
@@ -3,7 +3,7 @@ export const CONCEPT_GLOSSARY = [
|
|
|
3
3
|
term: "Permission",
|
|
4
4
|
definition: "Organization-wide permission object. indices 0-999 builtin, 1000-65535 custom. " +
|
|
5
5
|
"Shared across all Progress instances of a Service. Use for internal staff roles.",
|
|
6
|
-
aliases: ["permission object"
|
|
6
|
+
aliases: ["permission object"],
|
|
7
7
|
category: "permission",
|
|
8
8
|
},
|
|
9
9
|
{
|
|
@@ -17,7 +17,7 @@ export const CONCEPT_GLOSSARY = [
|
|
|
17
17
|
term: "OrderHolder",
|
|
18
18
|
definition: "The order holder and their agents. Represented by namedOperator=\"\" (empty string) " +
|
|
19
19
|
"on a Forward. Lets the customer operate their own order.",
|
|
20
|
-
aliases: ["order owner", "orderholder", "
|
|
20
|
+
aliases: ["order owner", "orderholder", "order holder"],
|
|
21
21
|
category: "permission",
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -25,139 +25,139 @@ export const CONCEPT_GLOSSARY = [
|
|
|
25
25
|
definition: "A state-transition edge in a Machine. Carries weight, a permission " +
|
|
26
26
|
"(Permission index / NamedOperator / OrderHolder), and an optional Guard. " +
|
|
27
27
|
"Every Forward MUST define at least one permission.",
|
|
28
|
-
aliases: ["
|
|
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,237 @@
|
|
|
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
|
+
"Reentrancy: LOW — Each purchase creates a fresh Order; no existing Order state is modified. Default: no reentrancy risk. IF business intent is 'limit one purchase per user' (limited-edition goods, whitelist single-buy), an anti-reentrancy check is REQUIRED but no direct GUARDQUERY primitive exists for per-user purchase history — use a Repository to record prior purchases and add `repository.data has` (query 1166) + `logic_not` to root, or revoke EntityRegistrar membership after first buy",
|
|
16
17
|
],
|
|
17
18
|
common_patterns: [
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
19
|
+
"Identity check: context(Signer) + logic_equal (single address) / vec_contains_address (whitelist)",
|
|
20
|
+
"Membership validation: query EntityRegistrar(0xaab) + logic_and combination",
|
|
21
|
+
"Time limit: context(Clock) + logic_as_u256_greater_or_equal",
|
|
22
|
+
"Multi-condition: logic_and combining multiple checks",
|
|
22
23
|
],
|
|
23
24
|
mutable_after_publish: true,
|
|
24
25
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R9"],
|
|
25
26
|
},
|
|
26
27
|
{
|
|
27
28
|
id: "service_order_allocators_guard",
|
|
28
|
-
name: "
|
|
29
|
+
name: "Allocation strategy selection validation (order_allocators[].guard)",
|
|
29
30
|
host_object: "Service",
|
|
30
31
|
binding_field: "order_allocators",
|
|
31
|
-
validation_scene: "
|
|
32
|
-
"
|
|
33
|
-
pass_result: "
|
|
34
|
-
fail_result: "
|
|
35
|
-
submission_source: "System
|
|
32
|
+
validation_scene: "When an order is completed or allocation conditions are met, the system evaluates each Allocator's Guard in order_allocators order. " +
|
|
33
|
+
"The first Allocator whose Guard passes executes the allocation",
|
|
34
|
+
pass_result: "Execute that Allocator's allocation strategy (distribute funds by ratio/condition)",
|
|
35
|
+
fail_result: "Skip this Allocator and try the next (first-match-wins). If all Allocators fail, funds are not distributed",
|
|
36
|
+
submission_source: "System auto-derives from Progress state (no explicit customer submission needed)",
|
|
36
37
|
special_constraints: [
|
|
37
|
-
"order_allocators
|
|
38
|
-
"Service
|
|
39
|
-
"Guard
|
|
40
|
-
"
|
|
41
|
-
"GuardIdentifier
|
|
38
|
+
"order_allocators is order-sensitive: the first Allocator whose Guard passes executes allocation",
|
|
39
|
+
"order_allocators cannot be modified after Service is published (immutable)",
|
|
40
|
+
"Guard usually queries Order/Progress state to determine allocation conditions",
|
|
41
|
+
"Common queries: order.amount, progress.current_node, order.completed, etc.",
|
|
42
|
+
"GuardIdentifier can be used for dynamic amounts (extract u64 value from table as allocation ratio)",
|
|
43
|
+
"Guard+sharing coupling: Guard determines IF allocation happens; sharing.who determines WHERE funds go. If sharing.who=Signer, the caller receives funds — the Guard MUST bind Signer (context(Signer)==authorized) to prevent theft. PREFERRED: use sharing.who=Entity (Treasury or fixed address) so funds always go to the legitimate recipient regardless of caller.",
|
|
44
|
+
"allocators require unique guard addresses: no two allocators may reference the same Guard object (create separate Guard objects with identical root/table but different descriptions if needed).",
|
|
45
|
+
"First-match-wins: only the first allocator whose Guard passes executes; subsequent allocators are skipped. Multiple allocators represent alternative strategies, not a simultaneous split.",
|
|
46
|
+
"If sharing.who=Entity references a Treasury object, verify the Treasury's permission is consistent with the Service's permission (different permissions = different permission organizations = minor risk).",
|
|
47
|
+
"Reentrancy: LOW — Protocol-level protection: order::on_allocation (order.move L116-119) asserts `allocation` field is None (E_ALLOCATION_ALREADY_SPECIFIED), enforcing ONE Allocation object per Order, ever. After alloc() executes, typical Rate-mode allocators (sum=10000, validated at allocation.move L162-163) and any Surplus-mode allocator drain balance to 0 via balance::withdraw_all (L254), making a second alloc() fail at `assert!(balance >= threshold)` (L193). EDGE CASE: Amount-mode-only allocators (no Surplus, total < full balance) leave remainder; a second alloc() could extract more — mitigated by preferring Rate/Surplus modes. External deposit via receive() (L291) is possible but irrational (attacker funds the Allocation they attack). Optional anti-reentrancy primitive: `order.allocation some` (query 1568) + logic_not",
|
|
42
48
|
],
|
|
43
49
|
common_patterns: [
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"GuardIdentifier
|
|
50
|
+
"Node state check: query(Progress.current_node) + logic_equal('Completed')",
|
|
51
|
+
"Amount threshold: query(Order.amount) + logic_as_u256_greater_or_equal(threshold)",
|
|
52
|
+
"Multi-condition combination: logic_and (node state + amount + time)",
|
|
53
|
+
"GuardIdentifier dynamic ratio: table[u64] extracts allocation ratio",
|
|
54
|
+
"Treasury+personal 2-allocator pattern: 2 Guard objects (identical root/table, different descriptions) + 2 allocators (sharing.who=Entity Treasury / Entity personal) — 2 alternative merchant collection approaches; first-match-wins means only the first executes.",
|
|
48
55
|
],
|
|
49
56
|
mutable_after_publish: false,
|
|
50
57
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
|
|
51
58
|
},
|
|
52
59
|
{
|
|
53
60
|
id: "machine_forward_guard",
|
|
54
|
-
name: "
|
|
61
|
+
name: "Workflow node advancement validation (Forward.guard)",
|
|
55
62
|
host_object: "Machine",
|
|
56
63
|
binding_field: "Forward.guard",
|
|
57
|
-
validation_scene: "
|
|
58
|
-
pass_result: "Progress
|
|
59
|
-
fail_result: "Forward
|
|
60
|
-
submission_source: "
|
|
64
|
+
validation_scene: "When a customer or provider executes a Forward operation to advance the workflow, the Guard validates whether advancement to the next node is allowed",
|
|
65
|
+
pass_result: "Progress advances to next_node; session accumulates weight",
|
|
66
|
+
fail_result: "Forward is blocked; Progress stays at the current node. Optional retained_submission retains audit data",
|
|
67
|
+
submission_source: "The party executing Forward (Customer or Provider, depending on Forward configuration)",
|
|
61
68
|
special_constraints: [
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"retained_submission
|
|
65
|
-
"
|
|
66
|
-
"
|
|
69
|
+
"Forward.guard cannot be modified after Machine is published (a new Machine must be created)",
|
|
70
|
+
"Optional retained_submission: stores submission data in Progress for later audit",
|
|
71
|
+
"retained_submission indices must correspond to the Guard table",
|
|
72
|
+
"Common queries: progress.current_node, progress.session_forward, order.service, etc.",
|
|
73
|
+
"Time lock: context(Clock) + calc_number_add(progress.entry_time, duration) tested with 1000ms",
|
|
74
|
+
"Reentrancy: ALLOWED — By design, Forward moves progress.current_node to next_node (progress.move L443), naturally invalidating the Guard at the old node. Re-submission at the SAME node (before forward completes) is intentional: users may fix prior submission data or accumulate session weight toward threshold. No anti-reentrancy primitive needed. Optional observability queries: `progress.session_forward` (1262), `progress.history` (1273), `query_progress_history_find` (1274)",
|
|
67
75
|
],
|
|
68
76
|
common_patterns: [
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
77
|
+
"Identity check: context(Signer) + logic_equal (only specific parties can advance)",
|
|
78
|
+
"Time lock: context(Clock) + calc_number_add + logic_as_u256_greater_or_equal",
|
|
79
|
+
"Prior Forward completion: query_progress_history_find + logic_equal(accomplished=true)",
|
|
80
|
+
"Submission data validation: identifier(submission) + logic_equal(expected_value)",
|
|
81
|
+
"Cross-object query: convert_witness=TypeOrderProgress(100) queries Progress from Order",
|
|
74
82
|
],
|
|
75
83
|
mutable_after_publish: false,
|
|
76
84
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
|
|
77
85
|
},
|
|
78
86
|
{
|
|
79
87
|
id: "progress_submission_guard",
|
|
80
|
-
name: "Progress
|
|
88
|
+
name: "Progress submission data validation (submission guard)",
|
|
81
89
|
host_object: "Progress",
|
|
82
90
|
binding_field: "submission",
|
|
83
|
-
validation_scene: "Forward
|
|
84
|
-
pass_result: "Forward
|
|
85
|
-
fail_result: "Forward
|
|
86
|
-
submission_source: "
|
|
91
|
+
validation_scene: "Whether the data (e.g. signature, credential, confirmation) submitted during Forward execution satisfies the Guard condition",
|
|
92
|
+
pass_result: "Forward completes; node advances after session accumulates weight to threshold",
|
|
93
|
+
fail_result: "Forward does not complete; waits for resubmission or condition satisfaction",
|
|
94
|
+
submission_source: "The party submitting data (Customer or Provider)",
|
|
87
95
|
special_constraints: [
|
|
88
|
-
"
|
|
89
|
-
"retained_submission
|
|
90
|
-
"
|
|
96
|
+
"Works in concert with Forward.guard: Forward.guard validates eligibility, submission guard validates data",
|
|
97
|
+
"retained_submission stores submission data in Progress session for audit",
|
|
98
|
+
"Common queries: progress.session_forward, progress.session_weight, etc.",
|
|
99
|
+
"Reentrancy: ALLOWED — Multiple submissions accumulate session weight toward threshold by design (progress.move session_accomplish_imp). Re-submission is the intended mechanism for reaching threshold; no anti-reentrancy primitive needed",
|
|
91
100
|
],
|
|
92
101
|
common_patterns: [
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
102
|
+
"Signature validation: identifier(signature_submission) + logic_equal(expected)",
|
|
103
|
+
"Credential validation: query(Repository.data) + logic_equal(submission_proof)",
|
|
104
|
+
"Confirmation validation: identifier(confirm_submission) + logic_equal(true)",
|
|
96
105
|
],
|
|
97
106
|
mutable_after_publish: false,
|
|
98
107
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R8"],
|
|
99
108
|
},
|
|
100
109
|
{
|
|
101
110
|
id: "reward_guard",
|
|
102
|
-
name: "
|
|
111
|
+
name: "Reward claim validation (Reward.guard)",
|
|
103
112
|
host_object: "Reward",
|
|
104
113
|
binding_field: "guard",
|
|
105
|
-
validation_scene: "
|
|
106
|
-
pass_result: "
|
|
107
|
-
fail_result: "
|
|
108
|
-
submission_source: "Claimant
|
|
114
|
+
validation_scene: "When a user claims from a reward pool, the Guard validates eligibility to claim",
|
|
115
|
+
pass_result: "Reward is distributed to the Claimant and recorded in reward_record",
|
|
116
|
+
fail_result: "Claim rejected; reward is not distributed",
|
|
117
|
+
submission_source: "Claimant (address, credentials, Passport)",
|
|
109
118
|
special_constraints: [
|
|
110
|
-
"
|
|
111
|
-
"Guard
|
|
112
|
-
"
|
|
119
|
+
"Common query_reward_record_count prevents duplicate claims (one-time claim)",
|
|
120
|
+
"Guard usually queries history records + time conditions + identity validation",
|
|
121
|
+
"If the Reward references a Service, use the circular reference pattern",
|
|
122
|
+
"Reentrancy: CRITICAL — Guard pass distributes reward funds to the Claimant AND creates a reward_record, but the Guard conditions (identity, time, node state) do NOT naturally invalidate after a claim. Without an explicit anti-reentrancy primitive, the same Claimant can repeatedly pass the Guard and DRAIN THE ENTIRE POOL. This is the most severe reentrancy scene. REQUIRED anti-reentrancy primitive (any one): `reward.record has` (query 1613, Bool) + `logic_not`; OR `reward.record count` (query 1612, U64) + `logic_equal(0)`; OR `reward.record.find_first` (query 1626, U64) + `logic_not`/`logic_equal(0)`. Reference template: MyShop_Advanced Guard 7 condition 4 — `logic_not(query_reward_record_exists(where.storeFromId=order_id))`",
|
|
113
123
|
],
|
|
114
124
|
common_patterns: [
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
125
|
+
"One-time claim: query_reward_record_count(recipient) + logic_equal(0)",
|
|
126
|
+
"Time window: context(Clock) + logic_as_u256_greater_or_equal(start_time)",
|
|
127
|
+
"Identity validation: context(Signer) + vec_contains_address(allowlist)",
|
|
128
|
+
"Multi-condition: logic_and (identity + time + not claimed before)",
|
|
119
129
|
],
|
|
120
130
|
mutable_after_publish: true,
|
|
121
131
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
|
|
122
132
|
},
|
|
123
133
|
{
|
|
124
134
|
id: "repository_write_guard",
|
|
125
|
-
name: "
|
|
135
|
+
name: "Repository write validation (write_guard)",
|
|
126
136
|
host_object: "Repository",
|
|
127
137
|
binding_field: "write_guard",
|
|
128
|
-
validation_scene: "
|
|
129
|
-
pass_result: "
|
|
130
|
-
fail_result: "
|
|
138
|
+
validation_scene: "When writing to on-chain storage, the Guard validates write eligibility and optionally extracts data",
|
|
139
|
+
pass_result: "Write succeeds; optional id_from_submission extracts the entity ID, data_from_submission extracts the data value",
|
|
140
|
+
fail_result: "Write rejected",
|
|
131
141
|
submission_source: "Writer/Reader",
|
|
132
142
|
special_constraints: [
|
|
133
|
-
"id_from_submission
|
|
134
|
-
"data_from_submission
|
|
135
|
-
"
|
|
136
|
-
"
|
|
143
|
+
"The table entry referenced by id_from_submission must be of Address type",
|
|
144
|
+
"The table entry referenced by data_from_submission must match the Repository's value_type",
|
|
145
|
+
"Type mismatch leads to write failure or data corruption",
|
|
146
|
+
"Commonly used for oracle data writes, third-party credential attestation, etc.",
|
|
147
|
+
"Reentrancy: LOW — Default writes are idempotent (same ID overwrites, different ID appends); no fund flow. IF business intent is 'one write per ID' (e.g. voting, immutable credential, single-attestation), an anti-reentrancy check is needed. Optional primitive: `repository.data has` (query 1166, Bool) + `logic_not`",
|
|
137
148
|
],
|
|
138
149
|
common_patterns: [
|
|
139
|
-
"
|
|
140
|
-
"
|
|
141
|
-
"ID
|
|
150
|
+
"Authorized writer: context(Signer) + vec_contains_address(authorized_writers)",
|
|
151
|
+
"Data format validation: identifier(data_submission) + logic_string_contains(expected_prefix)",
|
|
152
|
+
"ID extraction: id_from_submission + data_from_submission combination",
|
|
142
153
|
],
|
|
143
154
|
mutable_after_publish: true,
|
|
144
155
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
|
|
145
156
|
},
|
|
146
157
|
{
|
|
147
158
|
id: "arbitration_usage_guard",
|
|
148
|
-
name: "
|
|
159
|
+
name: "Dispute initiation validation (usage_guard)",
|
|
149
160
|
host_object: "Arbitration",
|
|
150
161
|
binding_field: "usage_guard",
|
|
151
|
-
validation_scene: "
|
|
152
|
-
pass_result: "
|
|
153
|
-
fail_result: "
|
|
154
|
-
submission_source: "Customer
|
|
162
|
+
validation_scene: "When a customer initiates a dispute against an order, the Guard validates whether the customer is eligible to initiate the dispute",
|
|
163
|
+
pass_result: "Create an Arb case and enter the arbitration flow",
|
|
164
|
+
fail_result: "Dispute rejected; Arb is not created",
|
|
165
|
+
submission_source: "Customer (Passport credential)",
|
|
155
166
|
special_constraints: [
|
|
156
|
-
"Arbitration bPaused=true
|
|
157
|
-
"
|
|
158
|
-
"
|
|
159
|
-
"Guard
|
|
167
|
+
"When Arbitration bPaused=true, it blocks first (before the Guard check)",
|
|
168
|
+
"The customer must first generate a Passport (gen_passport passes usage_guard)",
|
|
169
|
+
"Common queries: order.completed, order.service, entity.has, etc.",
|
|
170
|
+
"Guard validates customer identity + order status + dispute eligibility",
|
|
171
|
+
"Reentrancy: HIGH — Guard pass creates a new Arb case. Without anti-reentrancy, a customer can create multiple Arb cases for the SAME Order (up to MAX_DISPUTE_COUNT=10 per order.move L96), harassing the counterparty and inflating arbitration system load. Not direct fund loss, but severe system abuse. Note: order::dispute (order.move L93-99) deduplicates by Arb address but does NOT prevent multiple distinct Arbs for the same Order. REQUIRED anti-reentrancy primitive (any one): `order.dispute has` (query 1565, Bool, per-Arb check) + `logic_not`; OR `order.dispute count` (query 1564, U64) + `logic_equal(0)` (strict: block any prior dispute) or `logic_as_u256_less_or_equal(N)` (lenient: allow up to N disputes)",
|
|
160
172
|
],
|
|
161
173
|
common_patterns: [
|
|
162
|
-
"
|
|
163
|
-
"
|
|
164
|
-
"
|
|
165
|
-
"
|
|
174
|
+
"Order status validation: query(Order.status) + logic_equal('completed')",
|
|
175
|
+
"Membership validation: query(EntityRegistrar) + logic_and",
|
|
176
|
+
"Time window: query(Order.time) + calc_number_add + context(Clock)",
|
|
177
|
+
"Passport credential: identifier(passport_submission) + context(Signer)",
|
|
166
178
|
],
|
|
167
179
|
mutable_after_publish: true,
|
|
168
180
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R7", "R8", "R9"],
|
|
169
181
|
},
|
|
170
182
|
{
|
|
171
183
|
id: "arbitration_voting_guard",
|
|
172
|
-
name: "
|
|
184
|
+
name: "Arbitration voting weight validation (voting_guard[])",
|
|
173
185
|
host_object: "Arbitration",
|
|
174
186
|
binding_field: "voting_guard",
|
|
175
|
-
validation_scene: "
|
|
176
|
-
pass_result: "
|
|
177
|
-
fail_result: "
|
|
178
|
-
submission_source: "Voter
|
|
187
|
+
validation_scene: "When an arbitrator votes, the Guard validates voting eligibility and extracts the voting weight (u32) from GuardIdentifier",
|
|
188
|
+
pass_result: "Vote is counted; weight is the value extracted by GuardIdentifier",
|
|
189
|
+
fail_result: "Vote rejected",
|
|
190
|
+
submission_source: "Voter (Passport credential with weight data)",
|
|
179
191
|
special_constraints: [
|
|
180
|
-
"GuardIdentifier
|
|
181
|
-
"
|
|
182
|
-
"b_submission
|
|
183
|
-
"
|
|
184
|
-
"Arbitration bPaused=true
|
|
192
|
+
"The table entry referenced by GuardIdentifier must be of a numeric type (U8-U256), cast to u32",
|
|
193
|
+
"Non-numeric types cause E_GUARD_IDENTIFIER_NOT_NUMBER error",
|
|
194
|
+
"b_submission must be true (weight is submitted at runtime by the voter)",
|
|
195
|
+
"Multiple voting_guards can be configured, each corresponding to a different voter group",
|
|
196
|
+
"When Arbitration bPaused=true, voting is blocked",
|
|
197
|
+
"Reentrancy: CRITICAL — Guard pass counts the vote with the extracted weight. Without anti-reentrancy, the same voter can vote MULTIPLE times, multiplying their weight and skewing the arbitration result (which directly determines fund ownership via compensation). The voter's eligibility (identity, reputation) does NOT naturally invalidate after voting. REQUIRED anti-reentrancy primitive (any one): `arb.voted has` (query 1404, Bool, per-voter) + `logic_not`; OR `arb.voted.agree has` (query 1406, Bool, per-voter-per-proposition) + `logic_not`; OR `arb.voted.agree count` (query 1405, U64, per-voter) + `logic_equal(0)`. Note: `arb.voted_count` (1403) is total voter count (NOT per-voter) and does NOT serve as an anti-reentrancy primitive for individual voters",
|
|
185
198
|
],
|
|
186
199
|
common_patterns: [
|
|
187
|
-
"
|
|
188
|
-
"
|
|
189
|
-
"
|
|
190
|
-
"
|
|
200
|
+
"Reputation score weight: query(EntityRegistrar.records[reputation]) + GuardIdentifier(u64)",
|
|
201
|
+
"Fixed weight: identifier(constant_weight) + GuardIdentifier",
|
|
202
|
+
"Multi-tier voting: different voting_guards correspond to different weight tiers",
|
|
203
|
+
"Eligibility + weight: logic_and (eligibility check + GuardIdentifier extracts weight)",
|
|
191
204
|
],
|
|
192
205
|
mutable_after_publish: true,
|
|
193
206
|
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7", "R8", "R9"],
|
|
194
207
|
},
|
|
208
|
+
{
|
|
209
|
+
id: "gen_passport_guard",
|
|
210
|
+
name: "Passport credential generation validation (gen_passport)",
|
|
211
|
+
host_object: "Standalone",
|
|
212
|
+
binding_field: "none",
|
|
213
|
+
validation_scene: "When a user calls gen_passport, the Guard validates user eligibility and generates a Passport with credentials",
|
|
214
|
+
pass_result: "Passport is generated, containing credentials validated by the Guard",
|
|
215
|
+
fail_result: "Passport generation fails; the user did not pass validation",
|
|
216
|
+
submission_source: "Passport applicant (signer + credentials)",
|
|
217
|
+
special_constraints: [
|
|
218
|
+
"impack_list is always empty during the verify phase (only filled after result_for_permission)",
|
|
219
|
+
"Therefore quote_guard (query 1167) always fails in the gen_passport flow (IMPACK_GUARD_NOT_FOUND)",
|
|
220
|
+
"Only Repository queries with quote_guard==None can pass in gen_passport",
|
|
221
|
+
"Guard can be created standalone (not bound to a specific Host Object)",
|
|
222
|
+
"Guard can be depended on by other Guards via rely (requires rep=true)",
|
|
223
|
+
"The Passport generated by gen_passport can be used as submission data for subsequent operations",
|
|
224
|
+
"Reentrancy: LOW — Each gen_passport call generates an independent Passport (one Passport per operation). Multiple Passports for the same user are usually valid (each serves a different subsequent operation). IF business intent is 'one active Passport per user', an anti-reentrancy check is needed but no direct GUARDQUERY primitive exists — use off-chain tracking or a Repository to record issued Passport IDs",
|
|
225
|
+
],
|
|
226
|
+
common_patterns: [
|
|
227
|
+
"Identity validation: context(Signer) + logic_equal (single address/whitelist)",
|
|
228
|
+
"Membership eligibility: query(EntityRegistrar) + logic_equal",
|
|
229
|
+
"Reputation threshold: query(EntityRegistrar.records[reputation]) + logic_as_u256_greater_or_equal",
|
|
230
|
+
"Multi-condition combination: logic_and (identity + eligibility + reputation)",
|
|
231
|
+
],
|
|
232
|
+
mutable_after_publish: false,
|
|
233
|
+
r_rounds_focus: ["R1", "R2", "R3", "R5", "R6", "R7"],
|
|
234
|
+
},
|
|
195
235
|
];
|
|
196
236
|
export function findScene(host_object, binding_field) {
|
|
197
237
|
return GUARD_SCENES.find((s) => s.host_object === host_object &&
|
|
@@ -207,6 +247,7 @@ export function inferSceneFromAction(action) {
|
|
|
207
247
|
dispute: "arbitration_usage_guard",
|
|
208
248
|
write_repository: "repository_write_guard",
|
|
209
249
|
submit_progress: "progress_submission_guard",
|
|
250
|
+
gen_passport: "gen_passport_guard",
|
|
210
251
|
};
|
|
211
252
|
const id = map[action];
|
|
212
253
|
return GUARD_SCENES.find((s) => s.id === id);
|