@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,312 @@
|
|
|
1
|
+
import { MAX_POLICY_COUNT, MAX_POLICY_GUARD_COUNT, MAX_DATA_SIZE, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT, } from "@wowok/wowok";
|
|
2
|
+
function normalizeIdFrom(v) {
|
|
3
|
+
if (typeof v === "number")
|
|
4
|
+
return v;
|
|
5
|
+
const lower = String(v).toLowerCase();
|
|
6
|
+
if (lower === "none")
|
|
7
|
+
return 0;
|
|
8
|
+
if (lower === "clock")
|
|
9
|
+
return 1;
|
|
10
|
+
if (lower === "signer")
|
|
11
|
+
return 2;
|
|
12
|
+
const parsed = Number(v);
|
|
13
|
+
return Number.isNaN(parsed) ? -1 : parsed;
|
|
14
|
+
}
|
|
15
|
+
const R_REP_1_01 = {
|
|
16
|
+
rule: {
|
|
17
|
+
id: "R-REP-01",
|
|
18
|
+
level: "MEDIUM",
|
|
19
|
+
category: "structural",
|
|
20
|
+
title: `Policy count exceeds MAX_POLICY_COUNT (${MAX_POLICY_COUNT})`,
|
|
21
|
+
description: `A single Repository may hold up to MAX_POLICY_COUNT=${MAX_POLICY_COUNT} policies (Move source: repository.move:22). ` +
|
|
22
|
+
`Exceeding this limit aborts with E_POLICY_COUNT_EXCEEDED (3) in policy_add_imp(). Each policy defines a named ` +
|
|
23
|
+
`data slot with its own write_guard list and id_from routing — having too many policies makes the Repository ` +
|
|
24
|
+
`hard to audit and increases gas cost for policy lookups (O(n) scan in policy_by_name).`,
|
|
25
|
+
affected_stakeholders: ["creator"],
|
|
26
|
+
scenario: "Caller adds 51 policies to a single Repository",
|
|
27
|
+
mitigation: "Consolidate related data under fewer policies. If truly needed, split data across multiple Repository " +
|
|
28
|
+
"objects and reference them via Service.repository or Progress.context_repositories.",
|
|
29
|
+
related_move_error: "E_POLICY_COUNT_EXCEEDED (3)",
|
|
30
|
+
auto_fixable: false,
|
|
31
|
+
},
|
|
32
|
+
check: (ctx) => {
|
|
33
|
+
if (!ctx.policies || ctx.existing_policy_count === undefined)
|
|
34
|
+
return null;
|
|
35
|
+
const total = ctx.existing_policy_count + ctx.policies.length;
|
|
36
|
+
if (total <= MAX_POLICY_COUNT)
|
|
37
|
+
return null;
|
|
38
|
+
return { ...R_REP_1_01.rule, evidence: `existing=${ctx.existing_policy_count}, adding=${ctx.policies.length}, total=${total}, limit=${MAX_POLICY_COUNT}` };
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
const R_REP_2_01 = {
|
|
42
|
+
rule: {
|
|
43
|
+
id: "R-REP-02",
|
|
44
|
+
level: "HIGH",
|
|
45
|
+
category: "policy",
|
|
46
|
+
title: `write_guard empty when id_from=None — unauthorized writes (R-D-1 Move assert)`,
|
|
47
|
+
description: "When id_from is None, the data ID must be provided by the caller (via id_data_with_passport or " +
|
|
48
|
+
"id_data_mixed_with_passport). Without a write_guard, ANY address can write data with any ID — this " +
|
|
49
|
+
"is almost certainly a misconfiguration. The Move contract now enforces this via " +
|
|
50
|
+
"E_POLICY_WRITE_GUARD_REQUIRED (22) in policy_add_imp() [R-D-1=A].",
|
|
51
|
+
affected_stakeholders: ["creator", "writer"],
|
|
52
|
+
scenario: "Caller creates a policy with id_from=None and empty write_guard list",
|
|
53
|
+
mitigation: "When id_from=None, provide at least one PolicyGuard entry in write_guard. If you want unrestricted " +
|
|
54
|
+
"writes, use id_from=Clock or id_from=Signer instead (which auto-generates the ID and requires empty write_guard).",
|
|
55
|
+
related_move_error: "E_POLICY_WRITE_GUARD_REQUIRED (22)",
|
|
56
|
+
auto_fixable: false,
|
|
57
|
+
},
|
|
58
|
+
check: (ctx) => {
|
|
59
|
+
if (!ctx.policies)
|
|
60
|
+
return null;
|
|
61
|
+
const offenders = ctx.policies.filter(p => normalizeIdFrom(p.id_from) === 0 && p.write_guard_count === 0);
|
|
62
|
+
if (offenders.length === 0)
|
|
63
|
+
return null;
|
|
64
|
+
return {
|
|
65
|
+
...R_REP_2_01.rule,
|
|
66
|
+
evidence: `policies with id_from=None + empty write_guard: ${offenders.map(p => p.name).join(", ")}`,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const R_REP_2_02 = {
|
|
71
|
+
rule: {
|
|
72
|
+
id: "R-REP-03",
|
|
73
|
+
level: "HIGH",
|
|
74
|
+
category: "policy",
|
|
75
|
+
title: `id_from_submission set when id_from=Clock/Signer — id routing conflict (R-D-1 Move assert)`,
|
|
76
|
+
description: "When id_from is Clock or Signer, the data ID is auto-generated (timestamp or signer address). " +
|
|
77
|
+
"A PolicyGuard with id_from_submission set would try to route the id from a Passport submission, " +
|
|
78
|
+
"conflicting with the auto-generated id_from path. The Move contract enforces that id_from_submission " +
|
|
79
|
+
"MUST be None for every PolicyGuard when id_from is Clock/Signer (data_from_submission is still " +
|
|
80
|
+
"allowed — it is used by data_when_id_from_set_with_passport to extract data from the submission). " +
|
|
81
|
+
"Violations abort with E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN (23) in policy_add_imp() [R-D-1=A, refined].",
|
|
82
|
+
affected_stakeholders: ["creator", "writer"],
|
|
83
|
+
scenario: "Caller creates a policy with id_from=Clock and a write_guard entry whose id_from_submission is set",
|
|
84
|
+
mitigation: "When id_from=Clock or Signer, ensure every PolicyGuard has id_from_submission=null. " +
|
|
85
|
+
"data_from_submission may still be set if you want the guard to supply the data payload " +
|
|
86
|
+
"(routed via data_when_id_from_set_with_passport). If you need submission-derived ids, " +
|
|
87
|
+
"switch to id_from=None and set id_from_submission on the guard.",
|
|
88
|
+
related_move_error: "E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN (23)",
|
|
89
|
+
auto_fixable: false,
|
|
90
|
+
},
|
|
91
|
+
check: (ctx) => {
|
|
92
|
+
if (!ctx.policies)
|
|
93
|
+
return null;
|
|
94
|
+
const offenders = ctx.policies.filter(p => {
|
|
95
|
+
const idFrom = normalizeIdFrom(p.id_from);
|
|
96
|
+
return (idFrom === 1 || idFrom === 2) && p.has_id_from_submission;
|
|
97
|
+
});
|
|
98
|
+
if (offenders.length === 0)
|
|
99
|
+
return null;
|
|
100
|
+
return {
|
|
101
|
+
...R_REP_2_02.rule,
|
|
102
|
+
evidence: `policies with id_from=Clock/Signer + id_from_submission set: ${offenders.map(p => `${p.name}(id_from=${p.id_from})`).join(", ")}`,
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
const R_REP_1_02 = {
|
|
107
|
+
rule: {
|
|
108
|
+
id: "R-REP-04",
|
|
109
|
+
level: "MEDIUM",
|
|
110
|
+
category: "structural",
|
|
111
|
+
title: `Policy write_guard count exceeds MAX_POLICY_GUARD_COUNT (${MAX_POLICY_GUARD_COUNT})`,
|
|
112
|
+
description: `Each policy may define up to MAX_POLICY_GUARD_COUNT=${MAX_POLICY_GUARD_COUNT} guard entries in its write_guard list ` +
|
|
113
|
+
`(Move source: repository.move:23). Exceeding this limit aborts with E_POLICY_GUARD_COUNT_EXCEEDED (2). ` +
|
|
114
|
+
`Each entry maps to a Guard object that must be verified via Passport submission, so more guards = ` +
|
|
115
|
+
`more complex write authorization semantics.`,
|
|
116
|
+
affected_stakeholders: ["creator"],
|
|
117
|
+
scenario: "Caller creates a policy with 11 guard entries in write_guard",
|
|
118
|
+
mitigation: "Consolidate guard logic. If multiple guards must verify the same data, consider composing them into a " +
|
|
119
|
+
"single Guard with relies/rep fields, or split the data across multiple policies with fewer guards each.",
|
|
120
|
+
related_move_error: "E_POLICY_GUARD_COUNT_EXCEEDED (2)",
|
|
121
|
+
auto_fixable: false,
|
|
122
|
+
},
|
|
123
|
+
check: (ctx) => {
|
|
124
|
+
if (!ctx.policies)
|
|
125
|
+
return null;
|
|
126
|
+
const offenders = ctx.policies.filter(p => p.write_guard_count > MAX_POLICY_GUARD_COUNT);
|
|
127
|
+
if (offenders.length === 0)
|
|
128
|
+
return null;
|
|
129
|
+
return {
|
|
130
|
+
...R_REP_1_02.rule,
|
|
131
|
+
evidence: `policies exceeding guard count: ${offenders.map(p => `${p.name}(${p.write_guard_count})`).join(", ")}`,
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const R_REP_1_03 = {
|
|
136
|
+
rule: {
|
|
137
|
+
id: "R-REP-05",
|
|
138
|
+
level: "MEDIUM",
|
|
139
|
+
category: "structural",
|
|
140
|
+
title: `Data value exceeds MAX_DATA_SIZE (${MAX_DATA_SIZE} bytes)`,
|
|
141
|
+
description: `A single Repository data value must be ≤ MAX_DATA_SIZE=${MAX_DATA_SIZE} bytes (Move source: repository.move:24). ` +
|
|
142
|
+
`Exceeding this limit aborts with E_DATA_EXCEEDED (4). The value is stored as a BCS-serialized vector<u8> ` +
|
|
143
|
+
`with a type-tag prefix byte. Large data should be stored off-chain (e.g. IPFS, Walrus) and referenced ` +
|
|
144
|
+
`by hash/address, NOT inlined into the Repository data value.`,
|
|
145
|
+
affected_stakeholders: ["writer"],
|
|
146
|
+
scenario: "Caller writes a 50KB JSON blob as a Repository data value",
|
|
147
|
+
mitigation: "Store large payloads off-chain and write only the content hash (32-64 bytes) to the Repository. " +
|
|
148
|
+
"Use about_address on a Proof object to bind the off-chain data to an on-chain attestation.",
|
|
149
|
+
related_move_error: "E_DATA_EXCEEDED (4)",
|
|
150
|
+
auto_fixable: false,
|
|
151
|
+
},
|
|
152
|
+
check: (ctx) => {
|
|
153
|
+
if (ctx.data_size === undefined)
|
|
154
|
+
return null;
|
|
155
|
+
if (ctx.data_size <= MAX_DATA_SIZE)
|
|
156
|
+
return null;
|
|
157
|
+
return { ...R_REP_1_03.rule, evidence: `data_size=${ctx.data_size}, limit=${MAX_DATA_SIZE}` };
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
const R_REP_3_01 = {
|
|
161
|
+
rule: {
|
|
162
|
+
id: "R-REP-06",
|
|
163
|
+
level: "LOW",
|
|
164
|
+
category: "routing",
|
|
165
|
+
title: `Policy has data_from_submission but no id_from_submission — verify Mode 5 routing intent`,
|
|
166
|
+
description: "When a PolicyGuard has data_from_submission set (data comes from Passport submission) but no " +
|
|
167
|
+
"id_from_submission (id comes from caller), the SDK routes to id_data_mixed_with_passport (Mode 5). " +
|
|
168
|
+
"This is a valid but advanced pattern — ensure the caller provides matching id vectors. The SDK " +
|
|
169
|
+
"hasSubmissionSettings helper now correctly detects this case [P1-1 fix, R-D-3=A].",
|
|
170
|
+
affected_stakeholders: ["creator", "writer"],
|
|
171
|
+
scenario: "Policy has a guard with data_from_submission=2, id_from_submission=undefined",
|
|
172
|
+
mitigation: "Document the expected caller input shape. Ensure the caller provides both the id vector (positional) " +
|
|
173
|
+
"and the Passport submission (for data). Verify routing via the SDK hasSubmissionSettings helper.",
|
|
174
|
+
auto_fixable: false,
|
|
175
|
+
},
|
|
176
|
+
check: (ctx) => {
|
|
177
|
+
if (!ctx.policies)
|
|
178
|
+
return null;
|
|
179
|
+
const offenders = ctx.policies.filter(p => p.has_data_from_submission && !p.has_id_from_submission);
|
|
180
|
+
if (offenders.length === 0)
|
|
181
|
+
return null;
|
|
182
|
+
return {
|
|
183
|
+
...R_REP_3_01.rule,
|
|
184
|
+
evidence: `policies with data_from_submission but no id_from_submission: ${offenders.map(p => p.name).join(", ")}`,
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
};
|
|
188
|
+
const R_REP_4_01 = {
|
|
189
|
+
rule: {
|
|
190
|
+
id: "R-REP-07",
|
|
191
|
+
level: "HIGH",
|
|
192
|
+
category: "submission",
|
|
193
|
+
title: `data_from_submission set on a policy used in id_data_remove_with_passport — Move will abort (R-D-2)`,
|
|
194
|
+
description: "id_data_remove_with_passport only removes data identified by the caller-provided id vector; it " +
|
|
195
|
+
"cannot consume Passport submissions for either id or data. The Move contract now enforces that BOTH " +
|
|
196
|
+
"id_from_submission AND data_from_submission MUST be None for this entry point [R-D-2=A], aborting " +
|
|
197
|
+
"with E_GUARD_SPECIFIED_ID_FROM_SUBMISSION (11). Previously, only id_from_submission was checked, " +
|
|
198
|
+
"allowing data_from_submission to be silently ignored — masking a routing bug.",
|
|
199
|
+
affected_stakeholders: ["writer", "verifier"],
|
|
200
|
+
scenario: "Caller uses id_data_remove_with_passport on a policy whose guard has data_from_submission=2",
|
|
201
|
+
mitigation: "For data removal via Passport, use id_data_mixed_remove_with_passport instead (which requires " +
|
|
202
|
+
"id_from_submission and derives the id from the submission). Do not set data_from_submission on " +
|
|
203
|
+
"policies intended for id_data_remove_with_passport.",
|
|
204
|
+
related_move_error: "E_GUARD_SPECIFIED_ID_FROM_SUBMISSION (11)",
|
|
205
|
+
auto_fixable: false,
|
|
206
|
+
},
|
|
207
|
+
check: (ctx) => {
|
|
208
|
+
if (!ctx.is_data_remove_with_passport || !ctx.policies)
|
|
209
|
+
return null;
|
|
210
|
+
const offenders = ctx.policies.filter(p => p.has_data_from_submission);
|
|
211
|
+
if (offenders.length === 0)
|
|
212
|
+
return null;
|
|
213
|
+
return {
|
|
214
|
+
...R_REP_4_01.rule,
|
|
215
|
+
evidence: `policies with data_from_submission used in id_data_remove_with_passport: ${offenders.map(p => p.name).join(", ")}`,
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
const R_REP_1_04 = {
|
|
220
|
+
rule: {
|
|
221
|
+
id: "R-REP-08",
|
|
222
|
+
level: "LOW",
|
|
223
|
+
category: "structural",
|
|
224
|
+
title: `ID count per single op exceeds MAX_ID_COUNT_ONCE (${MAX_ID_COUNT_ONCE})`,
|
|
225
|
+
description: `A single Repository call (data_add, data_remove, id_data_*) may operate on at most ` +
|
|
226
|
+
`MAX_ID_COUNT_ONCE=${MAX_ID_COUNT_ONCE} IDs (Move source: repository.move:25). Exceeding this limit ` +
|
|
227
|
+
`aborts with E_ID_COUNT_EXCEEDED (5). Batch large operations across multiple transactions.`,
|
|
228
|
+
affected_stakeholders: ["writer"],
|
|
229
|
+
scenario: "Caller passes 150 IDs in a single data_remove call",
|
|
230
|
+
mitigation: `Split into batches of ≤ ${MAX_ID_COUNT_ONCE} IDs per transaction.`,
|
|
231
|
+
related_move_error: "E_ID_COUNT_EXCEEDED (5)",
|
|
232
|
+
auto_fixable: false,
|
|
233
|
+
},
|
|
234
|
+
check: (ctx) => {
|
|
235
|
+
if (ctx.id_count_once === undefined)
|
|
236
|
+
return null;
|
|
237
|
+
if (ctx.id_count_once <= MAX_ID_COUNT_ONCE)
|
|
238
|
+
return null;
|
|
239
|
+
return { ...R_REP_1_04.rule, evidence: `id_count=${ctx.id_count_once}, limit=${MAX_ID_COUNT_ONCE}` };
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
const R_REP_1_05 = {
|
|
243
|
+
rule: {
|
|
244
|
+
id: "R-REP-09",
|
|
245
|
+
level: "INFO",
|
|
246
|
+
category: "structural",
|
|
247
|
+
title: `Reward count approaches MAX_REWARD_COUNT (${MAX_REWARD_COUNT})`,
|
|
248
|
+
description: `A Repository may reference up to MAX_REWARD_COUNT=${MAX_REWARD_COUNT} Reward objects (Move source: repository.move:26). ` +
|
|
249
|
+
`Exceeding this limit aborts with E_MAX_REWARD_COUNT_EXCEEDED (19). Rewards incentivize data contribution; ` +
|
|
250
|
+
`having many rewards is fine but increases accounting complexity.`,
|
|
251
|
+
affected_stakeholders: ["creator"],
|
|
252
|
+
scenario: "Caller adds 20 rewards to a Repository (at the limit)",
|
|
253
|
+
mitigation: "Monitor reward count. If more incentives are needed, consolidate rewards or use a separate Repository.",
|
|
254
|
+
related_move_error: "E_MAX_REWARD_COUNT_EXCEEDED (19)",
|
|
255
|
+
auto_fixable: false,
|
|
256
|
+
},
|
|
257
|
+
check: (ctx) => {
|
|
258
|
+
if (ctx.reward_count === undefined)
|
|
259
|
+
return null;
|
|
260
|
+
if (ctx.reward_count < MAX_REWARD_COUNT)
|
|
261
|
+
return null;
|
|
262
|
+
return { ...R_REP_1_05.rule, evidence: `reward_count=${ctx.reward_count}, limit=${MAX_REWARD_COUNT}` };
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
const R_REP_5_01 = {
|
|
266
|
+
rule: {
|
|
267
|
+
id: "R-REP-10",
|
|
268
|
+
level: "INFO",
|
|
269
|
+
category: "knowledge",
|
|
270
|
+
title: "Knowledge layer & constant sync — RESOLVED",
|
|
271
|
+
description: "All 6 Repository constants (MAX_POLICY_COUNT, MAX_POLICY_DESCRIPTION_LEN, MAX_POLICY_GUARD_COUNT, " +
|
|
272
|
+
"MAX_DATA_SIZE, MAX_ID_COUNT_ONCE, MAX_REWARD_COUNT) are now synced to onchain-constants.ts. " +
|
|
273
|
+
"The MCP Knowledge layer now includes repository-risk.ts, repository-confirm.ts, " +
|
|
274
|
+
"repository-translation.ts (R-D-4=A). The SDK hasSubmissionSettings helper now correctly checks both " +
|
|
275
|
+
"id_from_submission AND data_from_submission (P1-1). parseIdFrom is used in data/data_remove (P1-2). " +
|
|
276
|
+
"This risk rule is retained for historical audit and to detect future regressions.",
|
|
277
|
+
affected_stakeholders: ["system"],
|
|
278
|
+
scenario: "Future regression: someone removes a Repository constant from onchain-constants.ts",
|
|
279
|
+
mitigation: "Run the onchain-constants sync test to detect drift.",
|
|
280
|
+
auto_fixable: false,
|
|
281
|
+
},
|
|
282
|
+
check: (ctx) => {
|
|
283
|
+
if (ctx.constants_synced)
|
|
284
|
+
return null;
|
|
285
|
+
return { ...R_REP_5_01.rule, evidence: "constants_synced=false" };
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
export const REPOSITORY_RISK_RULES = [
|
|
289
|
+
R_REP_1_01,
|
|
290
|
+
R_REP_2_01,
|
|
291
|
+
R_REP_2_02,
|
|
292
|
+
R_REP_1_02,
|
|
293
|
+
R_REP_1_03,
|
|
294
|
+
R_REP_3_01,
|
|
295
|
+
R_REP_4_01,
|
|
296
|
+
R_REP_1_04,
|
|
297
|
+
R_REP_1_05,
|
|
298
|
+
R_REP_5_01,
|
|
299
|
+
];
|
|
300
|
+
export function checkRepositoryRisks(ctx) {
|
|
301
|
+
const risks = [];
|
|
302
|
+
for (const rule of REPOSITORY_RISK_RULES) {
|
|
303
|
+
const r = rule.check(ctx);
|
|
304
|
+
if (r)
|
|
305
|
+
risks.push(r);
|
|
306
|
+
}
|
|
307
|
+
return risks;
|
|
308
|
+
}
|
|
309
|
+
export function getRepositoryRiskById(id) {
|
|
310
|
+
return REPOSITORY_RISK_RULES.find(r => r.rule.id === id)?.rule;
|
|
311
|
+
}
|
|
312
|
+
export { normalizeIdFrom as parseIdFromForRiskCheck };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface SemanticToRepositorySchemaRule {
|
|
2
|
+
id: string;
|
|
3
|
+
pattern_name: string;
|
|
4
|
+
routing_mode: "clock" | "signer" | "guard_caller" | "guard_submission";
|
|
5
|
+
semantic_intent: string;
|
|
6
|
+
match_keywords: string[];
|
|
7
|
+
schema_elements: {
|
|
8
|
+
id_from_value: number | string;
|
|
9
|
+
required_policy_fields: string[];
|
|
10
|
+
write_guard_requirement: "empty" | "non_empty" | "either";
|
|
11
|
+
move_entry_point: string;
|
|
12
|
+
caller_input_shape: string;
|
|
13
|
+
};
|
|
14
|
+
constraints: string[];
|
|
15
|
+
example: Record<string, unknown>;
|
|
16
|
+
}
|
|
17
|
+
export declare const SEMANTIC_TO_REPOSITORY_SCHEMA_RULES: SemanticToRepositorySchemaRule[];
|
|
18
|
+
export interface RepositoryFieldTranslation {
|
|
19
|
+
field_name: string;
|
|
20
|
+
move_field?: string;
|
|
21
|
+
value_type: string;
|
|
22
|
+
semantic: string;
|
|
23
|
+
format_example: string;
|
|
24
|
+
validation_rules: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare const REPOSITORY_FIELD_TRANSLATIONS: RepositoryFieldTranslation[];
|
|
27
|
+
export interface RepositoryConstraintRule {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
validation_logic: string;
|
|
32
|
+
failure_message: string;
|
|
33
|
+
related_field: string;
|
|
34
|
+
}
|
|
35
|
+
export declare const REPOSITORY_CONSTRAINT_RULES: RepositoryConstraintRule[];
|
|
36
|
+
export interface RepositoryExplainInput {
|
|
37
|
+
policies?: RepositoryPolicyInput[];
|
|
38
|
+
op?: string;
|
|
39
|
+
is_data_remove_with_passport?: boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface RepositoryPolicyInput {
|
|
42
|
+
name: string;
|
|
43
|
+
id_from: number | string;
|
|
44
|
+
write_guard_count: number;
|
|
45
|
+
has_id_from_submission: boolean;
|
|
46
|
+
has_data_from_submission: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface RepositoryExplanation {
|
|
49
|
+
summary: string;
|
|
50
|
+
routing_modes: string[];
|
|
51
|
+
r_d_1_status: string;
|
|
52
|
+
r_d_2_status: string;
|
|
53
|
+
p1_1_status: string;
|
|
54
|
+
p1_2_status: string;
|
|
55
|
+
warnings: string[];
|
|
56
|
+
recommendations: string[];
|
|
57
|
+
}
|
|
58
|
+
export declare function explainRepository(input: RepositoryExplainInput): RepositoryExplanation;
|