@wowok/agent-mcp 2.4.3 → 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.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 +1392 -6
- package/dist/schema/project/index.js +426 -2
- 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 +1802 -313
- 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 +584 -70
- 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 +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 +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 +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/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 +258 -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 +55 -8
- 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,37 @@
|
|
|
1
|
+
export type ArbRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
|
|
2
|
+
export type ArbRiskCategory = "structural" | "lifecycle" | "semantic" | "permission" | "knowledge";
|
|
3
|
+
export type ArbStakeholder = "principal" | "arbitrator" | "voter" | "system";
|
|
4
|
+
export interface ArbRisk {
|
|
5
|
+
id: string;
|
|
6
|
+
level: ArbRiskLevel;
|
|
7
|
+
category: ArbRiskCategory;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
affected_stakeholders: ArbStakeholder[];
|
|
11
|
+
scenario: string;
|
|
12
|
+
mitigation: string;
|
|
13
|
+
evidence?: string;
|
|
14
|
+
related_move_error?: string;
|
|
15
|
+
auto_fixable: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ArbRiskCheckContext {
|
|
18
|
+
status?: number;
|
|
19
|
+
invalid_transition?: boolean;
|
|
20
|
+
withdraw_too_early?: boolean;
|
|
21
|
+
proposition_count?: number;
|
|
22
|
+
votor_count?: number;
|
|
23
|
+
voting_deadline_none?: boolean;
|
|
24
|
+
expects_proposition_event?: boolean;
|
|
25
|
+
indemnity_none?: boolean;
|
|
26
|
+
weight_concentrated?: boolean;
|
|
27
|
+
expects_status_enum?: boolean;
|
|
28
|
+
order_mismatch?: boolean;
|
|
29
|
+
constants_synced?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare const ARB_RISK_RULES: {
|
|
32
|
+
rule: ArbRisk;
|
|
33
|
+
check: (ctx: ArbRiskCheckContext) => ArbRisk | null;
|
|
34
|
+
}[];
|
|
35
|
+
export declare const ARB_RISK_VERSION = "1.0.0";
|
|
36
|
+
export declare function checkArbRisks(ctx: ArbRiskCheckContext): ArbRisk[];
|
|
37
|
+
export declare function getArbRiskById(id: string): ArbRisk | undefined;
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { MAX_VOTOR_COUNT, WITHDRAW_DURATION_TIME, } from "@wowok/wowok";
|
|
2
|
+
const R_A_01 = {
|
|
3
|
+
rule: {
|
|
4
|
+
id: "R-ARB-01",
|
|
5
|
+
level: "HIGH",
|
|
6
|
+
category: "lifecycle",
|
|
7
|
+
title: "7-state machine — invalid transitions can deadlock the arbitration",
|
|
8
|
+
description: "Arb has a 7-state machine: Principal_confirming(0) → Arbitrator_confirming(1) → " +
|
|
9
|
+
"Voting(2) → Arbitrated(3) → Objectionable(4) → Finished(5) → Withdrawn(6). reset() " +
|
|
10
|
+
"can revert from {1, 4} back to 0. Each op asserts the current status; calling an op " +
|
|
11
|
+
"out of order aborts with E_STATUS_NOT_MATCH (3). Repeated mis-calls leave the Arb " +
|
|
12
|
+
"stuck in a non-terminal state with no automatic recovery.",
|
|
13
|
+
affected_stakeholders: ["principal", "arbitrator", "voter"],
|
|
14
|
+
scenario: "Caller calls vote() when status is still Arbitrator_confirming; abort blocks progress",
|
|
15
|
+
mitigation: "Strictly validate the current status before submitting any Arb op. The SDK should " +
|
|
16
|
+
"expose a status-aware state machine helper. Provide a recovery path (reset) for " +
|
|
17
|
+
"Arbitrator_confirming and Objectionable states.",
|
|
18
|
+
related_move_error: "E_STATUS_NOT_MATCH (3)",
|
|
19
|
+
auto_fixable: false,
|
|
20
|
+
},
|
|
21
|
+
check: (ctx) => {
|
|
22
|
+
if (!ctx.invalid_transition)
|
|
23
|
+
return null;
|
|
24
|
+
return { ...R_A_01.rule, evidence: `invalid_transition=true (status=${ctx.status ?? "?"})` };
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const R_A_02 = {
|
|
28
|
+
rule: {
|
|
29
|
+
id: "R-ARB-02",
|
|
30
|
+
level: "MEDIUM",
|
|
31
|
+
category: "lifecycle",
|
|
32
|
+
title: `WITHDRAW_DURATION_TIME=${WITHDRAW_DURATION_TIME}ms (30 days) — funds locked`,
|
|
33
|
+
description: `After arbitration, the fee Balance can only be withdrawn after ` +
|
|
34
|
+
`WITHDRAW_DURATION_TIME=${WITHDRAW_DURATION_TIME}ms (30 days) when status is ` +
|
|
35
|
+
`Arbitrated(3) or Objectionable(4). From Finished(5), withdraw is immediate. ` +
|
|
36
|
+
`The 30-day lock is a dispute-window safeguard, but it locks funds for a long time ` +
|
|
37
|
+
`and users may not understand why.`,
|
|
38
|
+
affected_stakeholders: ["principal", "arbitrator"],
|
|
39
|
+
scenario: "Arbitrator finishes a case but must wait 30 days to claim the fee",
|
|
40
|
+
mitigation: "Surface the unlock timestamp in the UI. To shorten the lock, drive the case to " +
|
|
41
|
+
"Finished(5) via finish() rather than leaving it in Arbitrated/Objectionable.",
|
|
42
|
+
related_move_error: "E_WITHDRAW_DURATION_TIME_NOT_PASSED (8)",
|
|
43
|
+
auto_fixable: false,
|
|
44
|
+
},
|
|
45
|
+
check: (ctx) => {
|
|
46
|
+
if (!ctx.withdraw_too_early)
|
|
47
|
+
return null;
|
|
48
|
+
return { ...R_A_02.rule, evidence: `withdraw_too_early=true (limit=${WITHDRAW_DURATION_TIME}ms)` };
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
const R_A_03 = {
|
|
52
|
+
rule: {
|
|
53
|
+
id: "R-ARB-03",
|
|
54
|
+
level: "MEDIUM",
|
|
55
|
+
category: "structural",
|
|
56
|
+
title: `MAX_VOTOR_COUNT=${MAX_VOTOR_COUNT} permissive — voting efficiency cost`,
|
|
57
|
+
description: `A single Arb may record up to MAX_VOTOR_COUNT=${MAX_VOTOR_COUNT} voters (arb.move:236). ` +
|
|
58
|
+
`The limit aborts with E_MAX_VOTOR_COUNT (6) only at the boundary. 520 voters in one ` +
|
|
59
|
+
`Arb inflates the voted vector, slowing tally and gas, and complicates weighted-quorum ` +
|
|
60
|
+
`reasoning.`,
|
|
61
|
+
affected_stakeholders: ["voter", "arbitrator"],
|
|
62
|
+
scenario: "Arbitration allows 520 voters; tallying the vote vector is slow and gas-heavy",
|
|
63
|
+
mitigation: "Business layer should self-limit voter count based on the Arbitration rule's quorum. " +
|
|
64
|
+
"For large juries, shard across multiple Arb instances or aggregate off-chain.",
|
|
65
|
+
related_move_error: "E_MAX_VOTOR_COUNT (6)",
|
|
66
|
+
auto_fixable: false,
|
|
67
|
+
},
|
|
68
|
+
check: (ctx) => {
|
|
69
|
+
if (ctx.votor_count === undefined)
|
|
70
|
+
return null;
|
|
71
|
+
if (ctx.votor_count < MAX_VOTOR_COUNT)
|
|
72
|
+
return null;
|
|
73
|
+
return { ...R_A_03.rule, evidence: `votor_count=${ctx.votor_count}, limit=${MAX_VOTOR_COUNT}` };
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
const R_A_04 = {
|
|
77
|
+
rule: {
|
|
78
|
+
id: "R-ARB-04",
|
|
79
|
+
level: "LOW",
|
|
80
|
+
category: "semantic",
|
|
81
|
+
title: "proposition_change may not emit a discrete event — indexers must infer",
|
|
82
|
+
description: "proposition_change (arb.move) updates the proposition vector in place. Unlike " +
|
|
83
|
+
"state transitions (which emit ArbEvent), proposition edits may not produce a " +
|
|
84
|
+
"discrete event — indexers must infer changes by diffing the proposition vector " +
|
|
85
|
+
"across polls.",
|
|
86
|
+
affected_stakeholders: ["arbitrator", "voter"],
|
|
87
|
+
scenario: "Indexer expects a PropositionChangedEvent; none is emitted, UI fails to refresh",
|
|
88
|
+
mitigation: "External indexers should poll the proposition vector. UI should display 'propositions " +
|
|
89
|
+
"may have changed' on each poll rather than relying on event-driven refresh.",
|
|
90
|
+
auto_fixable: false,
|
|
91
|
+
},
|
|
92
|
+
check: (ctx) => {
|
|
93
|
+
if (!ctx.expects_proposition_event)
|
|
94
|
+
return null;
|
|
95
|
+
return { ...R_A_04.rule, evidence: "expects_proposition_event=true (poll instead)" };
|
|
96
|
+
},
|
|
97
|
+
};
|
|
98
|
+
const R_A_05 = {
|
|
99
|
+
rule: {
|
|
100
|
+
id: "R-ARB-05",
|
|
101
|
+
level: "MEDIUM",
|
|
102
|
+
category: "semantic",
|
|
103
|
+
title: "voting_deadline is Option<u64> — None means open-ended vote",
|
|
104
|
+
description: "voting_deadline is Option<u64>. When None, voting has no deadline (open-ended) and " +
|
|
105
|
+
"E_VOTING_DEADLINE_PASSED (7) never triggers. When Some(t), vote() aborts if " +
|
|
106
|
+
"clock.timestamp_ms() > t. Callers who assume a default deadline may be surprised by " +
|
|
107
|
+
"an open-ended vote that never finalizes.",
|
|
108
|
+
affected_stakeholders: ["voter", "arbitrator"],
|
|
109
|
+
scenario: "Voter assumes a deadline; voting_deadline is None and the case stalls indefinitely",
|
|
110
|
+
mitigation: "Document that None means open-ended. Arbitrators should set an explicit deadline via " +
|
|
111
|
+
"arbitrator_confirm unless they intend an open vote. SDK should surface voting_deadline " +
|
|
112
|
+
"prominently.",
|
|
113
|
+
related_move_error: "E_VOTING_DEADLINE_PASSED (7) / E_VOTING_DEADLINE_NOT_PASSED (4)",
|
|
114
|
+
auto_fixable: false,
|
|
115
|
+
},
|
|
116
|
+
check: (ctx) => {
|
|
117
|
+
if (!ctx.voting_deadline_none)
|
|
118
|
+
return null;
|
|
119
|
+
return { ...R_A_05.rule, evidence: "voting_deadline_none=true (open-ended vote)" };
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
const R_A_06 = {
|
|
123
|
+
rule: {
|
|
124
|
+
id: "R-ARB-06",
|
|
125
|
+
level: "LOW",
|
|
126
|
+
category: "semantic",
|
|
127
|
+
title: "indemnity is Option<Indemnity> — None means no compensation",
|
|
128
|
+
description: "indemnity is Option<Indemnity>. When None, the arbitration produces no compensation " +
|
|
129
|
+
"(e.g. a pure declaratory ruling). Consumers who assume a non-null indemnity will " +
|
|
130
|
+
"mis-handle None cases. finish() returns the indemnity amount (0 when None).",
|
|
131
|
+
affected_stakeholders: ["principal"],
|
|
132
|
+
scenario: "Principal expects compensation; indemnity is None and finish() returns 0",
|
|
133
|
+
mitigation: "Document that None means no compensation. UI should show 'no compensation awarded' " +
|
|
134
|
+
"rather than 'compensation pending'.",
|
|
135
|
+
auto_fixable: false,
|
|
136
|
+
},
|
|
137
|
+
check: (ctx) => {
|
|
138
|
+
if (!ctx.indemnity_none)
|
|
139
|
+
return null;
|
|
140
|
+
return { ...R_A_06.rule, evidence: "indemnity_none=true (no compensation)" };
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
const R_A_07 = {
|
|
144
|
+
rule: {
|
|
145
|
+
id: "R-ARB-07",
|
|
146
|
+
level: "MEDIUM",
|
|
147
|
+
category: "permission",
|
|
148
|
+
title: "Voted.weight is set by the Arbitration rule — concentrated weight risk",
|
|
149
|
+
description: "Voted.weight (u32) is assigned by the Arbitration object's voting_guard logic, not " +
|
|
150
|
+
"by the voter. If the Arbitration rule concentrates weight in one voter (e.g. an " +
|
|
151
|
+
"admin with weight 1000 vs. others with weight 1), a single voter can dictate the " +
|
|
152
|
+
"outcome. The Arb contract itself does not detect concentration — that is the " +
|
|
153
|
+
"Arbitration designer's responsibility.",
|
|
154
|
+
affected_stakeholders: ["voter", "arbitrator"],
|
|
155
|
+
scenario: "Arbitration rule gives one voter weight 1000; that voter single-handedly decides the case",
|
|
156
|
+
mitigation: "When designing the Arbitration rule, cap individual voter weight and require a " +
|
|
157
|
+
"quorum. Audit the voting_guard to ensure no single voter can exceed the quorum alone.",
|
|
158
|
+
auto_fixable: false,
|
|
159
|
+
},
|
|
160
|
+
check: (ctx) => {
|
|
161
|
+
if (!ctx.weight_concentrated)
|
|
162
|
+
return null;
|
|
163
|
+
return { ...R_A_07.rule, evidence: "weight_concentrated=true (rule-level risk)" };
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
const R_A_08 = {
|
|
167
|
+
rule: {
|
|
168
|
+
id: "R-ARB-08",
|
|
169
|
+
level: "LOW",
|
|
170
|
+
category: "semantic",
|
|
171
|
+
title: "Status uses u8 constants — Move enum is commented out",
|
|
172
|
+
description: "The 7 statuses are defined as u8 constants (Status_Principal_confirming=0, etc.). " +
|
|
173
|
+
"The Move enum definition is commented out (arb.move). Consumers cannot rely on a " +
|
|
174
|
+
"type-safe enum and must compare against magic numbers. A future Wow release enabling " +
|
|
175
|
+
"the enum would be a breaking change to downstream code.",
|
|
176
|
+
affected_stakeholders: ["system"],
|
|
177
|
+
scenario: "Developer expects a Status enum; only u8 constants are available, causing type errors",
|
|
178
|
+
mitigation: "SDK should expose a TypeScript enum mirroring the u8 constants. Document that the " +
|
|
179
|
+
"Move enum is intentionally disabled and may be enabled in a future version.",
|
|
180
|
+
auto_fixable: false,
|
|
181
|
+
},
|
|
182
|
+
check: (ctx) => {
|
|
183
|
+
if (!ctx.expects_status_enum)
|
|
184
|
+
return null;
|
|
185
|
+
return { ...R_A_08.rule, evidence: "expects_status_enum=true (only u8 constants exist)" };
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
export const ARB_RISK_RULES = [
|
|
189
|
+
R_A_01,
|
|
190
|
+
R_A_02,
|
|
191
|
+
R_A_03,
|
|
192
|
+
R_A_04,
|
|
193
|
+
R_A_05,
|
|
194
|
+
R_A_06,
|
|
195
|
+
R_A_07,
|
|
196
|
+
R_A_08,
|
|
197
|
+
];
|
|
198
|
+
export const ARB_RISK_VERSION = "1.0.0";
|
|
199
|
+
export function checkArbRisks(ctx) {
|
|
200
|
+
const risks = [];
|
|
201
|
+
for (const rule of ARB_RISK_RULES) {
|
|
202
|
+
const r = rule.check(ctx);
|
|
203
|
+
if (r)
|
|
204
|
+
risks.push(r);
|
|
205
|
+
}
|
|
206
|
+
return risks;
|
|
207
|
+
}
|
|
208
|
+
export function getArbRiskById(id) {
|
|
209
|
+
return ARB_RISK_RULES.find(r => r.rule.id === id)?.rule;
|
|
210
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { type ArbStatus } from "./arbitration-ledger.js";
|
|
2
|
+
import { type ArbitrationRiskAssessment } from "./arbitration-risk.js";
|
|
3
|
+
export type ConfirmGateStatus = "approved" | "blocked_checklist" | "blocked_risk" | "blocked_user" | "blocked_environment";
|
|
4
|
+
export interface ConfirmGateResult {
|
|
5
|
+
status: ConfirmGateStatus;
|
|
6
|
+
checklist_result: ChecklistResult;
|
|
7
|
+
risk_result?: ArbitrationRiskAssessment;
|
|
8
|
+
user_confirmation?: UserConfirmation;
|
|
9
|
+
environment_result?: EnvironmentResult;
|
|
10
|
+
confirmation_text?: string;
|
|
11
|
+
block_reason?: string;
|
|
12
|
+
decision_record: DecisionRecord;
|
|
13
|
+
}
|
|
14
|
+
export interface ChecklistResult {
|
|
15
|
+
all_passed: boolean;
|
|
16
|
+
items: ChecklistItem[];
|
|
17
|
+
}
|
|
18
|
+
export interface ChecklistItem {
|
|
19
|
+
id: string;
|
|
20
|
+
description: string;
|
|
21
|
+
passed: boolean;
|
|
22
|
+
message: string;
|
|
23
|
+
}
|
|
24
|
+
export interface UserConfirmation {
|
|
25
|
+
questions_asked: ConfirmationQuestion[];
|
|
26
|
+
responses: ConfirmationResponse[];
|
|
27
|
+
all_confirmed: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface ConfirmationQuestion {
|
|
30
|
+
id: string;
|
|
31
|
+
question: string;
|
|
32
|
+
requires_explicit_yes: boolean;
|
|
33
|
+
related_risk_ids?: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface ConfirmationResponse {
|
|
36
|
+
question_id: string;
|
|
37
|
+
response: "yes" | "no" | "skip";
|
|
38
|
+
}
|
|
39
|
+
export interface EnvironmentResult {
|
|
40
|
+
passed: boolean;
|
|
41
|
+
checks: {
|
|
42
|
+
name: string;
|
|
43
|
+
passed: boolean;
|
|
44
|
+
message: string;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
export interface DecisionRecord {
|
|
48
|
+
timestamp: string;
|
|
49
|
+
gate_version: string;
|
|
50
|
+
final_status: ConfirmGateStatus;
|
|
51
|
+
layers_passed: string[];
|
|
52
|
+
layers_failed: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface ArbitrationJsonForConfirm {
|
|
55
|
+
object?: string | null | object;
|
|
56
|
+
description?: string;
|
|
57
|
+
location?: string;
|
|
58
|
+
fee?: string | number;
|
|
59
|
+
pause?: boolean;
|
|
60
|
+
dispute?: {
|
|
61
|
+
order: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
proposition: string[];
|
|
64
|
+
fee?: unknown;
|
|
65
|
+
};
|
|
66
|
+
confirm?: {
|
|
67
|
+
arb: string;
|
|
68
|
+
voting_deadline: number | null;
|
|
69
|
+
};
|
|
70
|
+
voting_deadline_change?: {
|
|
71
|
+
arb: string;
|
|
72
|
+
voting_deadline: number | null;
|
|
73
|
+
};
|
|
74
|
+
vote?: {
|
|
75
|
+
arb: string;
|
|
76
|
+
votes: number[];
|
|
77
|
+
voting_guard?: string;
|
|
78
|
+
};
|
|
79
|
+
feedback?: {
|
|
80
|
+
arb: string;
|
|
81
|
+
feedback: string;
|
|
82
|
+
};
|
|
83
|
+
arbitration?: {
|
|
84
|
+
arb: string;
|
|
85
|
+
feedback: string;
|
|
86
|
+
indemnity: number;
|
|
87
|
+
};
|
|
88
|
+
reset?: {
|
|
89
|
+
arb: string;
|
|
90
|
+
feedback: string;
|
|
91
|
+
};
|
|
92
|
+
arb_withdraw?: {
|
|
93
|
+
arb: string;
|
|
94
|
+
};
|
|
95
|
+
fees_transfer?: {
|
|
96
|
+
to: {
|
|
97
|
+
allocation?: string;
|
|
98
|
+
treasury?: string;
|
|
99
|
+
};
|
|
100
|
+
payment_remark: string;
|
|
101
|
+
payment_index: number;
|
|
102
|
+
};
|
|
103
|
+
usage_guard?: string | null;
|
|
104
|
+
voting_guard?: {
|
|
105
|
+
op: string;
|
|
106
|
+
guards?: unknown[];
|
|
107
|
+
};
|
|
108
|
+
um?: string | null;
|
|
109
|
+
builder?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface ConfirmGateInput {
|
|
112
|
+
arbitration_json: ArbitrationJsonForConfirm;
|
|
113
|
+
intent?: string;
|
|
114
|
+
current_arb_status?: ArbStatus;
|
|
115
|
+
expected_arb_status?: ArbStatus;
|
|
116
|
+
current_voting_guard_count?: number;
|
|
117
|
+
current_voting_guard_addresses?: string[];
|
|
118
|
+
current_arbitration_fee?: string | number;
|
|
119
|
+
current_bPaused?: boolean;
|
|
120
|
+
current_timestamp_ms?: number;
|
|
121
|
+
target_objects_types?: string[];
|
|
122
|
+
skip_user_confirmation?: boolean;
|
|
123
|
+
skip_environment_check?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export declare const ARBITRATION_OPERATION_CHECKLIST: ChecklistItem[];
|
|
126
|
+
export declare const ARBITRATION_CONFIRMATION_QUESTIONS: ConfirmationQuestion[];
|
|
127
|
+
export declare const ARBITRATION_CONFIRM_VERSION = "1.0.0";
|
|
128
|
+
export declare function runArbitrationConfirmGate(input: ConfirmGateInput): ConfirmGateResult;
|
|
129
|
+
export interface ProgressiveCheckResult {
|
|
130
|
+
stage: "checklist" | "risk" | "confirmation" | "environment" | "complete";
|
|
131
|
+
status: "pass" | "fail" | "pending";
|
|
132
|
+
message: string;
|
|
133
|
+
next_action?: string;
|
|
134
|
+
}
|
|
135
|
+
export declare function progressiveArbitrationCheck(input: ConfirmGateInput): ProgressiveCheckResult;
|