@wowok/agent-mcp 2.4.3 → 2.5.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/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.js +21 -0
- 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-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- 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/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/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- 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 +58 -58
- 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/service.d.ts +231 -231
- 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 +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1412 -6
- package/dist/schema/project/index.js +441 -3
- package/dist/schema/query/index.d.ts +672 -672
- 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/schemas/account_operation.output.json +718 -0
- 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/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1809 -336
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- 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 +578 -579
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +0 -514
- package/dist/schemas/onchain_operations_permission.schema.json +0 -514
- package/dist/schemas/onchain_operations_personal.schema.json +0 -514
- 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 +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +918 -0
- package/dist/schemas/project_operation.schema.json +474 -3
- 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/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +262 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +96 -25
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,653 @@
|
|
|
1
|
+
import { MAX_AGENT_COUNT, MAX_DISPUTE_COUNT, } from "@wowok/wowok";
|
|
2
|
+
import { findSceneById, } from "./order-ledger.js";
|
|
3
|
+
const R_O_1_01 = {
|
|
4
|
+
id: "R-O-1-01",
|
|
5
|
+
category: "structural",
|
|
6
|
+
trigger: "Order has 14 fields but no Permission field (unique among 22 objects)",
|
|
7
|
+
check: (ctx) => {
|
|
8
|
+
if (ctx.is_buy_operation) {
|
|
9
|
+
return {
|
|
10
|
+
id: "R-O-1-01",
|
|
11
|
+
level: "LOW",
|
|
12
|
+
category: "structural",
|
|
13
|
+
title: "Order uses owner/agent dual-layer (no Permission)",
|
|
14
|
+
description: "Order is the only business object among 22 WoWok objects that does NOT use the Permission system. All access control flows through assert_owner and has_op_permission inline functions.",
|
|
15
|
+
affected_stakeholders: ["system", "owner", "agent"],
|
|
16
|
+
scenario: "Developer assumes Order uses Permission and writes permission::check logic",
|
|
17
|
+
mitigation: "Use owner/agent checks directly. Do NOT attempt to apply a Permission object to Order.",
|
|
18
|
+
evidence: "no_permission_field",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return null;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
const R_O_1_02 = {
|
|
25
|
+
id: "R-O-1-02",
|
|
26
|
+
category: "structural",
|
|
27
|
+
trigger: "Item count check (informational; no Move-level limit on items)",
|
|
28
|
+
check: (ctx) => {
|
|
29
|
+
if (!ctx.items || ctx.items.length === 0)
|
|
30
|
+
return null;
|
|
31
|
+
if (ctx.items.length > 50) {
|
|
32
|
+
return {
|
|
33
|
+
id: "R-O-1-02",
|
|
34
|
+
level: "LOW",
|
|
35
|
+
category: "structural",
|
|
36
|
+
title: "Large items list may exceed tx size limits",
|
|
37
|
+
description: `${ctx.items.length} items in a single Order — no protocol limit, but large lists increase transaction size and may hit gas/size limits`,
|
|
38
|
+
affected_stakeholders: ["owner"],
|
|
39
|
+
scenario: "Bulk purchase with many line items",
|
|
40
|
+
mitigation: "Split into multiple Orders if items > 50",
|
|
41
|
+
evidence: `items_count=${ctx.items.length}`,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const R_O_1_03 = {
|
|
48
|
+
id: "R-O-1-03",
|
|
49
|
+
category: "structural",
|
|
50
|
+
trigger: "dispute count >= MAX_DISPUTE_COUNT (10)",
|
|
51
|
+
check: (ctx) => {
|
|
52
|
+
const count = ctx.current_dispute_count ?? 0;
|
|
53
|
+
if (count >= MAX_DISPUTE_COUNT) {
|
|
54
|
+
return {
|
|
55
|
+
id: "R-O-1-03",
|
|
56
|
+
level: "HIGH",
|
|
57
|
+
category: "structural",
|
|
58
|
+
title: "Dispute count at MAX_DISPUTE_COUNT limit",
|
|
59
|
+
description: `Order already has ${count} disputes (MAX_DISPUTE_COUNT=${MAX_DISPUTE_COUNT}). Next dispute() call will abort E_DISPUTE_COUNT_EXCEEDED.`,
|
|
60
|
+
affected_stakeholders: ["owner", "agent", "arbitrator"],
|
|
61
|
+
scenario: "Filing 11th dispute on an Order with 10 existing disputes",
|
|
62
|
+
mitigation: "Resolve existing disputes (via arb_claim_compensation) before filing new ones. Note: claimed_by blocks ALL future disputes.",
|
|
63
|
+
evidence: `dispute_count=${count}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
return null;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
const R_O_1_04 = {
|
|
70
|
+
id: "R-O-1-04",
|
|
71
|
+
category: "structural",
|
|
72
|
+
trigger: "agent count > MAX_AGENT_COUNT (doc=10, actual allows 11 due to <= bug)",
|
|
73
|
+
check: (ctx) => {
|
|
74
|
+
if (!ctx.agent_set)
|
|
75
|
+
return null;
|
|
76
|
+
const count = ctx.agent_set.agents.length;
|
|
77
|
+
if (count > MAX_AGENT_COUNT) {
|
|
78
|
+
return {
|
|
79
|
+
id: "R-O-1-04",
|
|
80
|
+
level: "HIGH",
|
|
81
|
+
category: "structural",
|
|
82
|
+
title: "Agent count exceeds documented MAX_AGENT_COUNT (boundary bug)",
|
|
83
|
+
description: `Attempting to set ${count} agents. Doc says MAX_AGENT_COUNT=${MAX_AGENT_COUNT}, but Move agent_set_imp uses <= instead of <, actually allowing 11. SDK constant = ${MAX_AGENT_COUNT} does not match chain behavior.`,
|
|
84
|
+
affected_stakeholders: ["owner", "system"],
|
|
85
|
+
scenario: "Setting 11 agents — succeeds on chain but contradicts SDK/docs",
|
|
86
|
+
mitigation: "Treat 10 as the soft cap (matching docs). If 11 is intentional, document the boundary bug explicitly. Long-term: fix Move to use < and sync SDK.",
|
|
87
|
+
evidence: `agent_count=${count}, max_doc=${MAX_AGENT_COUNT}, max_actual=11`,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
const R_O_1_05 = {
|
|
94
|
+
id: "R-O-1-05",
|
|
95
|
+
category: "structural",
|
|
96
|
+
trigger: "wip_hash is empty string in any item",
|
|
97
|
+
check: (ctx) => {
|
|
98
|
+
if (!ctx.items)
|
|
99
|
+
return null;
|
|
100
|
+
const emptyHashItem = ctx.items.find(i => !i.wip_hash || i.wip_hash === "");
|
|
101
|
+
if (emptyHashItem) {
|
|
102
|
+
return {
|
|
103
|
+
id: "R-O-1-05",
|
|
104
|
+
level: "HIGH",
|
|
105
|
+
category: "structural",
|
|
106
|
+
title: "Empty wip_hash in item",
|
|
107
|
+
description: `Item "${emptyHashItem.name}" has empty wip_hash. Move rejects empty strings (F-O-18).`,
|
|
108
|
+
affected_stakeholders: ["owner"],
|
|
109
|
+
scenario: "User submits item without computing WIP hash",
|
|
110
|
+
mitigation: "Compute wip_hash from the work-in-progress file content before service::buy().",
|
|
111
|
+
evidence: `item_name=${emptyHashItem.name}`,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
const R_O_2_01 = {
|
|
118
|
+
id: "R-O-2-01",
|
|
119
|
+
category: "semantic",
|
|
120
|
+
trigger: "Order.machine snapshot differs from current Service.machine",
|
|
121
|
+
check: (ctx) => {
|
|
122
|
+
if (!ctx.current_service_machine || !ctx.order_machine_snapshot)
|
|
123
|
+
return null;
|
|
124
|
+
if (ctx.current_service_machine !== ctx.order_machine_snapshot) {
|
|
125
|
+
return {
|
|
126
|
+
id: "R-O-2-01",
|
|
127
|
+
level: "HIGH",
|
|
128
|
+
category: "semantic",
|
|
129
|
+
title: "Machine snapshot diverges from Service.machine",
|
|
130
|
+
description: `Order.machine=${ctx.order_machine_snapshot} was snapshotted at buy time. Service.machine is now ${ctx.current_service_machine}. Same Service has Orders running different Machine versions.`,
|
|
131
|
+
affected_stakeholders: ["owner", "service_provider", "arbitrator"],
|
|
132
|
+
scenario: "Service provider upgrades Machine after some Orders are created",
|
|
133
|
+
mitigation: "Audit each Order's machine snapshot separately. Document Machine version per Order. Plan migration paths for legacy Orders.",
|
|
134
|
+
evidence: `order_machine=${ctx.order_machine_snapshot}, service_machine=${ctx.current_service_machine}`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
return null;
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
const R_O_2_02 = {
|
|
141
|
+
id: "R-O-2-02",
|
|
142
|
+
category: "semantic",
|
|
143
|
+
trigger: "SDK uses 'builder' field for Move's 'owner' field (naming deviation)",
|
|
144
|
+
check: (ctx) => {
|
|
145
|
+
if (ctx.object) {
|
|
146
|
+
return {
|
|
147
|
+
id: "R-O-2-02",
|
|
148
|
+
level: "MEDIUM",
|
|
149
|
+
category: "semantic",
|
|
150
|
+
title: "SDK builder ≠ Move owner (only naming deviation in 22 objects)",
|
|
151
|
+
description: "SDK ObjectOrder.builder corresponds to Move Order.owner. This is the only field name deviation across all 22 WoWok objects. All Order knowledge uses Move's 'owner' as canonical.",
|
|
152
|
+
affected_stakeholders: ["system"],
|
|
153
|
+
scenario: "Developer reads SDK 'builder' and assumes it's a different concept from owner",
|
|
154
|
+
mitigation: "Use moveToSdkField()/sdkToMoveField() helpers from order-ledger.ts. Document 'builder = owner' in all SDK consumers.",
|
|
155
|
+
evidence: "sdk_field=builder, move_field=owner",
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
return null;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
const R_O_2_03 = {
|
|
162
|
+
id: "R-O-2-03",
|
|
163
|
+
category: "semantic",
|
|
164
|
+
trigger: "owner_change or agent_set aborted with E_PROGRESS_NOT_SPECIFIED (dual semantics)",
|
|
165
|
+
check: (ctx) => {
|
|
166
|
+
if (!ctx.operation)
|
|
167
|
+
return null;
|
|
168
|
+
if ((ctx.operation === "agent_set") && ctx.progress_bound) {
|
|
169
|
+
return {
|
|
170
|
+
id: "R-O-2-03",
|
|
171
|
+
level: "MEDIUM",
|
|
172
|
+
category: "semantic",
|
|
173
|
+
title: "E_PROGRESS_NOT_SPECIFIED dual semantics (literal vs actual)",
|
|
174
|
+
description: "agent_set aborted because progress.is_some() — but error code says 'PROGRESS_NOT_SPECIFIED'. The code is used in two OPPOSITE scenarios: (A) progress.is_none() during on_progress (literal), (B) progress.is_some() during owner_change/agent_set (opposite).",
|
|
175
|
+
affected_stakeholders: ["owner", "agent"],
|
|
176
|
+
scenario: "User sees 'Progress not specified' error when Progress IS specified — confusion",
|
|
177
|
+
mitigation: "Translate error to: 'Cannot modify owner/agent: Progress already bound (frozen).' Long-term: split into two error codes (E_PROGRESS_ALREADY_BOUND and E_PROGRESS_NOT_SPECIFIED).",
|
|
178
|
+
evidence: `operation=${ctx.operation}, progress_bound=${ctx.progress_bound}`,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const R_O_2_04 = {
|
|
185
|
+
id: "R-O-2-04",
|
|
186
|
+
category: "semantic",
|
|
187
|
+
trigger: "SaleItem.item → PurchasedItem.name field name mapping",
|
|
188
|
+
check: (ctx) => {
|
|
189
|
+
if (ctx.is_buy_operation) {
|
|
190
|
+
return {
|
|
191
|
+
id: "R-O-2-04",
|
|
192
|
+
level: "LOW",
|
|
193
|
+
category: "semantic",
|
|
194
|
+
title: "SaleItem.item (Move) maps to PurchasedItem.name (SDK)",
|
|
195
|
+
description: "Move struct SaleItem uses field 'item', but SDK ObjectOrder.items uses field 'name'. This is the second naming deviation in Order system (after builder/owner).",
|
|
196
|
+
affected_stakeholders: ["system"],
|
|
197
|
+
scenario: "Cross-layer data mapping between Move and SDK",
|
|
198
|
+
mitigation: "Use consistent SDK field names in user-facing code; document Move ↔ SDK mapping in audit logs.",
|
|
199
|
+
evidence: "move_field=SaleItem.item, sdk_field=PurchasedItem.name",
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return null;
|
|
203
|
+
},
|
|
204
|
+
};
|
|
205
|
+
const R_O_3_01 = {
|
|
206
|
+
id: "R-O-3-01",
|
|
207
|
+
category: "authority",
|
|
208
|
+
trigger: "Agent attempts receive or transfer_to (L1 owner-only operations)",
|
|
209
|
+
check: (ctx) => {
|
|
210
|
+
if (!ctx.operation)
|
|
211
|
+
return null;
|
|
212
|
+
if ((ctx.operation === "receive" || ctx.operation === "transfer_to") &&
|
|
213
|
+
ctx.caller_is_agent && !ctx.caller_is_owner) {
|
|
214
|
+
return {
|
|
215
|
+
id: "R-O-3-01",
|
|
216
|
+
level: "HIGH",
|
|
217
|
+
category: "authority",
|
|
218
|
+
title: "Agent attempting owner-only operation",
|
|
219
|
+
description: `Agent cannot call ${ctx.operation} — these are L1 owner-only operations (assert_owner). Agent can operate progress/arb_*/required_info but CANNOT receive funds or transfer ownership.`,
|
|
220
|
+
affected_stakeholders: ["agent", "owner"],
|
|
221
|
+
scenario: "Logistics agent tries to collect payment on behalf of buyer",
|
|
222
|
+
mitigation: "Owner must call receive/transfer_to directly. If delegation is needed, owner can transfer_to a multi-sig wallet that includes the agent.",
|
|
223
|
+
evidence: `operation=${ctx.operation}, caller=agent`,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
return null;
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
const R_O_3_02 = {
|
|
230
|
+
id: "R-O-3-02",
|
|
231
|
+
category: "authority",
|
|
232
|
+
trigger: "Non-owner non-agent attempts operation (no permission)",
|
|
233
|
+
check: (ctx) => {
|
|
234
|
+
if (!ctx.operation)
|
|
235
|
+
return null;
|
|
236
|
+
if (ctx.caller_is_owner === false && ctx.caller_is_agent === false) {
|
|
237
|
+
return {
|
|
238
|
+
id: "R-O-3-02",
|
|
239
|
+
level: "HIGH",
|
|
240
|
+
category: "authority",
|
|
241
|
+
title: "Non-owner non-agent attempting operation",
|
|
242
|
+
description: `Caller is neither owner nor agent. All Order operations require at least has_op_permission (L2 layer). Aborts E_PERMISSION.`,
|
|
243
|
+
affected_stakeholders: ["system"],
|
|
244
|
+
scenario: "Random address attempts to advance someone else's Order",
|
|
245
|
+
mitigation: "Verify caller is owner or in agent[] before submitting transaction.",
|
|
246
|
+
evidence: `operation=${ctx.operation}, caller=unauthorized`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return null;
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
const R_O_3_03 = {
|
|
253
|
+
id: "R-O-3-03",
|
|
254
|
+
category: "authority",
|
|
255
|
+
trigger: "arb_claim_compensation called (sets claimed_by, irreversible)",
|
|
256
|
+
check: (ctx) => {
|
|
257
|
+
if (ctx.operation !== "arb_claim_compensation")
|
|
258
|
+
return null;
|
|
259
|
+
return {
|
|
260
|
+
id: "R-O-3-03",
|
|
261
|
+
level: "HIGH",
|
|
262
|
+
category: "authority",
|
|
263
|
+
title: "arb_claim_compensation is IRREVERSIBLE (claimed_by one-time set)",
|
|
264
|
+
description: "Setting claimed_by is permanent. After this call: (1) claimed_by cannot be reset, (2) NO new disputes can be filed (E_ORDER_ALREADY_CLAIMED), (3) all unresolved disputes become unactionable. If first compensation is insufficient, buyer has no recourse.",
|
|
265
|
+
affected_stakeholders: ["owner", "agent", "arbitrator"],
|
|
266
|
+
scenario: "Buyer claims partial compensation, then discovers additional damages",
|
|
267
|
+
mitigation: "BEFORE claiming: (1) enumerate ALL disputes, (2) ensure proposition covers all damages, (3) confirm Arb ruling is final. Add explicit user confirmation (C-O-08).",
|
|
268
|
+
evidence: `operation=arb_claim_compensation, current_claimed_by=${ctx.claimed_by_set ?? false}`,
|
|
269
|
+
};
|
|
270
|
+
},
|
|
271
|
+
};
|
|
272
|
+
const R_O_3_04 = {
|
|
273
|
+
id: "R-O-3-04",
|
|
274
|
+
category: "authority",
|
|
275
|
+
trigger: "dispute attempted after claimed_by is set",
|
|
276
|
+
check: (ctx) => {
|
|
277
|
+
if (ctx.claimed_by_set && (ctx.operation === "arb_confirm" || ctx.operation === "arb_objection")) {
|
|
278
|
+
return {
|
|
279
|
+
id: "R-O-3-04",
|
|
280
|
+
level: "HIGH",
|
|
281
|
+
category: "authority",
|
|
282
|
+
title: "Cannot file new dispute after claimed_by is set",
|
|
283
|
+
description: "Order.claimed_by is set — any new dispute() call aborts E_ORDER_ALREADY_CLAIMED. arb_confirm/arb_objection trigger dispute() internally.",
|
|
284
|
+
affected_stakeholders: ["owner", "agent"],
|
|
285
|
+
scenario: "Buyer claims compensation then tries to file additional dispute",
|
|
286
|
+
mitigation: "Resolve ALL disputes BEFORE calling arb_claim_compensation. claimed_by is terminal for dispute flow.",
|
|
287
|
+
evidence: `operation=${ctx.operation}, claimed_by_set=true`,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
return null;
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
const R_O_4_01 = {
|
|
294
|
+
id: "R-O-4-01",
|
|
295
|
+
category: "lifecycle",
|
|
296
|
+
trigger: "Attempt to create Order independently (not via service::buy)",
|
|
297
|
+
check: (ctx) => {
|
|
298
|
+
if (ctx.is_buy_operation === false && ctx.operation === "service_buy" && !ctx.object) {
|
|
299
|
+
return {
|
|
300
|
+
id: "R-O-4-01",
|
|
301
|
+
level: "CRITICAL",
|
|
302
|
+
category: "lifecycle",
|
|
303
|
+
title: "Order cannot be created independently (compound creation only)",
|
|
304
|
+
description: "order::new() is package-only — only service::buy() can create Orders. Any attempt to call order::new directly will fail at the Move module boundary. Order + Allocation + Progress are created atomically in one transaction.",
|
|
305
|
+
affected_stakeholders: ["system", "owner"],
|
|
306
|
+
scenario: "Developer tries to construct Order independently for testing",
|
|
307
|
+
mitigation: "Always use service::buy() to create Orders. For testing, deploy a minimal Service with machine/allocators configured.",
|
|
308
|
+
evidence: "independent_creation_attempted",
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
return null;
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const R_O_4_02 = {
|
|
315
|
+
id: "R-O-4-02",
|
|
316
|
+
category: "lifecycle",
|
|
317
|
+
trigger: "agent_set or owner_change attempted after Progress binding",
|
|
318
|
+
check: (ctx) => {
|
|
319
|
+
if (!ctx.operation)
|
|
320
|
+
return null;
|
|
321
|
+
if ((ctx.operation === "agent_set") && ctx.progress_bound) {
|
|
322
|
+
return {
|
|
323
|
+
id: "R-O-4-02",
|
|
324
|
+
level: "HIGH",
|
|
325
|
+
category: "lifecycle",
|
|
326
|
+
title: "agent_set blocked — Progress binding frozen owner/agent",
|
|
327
|
+
description: "Once order.progress is set (during service::buy if Service has machine), agent_set and owner_change abort E_PROGRESS_NOT_SPECIFIED. Owner/agent must be finalized BEFORE buy.",
|
|
328
|
+
affected_stakeholders: ["owner", "agent"],
|
|
329
|
+
scenario: "Buyer wants to add agent mid-fulfillment after Progress is bound",
|
|
330
|
+
mitigation: "Set agent list BEFORE service::buy (via pre-buy configuration). If post-buy agent change is needed, use transfer_to a new owner who has the desired agents.",
|
|
331
|
+
evidence: `operation=agent_set, progress_bound=${ctx.progress_bound}`,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
return null;
|
|
335
|
+
},
|
|
336
|
+
};
|
|
337
|
+
const R_O_4_03 = {
|
|
338
|
+
id: "R-O-4-03",
|
|
339
|
+
category: "lifecycle",
|
|
340
|
+
trigger: "Progress advance attempted without progress bound",
|
|
341
|
+
check: (ctx) => {
|
|
342
|
+
if (ctx.operation === "progress_advance" && ctx.progress_bound === false) {
|
|
343
|
+
return {
|
|
344
|
+
id: "R-O-4-03",
|
|
345
|
+
level: "HIGH",
|
|
346
|
+
category: "lifecycle",
|
|
347
|
+
title: "Cannot advance Progress — no Progress bound to Order",
|
|
348
|
+
description: "Order has no progress field set (Service had no machine configured). Cannot advance a non-existent Progress. SDK CallOrder validates this pre-flight (CallOrder_Data.progress requires order.machine and order.progress).",
|
|
349
|
+
affected_stakeholders: ["owner", "agent"],
|
|
350
|
+
scenario: "Buyer tries to advance Progress on an Order created from a Service without machine",
|
|
351
|
+
mitigation: "Use a Service with machine configured. If manual lifecycle is needed, track state off-chain.",
|
|
352
|
+
evidence: `operation=progress_advance, progress_bound=false`,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return null;
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
const R_O_4_04 = {
|
|
359
|
+
id: "R-O-4-04",
|
|
360
|
+
category: "lifecycle",
|
|
361
|
+
trigger: "arb_confirm/arb_objection/arb_claim_compensation (irreversible Arb operations)",
|
|
362
|
+
check: (ctx) => {
|
|
363
|
+
if (!ctx.operation)
|
|
364
|
+
return null;
|
|
365
|
+
if (ctx.operation === "arb_confirm" || ctx.operation === "arb_objection" || ctx.operation === "arb_claim_compensation") {
|
|
366
|
+
return {
|
|
367
|
+
id: "R-O-4-04",
|
|
368
|
+
level: "HIGH",
|
|
369
|
+
category: "lifecycle",
|
|
370
|
+
title: `${ctx.operation} is irreversible (triggers Arb flow)`,
|
|
371
|
+
description: `${ctx.operation} triggers the Arbitration workflow which cannot be undone. arb_confirm files a new dispute, arb_objection requests re-arbitration, arb_claim_compensation sets claimed_by permanently.`,
|
|
372
|
+
affected_stakeholders: ["owner", "agent", "arbitrator"],
|
|
373
|
+
scenario: "User accidentally files arb_confirm without understanding consequences",
|
|
374
|
+
mitigation: "Add explicit user confirmation (C-O-08, C-O-11, C-O-12) before these operations. Show warning text describing irreversibility.",
|
|
375
|
+
evidence: `operation=${ctx.operation}`,
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
return null;
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
const R_O_4_05 = {
|
|
382
|
+
id: "R-O-4-05",
|
|
383
|
+
category: "lifecycle",
|
|
384
|
+
trigger: "receive attempted while Progress not at terminal node",
|
|
385
|
+
check: (ctx) => {
|
|
386
|
+
if (ctx.operation === "receive" && ctx.progress_bound && !ctx.progress_at_terminal) {
|
|
387
|
+
return {
|
|
388
|
+
id: "R-O-4-05",
|
|
389
|
+
level: "HIGH",
|
|
390
|
+
category: "lifecycle",
|
|
391
|
+
title: "receive blocked — Order still delivering (E_ORDER_DELIVERING)",
|
|
392
|
+
description: "owner_receive aborts E_ORDER_DELIVERING when Progress has not reached a terminal node. Funds cannot be collected until fulfillment completes.",
|
|
393
|
+
affected_stakeholders: ["owner"],
|
|
394
|
+
scenario: "Buyer tries to collect refund before Progress reaches 'completed' or 'cancelled'",
|
|
395
|
+
mitigation: "Wait for Progress to reach terminal/cancel node. If urgent, file arb_confirm to dispute.",
|
|
396
|
+
evidence: `operation=receive, progress_at_terminal=${ctx.progress_at_terminal}`,
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
const R_O_4_06 = {
|
|
403
|
+
id: "R-O-4-06",
|
|
404
|
+
category: "lifecycle",
|
|
405
|
+
trigger: "transfer_to attempted (irreversible ownership transfer)",
|
|
406
|
+
check: (ctx) => {
|
|
407
|
+
if (ctx.operation !== "transfer_to")
|
|
408
|
+
return null;
|
|
409
|
+
return {
|
|
410
|
+
id: "R-O-4-06",
|
|
411
|
+
level: "CRITICAL",
|
|
412
|
+
category: "lifecycle",
|
|
413
|
+
title: "transfer_to is IRREVERSIBLE — new owner takes over ALL permissions",
|
|
414
|
+
description: `Ownership transfer to ${ctx.transfer_to_new_owner ?? "(unknown)"} is permanent. New owner becomes the sole receiver of payments and gains full L1 control. Original owner loses ALL access.`,
|
|
415
|
+
affected_stakeholders: ["owner"],
|
|
416
|
+
scenario: "Buyer transfers Order to wrong address by mistake",
|
|
417
|
+
mitigation: "1) Verify new owner address twice. 2) Coordinate with new owner before transfer. 3) Add explicit user confirmation (C-O-09). Note: transfer_to is NOT blocked by progress binding (unlike agent_set).",
|
|
418
|
+
evidence: `new_owner=${ctx.transfer_to_new_owner}`,
|
|
419
|
+
};
|
|
420
|
+
},
|
|
421
|
+
};
|
|
422
|
+
const R_O_5_01 = {
|
|
423
|
+
id: "R-O-5-01",
|
|
424
|
+
category: "cross_object",
|
|
425
|
+
trigger: "Service.machine upgraded after Order creation (snapshot divergence)",
|
|
426
|
+
check: (ctx) => {
|
|
427
|
+
if (ctx.is_buy_operation) {
|
|
428
|
+
return {
|
|
429
|
+
id: "R-O-5-01",
|
|
430
|
+
level: "LOW",
|
|
431
|
+
category: "cross_object",
|
|
432
|
+
title: "Service snapshot mechanism — order.machine is a copy, not a reference",
|
|
433
|
+
description: "When service::buy() creates an Order, order.machine is COPIED from service.machine. Future Service.machine upgrades do NOT affect this Order. Same Service may have Orders running different Machine versions.",
|
|
434
|
+
affected_stakeholders: ["owner", "service_provider", "arbitrator"],
|
|
435
|
+
scenario: "Service provider upgrades Machine workflow — old Orders keep old workflow",
|
|
436
|
+
mitigation: "Track Machine version per Order (via order.machine address). Plan migration paths for legacy Orders. Document that old Orders are decoupled.",
|
|
437
|
+
evidence: "snapshot_mechanism",
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
return null;
|
|
441
|
+
},
|
|
442
|
+
};
|
|
443
|
+
const R_O_5_02 = {
|
|
444
|
+
id: "R-O-5-02",
|
|
445
|
+
category: "cross_object",
|
|
446
|
+
trigger: "Order references Progress that no longer exists or is corrupted",
|
|
447
|
+
check: (ctx) => {
|
|
448
|
+
if (ctx.progress_bound && ctx.object) {
|
|
449
|
+
return {
|
|
450
|
+
id: "R-O-5-02",
|
|
451
|
+
level: "MEDIUM",
|
|
452
|
+
category: "cross_object",
|
|
453
|
+
title: "Order-Progress 1:1 binding (E_PROGRESS_ALREADY_SPECIFIED)",
|
|
454
|
+
description: "Order.progress is one-time-set via on_progress (package-only). Cannot be rebound. If Progress object is corrupted, Order becomes stuck — cannot advance, cannot rebind.",
|
|
455
|
+
affected_stakeholders: ["owner", "agent"],
|
|
456
|
+
scenario: "Progress object becomes unresponsive or corrupted",
|
|
457
|
+
mitigation: "Ensure Progress integrity via Machine audit before publishing Service. Use arb_claim_compensation as escape hatch if Progress is stuck.",
|
|
458
|
+
evidence: `progress_bound=${ctx.progress_bound}`,
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
return null;
|
|
462
|
+
},
|
|
463
|
+
};
|
|
464
|
+
const R_O_5_03 = {
|
|
465
|
+
id: "R-O-5-03",
|
|
466
|
+
category: "cross_object",
|
|
467
|
+
trigger: "Order references Allocation that no longer exists or is corrupted",
|
|
468
|
+
check: (ctx) => {
|
|
469
|
+
if (ctx.object && ctx.progress_bound) {
|
|
470
|
+
return {
|
|
471
|
+
id: "R-O-5-03",
|
|
472
|
+
level: "MEDIUM",
|
|
473
|
+
category: "cross_object",
|
|
474
|
+
title: "Order-Allocation 1:1 binding (E_ALLOCATION_ALREADY_SPECIFIED)",
|
|
475
|
+
description: "Order.allocation is one-time-set via on_allocation (package-only). Cannot be rebound. If Allocation object is corrupted, fund distribution is blocked.",
|
|
476
|
+
affected_stakeholders: ["owner", "service_provider"],
|
|
477
|
+
scenario: "Allocation object has wrong allocator configuration",
|
|
478
|
+
mitigation: "Audit order_allocators configuration on Service BEFORE publishing. Use compensation_fund as fallback fund source.",
|
|
479
|
+
evidence: "allocation_binding",
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
return null;
|
|
483
|
+
},
|
|
484
|
+
};
|
|
485
|
+
const R_O_5_04 = {
|
|
486
|
+
id: "R-O-5-04",
|
|
487
|
+
category: "cross_object",
|
|
488
|
+
trigger: "Arbitration dispute appended to Order.dispute list",
|
|
489
|
+
check: (ctx) => {
|
|
490
|
+
if (ctx.operation === "arb_confirm") {
|
|
491
|
+
return {
|
|
492
|
+
id: "R-O-5-04",
|
|
493
|
+
level: "LOW",
|
|
494
|
+
category: "cross_object",
|
|
495
|
+
title: "Arb object will be appended to order.dispute (package-only dispute())",
|
|
496
|
+
description: "arb_confirm triggers Arb module to call order::dispute(arb_address), appending the Arb object to order.dispute list. Max 10 disputes (MAX_DISPUTE_COUNT). Frozen when claimed_by is set.",
|
|
497
|
+
affected_stakeholders: ["arbitrator", "owner", "agent"],
|
|
498
|
+
scenario: "Multiple arb_confirm calls create multiple Arb objects on same Order",
|
|
499
|
+
mitigation: "Track dispute count. Once at 10, no more disputes can be filed. Resolve existing disputes before filing new ones.",
|
|
500
|
+
evidence: `operation=arb_confirm, current_disputes=${ctx.current_dispute_count ?? 0}`,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
return null;
|
|
504
|
+
},
|
|
505
|
+
};
|
|
506
|
+
const R_O_5_05 = {
|
|
507
|
+
id: "R-O-5-05",
|
|
508
|
+
category: "cross_object",
|
|
509
|
+
trigger: "External system expects OrderCompletedEvent (does not exist)",
|
|
510
|
+
check: (ctx) => {
|
|
511
|
+
if (ctx.is_buy_operation || ctx.object) {
|
|
512
|
+
return {
|
|
513
|
+
id: "R-O-5-05",
|
|
514
|
+
level: "MEDIUM",
|
|
515
|
+
category: "cross_object",
|
|
516
|
+
title: "Only NewOrderEvent emitted — no OrderCompletedEvent",
|
|
517
|
+
description: "Move contract ONLY emits NewOrderEvent at creation. Order completion/cancellation/refund are IMPLICIT — must be inferred by querying Progress.current_node (terminal? cancel?) or Order.claimed_by. External monitoring requires polling, not event-driven.",
|
|
518
|
+
affected_stakeholders: ["system"],
|
|
519
|
+
scenario: "Analytics dashboard expects OrderCompletedEvent to track completion rate",
|
|
520
|
+
mitigation: "Build composite query: NewOrderEvent + Order.progress query → infer completion. Document this limitation in monitoring tools. Long-term: advocate for Move upgrade to add OrderCompletedEvent.",
|
|
521
|
+
evidence: "no_order_completed_event",
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
return null;
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
const R_O_5_06 = {
|
|
528
|
+
id: "R-O-5-06",
|
|
529
|
+
category: "cross_object",
|
|
530
|
+
trigger: "service::buy pre-flight: Service not published or paused",
|
|
531
|
+
check: (ctx) => {
|
|
532
|
+
if (!ctx.is_buy_operation)
|
|
533
|
+
return null;
|
|
534
|
+
if (ctx.service_published === false) {
|
|
535
|
+
return {
|
|
536
|
+
id: "R-O-5-06",
|
|
537
|
+
level: "CRITICAL",
|
|
538
|
+
category: "cross_object",
|
|
539
|
+
title: "Service not published — service::buy will abort E_NOT_PUBLISHED",
|
|
540
|
+
description: "Cannot create Order from an unpublished Service. Service must be published (bPublished=true) before service::buy() can be called.",
|
|
541
|
+
affected_stakeholders: ["owner"],
|
|
542
|
+
scenario: "Buyer attempts to purchase from a draft Service",
|
|
543
|
+
mitigation: "Verify Service.bPublished=true before service::buy(). Service owner must call service::publish() first.",
|
|
544
|
+
evidence: `service_published=${ctx.service_published}`,
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
if (ctx.service_paused === true) {
|
|
548
|
+
return {
|
|
549
|
+
id: "R-O-5-06",
|
|
550
|
+
level: "CRITICAL",
|
|
551
|
+
category: "cross_object",
|
|
552
|
+
title: "Service paused — service::buy will abort E_PAUSED",
|
|
553
|
+
description: "Cannot create Order from a paused Service. Service must be unpaused before service::buy() can be called.",
|
|
554
|
+
affected_stakeholders: ["owner"],
|
|
555
|
+
scenario: "Buyer attempts to purchase from a paused Service (e.g. during maintenance)",
|
|
556
|
+
mitigation: "Wait for Service owner to call service::pause(false). Check Service.paused before service::buy().",
|
|
557
|
+
evidence: `service_paused=${ctx.service_paused}`,
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
return null;
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
const ALL_RULES = [
|
|
564
|
+
R_O_1_01, R_O_1_02, R_O_1_03, R_O_1_04, R_O_1_05,
|
|
565
|
+
R_O_2_01, R_O_2_02, R_O_2_03, R_O_2_04,
|
|
566
|
+
R_O_3_01, R_O_3_02, R_O_3_03, R_O_3_04,
|
|
567
|
+
R_O_4_01, R_O_4_02, R_O_4_03, R_O_4_04, R_O_4_05, R_O_4_06,
|
|
568
|
+
R_O_5_01, R_O_5_02, R_O_5_03, R_O_5_04, R_O_5_05, R_O_5_06,
|
|
569
|
+
];
|
|
570
|
+
export const ORDER_RISK_VERSION = "1.0.0";
|
|
571
|
+
export function getAllOrderRiskRules() {
|
|
572
|
+
return [...ALL_RULES];
|
|
573
|
+
}
|
|
574
|
+
export function getOrderRiskRulesCount() {
|
|
575
|
+
return ALL_RULES.length;
|
|
576
|
+
}
|
|
577
|
+
export function getOrderRiskRulesByCategory(category) {
|
|
578
|
+
return ALL_RULES.filter(r => r.category === category);
|
|
579
|
+
}
|
|
580
|
+
export function getOrderRiskRuleById(id) {
|
|
581
|
+
return ALL_RULES.find(r => r.id === id);
|
|
582
|
+
}
|
|
583
|
+
export function assessOrderRisks(ctx) {
|
|
584
|
+
const risks = [];
|
|
585
|
+
for (const rule of ALL_RULES) {
|
|
586
|
+
const r = rule.check(ctx);
|
|
587
|
+
if (r)
|
|
588
|
+
risks.push(r);
|
|
589
|
+
}
|
|
590
|
+
const overall = risks.length === 0
|
|
591
|
+
? "LOW"
|
|
592
|
+
: risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
|
|
593
|
+
: risks.some(r => r.level === "HIGH") ? "HIGH"
|
|
594
|
+
: risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
|
|
595
|
+
: "LOW";
|
|
596
|
+
const byCategory = {};
|
|
597
|
+
for (const r of risks) {
|
|
598
|
+
byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
|
|
599
|
+
}
|
|
600
|
+
const advice = {};
|
|
601
|
+
for (const r of risks) {
|
|
602
|
+
for (const s of r.affected_stakeholders) {
|
|
603
|
+
if (!advice[s])
|
|
604
|
+
advice[s] = [];
|
|
605
|
+
advice[s].push(`${r.id}: ${r.mitigation}`);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
let scene;
|
|
609
|
+
if (ctx.operation) {
|
|
610
|
+
const sceneMap = {
|
|
611
|
+
agent_set: "order_set_agent",
|
|
612
|
+
required_info_update: "order_required_info",
|
|
613
|
+
progress_advance: "order_advance",
|
|
614
|
+
arb_confirm: "order_arb_confirm",
|
|
615
|
+
arb_objection: "order_arb_objection",
|
|
616
|
+
arb_claim_compensation: "order_arb_claim_compensation",
|
|
617
|
+
receive: "order_receive",
|
|
618
|
+
transfer_to: "order_transfer",
|
|
619
|
+
service_buy: "order_create",
|
|
620
|
+
};
|
|
621
|
+
scene = findSceneById(sceneMap[ctx.operation] ?? "");
|
|
622
|
+
}
|
|
623
|
+
return {
|
|
624
|
+
summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
|
|
625
|
+
scene,
|
|
626
|
+
risks,
|
|
627
|
+
overall_risk: overall,
|
|
628
|
+
risks_by_category: byCategory,
|
|
629
|
+
stakeholder_advice: advice,
|
|
630
|
+
needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
export function checkPermissionLayer(operation, caller_is_owner, caller_is_agent) {
|
|
634
|
+
const l1_ops = ["receive", "transfer_to", "owner_change", "agent_set"];
|
|
635
|
+
const l2_ops = ["required_info_update", "progress_advance", "arb_confirm", "arb_objection", "arb_claim_compensation"];
|
|
636
|
+
const l3_ops = ["on_progress", "on_allocation", "dispute", "compensate"];
|
|
637
|
+
if (l3_ops.includes(operation)) {
|
|
638
|
+
return { allowed: false, layer: "L3_package_only", reason: "Package-only — not callable externally" };
|
|
639
|
+
}
|
|
640
|
+
if (l1_ops.includes(operation)) {
|
|
641
|
+
if (!caller_is_owner) {
|
|
642
|
+
return { allowed: false, layer: "L1_owner_only", reason: `Owner-only operation (${operation}) — agent or unauthorized caller` };
|
|
643
|
+
}
|
|
644
|
+
return { allowed: true, layer: "L1_owner_only" };
|
|
645
|
+
}
|
|
646
|
+
if (l2_ops.includes(operation)) {
|
|
647
|
+
if (!caller_is_owner && !caller_is_agent) {
|
|
648
|
+
return { allowed: false, layer: "L2_owner_or_agent", reason: `Requires owner or agent permission (${operation})` };
|
|
649
|
+
}
|
|
650
|
+
return { allowed: true, layer: "L2_owner_or_agent" };
|
|
651
|
+
}
|
|
652
|
+
return { allowed: false, layer: "L3_package_only", reason: `Unknown operation: ${operation}` };
|
|
653
|
+
}
|