@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,217 @@
|
|
|
1
|
+
import { MAX_ADDRESS_COUNT, MAX_RECORD_COUNT_REGISTRAR, MAX_RECORD_LENGTH, } from "@wowok/wowok";
|
|
2
|
+
const BIT_NO_INFO = 0x00;
|
|
3
|
+
const BIT_LIKE = 0x02;
|
|
4
|
+
const BIT_DISLIKE = 0x04;
|
|
5
|
+
const BIT_AFFILIATION = 0x08;
|
|
6
|
+
const R_REG_01 = {
|
|
7
|
+
rule: {
|
|
8
|
+
id: "R-REG-01",
|
|
9
|
+
level: "HIGH",
|
|
10
|
+
category: "lifecycle",
|
|
11
|
+
title: "Entity and Registrar are system singletons — cannot be migrated post-deploy",
|
|
12
|
+
description: "Entity and Registrar are created once at package init by @0x0 (registrar.move:152-166) " +
|
|
13
|
+
"and are globally unique. They cannot be re-created, migrated, or re-initialized. If " +
|
|
14
|
+
"the singleton's storage layout needs to change (e.g. ParentTable schema), the only " +
|
|
15
|
+
"option is a new package version with a migration path. There is no in-place migration " +
|
|
16
|
+
"API. All 22 objects depend on these singletons via affiliation, so a migration would " +
|
|
17
|
+
"cascade to every object.",
|
|
18
|
+
affected_stakeholders: ["system", "user"],
|
|
19
|
+
scenario: "Operator wants to migrate Entity to a new schema; no migration API exists",
|
|
20
|
+
mitigation: "Confirm the schema before deployment. For schema evolution, plan a new package " +
|
|
21
|
+
"version with an explicit migration script. Never assume the singleton can be 'reset'.",
|
|
22
|
+
auto_fixable: false,
|
|
23
|
+
},
|
|
24
|
+
check: (ctx) => {
|
|
25
|
+
if (!ctx.expects_singleton_migration)
|
|
26
|
+
return null;
|
|
27
|
+
return { ...R_REG_01.rule, evidence: "expects_singleton_migration=true (no migration API)" };
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
const R_REG_02 = {
|
|
31
|
+
rule: {
|
|
32
|
+
id: "R-REG-02",
|
|
33
|
+
level: "MEDIUM",
|
|
34
|
+
category: "structural",
|
|
35
|
+
title: `MAX_ADDRESS_COUNT=${MAX_ADDRESS_COUNT} may be insufficient for large deployments`,
|
|
36
|
+
description: `The Entity and Registrar ParentTables are bounded by MAX_ADDRESS_COUNT=${MAX_ADDRESS_COUNT} ` +
|
|
37
|
+
`(registrar.move). Exceeding the cap aborts address registration. For mass-market ` +
|
|
38
|
+
`applications, ${MAX_ADDRESS_COUNT} entries may be too few; the limit is a single ` +
|
|
39
|
+
`Move constant that requires a package upgrade to change.`,
|
|
40
|
+
affected_stakeholders: ["system", "user"],
|
|
41
|
+
scenario: "Popular service reaches 5200 registered users; new registrations abort",
|
|
42
|
+
mitigation: "Monitor address_count. Plan a package upgrade that raises MAX_ADDRESS_COUNT before " +
|
|
43
|
+
"hitting the cap. For shardable workloads, consider multiple Entity tables in a future " +
|
|
44
|
+
"package version.",
|
|
45
|
+
auto_fixable: false,
|
|
46
|
+
},
|
|
47
|
+
check: (ctx) => {
|
|
48
|
+
if (ctx.address_count === undefined)
|
|
49
|
+
return null;
|
|
50
|
+
if (ctx.address_count < MAX_ADDRESS_COUNT)
|
|
51
|
+
return null;
|
|
52
|
+
return { ...R_REG_02.rule, evidence: `address_count=${ctx.address_count}, limit=${MAX_ADDRESS_COUNT}` };
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
const R_REG_03 = {
|
|
56
|
+
rule: {
|
|
57
|
+
id: "R-REG-03",
|
|
58
|
+
level: "MEDIUM",
|
|
59
|
+
category: "semantic",
|
|
60
|
+
title: `Vote.info uses u8 bitmask — bits 4-7 reserved, future expansion must stay compatible`,
|
|
61
|
+
description: `Vote.info is a u8 bitmask: BIT_NO_INFO=${BIT_NO_INFO}, BIT_LIKE=${BIT_LIKE}, ` +
|
|
62
|
+
`BIT_DISLIKE=${BIT_DISLIKE}, BIT_AFFILIATION=${BIT_AFFILIATION}. Bits 4-7 are reserved. ` +
|
|
63
|
+
`A future version that repurposes bits 4-7 would conflict with any off-chain code that ` +
|
|
64
|
+
`reads the raw byte. The reserved bits MUST be treated as zero today; non-zero values ` +
|
|
65
|
+
`in bits 4-7 indicate a forward-incompatible voter.`,
|
|
66
|
+
affected_stakeholders: ["voter", "system"],
|
|
67
|
+
scenario: "Future version assigns bit 4 to a new flag; old indexers misread the byte",
|
|
68
|
+
mitigation: "Off-chain code must mask to bits 0-3 today and ignore bits 4-7. When a new flag is " +
|
|
69
|
+
"assigned, ship a coordinated Move + SDK + indexer update.",
|
|
70
|
+
auto_fixable: false,
|
|
71
|
+
},
|
|
72
|
+
check: (ctx) => {
|
|
73
|
+
if (!ctx.uses_reserved_vote_bits)
|
|
74
|
+
return null;
|
|
75
|
+
return { ...R_REG_03.rule, evidence: "uses_reserved_vote_bits=true (bits 4-7 are reserved)" };
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const R_REG_05 = {
|
|
79
|
+
rule: {
|
|
80
|
+
id: "R-REG-05",
|
|
81
|
+
level: "MEDIUM",
|
|
82
|
+
category: "cross_object",
|
|
83
|
+
title: "affiliation / disaffiliation emit no events — indexers must poll Registrar.table",
|
|
84
|
+
description: "affiliation, disaffiliation, and affiliation_change (registrar.move) mutate the " +
|
|
85
|
+
"Registrar dependency graph but emit no events. External indexers that track the " +
|
|
86
|
+
"object-dependency graph cannot rely on an event stream; they must poll the " +
|
|
87
|
+
"ParentTable, which is expensive as the graph grows.",
|
|
88
|
+
affected_stakeholders: ["system"],
|
|
89
|
+
scenario: "Indexer expects an AffiliationEvent; none is emitted, dependency graph is stale",
|
|
90
|
+
mitigation: "Indexers should poll Registrar.table on a cadence and diff. Future versions may add " +
|
|
91
|
+
"AffiliationEvent; until then, do not build critical UX on affiliation event streams.",
|
|
92
|
+
auto_fixable: false,
|
|
93
|
+
},
|
|
94
|
+
check: (ctx) => {
|
|
95
|
+
if (!ctx.expects_affiliation_event)
|
|
96
|
+
return null;
|
|
97
|
+
return { ...R_REG_05.rule, evidence: "expects_affiliation_event=true (no events)" };
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
const R_REG_04 = {
|
|
101
|
+
rule: {
|
|
102
|
+
id: "R-REG-04",
|
|
103
|
+
level: "LOW",
|
|
104
|
+
category: "lifecycle",
|
|
105
|
+
title: "entity_register is idempotent — returns existing Resource, not a fresh one",
|
|
106
|
+
description: "entity_register (registrar.move:177-187) checks whether the sender already has an " +
|
|
107
|
+
"Entity record. If so, it returns the existing Resource address without creating a new " +
|
|
108
|
+
"one. Callers who expect a fresh Resource on each call (e.g. after a forced destroy) " +
|
|
109
|
+
"will silently receive the old one. Use entity_register_with_resource_forced to " +
|
|
110
|
+
"force-reallocate, and only when the old Resource is truly gone.",
|
|
111
|
+
affected_stakeholders: ["user"],
|
|
112
|
+
scenario: "User destroys their Resource then calls entity_register; gets the old (now-invalid) address",
|
|
113
|
+
mitigation: "Document the idempotent behavior. After a forced destroy, callers MUST use " +
|
|
114
|
+
"entity_register_with_resource_forced. SDK should detect destroyed Resource and route " +
|
|
115
|
+
"accordingly.",
|
|
116
|
+
auto_fixable: false,
|
|
117
|
+
},
|
|
118
|
+
check: (ctx) => {
|
|
119
|
+
if (!ctx.expects_fresh_resource_on_register)
|
|
120
|
+
return null;
|
|
121
|
+
return { ...R_REG_04.rule, evidence: "expects_fresh_resource_on_register=true (idempotent)" };
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
const R_REG_06 = {
|
|
125
|
+
rule: {
|
|
126
|
+
id: "R-REG-06",
|
|
127
|
+
level: "LOW",
|
|
128
|
+
category: "semantic",
|
|
129
|
+
title: "Record.typed_value first byte is a ValueType — convention enforced only by docs",
|
|
130
|
+
description: "Record.typed_value is a vector<u8> whose first byte encodes the ValueType (registrar.move:111). " +
|
|
131
|
+
"The Move layer validates that the vector is non-empty and within MAX_RECORD_LENGTH=" +
|
|
132
|
+
`${MAX_RECORD_LENGTH}, but it does not validate that the first byte is a known ValueType. ` +
|
|
133
|
+
`Off-chain consumers must agree on the ValueType byte layout; a misencoded record will ` +
|
|
134
|
+
`deserialize to garbage without an on-chain abort. Record count is bounded by ` +
|
|
135
|
+
`MAX_RECORD_COUNT_REGISTRAR=${MAX_RECORD_COUNT_REGISTRAR}.`,
|
|
136
|
+
affected_stakeholders: ["user", "system"],
|
|
137
|
+
scenario: "Caller writes a record with first byte 0xFF; no on-chain error, but consumers cannot decode",
|
|
138
|
+
mitigation: "SDK must validate the first byte against the ValueType enum before submitting. " +
|
|
139
|
+
"Document the ValueType byte layout in both Move and SDK. Add a sync test that " +
|
|
140
|
+
"asserts the ValueType enum matches across layers.",
|
|
141
|
+
related_move_error: "ERecordTypeEmpty (3) — only catches empty typed_value",
|
|
142
|
+
auto_fixable: false,
|
|
143
|
+
},
|
|
144
|
+
check: (ctx) => {
|
|
145
|
+
if (!ctx.relies_on_typed_value_convention)
|
|
146
|
+
return null;
|
|
147
|
+
return { ...R_REG_06.rule, evidence: "relies_on_typed_value_convention=true (docs-only enforcement)" };
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const R_REG_07 = {
|
|
151
|
+
rule: {
|
|
152
|
+
id: "R-REG-07",
|
|
153
|
+
level: "MEDIUM",
|
|
154
|
+
category: "cross_object",
|
|
155
|
+
title: "entity_resource_transfer detaches Resource from the source address",
|
|
156
|
+
description: "entity_resource_transfer(resource, new_address, ctx) moves the Resource backing a " +
|
|
157
|
+
"user's identity mark to a new address. After transfer, the source address has no " +
|
|
158
|
+
"Resource — any downstream service that keyed identity on the source address loses " +
|
|
159
|
+
"the binding. There is no automatic forwarding stub left behind.",
|
|
160
|
+
affected_stakeholders: ["user", "system"],
|
|
161
|
+
scenario: "User transfers Resource to a new wallet; old-wallet-based services break",
|
|
162
|
+
mitigation: "Surface a 'transfer will detach the Resource from this address' warning. Consumers " +
|
|
163
|
+
"should track users by Resource address, not by user address. Provide a migration " +
|
|
164
|
+
"window where both addresses are valid.",
|
|
165
|
+
auto_fixable: false,
|
|
166
|
+
},
|
|
167
|
+
check: (ctx) => {
|
|
168
|
+
if (!ctx.is_resource_transfer)
|
|
169
|
+
return null;
|
|
170
|
+
return { ...R_REG_07.rule, evidence: "is_resource_transfer=true (source loses Resource)" };
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
const R_REG_08 = {
|
|
174
|
+
rule: {
|
|
175
|
+
id: "R-REG-08",
|
|
176
|
+
level: "LOW",
|
|
177
|
+
category: "semantic",
|
|
178
|
+
title: "Vote.time updates on every toggle — including like→no-like",
|
|
179
|
+
description: "Vote.time (registrar.move) is set to clock.timestamp_ms() on every like/dislike " +
|
|
180
|
+
"operation, including toggles that remove a like (like→no-like). Consumers who " +
|
|
181
|
+
"interpret Vote.time as 'last liked at' will be confused when it advances on an " +
|
|
182
|
+
"un-like. The field semantically means 'last vote op time', not 'last positive vote'.",
|
|
183
|
+
affected_stakeholders: ["voter", "system"],
|
|
184
|
+
scenario: "User un-likes; Vote.time advances; indexer reads it as 'recently liked'",
|
|
185
|
+
mitigation: "Document Vote.time as 'last vote operation time'. For 'last liked at' semantics, " +
|
|
186
|
+
"track the previous Vote.info state and only record time when BIT_LIKE transitions to set.",
|
|
187
|
+
auto_fixable: false,
|
|
188
|
+
},
|
|
189
|
+
check: (ctx) => {
|
|
190
|
+
if (!ctx.expects_vote_time_only_on_like)
|
|
191
|
+
return null;
|
|
192
|
+
return { ...R_REG_08.rule, evidence: "expects_vote_time_only_on_like=true (updates on toggle)" };
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
export const REGISTRAR_RISK_RULES = [
|
|
196
|
+
R_REG_01,
|
|
197
|
+
R_REG_02,
|
|
198
|
+
R_REG_03,
|
|
199
|
+
R_REG_04,
|
|
200
|
+
R_REG_05,
|
|
201
|
+
R_REG_06,
|
|
202
|
+
R_REG_07,
|
|
203
|
+
R_REG_08,
|
|
204
|
+
];
|
|
205
|
+
export const REGISTRAR_RISK_VERSION = "1.0.0";
|
|
206
|
+
export function checkRegistrarRisks(ctx) {
|
|
207
|
+
const risks = [];
|
|
208
|
+
for (const rule of REGISTRAR_RISK_RULES) {
|
|
209
|
+
const r = rule.check(ctx);
|
|
210
|
+
if (r)
|
|
211
|
+
risks.push(r);
|
|
212
|
+
}
|
|
213
|
+
return risks;
|
|
214
|
+
}
|
|
215
|
+
export function getRegistrarRiskById(id) {
|
|
216
|
+
return REGISTRAR_RISK_RULES.find(r => r.rule.id === id)?.rule;
|
|
217
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type ConfirmSeverity = "block" | "warn" | "info";
|
|
2
|
+
export interface RepositoryConfirmItem {
|
|
3
|
+
id: string;
|
|
4
|
+
severity: ConfirmSeverity;
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
passed: boolean;
|
|
8
|
+
evidence?: string;
|
|
9
|
+
fix_hint?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface RepositoryPolicyInput {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
id_from: number | string;
|
|
15
|
+
write_guard_count: number;
|
|
16
|
+
has_id_from_submission: boolean;
|
|
17
|
+
has_data_from_submission: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface RepositoryOpCheckInput {
|
|
20
|
+
op: "create" | "policy_add" | "policy_set" | "data_add" | "data_remove" | "rewards";
|
|
21
|
+
policies?: RepositoryPolicyInput[];
|
|
22
|
+
existing_policy_count?: number;
|
|
23
|
+
data_size?: number;
|
|
24
|
+
id_count_once?: number;
|
|
25
|
+
reward_count?: number;
|
|
26
|
+
is_data_remove_with_passport?: boolean;
|
|
27
|
+
description?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare function preCheckRepositoryOp(input: RepositoryOpCheckInput): RepositoryConfirmItem[];
|
|
30
|
+
export declare function canProceedRepositoryOp(input: RepositoryOpCheckInput): {
|
|
31
|
+
canProceed: boolean;
|
|
32
|
+
blockers: RepositoryConfirmItem[];
|
|
33
|
+
warnings: RepositoryConfirmItem[];
|
|
34
|
+
info: RepositoryConfirmItem[];
|
|
35
|
+
};
|
|
36
|
+
export declare function formatRepositoryOpSummary(input: RepositoryOpCheckInput): string;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { MAX_POLICY_COUNT, MAX_POLICY_DESCRIPTION_LEN, 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
|
+
function checkPolicyCount(input) {
|
|
16
|
+
if (!input.policies || input.existing_policy_count === undefined) {
|
|
17
|
+
return {
|
|
18
|
+
id: "C-REP-01",
|
|
19
|
+
severity: "info",
|
|
20
|
+
title: `Policy count within MAX_POLICY_COUNT (${MAX_POLICY_COUNT})`,
|
|
21
|
+
description: "Skipped: no policy count provided.",
|
|
22
|
+
passed: true,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const total = input.existing_policy_count + input.policies.length;
|
|
26
|
+
const passed = total <= MAX_POLICY_COUNT;
|
|
27
|
+
return {
|
|
28
|
+
id: "C-REP-01",
|
|
29
|
+
severity: passed ? "info" : "block",
|
|
30
|
+
title: `Policy count within MAX_POLICY_COUNT (${MAX_POLICY_COUNT})`,
|
|
31
|
+
description: "A single Repository may hold up to MAX_POLICY_COUNT policies. Exceeding aborts with E_POLICY_COUNT_EXCEEDED (3). " +
|
|
32
|
+
"Each policy is a named data slot with its own write_guard and id_from routing.",
|
|
33
|
+
passed,
|
|
34
|
+
evidence: `existing=${input.existing_policy_count}, adding=${input.policies.length}, total=${total}`,
|
|
35
|
+
fix_hint: `Consolidate or split across multiple Repository objects. Limit=${MAX_POLICY_COUNT}.`,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function checkWriteGuardRequiredWhenIdFromNone(input) {
|
|
39
|
+
if (!input.policies) {
|
|
40
|
+
return { id: "C-REP-02", severity: "info", title: "write_guard/id_from consistency (R-D-1)", description: "Skipped: no policies.", passed: true };
|
|
41
|
+
}
|
|
42
|
+
const offenders = input.policies.filter(p => normalizeIdFrom(p.id_from) === 0 && p.write_guard_count === 0);
|
|
43
|
+
const passed = offenders.length === 0;
|
|
44
|
+
return {
|
|
45
|
+
id: "C-REP-02",
|
|
46
|
+
severity: passed ? "info" : "block",
|
|
47
|
+
title: "write_guard non-empty when id_from=None (R-D-1 Move assert)",
|
|
48
|
+
description: "When id_from is None, the data ID comes from the caller — without write_guard, ANY address can write " +
|
|
49
|
+
"data with any ID. Move aborts with E_POLICY_WRITE_GUARD_REQUIRED (22) in policy_add_imp() [R-D-1=A].",
|
|
50
|
+
passed,
|
|
51
|
+
evidence: passed ? "all policies with id_from=None have write_guard" :
|
|
52
|
+
`offenders: ${offenders.map(p => p.name).join(", ")}`,
|
|
53
|
+
fix_hint: "Add at least one PolicyGuard to write_guard, OR switch id_from to Clock/Signer.",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function checkWriteGuardForbiddenWhenIdFromClockSigner(input) {
|
|
57
|
+
if (!input.policies) {
|
|
58
|
+
return { id: "C-REP-03", severity: "info", title: "id_from_submission null when id_from=Clock/Signer (R-D-1)", description: "Skipped: no policies.", passed: true };
|
|
59
|
+
}
|
|
60
|
+
const offenders = input.policies.filter(p => {
|
|
61
|
+
const idFrom = normalizeIdFrom(p.id_from);
|
|
62
|
+
return (idFrom === 1 || idFrom === 2) && p.has_id_from_submission;
|
|
63
|
+
});
|
|
64
|
+
const passed = offenders.length === 0;
|
|
65
|
+
return {
|
|
66
|
+
id: "C-REP-03",
|
|
67
|
+
severity: passed ? "info" : "block",
|
|
68
|
+
title: "id_from_submission null when id_from=Clock/Signer (R-D-1 Move assert)",
|
|
69
|
+
description: "When id_from is Clock/Signer, the ID is auto-generated — id_from_submission would conflict. " +
|
|
70
|
+
"data_from_submission is still allowed (used by data_when_id_from_set_with_passport). " +
|
|
71
|
+
"Move aborts with E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN (23) in policy_add_imp() [R-D-1=A, refined].",
|
|
72
|
+
passed,
|
|
73
|
+
evidence: passed ? "all policies with id_from=Clock/Signer have id_from_submission=null" :
|
|
74
|
+
`offenders: ${offenders.map(p => `${p.name}(id_from=${p.id_from})`).join(", ")}`,
|
|
75
|
+
fix_hint: "Set id_from_submission=null on all write_guard entries, OR switch id_from to None.",
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function checkPolicyGuardCount(input) {
|
|
79
|
+
if (!input.policies) {
|
|
80
|
+
return { id: "C-REP-04", severity: "info", title: `write_guard count ≤ ${MAX_POLICY_GUARD_COUNT}`, description: "Skipped: no policies.", passed: true };
|
|
81
|
+
}
|
|
82
|
+
const offenders = input.policies.filter(p => p.write_guard_count > MAX_POLICY_GUARD_COUNT);
|
|
83
|
+
const passed = offenders.length === 0;
|
|
84
|
+
return {
|
|
85
|
+
id: "C-REP-04",
|
|
86
|
+
severity: passed ? "info" : "block",
|
|
87
|
+
title: `Each policy write_guard count ≤ MAX_POLICY_GUARD_COUNT (${MAX_POLICY_GUARD_COUNT})`,
|
|
88
|
+
description: "Each policy may define up to MAX_POLICY_GUARD_COUNT guard entries. Move aborts with E_POLICY_GUARD_COUNT_EXCEEDED (2).",
|
|
89
|
+
passed,
|
|
90
|
+
evidence: passed ? "all policies within limit" :
|
|
91
|
+
`offenders: ${offenders.map(p => `${p.name}(${p.write_guard_count})`).join(", ")}`,
|
|
92
|
+
fix_hint: `Reduce write_guard entries to ≤ ${MAX_POLICY_GUARD_COUNT} per policy.`,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function checkPolicyDescription(input) {
|
|
96
|
+
if (!input.policies) {
|
|
97
|
+
return { id: "C-REP-05", severity: "info", title: `Policy description ≤ ${MAX_POLICY_DESCRIPTION_LEN}`, description: "Skipped: no policies.", passed: true };
|
|
98
|
+
}
|
|
99
|
+
const offenders = input.policies.filter(p => p.description !== undefined && p.description.length > MAX_POLICY_DESCRIPTION_LEN);
|
|
100
|
+
const passed = offenders.length === 0;
|
|
101
|
+
return {
|
|
102
|
+
id: "C-REP-05",
|
|
103
|
+
severity: passed ? "info" : "block",
|
|
104
|
+
title: `Each policy description ≤ MAX_POLICY_DESCRIPTION_LEN (${MAX_POLICY_DESCRIPTION_LEN})`,
|
|
105
|
+
description: "Policy description is bounded by MAX_POLICY_DESCRIPTION_LEN. Move aborts with E_POLICY_DESCRIPTION_EXCEEDED (1).",
|
|
106
|
+
passed,
|
|
107
|
+
evidence: passed ? "all descriptions within limit" :
|
|
108
|
+
`offenders: ${offenders.map(p => `${p.name}(len=${p.description.length})`).join(", ")}`,
|
|
109
|
+
fix_hint: `Shorten policy descriptions to ≤ ${MAX_POLICY_DESCRIPTION_LEN} chars.`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function checkDataSize(input) {
|
|
113
|
+
if (input.data_size === undefined) {
|
|
114
|
+
return { id: "C-REP-06", severity: "info", title: `Data value ≤ MAX_DATA_SIZE (${MAX_DATA_SIZE})`, description: "Skipped: no data_size.", passed: true };
|
|
115
|
+
}
|
|
116
|
+
const passed = input.data_size <= MAX_DATA_SIZE;
|
|
117
|
+
return {
|
|
118
|
+
id: "C-REP-06",
|
|
119
|
+
severity: passed ? "info" : "block",
|
|
120
|
+
title: `Data value ≤ MAX_DATA_SIZE (${MAX_DATA_SIZE} bytes)`,
|
|
121
|
+
description: "Each data value must be ≤ MAX_DATA_SIZE bytes (BCS-serialized, type-tag prefixed). Move aborts with E_DATA_EXCEEDED (4). " +
|
|
122
|
+
"Store large payloads off-chain and reference by hash.",
|
|
123
|
+
passed,
|
|
124
|
+
evidence: `data_size=${input.data_size}, limit=${MAX_DATA_SIZE}`,
|
|
125
|
+
fix_hint: `Store large data off-chain; write only the content hash. Limit=${MAX_DATA_SIZE} bytes.`,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function checkIdCountOnce(input) {
|
|
129
|
+
if (input.id_count_once === undefined) {
|
|
130
|
+
return { id: "C-REP-07", severity: "info", title: `ID count ≤ MAX_ID_COUNT_ONCE (${MAX_ID_COUNT_ONCE})`, description: "Skipped: no id_count.", passed: true };
|
|
131
|
+
}
|
|
132
|
+
const passed = input.id_count_once <= MAX_ID_COUNT_ONCE;
|
|
133
|
+
return {
|
|
134
|
+
id: "C-REP-07",
|
|
135
|
+
severity: passed ? "info" : "block",
|
|
136
|
+
title: `ID count per op ≤ MAX_ID_COUNT_ONCE (${MAX_ID_COUNT_ONCE})`,
|
|
137
|
+
description: "A single Repository call may operate on at most MAX_ID_COUNT_ONCE IDs. Move aborts with E_ID_COUNT_EXCEEDED (5). " +
|
|
138
|
+
"Batch large operations across multiple transactions.",
|
|
139
|
+
passed,
|
|
140
|
+
evidence: `id_count=${input.id_count_once}, limit=${MAX_ID_COUNT_ONCE}`,
|
|
141
|
+
fix_hint: `Split into batches of ≤ ${MAX_ID_COUNT_ONCE} IDs per transaction.`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
function checkRewardCount(input) {
|
|
145
|
+
if (input.reward_count === undefined) {
|
|
146
|
+
return { id: "C-REP-08", severity: "info", title: `Reward count ≤ MAX_REWARD_COUNT (${MAX_REWARD_COUNT})`, description: "Skipped: no reward_count.", passed: true };
|
|
147
|
+
}
|
|
148
|
+
const passed = input.reward_count <= MAX_REWARD_COUNT;
|
|
149
|
+
return {
|
|
150
|
+
id: "C-REP-08",
|
|
151
|
+
severity: passed ? "info" : "block",
|
|
152
|
+
title: `Reward count ≤ MAX_REWARD_COUNT (${MAX_REWARD_COUNT})`,
|
|
153
|
+
description: "A Repository may reference up to MAX_REWARD_COUNT Reward objects. Move aborts with E_MAX_REWARD_COUNT_EXCEEDED (19).",
|
|
154
|
+
passed,
|
|
155
|
+
evidence: `reward_count=${input.reward_count}, limit=${MAX_REWARD_COUNT}`,
|
|
156
|
+
fix_hint: `Consolidate rewards or use a separate Repository. Limit=${MAX_REWARD_COUNT}.`,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function checkDataRemoveWithPassportSubmission(input) {
|
|
160
|
+
if (!input.is_data_remove_with_passport || !input.policies) {
|
|
161
|
+
return { id: "C-REP-09", severity: "info", title: "id_data_remove_with_passport submission check (R-D-2)", description: "Skipped: not applicable.", passed: true };
|
|
162
|
+
}
|
|
163
|
+
const offenders = input.policies.filter(p => p.has_data_from_submission);
|
|
164
|
+
const passed = offenders.length === 0;
|
|
165
|
+
return {
|
|
166
|
+
id: "C-REP-09",
|
|
167
|
+
severity: passed ? "info" : "block",
|
|
168
|
+
title: "id_data_remove_with_passport: no data_from_submission (R-D-2 Move assert)",
|
|
169
|
+
description: "id_data_remove_with_passport only removes data by caller-provided id; it cannot consume Passport " +
|
|
170
|
+
"submissions. Move now checks BOTH id_from_submission AND data_from_submission are None [R-D-2=A], " +
|
|
171
|
+
"aborting with E_GUARD_SPECIFIED_ID_FROM_SUBMISSION (11).",
|
|
172
|
+
passed,
|
|
173
|
+
evidence: passed ? "no policies with data_from_submission" :
|
|
174
|
+
`offenders: ${offenders.map(p => p.name).join(", ")}`,
|
|
175
|
+
fix_hint: "Use id_data_mixed_remove_with_passport for submission-based removal, or unset data_from_submission.",
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
function checkIdFromString(input) {
|
|
179
|
+
if (!input.policies) {
|
|
180
|
+
return { id: "C-REP-10", severity: "info", title: "id_from string form valid (P1-2 parseIdFrom)", description: "Skipped: no policies.", passed: true };
|
|
181
|
+
}
|
|
182
|
+
const offenders = input.policies.filter(p => {
|
|
183
|
+
const n = normalizeIdFrom(p.id_from);
|
|
184
|
+
return n < 0 || n > 2;
|
|
185
|
+
});
|
|
186
|
+
const passed = offenders.length === 0;
|
|
187
|
+
return {
|
|
188
|
+
id: "C-REP-10",
|
|
189
|
+
severity: passed ? "info" : "warn",
|
|
190
|
+
title: "id_from string form is recognized (P1-2 parseIdFrom)",
|
|
191
|
+
description: "SDK parseIdFrom normalizes string id_from (e.g. \"none\"/\"clock\"/\"signer\") to numeric enum before " +
|
|
192
|
+
"comparison [P1-2 fix]. Unrecognized values fall through to Move which aborts with E_INVALID_ID_FROM (18).",
|
|
193
|
+
passed,
|
|
194
|
+
evidence: passed ? "all id_from values recognized" :
|
|
195
|
+
`offenders: ${offenders.map(p => `${p.name}(id_from=${p.id_from})`).join(", ")}`,
|
|
196
|
+
fix_hint: "Use 0/1/2, or 'None'/'Clock'/'Signer' (case-insensitive).",
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
export function preCheckRepositoryOp(input) {
|
|
200
|
+
return [
|
|
201
|
+
checkPolicyCount(input),
|
|
202
|
+
checkWriteGuardRequiredWhenIdFromNone(input),
|
|
203
|
+
checkWriteGuardForbiddenWhenIdFromClockSigner(input),
|
|
204
|
+
checkPolicyGuardCount(input),
|
|
205
|
+
checkPolicyDescription(input),
|
|
206
|
+
checkDataSize(input),
|
|
207
|
+
checkIdCountOnce(input),
|
|
208
|
+
checkRewardCount(input),
|
|
209
|
+
checkDataRemoveWithPassportSubmission(input),
|
|
210
|
+
checkIdFromString(input),
|
|
211
|
+
];
|
|
212
|
+
}
|
|
213
|
+
export function canProceedRepositoryOp(input) {
|
|
214
|
+
const items = preCheckRepositoryOp(input);
|
|
215
|
+
return {
|
|
216
|
+
canProceed: items.every(i => i.severity !== "block" || i.passed),
|
|
217
|
+
blockers: items.filter(i => i.severity === "block" && !i.passed),
|
|
218
|
+
warnings: items.filter(i => i.severity === "warn" && !i.passed),
|
|
219
|
+
info: items.filter(i => i.severity === "info"),
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
export function formatRepositoryOpSummary(input) {
|
|
223
|
+
const { canProceed, blockers, warnings, info } = canProceedRepositoryOp(input);
|
|
224
|
+
const lines = [];
|
|
225
|
+
lines.push(canProceed ? `✓ Repository ${input.op} pre-check PASSED` : `✗ Repository ${input.op} pre-check FAILED`);
|
|
226
|
+
lines.push("");
|
|
227
|
+
if (blockers.length > 0) {
|
|
228
|
+
lines.push("BLOCKERS (must fix before operation):");
|
|
229
|
+
blockers.forEach(b => lines.push(` [${b.id}] ${b.title} — ${b.evidence ?? ""}`));
|
|
230
|
+
lines.push("");
|
|
231
|
+
}
|
|
232
|
+
if (warnings.length > 0) {
|
|
233
|
+
lines.push("WARNINGS (review recommended):");
|
|
234
|
+
warnings.forEach(w => lines.push(` [${w.id}] ${w.title} — ${w.evidence ?? ""}`));
|
|
235
|
+
lines.push("");
|
|
236
|
+
}
|
|
237
|
+
if (info.length > 0) {
|
|
238
|
+
lines.push("INFO:");
|
|
239
|
+
info.forEach(i => lines.push(` [${i.id}] ${i.title}`));
|
|
240
|
+
}
|
|
241
|
+
return lines.join("\n");
|
|
242
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type RepositoryRiskLevel = "CRITICAL" | "HIGH" | "MEDIUM" | "LOW" | "INFO";
|
|
2
|
+
export type RepositoryRiskCategory = "structural" | "policy" | "routing" | "submission" | "knowledge";
|
|
3
|
+
export type RepositoryStakeholder = "creator" | "writer" | "reader" | "verifier" | "system";
|
|
4
|
+
export interface RepositoryRisk {
|
|
5
|
+
id: string;
|
|
6
|
+
level: RepositoryRiskLevel;
|
|
7
|
+
category: RepositoryRiskCategory;
|
|
8
|
+
title: string;
|
|
9
|
+
description: string;
|
|
10
|
+
affected_stakeholders: RepositoryStakeholder[];
|
|
11
|
+
scenario: string;
|
|
12
|
+
mitigation: string;
|
|
13
|
+
evidence?: string;
|
|
14
|
+
related_move_error?: string;
|
|
15
|
+
auto_fixable: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface RepositoryRiskCheckContext {
|
|
18
|
+
policies?: Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
id_from: number | string;
|
|
22
|
+
write_guard_count: number;
|
|
23
|
+
has_id_from_submission: boolean;
|
|
24
|
+
has_data_from_submission: boolean;
|
|
25
|
+
}>;
|
|
26
|
+
existing_policy_count?: number;
|
|
27
|
+
data_size?: number;
|
|
28
|
+
id_count_once?: number;
|
|
29
|
+
reward_count?: number;
|
|
30
|
+
is_data_remove_with_passport?: boolean;
|
|
31
|
+
constants_synced?: boolean;
|
|
32
|
+
}
|
|
33
|
+
declare function normalizeIdFrom(v: number | string): number;
|
|
34
|
+
export declare const REPOSITORY_RISK_RULES: {
|
|
35
|
+
rule: RepositoryRisk;
|
|
36
|
+
check: (ctx: RepositoryRiskCheckContext) => RepositoryRisk | null;
|
|
37
|
+
}[];
|
|
38
|
+
export declare function checkRepositoryRisks(ctx: RepositoryRiskCheckContext): RepositoryRisk[];
|
|
39
|
+
export declare function getRepositoryRiskById(id: string): RepositoryRisk | undefined;
|
|
40
|
+
export { normalizeIdFrom as parseIdFromForRiskCheck };
|