@wowok/agent-mcp 2.4.1 → 2.5.0
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/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -1621
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-ledger.js +14 -0
- package/dist/knowledge/guard-lint.d.ts +1 -0
- package/dist/knowledge/guard-lint.js +83 -3
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +3 -1
- package/dist/knowledge/guard-risk.js +832 -64
- package/dist/knowledge/guard-templates.d.ts +1 -0
- package/dist/knowledge/guard-templates.js +278 -2
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- 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/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +44 -44
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +6 -6
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +96 -96
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +238 -238
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1102 -1118
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +818 -818
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/bridge_operation.output.json +1 -1
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +5 -4
- package/dist/schemas/onchain_operations.schema.json +1813 -333
- package/dist/schemas/onchain_operations_allocation.schema.json +9 -11
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +4 -6
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +4 -6
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.output.json +6 -12
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -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 +74 -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 +3 -0
- package/dist/tools/handlers/local.js +38 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +188 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +248 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +293 -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 +93 -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 +526 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +23 -0
- package/dist/tools/shared.d.ts +20 -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 +14 -0
- package/dist/tools/wrap.js +267 -0
- package/package.json +20 -6
|
@@ -0,0 +1,545 @@
|
|
|
1
|
+
import { MAX_GUARD_COUNT_REWARD, MAX_RECORD_COUNT_REWARD, } from "./onchain-constants.js";
|
|
2
|
+
import { resolveGuardConstructor, } from "./reward-ledger.js";
|
|
3
|
+
const R_R_1_01 = {
|
|
4
|
+
id: "R-R-1-01",
|
|
5
|
+
category: "structural",
|
|
6
|
+
trigger: "guard_add would exceed MAX_GUARD_COUNT_REWARD (200)",
|
|
7
|
+
check: (ctx) => {
|
|
8
|
+
if (!ctx.guard_add || ctx.guard_add.length === 0)
|
|
9
|
+
return null;
|
|
10
|
+
const current = ctx.current_guard_count ?? 0;
|
|
11
|
+
const wouldAdd = ctx.guard_add.length;
|
|
12
|
+
if (current + wouldAdd > MAX_GUARD_COUNT_REWARD) {
|
|
13
|
+
return {
|
|
14
|
+
id: "R-R-1-01",
|
|
15
|
+
level: "HIGH",
|
|
16
|
+
category: "structural",
|
|
17
|
+
title: "guard_add would exceed MAX_GUARD_COUNT_REWARD",
|
|
18
|
+
description: `Reward has ${current} guards, adding ${wouldAdd} would total ${current + wouldAdd}, ` +
|
|
19
|
+
`exceeds MAX_GUARD_COUNT_REWARD ${MAX_GUARD_COUNT_REWARD}. Move aborts with E_GUARD_COUNT_EXCEEDED (3).`,
|
|
20
|
+
affected_stakeholders: ["owner", "service_provider"],
|
|
21
|
+
scenario: "Adding too many guards to a single Reward (e.g. milestone reward with > 200 recipients)",
|
|
22
|
+
mitigation: "Split into multiple Reward objects, or use GuardIdentifier recipient to handle multiple recipients with a single guard.",
|
|
23
|
+
evidence: `current=${current}, add=${wouldAdd}`,
|
|
24
|
+
related_move_error: "E_GUARD_COUNT_EXCEEDED (3)",
|
|
25
|
+
auto_fixable: false,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
const R_R_1_02 = {
|
|
32
|
+
id: "R-R-1-02",
|
|
33
|
+
category: "structural",
|
|
34
|
+
trigger: "claim would push recipient record count to MAX_RECORD_COUNT_REWARD (5200)",
|
|
35
|
+
check: (ctx) => {
|
|
36
|
+
if (!ctx.claim)
|
|
37
|
+
return null;
|
|
38
|
+
const current = ctx.current_record_count_for_recipient ?? 0;
|
|
39
|
+
if (current >= MAX_RECORD_COUNT_REWARD) {
|
|
40
|
+
return {
|
|
41
|
+
id: "R-R-1-02",
|
|
42
|
+
level: "HIGH",
|
|
43
|
+
category: "structural",
|
|
44
|
+
title: "claim blocked — recipient record count at limit",
|
|
45
|
+
description: `Recipient already has ${current} records, at MAX_RECORD_COUNT_REWARD ${MAX_RECORD_COUNT_REWARD}. ` +
|
|
46
|
+
`Next claim will abort with E_RECORD_COUNT_EXCEEDED (8). The recipient can no longer claim from this Reward.`,
|
|
47
|
+
affected_stakeholders: ["claimer"],
|
|
48
|
+
scenario: "High-frequency claimer hits the 5200-record ceiling (e.g. cashback on every micro-order)",
|
|
49
|
+
mitigation: "Owner can create a new Reward for the same recipient, OR redesign the Guard to batch claims (larger amount per claim).",
|
|
50
|
+
evidence: `recipient_records=${current}`,
|
|
51
|
+
related_move_error: "E_RECORD_COUNT_EXCEEDED (8)",
|
|
52
|
+
auto_fixable: false,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
const R_R_1_03 = {
|
|
59
|
+
id: "R-R-1-03",
|
|
60
|
+
category: "structural",
|
|
61
|
+
trigger: "guard_add batch size > MAX_GUARD_COUNT_REWARD (200) — schema-level overflow",
|
|
62
|
+
check: (ctx) => {
|
|
63
|
+
if (!ctx.guard_add)
|
|
64
|
+
return null;
|
|
65
|
+
if (ctx.guard_add.length > MAX_GUARD_COUNT_REWARD) {
|
|
66
|
+
return {
|
|
67
|
+
id: "R-R-1-03",
|
|
68
|
+
level: "CRITICAL",
|
|
69
|
+
category: "structural",
|
|
70
|
+
title: "guard_add batch exceeds absolute limit",
|
|
71
|
+
description: `Single guard_add call tries to add ${ctx.guard_add.length} guards in one transaction, ` +
|
|
72
|
+
`exceeds MAX_GUARD_COUNT_REWARD ${MAX_GUARD_COUNT_REWARD}. SDK rejects this in operate().`,
|
|
73
|
+
affected_stakeholders: ["owner"],
|
|
74
|
+
scenario: "Bulk guard addition without splitting transactions",
|
|
75
|
+
mitigation: `Split into multiple transactions, each ≤ ${MAX_GUARD_COUNT_REWARD} new guards.`,
|
|
76
|
+
evidence: `batch_size=${ctx.guard_add.length}`,
|
|
77
|
+
auto_fixable: true,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
const R_R_2_01 = {
|
|
84
|
+
id: "R-R-2-01",
|
|
85
|
+
category: "semantic",
|
|
86
|
+
trigger: "guard_add with GuardIdentifier recipient where identifier type is not address",
|
|
87
|
+
check: (ctx) => {
|
|
88
|
+
if (!ctx.guard_add)
|
|
89
|
+
return null;
|
|
90
|
+
for (let i = 0; i < ctx.guard_add.length; i++) {
|
|
91
|
+
const g = ctx.guard_add[i];
|
|
92
|
+
if ("GuardIdentifier" in g.recipient) {
|
|
93
|
+
const id = g.recipient.GuardIdentifier;
|
|
94
|
+
if (ctx.passport_identifier_is_address && ctx.passport_identifier_is_address[id] === false) {
|
|
95
|
+
return {
|
|
96
|
+
id: "R-R-2-01",
|
|
97
|
+
level: "HIGH",
|
|
98
|
+
category: "semantic",
|
|
99
|
+
title: `guard_add[${i}]: recipient GuardIdentifier ${id} is not address-typed`,
|
|
100
|
+
description: `RewardGuard constructor calls is_identifier_address(guard, ${id}). If the identifier type is not address, ` +
|
|
101
|
+
`Move aborts with E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4).`,
|
|
102
|
+
affected_stakeholders: ["owner"],
|
|
103
|
+
scenario: "Misconfigured Guard — recipient identifier is u64/bool instead of address",
|
|
104
|
+
mitigation: "Use a Guard with an address-typed identifier for recipient, OR switch to Entity/Signer recipient.",
|
|
105
|
+
evidence: `guard_add[${i}].recipient.GuardIdentifier=${id}, is_address=false`,
|
|
106
|
+
related_move_error: "E_RECIPIENT_IDENTIFIER_NOT_ADDRESS (4)",
|
|
107
|
+
auto_fixable: false,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const R_R_2_02 = {
|
|
116
|
+
id: "R-R-2-02",
|
|
117
|
+
category: "semantic",
|
|
118
|
+
trigger: "guard_add with GuardU64Identifier amount where identifier type is not u64",
|
|
119
|
+
check: (ctx) => {
|
|
120
|
+
if (!ctx.guard_add)
|
|
121
|
+
return null;
|
|
122
|
+
for (let i = 0; i < ctx.guard_add.length; i++) {
|
|
123
|
+
const g = ctx.guard_add[i];
|
|
124
|
+
const amountTypeStr = String(g.amount.type).toUpperCase();
|
|
125
|
+
if (amountTypeStr === "GUARDU64IDENTIFIER" || amountTypeStr === "GUARD_U64_IDENTIFIER") {
|
|
126
|
+
if (typeof g.amount.value !== "number")
|
|
127
|
+
continue;
|
|
128
|
+
const id = g.amount.value;
|
|
129
|
+
if (ctx.passport_submission_value_types && ctx.passport_submission_value_types[id] !== "u64") {
|
|
130
|
+
return {
|
|
131
|
+
id: "R-R-2-02",
|
|
132
|
+
level: "HIGH",
|
|
133
|
+
category: "semantic",
|
|
134
|
+
title: `guard_add[${i}]: amount GuardU64Identifier ${id} is not u64-typed`,
|
|
135
|
+
description: `RewardGuard constructor calls get_submission_value_type(guard, ${id}); if None or ≠ TYPE_U64, ` +
|
|
136
|
+
`Move aborts with E_AMOUNT_NOT_U64 (5).`,
|
|
137
|
+
affected_stakeholders: ["owner"],
|
|
138
|
+
scenario: "Misconfigured Guard — amount identifier is not u64-typed",
|
|
139
|
+
mitigation: "Use a Guard with a u64-typed identifier for amount, OR switch to Fixed amount.",
|
|
140
|
+
evidence: `guard_add[${i}].amount.value=${id}, value_type=${ctx.passport_submission_value_types[id] ?? "unknown"}`,
|
|
141
|
+
related_move_error: "E_AMOUNT_NOT_U64 (5)",
|
|
142
|
+
auto_fixable: false,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const R_R_2_03 = {
|
|
151
|
+
id: "R-R-2-03",
|
|
152
|
+
category: "semantic",
|
|
153
|
+
trigger: "guard_add with store_from_id set but identifier is not number/address compatible",
|
|
154
|
+
check: (ctx) => {
|
|
155
|
+
if (!ctx.guard_add)
|
|
156
|
+
return null;
|
|
157
|
+
for (let i = 0; i < ctx.guard_add.length; i++) {
|
|
158
|
+
const g = ctx.guard_add[i];
|
|
159
|
+
if (g.store_from_id == null)
|
|
160
|
+
continue;
|
|
161
|
+
if (ctx.guard_store_from_id_compatible && ctx.guard_store_from_id_compatible[g.guard] === false) {
|
|
162
|
+
return {
|
|
163
|
+
id: "R-R-2-03",
|
|
164
|
+
level: "MEDIUM",
|
|
165
|
+
category: "semantic",
|
|
166
|
+
title: `guard_add[${i}]: store_from_id incompatible with guard`,
|
|
167
|
+
description: `RewardGuard constructor with store_from_id=Some calls is_identifier_address_compatible(guard, store_from_id). ` +
|
|
168
|
+
`If the identifier type is not number or address, Move aborts with E_STORE_FROM_ID_NOT_COMPATIBLE (12).`,
|
|
169
|
+
affected_stakeholders: ["owner"],
|
|
170
|
+
scenario: "Misconfigured Guard — store_from_id points to a non-address/non-number identifier",
|
|
171
|
+
mitigation: "Use a compatible identifier, OR drop store_from_id (set to null) if cross-reference is not needed.",
|
|
172
|
+
evidence: `guard=${g.guard}, store_from_id=${g.store_from_id}`,
|
|
173
|
+
related_move_error: "E_STORE_FROM_ID_NOT_COMPATIBLE (12)",
|
|
174
|
+
auto_fixable: true,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return null;
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
const R_R_2_04 = {
|
|
182
|
+
id: "R-R-2-04",
|
|
183
|
+
category: "semantic",
|
|
184
|
+
trigger: "guard_add with invalid Recipient × Amount pairing (no matching constructor)",
|
|
185
|
+
check: (ctx) => {
|
|
186
|
+
if (!ctx.guard_add)
|
|
187
|
+
return null;
|
|
188
|
+
const recipientTypeMap = {
|
|
189
|
+
GuardIdentifier: "GuardIdentifier",
|
|
190
|
+
Entity: "Entity",
|
|
191
|
+
Signer: "Signer",
|
|
192
|
+
};
|
|
193
|
+
for (let i = 0; i < ctx.guard_add.length; i++) {
|
|
194
|
+
const g = ctx.guard_add[i];
|
|
195
|
+
const recipientKey = Object.keys(g.recipient)[0];
|
|
196
|
+
const recipientType = recipientTypeMap[recipientKey];
|
|
197
|
+
const amountTypeStr = String(g.amount.type).toUpperCase();
|
|
198
|
+
const amountType = amountTypeStr === "FIXED" ? "Fixed" : "GuardU64Identifier";
|
|
199
|
+
const constructor = resolveGuardConstructor(recipientType, amountType);
|
|
200
|
+
if (!constructor) {
|
|
201
|
+
return {
|
|
202
|
+
id: "R-R-2-04",
|
|
203
|
+
level: "HIGH",
|
|
204
|
+
category: "semantic",
|
|
205
|
+
title: `guard_add[${i}]: invalid Recipient × Amount pairing`,
|
|
206
|
+
description: `recipient=${recipientType}, amount=${amountType} — no matching Move constructor. ` +
|
|
207
|
+
`SDK reward_guard() will W_ERROR with "Invalid recipient or amount type combination".`,
|
|
208
|
+
affected_stakeholders: ["owner"],
|
|
209
|
+
scenario: "Schema validation bypassed or stale client",
|
|
210
|
+
mitigation: "Use one of the 6 valid pairings: guard_u8_u8, guard_u8_u64, guard_entity_u8, guard_entity_u64, guard_signer_u8, guard_signer_u64.",
|
|
211
|
+
evidence: `recipient=${recipientType}, amount=${amountType}`,
|
|
212
|
+
auto_fixable: false,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
const R_R_3_01 = {
|
|
220
|
+
id: "R-R-3-01",
|
|
221
|
+
category: "permission",
|
|
222
|
+
trigger: "claim attempted without permission context — claim is passport-driven",
|
|
223
|
+
check: (ctx) => {
|
|
224
|
+
if (!ctx.claim)
|
|
225
|
+
return null;
|
|
226
|
+
return {
|
|
227
|
+
id: "R-R-3-01",
|
|
228
|
+
level: "MEDIUM",
|
|
229
|
+
category: "permission",
|
|
230
|
+
title: "claim is permission-free — anyone with a valid Passport can claim",
|
|
231
|
+
description: `reward::claim() does NOT assert any permission index. Eligibility is determined entirely by the ` +
|
|
232
|
+
`Guard verification (passport::result_for_guard). If the Guard is too permissive, funds can be drained by anyone.`,
|
|
233
|
+
affected_stakeholders: ["owner", "service_provider"],
|
|
234
|
+
scenario: "Loose Guard allows unauthorized claims (e.g. time-only Guard without service binding)",
|
|
235
|
+
mitigation: "1) Use Guards that bind to specific Service/Order context. 2) Set expiration_time. 3) Monitor balance and refill only what's needed.",
|
|
236
|
+
evidence: `claim=${ctx.claim}`,
|
|
237
|
+
auto_fixable: false,
|
|
238
|
+
};
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
const R_R_3_02 = {
|
|
242
|
+
id: "R-R-3-02",
|
|
243
|
+
category: "permission",
|
|
244
|
+
trigger: "owner_receive (156) — broad blast radius, owner can drain balance",
|
|
245
|
+
check: (ctx) => {
|
|
246
|
+
if (ctx.owner_receive == null)
|
|
247
|
+
return null;
|
|
248
|
+
return {
|
|
249
|
+
id: "R-R-3-02",
|
|
250
|
+
level: "HIGH",
|
|
251
|
+
category: "permission",
|
|
252
|
+
title: "owner_receive drains balance to Permission owner",
|
|
253
|
+
description: `reward::owner_receive (156 permission) unwraps Receiving<K> / CoinWrapper<K> and forwards to Permission owner. ` +
|
|
254
|
+
`If 156 is granted too broadly, any 156-holder can sweep receivables. (Note: owner_receive does NOT directly drain balance — ` +
|
|
255
|
+
`only Receiving<K> envelopes sent to the Reward's id.)`,
|
|
256
|
+
affected_stakeholders: ["owner", "service_provider"],
|
|
257
|
+
scenario: "Compromised 156-holder sweeps receivables before owner",
|
|
258
|
+
mitigation: "1) Grant 156 only to the Permission owner address. 2) Reconcile Receiving<K> inflows vs owner_receive events.",
|
|
259
|
+
evidence: `owner_receive set`,
|
|
260
|
+
auto_fixable: false,
|
|
261
|
+
};
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
const R_R_3_03 = {
|
|
265
|
+
id: "R-R-3-03",
|
|
266
|
+
category: "permission",
|
|
267
|
+
trigger: "guard_expiration_time_add (155) — can permanently lock guard additions",
|
|
268
|
+
check: (ctx) => {
|
|
269
|
+
if (ctx.guard_expiration_time === undefined)
|
|
270
|
+
return null;
|
|
271
|
+
if (ctx.guard_expiration_time !== null && ctx.current_clock_ms !== undefined) {
|
|
272
|
+
const lockDurationMs = ctx.guard_expiration_time - ctx.current_clock_ms;
|
|
273
|
+
const oneYearMs = 365 * 24 * 60 * 60 * 1000;
|
|
274
|
+
if (lockDurationMs > oneYearMs) {
|
|
275
|
+
return {
|
|
276
|
+
id: "R-R-3-03",
|
|
277
|
+
level: "MEDIUM",
|
|
278
|
+
category: "permission",
|
|
279
|
+
title: "guard_expiration_time_add locks guard additions for > 1 year",
|
|
280
|
+
description: `Setting guard_not_added_expiration_time to ${ctx.guard_expiration_time} ` +
|
|
281
|
+
`(> 1 year from now) effectively freezes the guard list. While this is sometimes intentional ` +
|
|
282
|
+
`(milestone rewards), it cannot be undone without setting a new time (which itself requires 155 permission).`,
|
|
283
|
+
affected_stakeholders: ["owner"],
|
|
284
|
+
scenario: "Operator sets excessively long lock period by mistake",
|
|
285
|
+
mitigation: "Confirm intent. If wrong, call guard_expiration_time_add again with a shorter time (must be ≥ current clock per E_GUARD_LOCKED_TIME_NOT_INCREASING).",
|
|
286
|
+
evidence: `lock_until=${ctx.guard_expiration_time}, clock=${ctx.current_clock_ms}`,
|
|
287
|
+
auto_fixable: false,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
const R_R_4_01 = {
|
|
295
|
+
id: "R-R-4-01",
|
|
296
|
+
category: "lifecycle",
|
|
297
|
+
trigger: "claim on guard with expiration_time < now (E_GUARD_EXPIRED)",
|
|
298
|
+
check: (ctx) => {
|
|
299
|
+
if (!ctx.claim)
|
|
300
|
+
return null;
|
|
301
|
+
return null;
|
|
302
|
+
},
|
|
303
|
+
};
|
|
304
|
+
const R_R_4_02 = {
|
|
305
|
+
id: "R-R-4-02",
|
|
306
|
+
category: "lifecycle",
|
|
307
|
+
trigger: "claim: balance < amount (E_INSUFFICIENT_BALANCE)",
|
|
308
|
+
check: (ctx) => {
|
|
309
|
+
if (!ctx.claim)
|
|
310
|
+
return null;
|
|
311
|
+
if (ctx.current_balance !== undefined && ctx.current_guard_count !== undefined) {
|
|
312
|
+
const balance = BigInt(ctx.current_balance);
|
|
313
|
+
if (balance === 0n) {
|
|
314
|
+
return {
|
|
315
|
+
id: "R-R-4-02",
|
|
316
|
+
level: "HIGH",
|
|
317
|
+
category: "lifecycle",
|
|
318
|
+
title: "claim on Reward with zero balance",
|
|
319
|
+
description: `Reward balance is 0. Any claim will abort with E_INSUFFICIENT_BALANCE (6). ` +
|
|
320
|
+
`Owner must coin_add (153) or receive (154) to replenish.`,
|
|
321
|
+
affected_stakeholders: ["claimer", "owner"],
|
|
322
|
+
scenario: "Marketing campaign budget exhausted but guards remain active",
|
|
323
|
+
mitigation: "1) Owner: coin_add to replenish. 2) Owner: guard_remove_expired + guard_expiration_time_add to deactivate. 3) Claimer: wait for replenishment.",
|
|
324
|
+
evidence: `balance=0`,
|
|
325
|
+
related_move_error: "E_INSUFFICIENT_BALANCE (6)",
|
|
326
|
+
auto_fixable: false,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return null;
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
const R_R_4_03 = {
|
|
334
|
+
id: "R-R-4-03",
|
|
335
|
+
category: "lifecycle",
|
|
336
|
+
trigger: "guard_add while guard_not_added_expiration_time is Some and clock ≤ expiration (E_GUARD_LOCKED_TIME)",
|
|
337
|
+
check: (ctx) => {
|
|
338
|
+
if (!ctx.guard_add || ctx.guard_add.length === 0)
|
|
339
|
+
return null;
|
|
340
|
+
if (ctx.current_guard_not_added_expiration_time == null)
|
|
341
|
+
return null;
|
|
342
|
+
if (ctx.current_clock_ms === undefined)
|
|
343
|
+
return null;
|
|
344
|
+
if (ctx.current_clock_ms <= ctx.current_guard_not_added_expiration_time) {
|
|
345
|
+
return {
|
|
346
|
+
id: "R-R-4-03",
|
|
347
|
+
level: "HIGH",
|
|
348
|
+
category: "lifecycle",
|
|
349
|
+
title: "guard_add blocked by time-lock (guard_not_added_expiration_time)",
|
|
350
|
+
description: `guard_not_added_expiration_time is Some(${ctx.current_guard_not_added_expiration_time}); ` +
|
|
351
|
+
`clock is ${ctx.current_clock_ms}. Move asserts clock > expiration_time ` +
|
|
352
|
+
`(E_GUARD_LOCKED_TIME = 10).`,
|
|
353
|
+
affected_stakeholders: ["owner"],
|
|
354
|
+
scenario: "Trying to add guards during a flash sale lock period",
|
|
355
|
+
mitigation: "1) Wait until clock > expiration_time. 2) Call guard_expiration_time_add (155) to extend the lock (cannot shorten below current clock).",
|
|
356
|
+
evidence: `lock_until=${ctx.current_guard_not_added_expiration_time}, clock=${ctx.current_clock_ms}`,
|
|
357
|
+
related_move_error: "E_GUARD_LOCKED_TIME (10)",
|
|
358
|
+
auto_fixable: false,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return null;
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
const R_R_4_04 = {
|
|
365
|
+
id: "R-R-4-04",
|
|
366
|
+
category: "lifecycle",
|
|
367
|
+
trigger: "guard_expiration_time_add regression (new time < current clock)",
|
|
368
|
+
check: (ctx) => {
|
|
369
|
+
if (ctx.guard_expiration_time === undefined)
|
|
370
|
+
return null;
|
|
371
|
+
if (ctx.guard_expiration_time === null)
|
|
372
|
+
return null;
|
|
373
|
+
if (ctx.current_clock_ms === undefined)
|
|
374
|
+
return null;
|
|
375
|
+
if (ctx.guard_expiration_time <= ctx.current_clock_ms) {
|
|
376
|
+
return {
|
|
377
|
+
id: "R-R-4-04",
|
|
378
|
+
level: "HIGH",
|
|
379
|
+
category: "lifecycle",
|
|
380
|
+
title: "guard_expiration_time_add: new time must be in the future",
|
|
381
|
+
description: `New guard_not_added_expiration_time = ${ctx.guard_expiration_time} ≤ clock ${ctx.current_clock_ms}. ` +
|
|
382
|
+
`Move aborts with E_GUARD_LOCKED_TIME_INVALID (11).`,
|
|
383
|
+
affected_stakeholders: ["owner"],
|
|
384
|
+
scenario: "Operator sets lock time in the past by mistake",
|
|
385
|
+
mitigation: `Set guard_expiration_time to a value > ${ctx.current_clock_ms} (current clock).`,
|
|
386
|
+
evidence: `new_time=${ctx.guard_expiration_time}, clock=${ctx.current_clock_ms}`,
|
|
387
|
+
related_move_error: "E_GUARD_LOCKED_TIME_INVALID (11)",
|
|
388
|
+
auto_fixable: true,
|
|
389
|
+
};
|
|
390
|
+
}
|
|
391
|
+
return null;
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
const R_R_5_01 = {
|
|
395
|
+
id: "R-R-5-01",
|
|
396
|
+
category: "cross_object",
|
|
397
|
+
trigger: "claim: guard not found in self.guards (E_GUARD_NOT_FOUND)",
|
|
398
|
+
check: (ctx) => {
|
|
399
|
+
if (!ctx.claim)
|
|
400
|
+
return null;
|
|
401
|
+
if (!ctx.target_guard_addresses)
|
|
402
|
+
return null;
|
|
403
|
+
if (!ctx.target_guard_addresses.includes(ctx.claim)) {
|
|
404
|
+
return {
|
|
405
|
+
id: "R-R-5-01",
|
|
406
|
+
level: "HIGH",
|
|
407
|
+
category: "cross_object",
|
|
408
|
+
title: "claim: supplied guard not in Reward.guards",
|
|
409
|
+
description: `Guard ${ctx.claim} is not in the Reward's guard list. Move iterates self.guards and ` +
|
|
410
|
+
`aborts with E_GUARD_NOT_FOUND (7) if no match.`,
|
|
411
|
+
affected_stakeholders: ["claimer"],
|
|
412
|
+
scenario: "Claimer uses the wrong Guard object (typo or wrong Service)",
|
|
413
|
+
mitigation: "1) Verify the Guard address via query ObjectReward. 2) Ensure the Guard was added via guard_add (152).",
|
|
414
|
+
evidence: `claim_guard=${ctx.claim}, known_guards=${ctx.target_guard_addresses.join(",")}`,
|
|
415
|
+
related_move_error: "E_GUARD_NOT_FOUND (7)",
|
|
416
|
+
auto_fixable: false,
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
return null;
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
const R_R_5_02 = {
|
|
423
|
+
id: "R-R-5-02",
|
|
424
|
+
category: "cross_object",
|
|
425
|
+
trigger: "coin_add: coin type T mismatch with Reward<T>",
|
|
426
|
+
check: (ctx) => {
|
|
427
|
+
if (!ctx.coin_add || !ctx.reward_type)
|
|
428
|
+
return null;
|
|
429
|
+
if (ctx.coin_add.coin_type !== ctx.reward_type) {
|
|
430
|
+
return {
|
|
431
|
+
id: "R-R-5-02",
|
|
432
|
+
level: "CRITICAL",
|
|
433
|
+
category: "cross_object",
|
|
434
|
+
title: "coin_add: coin type T mismatch",
|
|
435
|
+
description: `Reward is Reward<${ctx.reward_type}> but coin_add passes Coin<${ctx.coin_add.coin_type}>. ` +
|
|
436
|
+
`Move type-system mismatch; SDK W_ERROR in operate().`,
|
|
437
|
+
affected_stakeholders: ["owner"],
|
|
438
|
+
scenario: "Operator tries to deposit wrong coin type (e.g. USDC into a WOW Reward)",
|
|
439
|
+
mitigation: `Use Coin<${ctx.reward_type}> for coin_add.`,
|
|
440
|
+
evidence: `reward_type=${ctx.reward_type}, coin_type=${ctx.coin_add.coin_type}`,
|
|
441
|
+
auto_fixable: false,
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
return null;
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
const R_R_5_03 = {
|
|
448
|
+
id: "R-R-5-03",
|
|
449
|
+
category: "cross_object",
|
|
450
|
+
trigger: "receive: Payment<T> type mismatch with Reward<T>",
|
|
451
|
+
check: (ctx) => {
|
|
452
|
+
if (!ctx.receive || !ctx.reward_type)
|
|
453
|
+
return null;
|
|
454
|
+
if (ctx.receive.token_type !== ctx.reward_type) {
|
|
455
|
+
return {
|
|
456
|
+
id: "R-R-5-03",
|
|
457
|
+
level: "CRITICAL",
|
|
458
|
+
category: "cross_object",
|
|
459
|
+
title: "receive: Payment token_type mismatch",
|
|
460
|
+
description: `Reward is Reward<${ctx.reward_type}> but receive's Payment<CoinWrapper<${ctx.receive.token_type}>>. ` +
|
|
461
|
+
`SDK W_ERROR in operate().`,
|
|
462
|
+
affected_stakeholders: ["owner"],
|
|
463
|
+
scenario: "Operator tries to receive wrong-token Payment",
|
|
464
|
+
mitigation: `Use Payment<${ctx.reward_type}> for receive.`,
|
|
465
|
+
evidence: `reward_type=${ctx.reward_type}, payment_token=${ctx.receive.token_type}`,
|
|
466
|
+
auto_fixable: false,
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
return null;
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
const ALL_RULES = [
|
|
473
|
+
R_R_1_01, R_R_1_02, R_R_1_03,
|
|
474
|
+
R_R_2_01, R_R_2_02, R_R_2_03, R_R_2_04,
|
|
475
|
+
R_R_3_01, R_R_3_02, R_R_3_03,
|
|
476
|
+
R_R_4_01, R_R_4_02, R_R_4_03, R_R_4_04,
|
|
477
|
+
R_R_5_01, R_R_5_02, R_R_5_03,
|
|
478
|
+
];
|
|
479
|
+
export const REWARD_RISK_VERSION = "1.0.0";
|
|
480
|
+
export function getAllRewardRiskRules() {
|
|
481
|
+
return [...ALL_RULES];
|
|
482
|
+
}
|
|
483
|
+
export function getRewardRiskRulesCount() {
|
|
484
|
+
return ALL_RULES.length;
|
|
485
|
+
}
|
|
486
|
+
export function getRewardRiskRulesByCategory(category) {
|
|
487
|
+
return ALL_RULES.filter(r => r.category === category);
|
|
488
|
+
}
|
|
489
|
+
export function assessRewardRisks(ctx) {
|
|
490
|
+
const risks = [];
|
|
491
|
+
for (const rule of ALL_RULES) {
|
|
492
|
+
const r = rule.check(ctx);
|
|
493
|
+
if (r)
|
|
494
|
+
risks.push(r);
|
|
495
|
+
}
|
|
496
|
+
const overall = risks.length === 0
|
|
497
|
+
? "LOW"
|
|
498
|
+
: risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
|
|
499
|
+
: risks.some(r => r.level === "HIGH") ? "HIGH"
|
|
500
|
+
: risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
|
|
501
|
+
: "LOW";
|
|
502
|
+
const byCategory = {};
|
|
503
|
+
for (const r of risks) {
|
|
504
|
+
byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
|
|
505
|
+
}
|
|
506
|
+
const advice = {};
|
|
507
|
+
for (const r of risks) {
|
|
508
|
+
for (const s of r.affected_stakeholders) {
|
|
509
|
+
if (!advice[s])
|
|
510
|
+
advice[s] = [];
|
|
511
|
+
advice[s].push(`${r.id}: ${r.mitigation}`);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return {
|
|
515
|
+
summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
|
|
516
|
+
risks,
|
|
517
|
+
overall_risk: overall,
|
|
518
|
+
risks_by_category: byCategory,
|
|
519
|
+
stakeholder_advice: advice,
|
|
520
|
+
needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
export const REWARD_STAKEHOLDERS = [
|
|
524
|
+
"owner",
|
|
525
|
+
"claimer",
|
|
526
|
+
"service_provider",
|
|
527
|
+
"system",
|
|
528
|
+
];
|
|
529
|
+
export function getRewardRiskRulesByStakeholder(stakeholder) {
|
|
530
|
+
return ALL_RULES.filter(rule => {
|
|
531
|
+
if (stakeholder === "owner") {
|
|
532
|
+
return ["structural", "permission", "lifecycle"].includes(rule.category);
|
|
533
|
+
}
|
|
534
|
+
if (stakeholder === "claimer") {
|
|
535
|
+
return rule.id.startsWith("R-R-4-0") || rule.id === "R-R-5-01" || rule.id === "R-R-1-02";
|
|
536
|
+
}
|
|
537
|
+
if (stakeholder === "service_provider") {
|
|
538
|
+
return rule.id === "R-R-4-02" || rule.id === "R-R-3-01" || rule.id === "R-R-3-02";
|
|
539
|
+
}
|
|
540
|
+
if (stakeholder === "system") {
|
|
541
|
+
return rule.category === "cross_object";
|
|
542
|
+
}
|
|
543
|
+
return false;
|
|
544
|
+
});
|
|
545
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface RewardSemanticToSchemaRule {
|
|
2
|
+
id: string;
|
|
3
|
+
pattern_name: string;
|
|
4
|
+
semantic_intent: string;
|
|
5
|
+
match_keywords: string[];
|
|
6
|
+
schema_fields: string[];
|
|
7
|
+
example_json: object;
|
|
8
|
+
reverse_explanation: string;
|
|
9
|
+
}
|
|
10
|
+
export interface RewardSchemaToSemanticRule {
|
|
11
|
+
element_type: "field" | "op" | "phase" | "constructor";
|
|
12
|
+
type_name: string;
|
|
13
|
+
semantic_explanation: string;
|
|
14
|
+
constraints?: string[];
|
|
15
|
+
}
|
|
16
|
+
export interface RewardConstraintRule {
|
|
17
|
+
id: string;
|
|
18
|
+
category: "structural" | "semantic" | "permission" | "lifecycle" | "cross_object";
|
|
19
|
+
rule: string;
|
|
20
|
+
applies_to: string[];
|
|
21
|
+
}
|
|
22
|
+
export declare const REWARD_SEMANTIC_TO_SCHEMA_RULES: RewardSemanticToSchemaRule[];
|
|
23
|
+
export declare const REWARD_SCHEMA_TO_SEMANTIC_RULES: RewardSchemaToSemanticRule[];
|
|
24
|
+
export declare const REWARD_CONSTRAINT_RULES: RewardConstraintRule[];
|
|
25
|
+
export declare const REWARD_TRANSLATION_VERSION = "1.0.0";
|
|
26
|
+
export declare function matchSemanticPattern(userIntent: string): RewardSemanticToSchemaRule[];
|
|
27
|
+
export interface RewardCallDataForExplanation {
|
|
28
|
+
object?: string | null;
|
|
29
|
+
claim?: string;
|
|
30
|
+
description?: string;
|
|
31
|
+
coin_add?: {
|
|
32
|
+
amount: string | number;
|
|
33
|
+
coin_type: string;
|
|
34
|
+
};
|
|
35
|
+
receive?: {
|
|
36
|
+
token_type: string;
|
|
37
|
+
};
|
|
38
|
+
guard_add?: Array<{
|
|
39
|
+
guard: string;
|
|
40
|
+
recipient: Record<string, unknown>;
|
|
41
|
+
amount: {
|
|
42
|
+
type: string;
|
|
43
|
+
value: number | string;
|
|
44
|
+
};
|
|
45
|
+
expiration_time?: number;
|
|
46
|
+
store_from_id?: number | null;
|
|
47
|
+
}>;
|
|
48
|
+
guard_remove_expired?: boolean;
|
|
49
|
+
guard_expiration_time?: number | null;
|
|
50
|
+
owner_receive?: unknown;
|
|
51
|
+
um?: string | null;
|
|
52
|
+
}
|
|
53
|
+
export declare function explainRewardCallData(data: RewardCallDataForExplanation): string;
|
|
54
|
+
export declare function explainField(fieldName: string): RewardSchemaToSemanticRule | undefined;
|
|
55
|
+
export declare function explainOp(opName: string): RewardSchemaToSemanticRule | undefined;
|
|
56
|
+
export declare function explainConstructor(constructorName: string): RewardSchemaToSemanticRule | undefined;
|
|
57
|
+
export declare function getConstraintsByCategory(category: RewardConstraintRule["category"]): RewardConstraintRule[];
|
|
58
|
+
export declare function explainPermissionIndex(index: number): string;
|