@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,182 @@
|
|
|
1
|
+
import { MAX_RECIPIENT_COUNT } from "@wowok/wowok";
|
|
2
|
+
const R_P_01 = {
|
|
3
|
+
rule: {
|
|
4
|
+
id: "R-PAYMENT-01",
|
|
5
|
+
level: "HIGH",
|
|
6
|
+
category: "permission",
|
|
7
|
+
title: "unwrap() performs no Payment match check — may unwrap wrong CoinWrapper",
|
|
8
|
+
description: "unwrap(wrapper, ctx) (payment.move:50) returns (Coin, payment_address) without " +
|
|
9
|
+
"verifying that wrapper.payment matches any expected Payment. Callers who use unwrap " +
|
|
10
|
+
"instead of unwrap_with_check can unwrap a CoinWrapper that was minted for a different " +
|
|
11
|
+
"Payment, leading to fund loss or accounting corruption. unwrap_with_check(payment_check) " +
|
|
12
|
+
"exists specifically to enforce the match (payment.move:54).",
|
|
13
|
+
affected_stakeholders: ["signer", "recipient"],
|
|
14
|
+
scenario: "Caller uses unwrap on a wrapper from a different Payment; funds are released anyway",
|
|
15
|
+
mitigation: "SDK should force callers to use unwrap_with_check and deprecate direct unwrap calls. " +
|
|
16
|
+
"The only safe use of unwrap is when the caller has already verified the match off-chain.",
|
|
17
|
+
related_move_error: "EPAYMENT_NOT_MATCH (3) — only raised by unwrap_with_check",
|
|
18
|
+
auto_fixable: false,
|
|
19
|
+
},
|
|
20
|
+
check: (ctx) => {
|
|
21
|
+
if (!ctx.uses_unsafe_unwrap)
|
|
22
|
+
return null;
|
|
23
|
+
return { ...R_P_01.rule, evidence: "uses_unsafe_unwrap=true (no Payment match check)" };
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const R_P_02 = {
|
|
27
|
+
rule: {
|
|
28
|
+
id: "R-PAYMENT-02",
|
|
29
|
+
level: "MEDIUM",
|
|
30
|
+
category: "structural",
|
|
31
|
+
title: `MAX_RECIPIENT_COUNT=${MAX_RECIPIENT_COUNT} permissive — gas and confirmation cost`,
|
|
32
|
+
description: `A single Payment may carry up to MAX_RECIPIENT_COUNT=${MAX_RECIPIENT_COUNT} recipients ` +
|
|
33
|
+
`(payment.move:14). The limit aborts with ERECIPIENT_COUNT_EXCEEDED (1) only at the boundary. ` +
|
|
34
|
+
`200 recipients in one transaction inflates gas, slows finalization, and complicates ` +
|
|
35
|
+
`retry on partial failure.`,
|
|
36
|
+
affected_stakeholders: ["signer", "recipient"],
|
|
37
|
+
scenario: "Caller submits a Payment with 200 recipients; transaction is heavy and slow",
|
|
38
|
+
mitigation: "Business layer should self-limit recipient count (e.g. ≤50). For mass payouts, split " +
|
|
39
|
+
"across multiple Payment objects in separate transactions.",
|
|
40
|
+
related_move_error: "ERECIPIENT_COUNT_EXCEEDED (1)",
|
|
41
|
+
auto_fixable: false,
|
|
42
|
+
},
|
|
43
|
+
check: (ctx) => {
|
|
44
|
+
if (ctx.recipient_count === undefined)
|
|
45
|
+
return null;
|
|
46
|
+
if (ctx.recipient_count < MAX_RECIPIENT_COUNT)
|
|
47
|
+
return null;
|
|
48
|
+
return { ...R_P_02.rule, evidence: `recipient_count=${ctx.recipient_count}, limit=${MAX_RECIPIENT_COUNT}` };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const R_P_03 = {
|
|
52
|
+
rule: {
|
|
53
|
+
id: "R-PAYMENT-03",
|
|
54
|
+
level: "LOW",
|
|
55
|
+
category: "lifecycle",
|
|
56
|
+
title: "Payment is immutable after create — errors cannot be corrected",
|
|
57
|
+
description: "create() calls transfer::freeze_object(payment) (payment.move:160). All fields " +
|
|
58
|
+
"(amount, time, info, from_object, signer, record) are permanently fixed. There is no " +
|
|
59
|
+
"update, refund, or void API on the Payment object itself — correction requires a new " +
|
|
60
|
+
"Payment (and off-chain reconciliation).",
|
|
61
|
+
affected_stakeholders: ["signer", "consumer"],
|
|
62
|
+
scenario: "Signer mistypes a recipient address; the Payment cannot be edited post-create",
|
|
63
|
+
mitigation: "Verify all fields before calling create. For refunds, create a new Payment in the " +
|
|
64
|
+
"opposite direction. Off-chain systems should treat Payment as an immutable receipt.",
|
|
65
|
+
auto_fixable: false,
|
|
66
|
+
},
|
|
67
|
+
check: (ctx) => {
|
|
68
|
+
if (!ctx.expects_mutation)
|
|
69
|
+
return null;
|
|
70
|
+
return { ...R_P_03.rule, evidence: "expects_mutation=true (Payment is frozen at create)" };
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
const R_P_04 = {
|
|
74
|
+
rule: {
|
|
75
|
+
id: "R-PAYMENT-04",
|
|
76
|
+
level: "MEDIUM",
|
|
77
|
+
category: "structural",
|
|
78
|
+
title: "CoinWrapper suppresses coin_field lint — Balance<T> stored in a struct field",
|
|
79
|
+
description: "CoinWrapper<phantom T> stores Balance<T> directly in a struct field and uses " +
|
|
80
|
+
"#[allow(lint(coin_field))] to suppress the Wow lint (payment.move:43-48). The lint " +
|
|
81
|
+
"normally warns against storing Balance in arbitrary structs because of object " +
|
|
82
|
+
"lifecycle concerns. The suppression is intentional but should be reviewed whenever " +
|
|
83
|
+
"the Wow framework updates its coin_field rules.",
|
|
84
|
+
affected_stakeholders: ["system"],
|
|
85
|
+
scenario: "Wow framework tightens coin_field lint semantics; CoinWrapper becomes non-compliant",
|
|
86
|
+
mitigation: "Review the coin_field suppression on each Wow upgrade. Confirm that Balance<T> " +
|
|
87
|
+
"ownership transfer in unwrap/unwrap_with_check is correct.",
|
|
88
|
+
auto_fixable: false,
|
|
89
|
+
},
|
|
90
|
+
check: (ctx) => {
|
|
91
|
+
if (ctx.coin_field_lint_reviewed)
|
|
92
|
+
return null;
|
|
93
|
+
return { ...R_P_04.rule, evidence: "coin_field_lint_reviewed=false (needs review)" };
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
const R_P_05 = {
|
|
97
|
+
rule: {
|
|
98
|
+
id: "R-PAYMENT-05",
|
|
99
|
+
level: "LOW",
|
|
100
|
+
category: "semantic",
|
|
101
|
+
title: "PaymentInfo has 4 constructor variants — caller may pick the wrong one",
|
|
102
|
+
description: "PaymentInfo can be built via payment_info (for_object+remark+index), payment_info2 " +
|
|
103
|
+
"(remark+index, no for_object), payment_info_with_guard (for_object+for_guard+remark+index), " +
|
|
104
|
+
"or payment_info2_with_guard (for_guard+remark+index, no for_object). Selecting the " +
|
|
105
|
+
"wrong variant leaves for_object/for_guard as None, breaking downstream lookups.",
|
|
106
|
+
affected_stakeholders: ["signer", "consumer"],
|
|
107
|
+
scenario: "Caller uses payment_info2 when they meant payment_info_with_guard; for_object is lost",
|
|
108
|
+
mitigation: "Document each variant's use case clearly. SDK should pick the variant automatically " +
|
|
109
|
+
"based on which optional fields the caller provides.",
|
|
110
|
+
auto_fixable: true,
|
|
111
|
+
},
|
|
112
|
+
check: (ctx) => null,
|
|
113
|
+
};
|
|
114
|
+
const R_P_06 = {
|
|
115
|
+
rule: {
|
|
116
|
+
id: "R-PAYMENT-06",
|
|
117
|
+
level: "MEDIUM",
|
|
118
|
+
category: "cross_object",
|
|
119
|
+
title: "Registrar registration filters recipients by is_object_address — user addresses skipped",
|
|
120
|
+
description: "create() iterates recipients and only calls registrar.affiliation for addresses that " +
|
|
121
|
+
"pass util::is_object_address (payment.move:147-161). User addresses (EOAs) are not " +
|
|
122
|
+
"registered in the Registrar dependency graph. Callers who expect every recipient to " +
|
|
123
|
+
"appear in affiliation queries will miss EOA recipients.",
|
|
124
|
+
affected_stakeholders: ["signer", "consumer"],
|
|
125
|
+
scenario: "Caller queries Registrar for all Payment recipients; EOA recipients are missing",
|
|
126
|
+
mitigation: "Document that affiliation is registered only for object-address recipients. Off-chain " +
|
|
127
|
+
"systems should track EOA recipients via the NewPaymentEvent record, not via Registrar.",
|
|
128
|
+
auto_fixable: false,
|
|
129
|
+
},
|
|
130
|
+
check: (ctx) => {
|
|
131
|
+
if (!ctx.expects_user_recipient_registered)
|
|
132
|
+
return null;
|
|
133
|
+
return { ...R_P_06.rule, evidence: "expects_user_recipient_registered=true (EOAs are skipped)" };
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
const R_P_07 = {
|
|
137
|
+
rule: {
|
|
138
|
+
id: "R-PAYMENT-07",
|
|
139
|
+
level: "LOW",
|
|
140
|
+
category: "semantic",
|
|
141
|
+
title: "Payment.signer records payer — useful for provenance but not authorization",
|
|
142
|
+
description: "Payment.signer is set to ctx.sender() at creation (payment.move). It can be read via " +
|
|
143
|
+
"payment_signer<T>(payment) for provenance (e.g. 'who paid for this order'). It is " +
|
|
144
|
+
"purely informational — it does NOT authorize any later operation. Consumers must not " +
|
|
145
|
+
"treat signer as a permission grant.",
|
|
146
|
+
affected_stakeholders: ["consumer"],
|
|
147
|
+
scenario: "Consumer treats Payment.signer as authorizing a refund; signer is just provenance",
|
|
148
|
+
mitigation: "Use Payment.signer only for audit/provenance. Authorization must come from the " +
|
|
149
|
+
"referencing object's own Permission, not from Payment.signer.",
|
|
150
|
+
auto_fixable: false,
|
|
151
|
+
},
|
|
152
|
+
check: (ctx) => {
|
|
153
|
+
if (!ctx.uses_signer_for_provenance)
|
|
154
|
+
return null;
|
|
155
|
+
return { ...R_P_07.rule, evidence: "uses_signer_for_provenance=true (informational only)" };
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
export const PAYMENT_RISK_RULES = [
|
|
159
|
+
R_P_01,
|
|
160
|
+
R_P_02,
|
|
161
|
+
R_P_03,
|
|
162
|
+
R_P_04,
|
|
163
|
+
R_P_05,
|
|
164
|
+
R_P_06,
|
|
165
|
+
R_P_07,
|
|
166
|
+
];
|
|
167
|
+
export const PAYMENT_RISK_VERSION = "1.0.0";
|
|
168
|
+
export function checkPaymentRisks(ctx) {
|
|
169
|
+
const risks = [];
|
|
170
|
+
for (const rule of PAYMENT_RISK_RULES) {
|
|
171
|
+
const r = rule.check(ctx);
|
|
172
|
+
if (r)
|
|
173
|
+
risks.push(r);
|
|
174
|
+
}
|
|
175
|
+
if (!risks.find(r => r.id === "R-PAYMENT-05")) {
|
|
176
|
+
risks.push(R_P_05.rule);
|
|
177
|
+
}
|
|
178
|
+
return risks;
|
|
179
|
+
}
|
|
180
|
+
export function getPaymentRiskById(id) {
|
|
181
|
+
return PAYMENT_RISK_RULES.find(r => r.rule.id === id)?.rule;
|
|
182
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type PermissionRiskAssessment } from "./permission-risk.js";
|
|
2
|
+
export type ConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
|
|
3
|
+
export interface ConfirmGateResult {
|
|
4
|
+
status: ConfirmGateStatus;
|
|
5
|
+
checklist_result: ChecklistResult;
|
|
6
|
+
risk_result?: PermissionRiskAssessment;
|
|
7
|
+
user_confirmation?: UserConfirmation;
|
|
8
|
+
environment_result?: EnvironmentResult;
|
|
9
|
+
confirmation_text?: string;
|
|
10
|
+
block_reason?: string;
|
|
11
|
+
decision_record: DecisionRecord;
|
|
12
|
+
}
|
|
13
|
+
export interface ChecklistResult {
|
|
14
|
+
all_passed: boolean;
|
|
15
|
+
items: ChecklistItem[];
|
|
16
|
+
}
|
|
17
|
+
export interface ChecklistItem {
|
|
18
|
+
id: string;
|
|
19
|
+
description: string;
|
|
20
|
+
passed: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
}
|
|
23
|
+
export interface UserConfirmation {
|
|
24
|
+
questions_asked: ConfirmationQuestion[];
|
|
25
|
+
responses: ConfirmationResponse[];
|
|
26
|
+
all_confirmed: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ConfirmationQuestion {
|
|
29
|
+
id: string;
|
|
30
|
+
question: string;
|
|
31
|
+
requires_explicit_yes: boolean;
|
|
32
|
+
related_risk_ids?: string[];
|
|
33
|
+
}
|
|
34
|
+
export interface ConfirmationResponse {
|
|
35
|
+
question_id: string;
|
|
36
|
+
response: "yes" | "no" | "skip";
|
|
37
|
+
}
|
|
38
|
+
export interface EnvironmentResult {
|
|
39
|
+
passed: boolean;
|
|
40
|
+
checks: {
|
|
41
|
+
name: string;
|
|
42
|
+
passed: boolean;
|
|
43
|
+
message: string;
|
|
44
|
+
}[];
|
|
45
|
+
}
|
|
46
|
+
export interface DecisionRecord {
|
|
47
|
+
timestamp: string;
|
|
48
|
+
gate_version: string;
|
|
49
|
+
final_status: ConfirmGateStatus;
|
|
50
|
+
layers_passed: string[];
|
|
51
|
+
layers_failed: string[];
|
|
52
|
+
}
|
|
53
|
+
export interface PermissionJsonForConfirm {
|
|
54
|
+
object?: string | null;
|
|
55
|
+
description?: string;
|
|
56
|
+
admin?: {
|
|
57
|
+
op: string;
|
|
58
|
+
addresses: string[];
|
|
59
|
+
};
|
|
60
|
+
table?: {
|
|
61
|
+
op: string;
|
|
62
|
+
index: number;
|
|
63
|
+
entity: string[];
|
|
64
|
+
} | {
|
|
65
|
+
op: string;
|
|
66
|
+
entity: string;
|
|
67
|
+
index: number[];
|
|
68
|
+
};
|
|
69
|
+
entity?: {
|
|
70
|
+
op: string;
|
|
71
|
+
entity1: string;
|
|
72
|
+
entity2: string;
|
|
73
|
+
} | {
|
|
74
|
+
op: string;
|
|
75
|
+
entity: string;
|
|
76
|
+
};
|
|
77
|
+
remark?: {
|
|
78
|
+
op: string;
|
|
79
|
+
index: number;
|
|
80
|
+
remark: string;
|
|
81
|
+
} | {
|
|
82
|
+
op: string;
|
|
83
|
+
index: number;
|
|
84
|
+
} | {
|
|
85
|
+
op: string;
|
|
86
|
+
};
|
|
87
|
+
apply?: string[];
|
|
88
|
+
builder?: string;
|
|
89
|
+
um?: string | null;
|
|
90
|
+
}
|
|
91
|
+
export interface ConfirmGateInput {
|
|
92
|
+
permission_json: PermissionJsonForConfirm;
|
|
93
|
+
intent?: string;
|
|
94
|
+
target_objects_types?: string[];
|
|
95
|
+
current_admin_count?: number;
|
|
96
|
+
current_entity_count?: number;
|
|
97
|
+
skip_user_confirmation?: boolean;
|
|
98
|
+
skip_environment_check?: boolean;
|
|
99
|
+
}
|
|
100
|
+
export declare const PERMISSION_PUBLISH_CHECKLIST: ChecklistItem[];
|
|
101
|
+
export declare const PERMISSION_CONFIRMATION_QUESTIONS: ConfirmationQuestion[];
|
|
102
|
+
export declare const PERMISSION_CONFIRM_VERSION = "1.0.0";
|
|
103
|
+
export declare function runPermissionConfirmGate(input: ConfirmGateInput): ConfirmGateResult;
|
|
104
|
+
export interface ProgressiveCheckResult {
|
|
105
|
+
stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
|
|
106
|
+
status: "pass" | "fail" | "pending";
|
|
107
|
+
message: string;
|
|
108
|
+
next_action?: string;
|
|
109
|
+
}
|
|
110
|
+
export declare function progressivePermissionCheck(input: ConfirmGateInput): ProgressiveCheckResult;
|