@wowok/agent-mcp 2.4.3 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1802 -313
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +258 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +55 -8
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { analyzeTopology, } from "./machine-topology.js";
|
|
2
|
+
import { USER_DEFINED_PERM_INDEX_START, MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, MAX_FORWARD_ORDER_COUNT, } from "./onchain-constants.js";
|
|
3
|
+
import { assessMachineRisks, } from "./machine-risk.js";
|
|
4
|
+
import { derivePuzzleFromMachineJson, generateConfirmationText, } from "./machine-puzzle.js";
|
|
5
|
+
export const PUBLISH_CHECKLIST = [
|
|
6
|
+
{
|
|
7
|
+
id: "C-01",
|
|
8
|
+
description: "Entry point exists: at least one Pair with prev_node=''",
|
|
9
|
+
status: "skip",
|
|
10
|
+
detail: "Workflow cannot start without entry Pair. Verify Pair table for empty prev_node.",
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
id: "C-02",
|
|
14
|
+
description: "Every node has outgoing Forwards (except terminal nodes)",
|
|
15
|
+
status: "skip",
|
|
16
|
+
detail: "Dead-end nodes trap workflow. Identify terminals and verify they are intended.",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "C-03",
|
|
20
|
+
description: "Every node has incoming Pair (except entry point)",
|
|
21
|
+
status: "skip",
|
|
22
|
+
detail: "Orphaned nodes are unreachable. Verify all non-entry nodes are reachable.",
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: "C-04",
|
|
26
|
+
description: "All thresholds independently achievable (no dead branches)",
|
|
27
|
+
status: "skip",
|
|
28
|
+
detail: "If a competing Pair always loses, it is dead code. Use topology analysis.",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "C-05",
|
|
32
|
+
description: "All Guards exist on-chain and tested (via gen_passport)",
|
|
33
|
+
status: "skip",
|
|
34
|
+
detail: "Guard addresses referenced in forwards must be valid published Guard objects.",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: "C-06",
|
|
38
|
+
description: "namedOperator vs permissionIndex correct per Forward",
|
|
39
|
+
status: "skip",
|
|
40
|
+
detail: "Each Forward must have at least one of namedOperator or permissionIndex.",
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: "C-07",
|
|
44
|
+
description: "Terminal nodes mapped to Allocator entries for fund distribution",
|
|
45
|
+
status: "skip",
|
|
46
|
+
detail: "Terminal nodes without Allocator risk funds being locked forever.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "C-08",
|
|
50
|
+
description: "Tested end-to-end on testnet via a test Progress",
|
|
51
|
+
status: "skip",
|
|
52
|
+
detail: "Testnet verification is mandatory before mainnet publish.",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: "C-09",
|
|
56
|
+
description: "Current state exported via machineNode2file as backup",
|
|
57
|
+
status: "skip",
|
|
58
|
+
detail: "Backup before publish. If publish fails, you can rebuild from export.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "C-10",
|
|
62
|
+
description: `On-chain constraint limits respected (MAX_NODE_COUNT=${MAX_NODE_COUNT}, MAX_NODE_PAIR_COUNT=${MAX_NODE_PAIR_COUNT}, MAX_FORWARD_COUNT=${MAX_FORWARD_COUNT})`,
|
|
63
|
+
status: "skip",
|
|
64
|
+
detail: "Exceeding on-chain constants will cause transaction failure.",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "C-11",
|
|
68
|
+
description: "All permissionIndex values >= 1000 (USER_DEFINED_PERM_INDEX_START)",
|
|
69
|
+
status: "skip",
|
|
70
|
+
detail: "On-chain permission.move reserves indexes 0-999 for built-in permissions. " +
|
|
71
|
+
"Custom permission_index MUST be >= 1000 (see doc 06 §4.4). " +
|
|
72
|
+
"Using index < 1000 causes confusion with built-in permissions.",
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
export function runStaticChecklist(machine) {
|
|
76
|
+
const checked = [];
|
|
77
|
+
const failed = [];
|
|
78
|
+
const warnings = [];
|
|
79
|
+
const topology = analyzeTopology(machine.nodes, machine.pairs);
|
|
80
|
+
const hasEntry = topology.entry_nodes.length > 0;
|
|
81
|
+
checked.push({
|
|
82
|
+
id: "C-01",
|
|
83
|
+
description: "Entry point exists",
|
|
84
|
+
status: hasEntry ? "pass" : "fail",
|
|
85
|
+
detail: hasEntry
|
|
86
|
+
? `Found entry nodes: ${topology.entry_nodes.join(", ")}`
|
|
87
|
+
: "NO entry Pair with prev_node=''",
|
|
88
|
+
});
|
|
89
|
+
if (!hasEntry)
|
|
90
|
+
failed.push(checked[checked.length - 1]);
|
|
91
|
+
const nonTerminalWithoutOutgoing = machine.nodes.filter((n) => !topology.terminal_nodes.includes(n.name) &&
|
|
92
|
+
!machine.pairs.some((p) => p.prev_node === n.name));
|
|
93
|
+
checked.push({
|
|
94
|
+
id: "C-02",
|
|
95
|
+
description: "Every node has outgoing Forwards (except terminals)",
|
|
96
|
+
status: nonTerminalWithoutOutgoing.length === 0 ? "pass" : "fail",
|
|
97
|
+
detail: nonTerminalWithoutOutgoing.length === 0
|
|
98
|
+
? "All non-terminal nodes have outgoing Pairs"
|
|
99
|
+
: `Dead-end nodes: ${nonTerminalWithoutOutgoing.map((n) => n.name).join(", ")}`,
|
|
100
|
+
});
|
|
101
|
+
if (nonTerminalWithoutOutgoing.length > 0)
|
|
102
|
+
failed.push(checked[checked.length - 1]);
|
|
103
|
+
checked.push({
|
|
104
|
+
id: "C-03",
|
|
105
|
+
description: "Every node has incoming Pair",
|
|
106
|
+
status: topology.orphaned_nodes.length === 0 ? "pass" : "fail",
|
|
107
|
+
detail: topology.orphaned_nodes.length === 0
|
|
108
|
+
? "All non-entry nodes are reachable"
|
|
109
|
+
: `Orphaned nodes: ${topology.orphaned_nodes.join(", ")}`,
|
|
110
|
+
});
|
|
111
|
+
if (topology.orphaned_nodes.length > 0)
|
|
112
|
+
failed.push(checked[checked.length - 1]);
|
|
113
|
+
checked.push({
|
|
114
|
+
id: "C-04",
|
|
115
|
+
description: "All thresholds achievable",
|
|
116
|
+
status: topology.dead_branches.length === 0 ? "pass" : "warning",
|
|
117
|
+
detail: topology.dead_branches.length === 0
|
|
118
|
+
? "No dead branches detected"
|
|
119
|
+
: `Potential dead branches: ${topology.dead_branches.length}`,
|
|
120
|
+
});
|
|
121
|
+
if (topology.dead_branches.length > 0)
|
|
122
|
+
warnings.push(checked[checked.length - 1]);
|
|
123
|
+
checked.push({
|
|
124
|
+
id: "C-05",
|
|
125
|
+
description: "All Guards exist on-chain",
|
|
126
|
+
status: "skip",
|
|
127
|
+
detail: "Verify at runtime via onchain_objects query for each Guard address",
|
|
128
|
+
});
|
|
129
|
+
const invalidForwards = [];
|
|
130
|
+
for (const pair of machine.pairs) {
|
|
131
|
+
for (const fwd of pair.forwards) {
|
|
132
|
+
const hasNamed = fwd.named_operator !== undefined;
|
|
133
|
+
const hasPerm = fwd.permission_index !== undefined;
|
|
134
|
+
if (!hasNamed && !hasPerm) {
|
|
135
|
+
invalidForwards.push(`${pair.prev_node}->${pair.next_node}:${fwd.name}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
checked.push({
|
|
140
|
+
id: "C-06",
|
|
141
|
+
description: "Forward permission model correct",
|
|
142
|
+
status: invalidForwards.length === 0 ? "pass" : "fail",
|
|
143
|
+
detail: invalidForwards.length === 0
|
|
144
|
+
? "All Forwards have valid permission"
|
|
145
|
+
: `Invalid Forwards: ${invalidForwards.join(", ")}`,
|
|
146
|
+
});
|
|
147
|
+
if (invalidForwards.length > 0)
|
|
148
|
+
failed.push(checked[checked.length - 1]);
|
|
149
|
+
checked.push({
|
|
150
|
+
id: "C-07",
|
|
151
|
+
description: "Terminal nodes have Allocator",
|
|
152
|
+
status: "skip",
|
|
153
|
+
detail: "Verify at Service binding stage",
|
|
154
|
+
});
|
|
155
|
+
checked.push({
|
|
156
|
+
id: "C-08",
|
|
157
|
+
description: "Testnet test passed",
|
|
158
|
+
status: "skip",
|
|
159
|
+
detail: "Verify at Layer 4 (environment)",
|
|
160
|
+
});
|
|
161
|
+
checked.push({
|
|
162
|
+
id: "C-09",
|
|
163
|
+
description: "machineNode2file backup created",
|
|
164
|
+
status: "skip",
|
|
165
|
+
detail: "Recommend exporting before publish",
|
|
166
|
+
});
|
|
167
|
+
const limitViolations = [];
|
|
168
|
+
if (!topology.within_limits.max_node_count)
|
|
169
|
+
limitViolations.push(`MAX_NODE_COUNT=${MAX_NODE_COUNT}`);
|
|
170
|
+
if (!topology.within_limits.max_node_pair_count)
|
|
171
|
+
limitViolations.push(`MAX_NODE_PAIR_COUNT=${MAX_NODE_PAIR_COUNT}`);
|
|
172
|
+
if (!topology.within_limits.max_forward_count)
|
|
173
|
+
limitViolations.push(`MAX_FORWARD_COUNT=${MAX_FORWARD_COUNT}`);
|
|
174
|
+
if (!topology.within_limits.max_forward_order_count)
|
|
175
|
+
limitViolations.push(`MAX_FORWARD_ORDER_COUNT=${MAX_FORWARD_ORDER_COUNT}`);
|
|
176
|
+
checked.push({
|
|
177
|
+
id: "C-10",
|
|
178
|
+
description: "On-chain limits respected",
|
|
179
|
+
status: limitViolations.length === 0 ? "pass" : "fail",
|
|
180
|
+
detail: limitViolations.length === 0
|
|
181
|
+
? "All limits within bounds"
|
|
182
|
+
: `Violations: ${limitViolations.join(", ")}`,
|
|
183
|
+
});
|
|
184
|
+
if (limitViolations.length > 0)
|
|
185
|
+
failed.push(checked[checked.length - 1]);
|
|
186
|
+
const lowPermissionIndexes = [];
|
|
187
|
+
for (const pair of machine.pairs) {
|
|
188
|
+
for (const fwd of pair.forwards) {
|
|
189
|
+
if (fwd.permission_index !== undefined &&
|
|
190
|
+
fwd.permission_index !== null &&
|
|
191
|
+
fwd.permission_index < USER_DEFINED_PERM_INDEX_START) {
|
|
192
|
+
lowPermissionIndexes.push(`${pair.prev_node}->${pair.next_node}:${fwd.name} (idx=${fwd.permission_index})`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
checked.push({
|
|
197
|
+
id: "C-11",
|
|
198
|
+
description: `permissionIndex >= ${USER_DEFINED_PERM_INDEX_START}`,
|
|
199
|
+
status: lowPermissionIndexes.length === 0 ? "pass" : "fail",
|
|
200
|
+
detail: lowPermissionIndexes.length === 0
|
|
201
|
+
? `All permission_index values >= ${USER_DEFINED_PERM_INDEX_START}`
|
|
202
|
+
: `permission_index < ${USER_DEFINED_PERM_INDEX_START}: ${lowPermissionIndexes.join(", ")}`,
|
|
203
|
+
});
|
|
204
|
+
if (lowPermissionIndexes.length > 0)
|
|
205
|
+
failed.push(checked[checked.length - 1]);
|
|
206
|
+
return {
|
|
207
|
+
passed: failed.length === 0,
|
|
208
|
+
checked_items: checked,
|
|
209
|
+
failed_items: failed,
|
|
210
|
+
warnings,
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export function integrateRiskAssessment(machine, context) {
|
|
214
|
+
const machineForRisk = {
|
|
215
|
+
nodes: machine.nodes,
|
|
216
|
+
pairs: machine.pairs,
|
|
217
|
+
b_published: machine.b_published,
|
|
218
|
+
b_paused: machine.b_paused,
|
|
219
|
+
scene_id: machine.scene_id,
|
|
220
|
+
};
|
|
221
|
+
const assessment = assessMachineRisks(machineForRisk, context);
|
|
222
|
+
const blocking_risks = [];
|
|
223
|
+
const warning_risks = [];
|
|
224
|
+
for (const risk of assessment.detected_risks) {
|
|
225
|
+
if (risk.severity === "critical" || risk.severity === "high") {
|
|
226
|
+
blocking_risks.push(risk.rule_id);
|
|
227
|
+
}
|
|
228
|
+
else if (risk.severity === "medium") {
|
|
229
|
+
warning_risks.push(risk.rule_id);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
let recommendation;
|
|
233
|
+
if (blocking_risks.some((id) => {
|
|
234
|
+
const risk = assessment.detected_risks.find((r) => r.rule_id === id);
|
|
235
|
+
return risk?.severity === "critical";
|
|
236
|
+
})) {
|
|
237
|
+
recommendation = "do_not_publish";
|
|
238
|
+
}
|
|
239
|
+
else if (blocking_risks.length > 0) {
|
|
240
|
+
recommendation = "fix_first";
|
|
241
|
+
}
|
|
242
|
+
else if (warning_risks.length > 3) {
|
|
243
|
+
recommendation = "fix_first";
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
recommendation = "publish";
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
overall_risk_level: assessment.overall_level,
|
|
250
|
+
blocking_risks,
|
|
251
|
+
warning_risks,
|
|
252
|
+
recommendation,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export const CONFIRMATION_QUESTIONS = [
|
|
256
|
+
{ id: "Q1", question: "Reviewed topology and confirmed all nodes/forwards are correct?", expected_response: "yes", blocking: true },
|
|
257
|
+
{ id: "Q2", question: "Tested this Machine on TESTNET with a successful Progress run?", expected_response: "yes", blocking: true },
|
|
258
|
+
{ id: "Q3", question: "All Guards created, bound, and verified via gen_passport?", expected_response: "yes", blocking: true },
|
|
259
|
+
{ id: "Q4", question: "All Allocators configured for terminal nodes?", expected_response: "yes", blocking: true },
|
|
260
|
+
{ id: "Q5", question: "Acknowledge that publishing is IRREVERSIBLE and gas will be consumed?", expected_response: "yes", blocking: true },
|
|
261
|
+
{ id: "Q6", question: "Proceed with publishing this Machine NOW?", expected_response: "yes", blocking: true },
|
|
262
|
+
];
|
|
263
|
+
export function parseUserConfirmation(userInput) {
|
|
264
|
+
const responses = userInput.split(",").map((s) => s.trim().toLowerCase());
|
|
265
|
+
const user_responses = [];
|
|
266
|
+
for (let i = 0; i < CONFIRMATION_QUESTIONS.length; i++) {
|
|
267
|
+
const q = CONFIRMATION_QUESTIONS[i];
|
|
268
|
+
const answer = responses[i] || "(no answer)";
|
|
269
|
+
const is_yes = answer.startsWith("y") || answer === "yes";
|
|
270
|
+
const is_no = answer.startsWith("n") || answer === "no";
|
|
271
|
+
user_responses.push({
|
|
272
|
+
question_id: q.id,
|
|
273
|
+
response: is_yes ? "yes" : is_no ? "no" : "unclear",
|
|
274
|
+
raw_input: answer,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
const all_blocking_yes = CONFIRMATION_QUESTIONS
|
|
278
|
+
.filter((q) => q.blocking)
|
|
279
|
+
.every((q, idx) => user_responses[idx].response === "yes");
|
|
280
|
+
return {
|
|
281
|
+
questions_asked: CONFIRMATION_QUESTIONS,
|
|
282
|
+
user_responses,
|
|
283
|
+
approved: all_blocking_yes,
|
|
284
|
+
declined_reason: all_blocking_yes
|
|
285
|
+
? undefined
|
|
286
|
+
: "One or more blocking questions answered 'no'",
|
|
287
|
+
timestamp: new Date().toISOString(),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
export function generateFullConfirmationText(machine, checklistResult, riskResult) {
|
|
291
|
+
const puzzle = derivePuzzleFromMachineJson({
|
|
292
|
+
nodes: machine.nodes,
|
|
293
|
+
pairs: machine.pairs,
|
|
294
|
+
scene_id: machine.scene_id,
|
|
295
|
+
template_id: machine.template_id,
|
|
296
|
+
});
|
|
297
|
+
const puzzleText = generateConfirmationText(puzzle);
|
|
298
|
+
const lines = [
|
|
299
|
+
"╔═══════════════════════════════════════════════════════════════╗",
|
|
300
|
+
"║ MACHINE PUBLISH CONFIRMATION REQUIRED ║",
|
|
301
|
+
"╚═══════════════════════════════════════════════════════════════╝",
|
|
302
|
+
"",
|
|
303
|
+
"⚠️ WARNING: Publishing a Machine is IRREVERSIBLE.",
|
|
304
|
+
" - Nodes, Pairs, Forwards will be FROZEN permanently.",
|
|
305
|
+
" - Gas will be consumed (cannot be refunded).",
|
|
306
|
+
" - Any error requires creating a NEW Machine (with new gas cost).",
|
|
307
|
+
"",
|
|
308
|
+
"═══════════════════════════════════════════════════════════════",
|
|
309
|
+
puzzleText,
|
|
310
|
+
"═══════════════════════════════════════════════════════════════",
|
|
311
|
+
"RISK ASSESSMENT:",
|
|
312
|
+
` Overall Risk Level: ${riskResult.overall_risk_level.toUpperCase()}`,
|
|
313
|
+
` Recommendation: ${riskResult.recommendation}`,
|
|
314
|
+
` Blocking Risks: ${riskResult.blocking_risks.length === 0 ? "None" : riskResult.blocking_risks.join(", ")}`,
|
|
315
|
+
` Warning Risks: ${riskResult.warning_risks.length === 0 ? "None" : riskResult.warning_risks.join(", ")}`,
|
|
316
|
+
"",
|
|
317
|
+
"═══════════════════════════════════════════════════════════════",
|
|
318
|
+
"STATIC CHECKLIST:",
|
|
319
|
+
` Passed: ${checklistResult.checked_items.filter((i) => i.status === "pass").length} / ${checklistResult.checked_items.length}`,
|
|
320
|
+
` Failed: ${checklistResult.failed_items.length}`,
|
|
321
|
+
` Warnings: ${checklistResult.warnings.length}`,
|
|
322
|
+
` Skipped: ${checklistResult.checked_items.filter((i) => i.status === "skip").length}`,
|
|
323
|
+
"",
|
|
324
|
+
...checklistResult.failed_items.map((i) => ` ❌ ${i.id}: ${i.description} — ${i.detail || ""}`),
|
|
325
|
+
...checklistResult.warnings.map((i) => ` ⚠️ ${i.id}: ${i.description} — ${i.detail || ""}`),
|
|
326
|
+
"",
|
|
327
|
+
"═══════════════════════════════════════════════════════════════",
|
|
328
|
+
"USER CONFIRMATION QUESTIONS:",
|
|
329
|
+
"",
|
|
330
|
+
...CONFIRMATION_QUESTIONS.map((q, idx) => ` Q${idx + 1}. ${q.question} [Yes / No]`),
|
|
331
|
+
"",
|
|
332
|
+
"If you answer 'No' to ANY of Q1-Q5, publish will be BLOCKED.",
|
|
333
|
+
"If you answer 'No' to Q6, publish will be CANCELLED (no gas spent).",
|
|
334
|
+
"",
|
|
335
|
+
"Type your answers (Q1-Q6) separated by commas:",
|
|
336
|
+
];
|
|
337
|
+
return lines.join("\n");
|
|
338
|
+
}
|
|
339
|
+
export function verifyEnvironment(machine, context, isMainnet) {
|
|
340
|
+
const missing_dependencies = [];
|
|
341
|
+
for (const pair of machine.pairs) {
|
|
342
|
+
for (const forward of pair.forwards) {
|
|
343
|
+
if (forward.guard && !context.published_guards.has(forward.guard)) {
|
|
344
|
+
missing_dependencies.push(`Guard: ${forward.guard}`);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const has_testnet_test_passed = context.testnet_test_passed;
|
|
349
|
+
const effectiveTestPassed = isMainnet ? has_testnet_test_passed : true;
|
|
350
|
+
return {
|
|
351
|
+
is_testnet: !isMainnet,
|
|
352
|
+
has_testnet_test_passed: effectiveTestPassed,
|
|
353
|
+
gas_estimation: context.gas_estimation,
|
|
354
|
+
dependency_table_complete: missing_dependencies.length === 0,
|
|
355
|
+
missing_dependencies,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
function hashMachineJson(machine) {
|
|
359
|
+
const json = JSON.stringify({
|
|
360
|
+
nodes: machine.nodes.map((n) => n.name),
|
|
361
|
+
pairs: machine.pairs.map((p) => ({
|
|
362
|
+
prev: p.prev_node,
|
|
363
|
+
next: p.next_node,
|
|
364
|
+
threshold: p.threshold,
|
|
365
|
+
forwards: p.forwards.map((f) => f.name),
|
|
366
|
+
})),
|
|
367
|
+
});
|
|
368
|
+
let hash = 0;
|
|
369
|
+
for (let i = 0; i < json.length; i++) {
|
|
370
|
+
const char = json.charCodeAt(i);
|
|
371
|
+
hash = ((hash << 5) - hash) + char;
|
|
372
|
+
hash = hash & hash;
|
|
373
|
+
}
|
|
374
|
+
return `0x${(hash >>> 0).toString(16).padStart(8, "0")}`;
|
|
375
|
+
}
|
|
376
|
+
export function confirmPublish(machine, context, isMainnet, userConfirmationInput) {
|
|
377
|
+
const decision_record = {
|
|
378
|
+
timestamp: new Date().toISOString(),
|
|
379
|
+
user_address: context.user_address,
|
|
380
|
+
machine_json_hash: hashMachineJson(machine),
|
|
381
|
+
template_id: machine.template_id,
|
|
382
|
+
scene_id: machine.scene_id,
|
|
383
|
+
final_status: "blocked_checklist",
|
|
384
|
+
};
|
|
385
|
+
const checklist_result = runStaticChecklist(machine);
|
|
386
|
+
if (!checklist_result.passed) {
|
|
387
|
+
return {
|
|
388
|
+
status: "blocked_checklist",
|
|
389
|
+
checklist_result,
|
|
390
|
+
decision_record: { ...decision_record, final_status: "blocked_checklist" },
|
|
391
|
+
block_reason: `Checklist failed: ${checklist_result.failed_items.map((i) => i.id).join(", ")}`,
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
const risk_result = integrateRiskAssessment(machine, context);
|
|
395
|
+
if (risk_result.recommendation === "do_not_publish") {
|
|
396
|
+
return {
|
|
397
|
+
status: "blocked_risk",
|
|
398
|
+
checklist_result,
|
|
399
|
+
risk_result,
|
|
400
|
+
decision_record: { ...decision_record, final_status: "blocked_risk" },
|
|
401
|
+
block_reason: `Critical risks detected: ${risk_result.blocking_risks.join(", ")}`,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
if (!userConfirmationInput) {
|
|
405
|
+
const confirmation_text = generateFullConfirmationText(machine, checklist_result, risk_result);
|
|
406
|
+
return {
|
|
407
|
+
status: "blocked_user",
|
|
408
|
+
checklist_result,
|
|
409
|
+
risk_result,
|
|
410
|
+
confirmation_text,
|
|
411
|
+
decision_record: { ...decision_record, final_status: "blocked_user" },
|
|
412
|
+
block_reason: "Awaiting user confirmation",
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
const user_confirmation = parseUserConfirmation(userConfirmationInput);
|
|
416
|
+
if (!user_confirmation.approved) {
|
|
417
|
+
return {
|
|
418
|
+
status: "blocked_user",
|
|
419
|
+
checklist_result,
|
|
420
|
+
risk_result,
|
|
421
|
+
user_confirmation,
|
|
422
|
+
decision_record: { ...decision_record, final_status: "blocked_user" },
|
|
423
|
+
block_reason: user_confirmation.declined_reason || "User declined",
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const environment_result = verifyEnvironment(machine, context, isMainnet);
|
|
427
|
+
if (!environment_result.dependency_table_complete || !environment_result.has_testnet_test_passed) {
|
|
428
|
+
const issues = [];
|
|
429
|
+
if (!environment_result.dependency_table_complete) {
|
|
430
|
+
issues.push(`missing dependencies: ${environment_result.missing_dependencies.join(", ")}`);
|
|
431
|
+
}
|
|
432
|
+
if (!environment_result.has_testnet_test_passed) {
|
|
433
|
+
issues.push("testnet test not passed (required for mainnet)");
|
|
434
|
+
}
|
|
435
|
+
return {
|
|
436
|
+
status: "blocked_environment",
|
|
437
|
+
checklist_result,
|
|
438
|
+
risk_result,
|
|
439
|
+
user_confirmation,
|
|
440
|
+
environment_result,
|
|
441
|
+
decision_record: { ...decision_record, final_status: "blocked_environment" },
|
|
442
|
+
block_reason: `Environment issues: ${issues.join("; ")}`,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
status: "approved",
|
|
447
|
+
checklist_result,
|
|
448
|
+
risk_result,
|
|
449
|
+
user_confirmation,
|
|
450
|
+
environment_result,
|
|
451
|
+
decision_record: { ...decision_record, final_status: "approved" },
|
|
452
|
+
};
|
|
453
|
+
}
|
|
454
|
+
export function overrideBlockWithReason(result, _userReason) {
|
|
455
|
+
if (result.status !== "blocked_risk") {
|
|
456
|
+
return result;
|
|
457
|
+
}
|
|
458
|
+
const hasCritical = result.risk_result?.blocking_risks.some((id) => id.includes("CRITICAL") || id.includes("critical"));
|
|
459
|
+
if (hasCritical) {
|
|
460
|
+
return {
|
|
461
|
+
...result,
|
|
462
|
+
block_reason: "Cannot override CRITICAL risks",
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
...result,
|
|
467
|
+
status: "approved",
|
|
468
|
+
block_reason: undefined,
|
|
469
|
+
decision_record: {
|
|
470
|
+
...result.decision_record,
|
|
471
|
+
final_status: "approved",
|
|
472
|
+
},
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
export function progressiveCheck(machine, round) {
|
|
476
|
+
const fullResult = runStaticChecklist(machine);
|
|
477
|
+
if (round === "R5") {
|
|
478
|
+
return filterChecklist(fullResult, ["C-01", "C-02", "C-03", "C-04", "C-06", "C-10"]);
|
|
479
|
+
}
|
|
480
|
+
if (round === "R6") {
|
|
481
|
+
return filterChecklist(fullResult, ["C-01", "C-02", "C-03", "C-04", "C-05", "C-06", "C-10"]);
|
|
482
|
+
}
|
|
483
|
+
return fullResult;
|
|
484
|
+
}
|
|
485
|
+
function filterChecklist(result, allowedIds) {
|
|
486
|
+
const filtered = result.checked_items.filter((i) => allowedIds.includes(i.id));
|
|
487
|
+
return {
|
|
488
|
+
passed: filtered.filter((i) => i.status === "fail").length === 0,
|
|
489
|
+
checked_items: filtered,
|
|
490
|
+
failed_items: filtered.filter((i) => i.status === "fail"),
|
|
491
|
+
warnings: filtered.filter((i) => i.status === "warning"),
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
export function prePublishHook(machine, context, isMainnet) {
|
|
495
|
+
const result = confirmPublish(machine, context, isMainnet);
|
|
496
|
+
if (result.status !== "blocked_user" && result.status !== "approved") {
|
|
497
|
+
return {
|
|
498
|
+
proceed: false,
|
|
499
|
+
error: formatBlockError(result),
|
|
500
|
+
confirmGateResult: result,
|
|
501
|
+
};
|
|
502
|
+
}
|
|
503
|
+
if (result.status === "blocked_user" && result.confirmation_text) {
|
|
504
|
+
return {
|
|
505
|
+
proceed: false,
|
|
506
|
+
error: result.confirmation_text,
|
|
507
|
+
confirmGateResult: result,
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
return { proceed: true, confirmGateResult: result };
|
|
511
|
+
}
|
|
512
|
+
export function postConfirmationHook(machine, context, isMainnet, userConfirmationInput) {
|
|
513
|
+
const result = confirmPublish(machine, context, isMainnet, userConfirmationInput);
|
|
514
|
+
if (result.status !== "approved") {
|
|
515
|
+
return {
|
|
516
|
+
proceed: false,
|
|
517
|
+
error: formatBlockError(result),
|
|
518
|
+
confirmGateResult: result,
|
|
519
|
+
};
|
|
520
|
+
}
|
|
521
|
+
return { proceed: true, confirmGateResult: result };
|
|
522
|
+
}
|
|
523
|
+
export function formatBlockError(result) {
|
|
524
|
+
const lines = [
|
|
525
|
+
"❌ MACHINE PUBLISH BLOCKED",
|
|
526
|
+
"",
|
|
527
|
+
`Status: ${result.status}`,
|
|
528
|
+
`Reason: ${result.block_reason || "(no reason provided)"}`,
|
|
529
|
+
"",
|
|
530
|
+
];
|
|
531
|
+
if (result.status === "blocked_checklist") {
|
|
532
|
+
lines.push("Failed checklist items:");
|
|
533
|
+
for (const item of result.checklist_result.failed_items) {
|
|
534
|
+
lines.push(` - ${item.id}: ${item.description}`);
|
|
535
|
+
lines.push(` Detail: ${item.detail || "(no detail)"}`);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
if (result.status === "blocked_risk" && result.risk_result) {
|
|
539
|
+
lines.push("Blocking risks:");
|
|
540
|
+
for (const riskId of result.risk_result.blocking_risks) {
|
|
541
|
+
lines.push(` - ${riskId}`);
|
|
542
|
+
}
|
|
543
|
+
lines.push("");
|
|
544
|
+
lines.push(`Recommendation: ${result.risk_result.recommendation}`);
|
|
545
|
+
}
|
|
546
|
+
if (result.status === "blocked_environment" && result.environment_result) {
|
|
547
|
+
lines.push("Environment issues:");
|
|
548
|
+
for (const dep of result.environment_result.missing_dependencies) {
|
|
549
|
+
lines.push(` - Missing dependency: ${dep}`);
|
|
550
|
+
}
|
|
551
|
+
if (!result.environment_result.has_testnet_test_passed) {
|
|
552
|
+
lines.push(" - Testnet test NOT passed (required for mainnet)");
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return lines.join("\n");
|
|
556
|
+
}
|
|
557
|
+
export const MACHINE_CONFIRM_VERSION = "1.0.0";
|
|
558
|
+
export const MACHINE_CHECKLIST_ITEMS_COUNT = PUBLISH_CHECKLIST.length;
|
|
559
|
+
export const MACHINE_CONFIRMATION_QUESTIONS_COUNT = CONFIRMATION_QUESTIONS.length;
|