@wowok/agent-mcp 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -1621
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-ledger.js +14 -0
- package/dist/knowledge/guard-lint.d.ts +1 -0
- package/dist/knowledge/guard-lint.js +83 -3
- package/dist/knowledge/guard-migration.d.ts +48 -0
- package/dist/knowledge/guard-migration.js +228 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +3 -1
- package/dist/knowledge/guard-risk.js +832 -64
- package/dist/knowledge/guard-templates.d.ts +1 -0
- package/dist/knowledge/guard-templates.js +278 -2
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/graph.d.ts +1 -0
- package/dist/project/graph.js +27 -1
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +39 -2
- package/dist/project/namespace.d.ts +11 -1
- package/dist/project/namespace.js +27 -2
- package/dist/project/query.d.ts +2 -0
- package/dist/project/query.js +56 -15
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/rules.d.ts +12 -0
- package/dist/rules.js +9 -0
- package/dist/schema/call/allocation.d.ts +44 -44
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +6 -6
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +96 -96
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +238 -238
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1102 -1118
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +818 -818
- package/dist/schema/query/index.js +15 -9
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schema/utils/guard-query-utils.d.ts +7 -0
- package/dist/schema/utils/guard-query-utils.js +14 -1
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/bridge_operation.output.json +1 -1
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/messenger_operation.output.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +5 -4
- package/dist/schemas/onchain_operations.schema.json +1813 -333
- package/dist/schemas/onchain_operations_allocation.schema.json +9 -11
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +4 -6
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +4 -6
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.output.json +6 -12
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/bridge.d.ts +1 -0
- package/dist/tools/handlers/bridge.js +1 -0
- package/dist/tools/handlers/config.d.ts +2 -0
- package/dist/tools/handlers/config.js +74 -0
- package/dist/tools/handlers/file-export.d.ts +3 -0
- package/dist/tools/handlers/file-export.js +90 -0
- package/dist/tools/handlers/local.d.ts +3 -0
- package/dist/tools/handlers/local.js +38 -0
- package/dist/tools/handlers/messenger.d.ts +16 -0
- package/dist/tools/handlers/messenger.js +188 -0
- package/dist/tools/handlers/onchain.d.ts +2 -0
- package/dist/tools/handlers/onchain.js +248 -0
- package/dist/tools/handlers/project.d.ts +2 -0
- package/dist/tools/handlers/project.js +293 -0
- package/dist/tools/handlers/query.d.ts +5 -0
- package/dist/tools/handlers/query.js +256 -0
- package/dist/tools/handlers/schema-query.d.ts +2 -0
- package/dist/tools/handlers/schema-query.js +93 -0
- package/dist/tools/handlers/trust.d.ts +2 -0
- package/dist/tools/handlers/trust.js +194 -0
- package/dist/tools/handlers/wip.d.ts +2 -0
- package/dist/tools/handlers/wip.js +44 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.js +526 -0
- package/dist/tools/rules-hook.d.ts +2 -0
- package/dist/tools/rules-hook.js +23 -0
- package/dist/tools/shared.d.ts +20 -0
- package/dist/tools/shared.js +130 -0
- package/dist/tools/types.d.ts +35 -0
- package/dist/tools/types.js +1 -0
- package/dist/tools/wrap.d.ts +14 -0
- package/dist/tools/wrap.js +267 -0
- package/package.json +20 -6
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, } from "@wowok/wowok";
|
|
2
|
+
const R_S_1_01 = {
|
|
3
|
+
id: "R-S-1-01",
|
|
4
|
+
category: "structural",
|
|
5
|
+
trigger: "sales count exceeds MAX_SALE_COUNT (50)",
|
|
6
|
+
check: (ctx) => {
|
|
7
|
+
const count = ctx.current_sales_count ?? 0;
|
|
8
|
+
if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
|
|
9
|
+
const newCount = ctx.sales.op === "set" ? ctx.sales.sales.length : count + ctx.sales.sales.length;
|
|
10
|
+
if (newCount > MAX_SALE_COUNT) {
|
|
11
|
+
return {
|
|
12
|
+
id: "R-S-1-01",
|
|
13
|
+
level: "HIGH",
|
|
14
|
+
category: "structural",
|
|
15
|
+
title: "Sales count exceeds limit",
|
|
16
|
+
description: `Service would have ${newCount} sales items, exceeds MAX_SALE_COUNT ${MAX_SALE_COUNT}`,
|
|
17
|
+
affected_stakeholders: ["owner", "system"],
|
|
18
|
+
scenario: "Adding too many product SKUs",
|
|
19
|
+
mitigation: "Split into multiple Service objects or remove discontinued items",
|
|
20
|
+
evidence: `sales_count=${newCount}`,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
const R_S_1_02 = {
|
|
28
|
+
id: "R-S-1-02",
|
|
29
|
+
category: "structural",
|
|
30
|
+
trigger: "repositories count exceeds MAX_REPOSITORY_COUNT (100)",
|
|
31
|
+
check: (ctx) => {
|
|
32
|
+
const count = ctx.current_repositories_count ?? 0;
|
|
33
|
+
if (ctx.repositories && (ctx.repositories.op === "add" || ctx.repositories.op === "set")) {
|
|
34
|
+
const newCount = ctx.repositories.op === "set" ? ctx.repositories.objects.length : count + ctx.repositories.objects.length;
|
|
35
|
+
if (newCount > MAX_REPOSITORY_COUNT) {
|
|
36
|
+
return {
|
|
37
|
+
id: "R-S-1-02",
|
|
38
|
+
level: "MEDIUM",
|
|
39
|
+
category: "structural",
|
|
40
|
+
title: "Repositories count exceeds limit",
|
|
41
|
+
description: `Service would have ${newCount} repositories, exceeds MAX_REPOSITORY_COUNT ${MAX_REPOSITORY_COUNT}`,
|
|
42
|
+
affected_stakeholders: ["owner"],
|
|
43
|
+
scenario: "Binding too many data repositories",
|
|
44
|
+
mitigation: "Consolidate repositories or remove inactive ones",
|
|
45
|
+
evidence: `repositories_count=${newCount}`,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
const R_S_1_03 = {
|
|
53
|
+
id: "R-S-1-03",
|
|
54
|
+
category: "structural",
|
|
55
|
+
trigger: "arbitrations count exceeds MAX_ARBITRATION_COUNT (20)",
|
|
56
|
+
check: (ctx) => {
|
|
57
|
+
const count = ctx.current_arbitrations_count ?? 0;
|
|
58
|
+
if (ctx.arbitrations && (ctx.arbitrations.op === "add" || ctx.arbitrations.op === "set")) {
|
|
59
|
+
const newCount = ctx.arbitrations.op === "set" ? ctx.arbitrations.objects.length : count + ctx.arbitrations.objects.length;
|
|
60
|
+
if (newCount > MAX_ARBITRATION_COUNT) {
|
|
61
|
+
return {
|
|
62
|
+
id: "R-S-1-03",
|
|
63
|
+
level: "HIGH",
|
|
64
|
+
category: "structural",
|
|
65
|
+
title: "Arbitrations count exceeds limit",
|
|
66
|
+
description: `Service would have ${newCount} arbitrations, exceeds MAX_ARBITRATION_COUNT ${MAX_ARBITRATION_COUNT}`,
|
|
67
|
+
affected_stakeholders: ["owner", "arbitrator"],
|
|
68
|
+
scenario: "Binding too many Arbitration objects",
|
|
69
|
+
mitigation: "Use 1-3 Arbitration objects covering different dispute scopes",
|
|
70
|
+
evidence: `arbitrations_count=${newCount}`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const R_S_1_04 = {
|
|
78
|
+
id: "R-S-1-04",
|
|
79
|
+
category: "structural",
|
|
80
|
+
trigger: "WIP hash length exceeds MAX_WIP_HASH_LENGTH (64) or URL exceeds MAX_WIP_LENGTH (1024)",
|
|
81
|
+
check: (ctx) => {
|
|
82
|
+
if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
|
|
83
|
+
for (const s of ctx.sales.sales) {
|
|
84
|
+
if (s.wip_hash && s.wip_hash.length > MAX_WIP_HASH_LENGTH) {
|
|
85
|
+
return {
|
|
86
|
+
id: "R-S-1-04",
|
|
87
|
+
level: "HIGH",
|
|
88
|
+
category: "structural",
|
|
89
|
+
title: "WIP hash length exceeds limit",
|
|
90
|
+
description: `Sale "${s.name}" wip_hash length ${s.wip_hash.length} > MAX_WIP_HASH_LENGTH ${MAX_WIP_HASH_LENGTH}`,
|
|
91
|
+
affected_stakeholders: ["owner", "customer"],
|
|
92
|
+
scenario: "Malformed WIP hash (should be sha256 hex, 64 chars)",
|
|
93
|
+
mitigation: "Use sha256 hex hash (64 characters, no prefix)",
|
|
94
|
+
evidence: `wip_hash_length=${s.wip_hash.length}`,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (s.wip && s.wip.length > MAX_WIP_LENGTH) {
|
|
98
|
+
return {
|
|
99
|
+
id: "R-S-1-04",
|
|
100
|
+
level: "HIGH",
|
|
101
|
+
category: "structural",
|
|
102
|
+
title: "WIP URL length exceeds limit",
|
|
103
|
+
description: `Sale "${s.name}" wip URL length ${s.wip.length} > MAX_WIP_LENGTH ${MAX_WIP_LENGTH}`,
|
|
104
|
+
affected_stakeholders: ["owner"],
|
|
105
|
+
scenario: "WIP URL too long (use IPFS or short HTTPS URL)",
|
|
106
|
+
mitigation: "Use IPFS CID or shorter URL",
|
|
107
|
+
evidence: `wip_url_length=${s.wip.length}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const R_S_1_05 = {
|
|
116
|
+
id: "R-S-1-05",
|
|
117
|
+
category: "structural",
|
|
118
|
+
trigger: "Permission index not in Service range (300-320) used on Service object",
|
|
119
|
+
check: (ctx) => {
|
|
120
|
+
if (ctx.target_objects_types?.includes("Service")) {
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
const R_S_2_01 = {
|
|
126
|
+
id: "R-S-2-01",
|
|
127
|
+
category: "semantic",
|
|
128
|
+
trigger: "WIP hash tampering risk — owner updates WIP file without updating wip_hash",
|
|
129
|
+
check: (ctx) => {
|
|
130
|
+
if (ctx.sales && (ctx.sales.op === "add" || ctx.sales.op === "set")) {
|
|
131
|
+
for (const s of ctx.sales.sales) {
|
|
132
|
+
if (s.wip && !s.wip_hash) {
|
|
133
|
+
return {
|
|
134
|
+
id: "R-S-2-01",
|
|
135
|
+
level: "CRITICAL",
|
|
136
|
+
category: "semantic",
|
|
137
|
+
title: "WIP hash missing — tampering risk",
|
|
138
|
+
description: `Sale "${s.name}" has wip URL but no wip_hash. Owner could replace the WIP file without customers noticing.`,
|
|
139
|
+
affected_stakeholders: ["customer", "owner"],
|
|
140
|
+
scenario: "Owner sets wip without hash, then changes file content later",
|
|
141
|
+
mitigation: "Always compute sha256(wip_file_content) and set as wip_hash. SDK auto-derives if omitted, but explicit hash is safer.",
|
|
142
|
+
evidence: `sale=${s.name}`,
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const R_S_2_02 = {
|
|
151
|
+
id: "R-S-2-02",
|
|
152
|
+
category: "semantic",
|
|
153
|
+
trigger: "compensation_fund confused with Service balance (internal Balance<T>)",
|
|
154
|
+
check: (ctx) => {
|
|
155
|
+
if (ctx.compensation_fund_add) {
|
|
156
|
+
return {
|
|
157
|
+
id: "R-S-2-02",
|
|
158
|
+
level: "HIGH",
|
|
159
|
+
category: "semantic",
|
|
160
|
+
title: "compensation_fund is internal Balance<T>, NOT Service-owned Treasury",
|
|
161
|
+
description: `Depositing ${ctx.compensation_fund_add.balance} to compensation_fund. This balance is internal to Service<T> and is consumed by arbitration::compensation_claim, not by owner withdrawals. Owner can only withdraw via compensation_fund_withdraw (requires bPaused=true + lock_duration expired).`,
|
|
162
|
+
affected_stakeholders: ["owner", "arbitrator", "customer"],
|
|
163
|
+
scenario: "Owner confuses compensation_fund with general Treasury",
|
|
164
|
+
mitigation: "Use external Treasury (referenced via order_allocators.sharing.who=Entity) for general funds. Use compensation_fund only for arbitration payouts.",
|
|
165
|
+
evidence: `deposit=${ctx.compensation_fund_add.balance}`,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
},
|
|
170
|
+
};
|
|
171
|
+
const R_S_2_03 = {
|
|
172
|
+
id: "R-S-2-03",
|
|
173
|
+
category: "semantic",
|
|
174
|
+
trigger: "quote side effect — stock deduction not rolled back on later failure",
|
|
175
|
+
check: (ctx) => {
|
|
176
|
+
if (ctx.order_new && ctx.order_new.buy.items.length > 0) {
|
|
177
|
+
return {
|
|
178
|
+
id: "R-S-2-03",
|
|
179
|
+
level: "HIGH",
|
|
180
|
+
category: "semantic",
|
|
181
|
+
title: "Order flow: stock deducted at quote stage — NOT rolled back on failure",
|
|
182
|
+
description: `Order will deduct stock at Stage 3 (quote). If Stages 4-7 fail, stock remains deducted. Customer must manually re-add stock or accept the loss.`,
|
|
183
|
+
affected_stakeholders: ["owner", "customer"],
|
|
184
|
+
scenario: "Customer's transaction fails after quote but stock is gone",
|
|
185
|
+
mitigation: "1) Monitor failed transactions and re-add stock via stock_add. 2) Set sales suspension during high-failure periods. 3) Use small batch orders to limit blast radius.",
|
|
186
|
+
evidence: `items=${ctx.order_new.buy.items.length}`,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
const R_S_2_04 = {
|
|
193
|
+
id: "R-S-2-04",
|
|
194
|
+
category: "semantic",
|
|
195
|
+
trigger: "Discount issuance — verify type and total count semantics",
|
|
196
|
+
check: (ctx) => {
|
|
197
|
+
if (ctx.discount) {
|
|
198
|
+
const count = ctx.discount.count;
|
|
199
|
+
if (count > MAX_DISCOUNT_TOTAL_COUNT) {
|
|
200
|
+
return {
|
|
201
|
+
id: "R-S-2-04",
|
|
202
|
+
level: "MEDIUM",
|
|
203
|
+
category: "semantic",
|
|
204
|
+
title: "Discount count exceeds total cap",
|
|
205
|
+
description: `Issuing ${count} discounts exceeds MAX_DISCOUNT_TOTAL_COUNT ${MAX_DISCOUNT_TOTAL_COUNT}`,
|
|
206
|
+
affected_stakeholders: ["owner"],
|
|
207
|
+
scenario: "Bulk discount issuance",
|
|
208
|
+
mitigation: `Issue in batches of <= 1000 (MAX_DISCOUNT_COUNT_ONCE) and keep total <= ${MAX_DISCOUNT_TOTAL_COUNT}`,
|
|
209
|
+
evidence: `count=${count}`,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
const R_S_2_05 = {
|
|
217
|
+
id: "R-S-2-05",
|
|
218
|
+
category: "semantic",
|
|
219
|
+
trigger: "Order placed without verifying WIP hash — buyer passes empty wip_hash",
|
|
220
|
+
check: (ctx) => {
|
|
221
|
+
if (ctx.order_new) {
|
|
222
|
+
const emptyHashItems = ctx.order_new.buy.items.filter(i => i.wip_hash === "");
|
|
223
|
+
if (emptyHashItems.length > 0) {
|
|
224
|
+
return {
|
|
225
|
+
id: "R-S-2-05",
|
|
226
|
+
level: "MEDIUM",
|
|
227
|
+
category: "semantic",
|
|
228
|
+
title: "Order with empty wip_hash — SDK auto-fills from sale",
|
|
229
|
+
description: `${emptyHashItems.length} item(s) have empty wip_hash. SDK will auto-fill from sale.wip_hash at order time. If owner updates the WIP file between viewing and ordering, buyer receives the new (potentially different) content.`,
|
|
230
|
+
affected_stakeholders: ["customer"],
|
|
231
|
+
scenario: "Time-of-check to time-of-use WIP mismatch",
|
|
232
|
+
mitigation: "Buyer should explicitly pass the wip_hash they saw when viewing the product. Empty string is convenience but riskier.",
|
|
233
|
+
evidence: `empty_hash_items=${emptyHashItems.length}`,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
const R_S_3_01 = {
|
|
241
|
+
id: "R-S-3-01",
|
|
242
|
+
category: "authority",
|
|
243
|
+
trigger: "publish operation — requires SERVICE_PUBLISH (311) + prerequisites",
|
|
244
|
+
check: (ctx) => {
|
|
245
|
+
if (!ctx.publish)
|
|
246
|
+
return null;
|
|
247
|
+
const blockers = [];
|
|
248
|
+
if (!ctx.current_order_allocators_set)
|
|
249
|
+
blockers.push("order_allocators not set (F-S-18, E_NO_ALLOCATOR)");
|
|
250
|
+
const compBalance = ctx.current_compensation_fund_balance ?? "0";
|
|
251
|
+
if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
|
|
252
|
+
blockers.push("compensation_fund > 0 but no arbitrations (F-S-19, E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)");
|
|
253
|
+
}
|
|
254
|
+
if (blockers.length > 0) {
|
|
255
|
+
return {
|
|
256
|
+
id: "R-S-3-01",
|
|
257
|
+
level: "CRITICAL",
|
|
258
|
+
category: "authority",
|
|
259
|
+
title: "Publish blocked — prerequisites not met",
|
|
260
|
+
description: `Cannot publish: ${blockers.join("; ")}`,
|
|
261
|
+
affected_stakeholders: ["owner"],
|
|
262
|
+
scenario: "Owner attempts publish without configuring prerequisites",
|
|
263
|
+
mitigation: "Configure order_allocators (and arbitrations if compensation_fund > 0) before publish",
|
|
264
|
+
evidence: `blockers=${blockers.length}`,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
return null;
|
|
268
|
+
},
|
|
269
|
+
};
|
|
270
|
+
const R_S_3_02 = {
|
|
271
|
+
id: "R-S-3-02",
|
|
272
|
+
category: "authority",
|
|
273
|
+
trigger: "pause operation — affects new orders but not existing Progress",
|
|
274
|
+
check: (ctx) => {
|
|
275
|
+
if (ctx.pause === undefined)
|
|
276
|
+
return null;
|
|
277
|
+
return {
|
|
278
|
+
id: "R-S-3-02",
|
|
279
|
+
level: "MEDIUM",
|
|
280
|
+
category: "authority",
|
|
281
|
+
title: ctx.pause ? "Pausing Service — new orders blocked, existing Progress continues" : "Resuming Service — new orders accepted",
|
|
282
|
+
description: ctx.pause
|
|
283
|
+
? "Service.bPaused = true will reject new orders (E_SERVICE_PAUSED). Existing orders' Progress continues normally."
|
|
284
|
+
: "Service.bPaused = false will allow new orders again.",
|
|
285
|
+
affected_stakeholders: ["owner", "customer"],
|
|
286
|
+
scenario: ctx.pause ? "Owner pauses for maintenance/stockout" : "Owner resumes after maintenance",
|
|
287
|
+
mitigation: ctx.pause ? "Communicate pause to customers. Use compensation_fund_withdraw only when paused." : "Verify stock levels before resuming.",
|
|
288
|
+
evidence: `pause=${ctx.pause}`,
|
|
289
|
+
};
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
const R_S_3_03 = {
|
|
293
|
+
id: "R-S-3-03",
|
|
294
|
+
category: "authority",
|
|
295
|
+
trigger: "buy_guard change — post-publish mutable (unusual exception)",
|
|
296
|
+
check: (ctx) => {
|
|
297
|
+
if (ctx.buy_guard === undefined)
|
|
298
|
+
return null;
|
|
299
|
+
if (ctx.current_bPublished) {
|
|
300
|
+
return {
|
|
301
|
+
id: "R-S-3-03",
|
|
302
|
+
level: "MEDIUM",
|
|
303
|
+
category: "authority",
|
|
304
|
+
title: "buy_guard change post-publish — unusual mutability",
|
|
305
|
+
description: `buy_guard is the ONLY publish-locked-field exception: it remains mutable post-publish. Other fields (machine/arbitrations/order_allocators) are immutable.`,
|
|
306
|
+
affected_stakeholders: ["owner", "customer"],
|
|
307
|
+
scenario: "Owner changes buy_guard strategy after publish (e.g. whitelist → public)",
|
|
308
|
+
mitigation: "Document buy_guard changes for transparency. Customers should re-verify buy_guard before ordering.",
|
|
309
|
+
evidence: `buy_guard=${ctx.buy_guard ?? "(cleared)"}`,
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
return null;
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
const R_S_3_04 = {
|
|
316
|
+
id: "R-S-3-04",
|
|
317
|
+
category: "authority",
|
|
318
|
+
trigger: "Ownership transfer (builder field) — irreversible",
|
|
319
|
+
check: (ctx) => {
|
|
320
|
+
if (!ctx.builder)
|
|
321
|
+
return null;
|
|
322
|
+
return {
|
|
323
|
+
id: "R-S-3-04",
|
|
324
|
+
level: "HIGH",
|
|
325
|
+
category: "authority",
|
|
326
|
+
title: "Service ownership transfer — IRREVERSIBLE",
|
|
327
|
+
description: `Transferring Service to ${ctx.builder}. Original owner loses ALL control. New owner inherits permission + compensation_fund + all bindings.`,
|
|
328
|
+
affected_stakeholders: ["owner"],
|
|
329
|
+
scenario: "Owner transfers Service to new address",
|
|
330
|
+
mitigation: "1) Verify new owner address twice. 2) Withdraw compensation_fund first (if applicable). 3) Export Service JSON before transfer.",
|
|
331
|
+
evidence: `new_owner=${ctx.builder}`,
|
|
332
|
+
};
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
const R_S_4_01 = {
|
|
336
|
+
id: "R-S-4-01",
|
|
337
|
+
category: "lifecycle",
|
|
338
|
+
trigger: "publish is irreversible — bPublished cannot be reset to false",
|
|
339
|
+
check: (ctx) => {
|
|
340
|
+
if (!ctx.publish)
|
|
341
|
+
return null;
|
|
342
|
+
if (ctx.current_bPublished) {
|
|
343
|
+
return {
|
|
344
|
+
id: "R-S-4-01",
|
|
345
|
+
level: "HIGH",
|
|
346
|
+
category: "lifecycle",
|
|
347
|
+
title: "Service already published — publish is no-op",
|
|
348
|
+
description: "Service.bPublished is already true. Subsequent publish calls have no effect (bPublished is one-shot, cannot revert).",
|
|
349
|
+
affected_stakeholders: ["owner"],
|
|
350
|
+
scenario: "Owner calls publish again on already-published Service",
|
|
351
|
+
mitigation: "Skip publish if already published. To 'reset' a Service, create a new one.",
|
|
352
|
+
evidence: `bPublished=true`,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
return {
|
|
356
|
+
id: "R-S-4-01",
|
|
357
|
+
level: "HIGH",
|
|
358
|
+
category: "lifecycle",
|
|
359
|
+
title: "Publish is IRREVERSIBLE — 3 fields will be locked forever",
|
|
360
|
+
description: "Once published: machine (306), arbitrations (308), order_allocators (313) become permanently immutable. bPublished cannot be reset to false. Clone Service to make changes.",
|
|
361
|
+
affected_stakeholders: ["owner", "customer"],
|
|
362
|
+
scenario: "Owner publishes Service for the first time",
|
|
363
|
+
mitigation: "Verify all configurations before publish. Run pre-publish checklist (service-confirm.ts).",
|
|
364
|
+
evidence: `bPublished=false→true`,
|
|
365
|
+
};
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
const R_S_4_02 = {
|
|
369
|
+
id: "R-S-4-02",
|
|
370
|
+
category: "lifecycle",
|
|
371
|
+
trigger: "setting_lock_duration add — only-increase mechanism",
|
|
372
|
+
check: (ctx) => {
|
|
373
|
+
if (ctx.setting_locked_time_add === undefined)
|
|
374
|
+
return null;
|
|
375
|
+
return {
|
|
376
|
+
id: "R-S-4-02",
|
|
377
|
+
level: "MEDIUM",
|
|
378
|
+
category: "lifecycle",
|
|
379
|
+
title: "setting_lock_duration can only INCREASE",
|
|
380
|
+
description: `Adding ${ctx.setting_locked_time_add} ms to setting_lock_duration. New value = old + input (safe_add). Cannot be decreased — protects customers from owner reducing lock to withdraw compensation_fund faster.`,
|
|
381
|
+
affected_stakeholders: ["owner", "customer"],
|
|
382
|
+
scenario: "Owner extends lock period to build trust",
|
|
383
|
+
mitigation: "Ensure extension is intentional. Lock affects rewards/compensation_fund_withdraw/compensation_fund_receive.",
|
|
384
|
+
evidence: `add_ms=${ctx.setting_locked_time_add}`,
|
|
385
|
+
};
|
|
386
|
+
},
|
|
387
|
+
};
|
|
388
|
+
const R_S_4_03 = {
|
|
389
|
+
id: "R-S-4-03",
|
|
390
|
+
category: "lifecycle",
|
|
391
|
+
trigger: "machine/arbitrations/order_allocators modification after publish — SDK blocks",
|
|
392
|
+
check: (ctx) => {
|
|
393
|
+
if (!ctx.current_bPublished)
|
|
394
|
+
return null;
|
|
395
|
+
const blockedFields = [];
|
|
396
|
+
if (ctx.machine !== undefined)
|
|
397
|
+
blockedFields.push("machine (306)");
|
|
398
|
+
if (ctx.arbitrations !== undefined)
|
|
399
|
+
blockedFields.push("arbitrations (308)");
|
|
400
|
+
if (ctx.order_allocators !== undefined)
|
|
401
|
+
blockedFields.push("order_allocators (313)");
|
|
402
|
+
if (blockedFields.length > 0) {
|
|
403
|
+
return {
|
|
404
|
+
id: "R-S-4-03",
|
|
405
|
+
level: "HIGH",
|
|
406
|
+
category: "lifecycle",
|
|
407
|
+
title: "Post-publish modification blocked by SDK",
|
|
408
|
+
description: `Service is published. Cannot modify: ${blockedFields.join(", ")}. SDK checkNotPublished() will abort. To change these fields, clone the Service.`,
|
|
409
|
+
affected_stakeholders: ["owner"],
|
|
410
|
+
scenario: "Owner attempts to change locked field post-publish",
|
|
411
|
+
mitigation: "Create a new Service with the desired configuration. Migrate active orders if needed.",
|
|
412
|
+
evidence: `blocked=${blockedFields.join(",")}`,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
return null;
|
|
416
|
+
},
|
|
417
|
+
};
|
|
418
|
+
const R_S_4_04 = {
|
|
419
|
+
id: "R-S-4-04",
|
|
420
|
+
category: "lifecycle",
|
|
421
|
+
trigger: "sales modification — stock/price changes affect future orders only",
|
|
422
|
+
check: (ctx) => {
|
|
423
|
+
if (!ctx.sales)
|
|
424
|
+
return null;
|
|
425
|
+
return {
|
|
426
|
+
id: "R-S-4-04",
|
|
427
|
+
level: "LOW",
|
|
428
|
+
category: "lifecycle",
|
|
429
|
+
title: "Sales modification affects future orders only",
|
|
430
|
+
description: "Sales add/set/remove/clear changes do NOT affect already-created Orders. Existing Orders' Progress continues with the original sale parameters.",
|
|
431
|
+
affected_stakeholders: ["owner", "customer"],
|
|
432
|
+
scenario: "Owner updates prices mid-campaign",
|
|
433
|
+
mitigation: "Communicate price/stock changes to customers. Existing orders are unaffected.",
|
|
434
|
+
evidence: `sales_op=${ctx.sales.op}`,
|
|
435
|
+
};
|
|
436
|
+
},
|
|
437
|
+
};
|
|
438
|
+
const R_S_5_01 = {
|
|
439
|
+
id: "R-S-5-01",
|
|
440
|
+
category: "cross_object",
|
|
441
|
+
trigger: "Machine binding — post-publish immutable, Progress inherits",
|
|
442
|
+
check: (ctx) => {
|
|
443
|
+
if (ctx.machine === undefined)
|
|
444
|
+
return null;
|
|
445
|
+
if (ctx.current_bPublished) {
|
|
446
|
+
return {
|
|
447
|
+
id: "R-S-5-01",
|
|
448
|
+
level: "HIGH",
|
|
449
|
+
category: "cross_object",
|
|
450
|
+
title: "Machine binding immutable post-publish",
|
|
451
|
+
description: `Service is published; machine cannot be changed. All future Progress objects will use the bound Machine.`,
|
|
452
|
+
affected_stakeholders: ["owner"],
|
|
453
|
+
scenario: "Owner wants to upgrade workflow post-publish",
|
|
454
|
+
mitigation: "Create new Service with new Machine. Migrate customers via discounts.",
|
|
455
|
+
evidence: `machine=${ctx.machine ?? "(cleared)"}`,
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
id: "R-S-5-01",
|
|
460
|
+
level: "MEDIUM",
|
|
461
|
+
category: "cross_object",
|
|
462
|
+
title: "Machine binding — verify Machine is published",
|
|
463
|
+
description: `Binding Machine ${ctx.machine}. Ensure Machine is published (machine::publish) — Service cannot bind unpublished Machine.`,
|
|
464
|
+
affected_stakeholders: ["owner"],
|
|
465
|
+
scenario: "Owner binds Machine before publishing Service",
|
|
466
|
+
mitigation: "Verify Machine.bPublished = true before binding.",
|
|
467
|
+
evidence: `machine=${ctx.machine}`,
|
|
468
|
+
};
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
const R_S_5_02 = {
|
|
472
|
+
id: "R-S-5-02",
|
|
473
|
+
category: "cross_object",
|
|
474
|
+
trigger: "Arbitration binding — required when compensation_fund > 0",
|
|
475
|
+
check: (ctx) => {
|
|
476
|
+
if (!ctx.arbitrations)
|
|
477
|
+
return null;
|
|
478
|
+
const compBalance = ctx.current_compensation_fund_balance ?? "0";
|
|
479
|
+
if (BigInt(compBalance) > 0n && (ctx.current_arbitrations_count ?? 0) === 0) {
|
|
480
|
+
return {
|
|
481
|
+
id: "R-S-5-02",
|
|
482
|
+
level: "HIGH",
|
|
483
|
+
category: "cross_object",
|
|
484
|
+
title: "Arbitration required — compensation_fund has balance",
|
|
485
|
+
description: `compensation_fund balance is ${compBalance}. Publish will fail (E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND) until arbitrations is non-empty.`,
|
|
486
|
+
affected_stakeholders: ["owner"],
|
|
487
|
+
scenario: "Owner deposits compensation_fund without configuring arbitrations",
|
|
488
|
+
mitigation: "Add at least 1 Arbitration object before publish.",
|
|
489
|
+
evidence: `compensation_fund=${compBalance}`,
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
return null;
|
|
493
|
+
},
|
|
494
|
+
};
|
|
495
|
+
const R_S_5_03 = {
|
|
496
|
+
id: "R-S-5-03",
|
|
497
|
+
category: "cross_object",
|
|
498
|
+
trigger: "order_allocators binding — publish prerequisite, post-publish immutable",
|
|
499
|
+
check: (ctx) => {
|
|
500
|
+
if (ctx.order_allocators === undefined)
|
|
501
|
+
return null;
|
|
502
|
+
if (ctx.current_bPublished) {
|
|
503
|
+
return {
|
|
504
|
+
id: "R-S-5-03",
|
|
505
|
+
level: "HIGH",
|
|
506
|
+
category: "cross_object",
|
|
507
|
+
title: "order_allocators immutable post-publish",
|
|
508
|
+
description: "Service is published; order_allocators cannot be changed. Fund distribution strategy is permanently locked.",
|
|
509
|
+
affected_stakeholders: ["owner"],
|
|
510
|
+
scenario: "Owner wants to adjust fee split post-publish",
|
|
511
|
+
mitigation: "Create new Service with new allocators. Cannot migrate existing Orders.",
|
|
512
|
+
evidence: `order_allocators=${ctx.order_allocators ? "(set)" : "(cleared)"}`,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
if (ctx.publish && !ctx.order_allocators) {
|
|
516
|
+
return {
|
|
517
|
+
id: "R-S-5-03",
|
|
518
|
+
level: "CRITICAL",
|
|
519
|
+
category: "cross_object",
|
|
520
|
+
title: "Publish without order_allocators — will fail",
|
|
521
|
+
description: "Publish will abort with E_NO_ALLOCATOR. order_allocators is a mandatory publish prerequisite.",
|
|
522
|
+
affected_stakeholders: ["owner"],
|
|
523
|
+
scenario: "Owner attempts publish without configuring allocators",
|
|
524
|
+
mitigation: "Set order_allocators before publish.",
|
|
525
|
+
evidence: `order_allocators=null`,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
},
|
|
530
|
+
};
|
|
531
|
+
const R_S_5_04 = {
|
|
532
|
+
id: "R-S-5-04",
|
|
533
|
+
category: "cross_object",
|
|
534
|
+
trigger: "Repository/Reward binding — verify object types before adding",
|
|
535
|
+
check: (ctx) => {
|
|
536
|
+
if (ctx.repositories && (ctx.repositories.op === "add" || ctx.repositories.op === "set")) {
|
|
537
|
+
return {
|
|
538
|
+
id: "R-S-5-04",
|
|
539
|
+
level: "LOW",
|
|
540
|
+
category: "cross_object",
|
|
541
|
+
title: "Repository binding — verify object types",
|
|
542
|
+
description: `Adding ${ctx.repositories.objects.length} repositories. SDK uses queryObjectsWithType to validate each is ObjectType.Repository before binding.`,
|
|
543
|
+
affected_stakeholders: ["owner"],
|
|
544
|
+
scenario: "Owner adds non-Repository object by mistake",
|
|
545
|
+
mitigation: "Use LocalMark names or addresses that are confirmed Repository objects.",
|
|
546
|
+
evidence: `objects=${ctx.repositories.objects.length}`,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
if (ctx.rewards && (ctx.rewards.op === "add" || ctx.rewards.op === "set")) {
|
|
550
|
+
return {
|
|
551
|
+
id: "R-S-5-04",
|
|
552
|
+
level: "LOW",
|
|
553
|
+
category: "cross_object",
|
|
554
|
+
title: "Reward binding — verify object types + lock_duration",
|
|
555
|
+
description: `Adding ${ctx.rewards.objects.length} rewards. SDK validates ObjectType.Reward. Note: rewards modification is locked by setting_lock_duration.`,
|
|
556
|
+
affected_stakeholders: ["owner"],
|
|
557
|
+
scenario: "Owner adds Reward objects",
|
|
558
|
+
mitigation: "Verify Reward objects exist and are active. Be aware of lock_duration implications.",
|
|
559
|
+
evidence: `objects=${ctx.rewards.objects.length}`,
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
return null;
|
|
563
|
+
},
|
|
564
|
+
};
|
|
565
|
+
const ALL_RULES = [
|
|
566
|
+
R_S_1_01, R_S_1_02, R_S_1_03, R_S_1_04, R_S_1_05,
|
|
567
|
+
R_S_2_01, R_S_2_02, R_S_2_03, R_S_2_04, R_S_2_05,
|
|
568
|
+
R_S_3_01, R_S_3_02, R_S_3_03, R_S_3_04,
|
|
569
|
+
R_S_4_01, R_S_4_02, R_S_4_03, R_S_4_04,
|
|
570
|
+
R_S_5_01, R_S_5_02, R_S_5_03, R_S_5_04,
|
|
571
|
+
];
|
|
572
|
+
export const SERVICE_RISK_VERSION = "1.0.0";
|
|
573
|
+
export function getAllServiceRiskRules() {
|
|
574
|
+
return [...ALL_RULES];
|
|
575
|
+
}
|
|
576
|
+
export function getServiceRiskRulesCount() {
|
|
577
|
+
return ALL_RULES.length;
|
|
578
|
+
}
|
|
579
|
+
export function getServiceRiskRulesByCategory(category) {
|
|
580
|
+
return ALL_RULES.filter(r => r.category === category);
|
|
581
|
+
}
|
|
582
|
+
export function assessServiceRisks(ctx) {
|
|
583
|
+
const risks = [];
|
|
584
|
+
for (const rule of ALL_RULES) {
|
|
585
|
+
const r = rule.check(ctx);
|
|
586
|
+
if (r)
|
|
587
|
+
risks.push(r);
|
|
588
|
+
}
|
|
589
|
+
const overall = risks.length === 0
|
|
590
|
+
? "LOW"
|
|
591
|
+
: risks.some(r => r.level === "CRITICAL") ? "CRITICAL"
|
|
592
|
+
: risks.some(r => r.level === "HIGH") ? "HIGH"
|
|
593
|
+
: risks.some(r => r.level === "MEDIUM") ? "MEDIUM"
|
|
594
|
+
: "LOW";
|
|
595
|
+
const byCategory = {};
|
|
596
|
+
for (const r of risks) {
|
|
597
|
+
byCategory[r.category] = (byCategory[r.category] ?? 0) + 1;
|
|
598
|
+
}
|
|
599
|
+
const advice = {};
|
|
600
|
+
for (const r of risks) {
|
|
601
|
+
for (const s of r.affected_stakeholders) {
|
|
602
|
+
if (!advice[s])
|
|
603
|
+
advice[s] = [];
|
|
604
|
+
advice[s].push(`${r.id}: ${r.mitigation}`);
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
return {
|
|
608
|
+
summary: `Assessed ${risks.length} risk(s) across ${Object.keys(byCategory).length} categories`,
|
|
609
|
+
risks,
|
|
610
|
+
overall_risk: overall,
|
|
611
|
+
risks_by_category: byCategory,
|
|
612
|
+
stakeholder_advice: advice,
|
|
613
|
+
needs_human_review: risks.some(r => r.level === "CRITICAL" || r.level === "HIGH"),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export type TemplateParamType = "address" | "string" | "number" | "string[]" | "object";
|
|
2
|
+
export interface ServiceTemplateParam {
|
|
3
|
+
name: string;
|
|
4
|
+
type: TemplateParamType;
|
|
5
|
+
description: string;
|
|
6
|
+
required: boolean;
|
|
7
|
+
default?: string | number | string[] | object;
|
|
8
|
+
}
|
|
9
|
+
export interface ServiceTemplate {
|
|
10
|
+
id: string;
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
applicable_scenes: string[];
|
|
14
|
+
industry_tags: string[];
|
|
15
|
+
params: ServiceTemplateParam[];
|
|
16
|
+
body: (params: Record<string, string | number | string[] | object>) => object;
|
|
17
|
+
notes?: string[];
|
|
18
|
+
post_publish_considerations?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare const SERVICE_TEMPLATES: ServiceTemplate[];
|
|
21
|
+
export declare const SERVICE_TEMPLATES_VERSION = "1.0.0";
|
|
22
|
+
export declare function getAllServiceTemplates(): ServiceTemplate[];
|
|
23
|
+
export declare function getServiceTemplateById(id: string): ServiceTemplate | undefined;
|
|
24
|
+
export declare function getServiceTemplatesByScene(sceneId: string): ServiceTemplate[];
|
|
25
|
+
export declare function getServiceTemplatesByIndustry(industry: string): ServiceTemplate[];
|
|
26
|
+
export declare function suggestServiceTemplateForScene(sceneId: string): ServiceTemplate | undefined;
|
|
27
|
+
export declare function listServiceTemplates(): {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
scenes: string[];
|
|
32
|
+
}[];
|
|
33
|
+
export interface FillServiceTemplateResult {
|
|
34
|
+
ok: boolean;
|
|
35
|
+
body?: object;
|
|
36
|
+
error?: string;
|
|
37
|
+
missing_required?: string[];
|
|
38
|
+
}
|
|
39
|
+
export declare function fillServiceTemplate(templateId: string, params: Record<string, string | number | string[] | object>): FillServiceTemplateResult;
|