@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,513 @@
|
|
|
1
|
+
export const SEMANTIC_TO_MACHINE_RULES = [
|
|
2
|
+
{
|
|
3
|
+
id: "P-M-SEQ",
|
|
4
|
+
pattern_name: "Sequential Execution",
|
|
5
|
+
category: "execution",
|
|
6
|
+
semantic_intent: "Single actor advances workflow one step at a time. Each Pair has threshold=1 with a single Forward weight=1.",
|
|
7
|
+
match_keywords: ["sequential", "linear", "one step at a time"],
|
|
8
|
+
schema_elements: {
|
|
9
|
+
threshold: 1,
|
|
10
|
+
forward_count: 1,
|
|
11
|
+
permission_model: "single",
|
|
12
|
+
pair_count: "dynamic",
|
|
13
|
+
structure: "Each Pair: { threshold: 1, forwards: [{ name, weight: 1, namedOperator | permissionIndex }] }",
|
|
14
|
+
},
|
|
15
|
+
constraints: [
|
|
16
|
+
"Each Forward must have at least one of namedOperator or permissionIndex",
|
|
17
|
+
"weight > 0 (typically 1)",
|
|
18
|
+
"prev_node references must form a valid DAG (no cycles)",
|
|
19
|
+
],
|
|
20
|
+
example: {
|
|
21
|
+
pair: {
|
|
22
|
+
prev_node: "NodeA",
|
|
23
|
+
next_node: "NodeB",
|
|
24
|
+
threshold: 1,
|
|
25
|
+
forwards: [{ name: "Advance", weight: 1, named_operator: "" }],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: "P-M-AND",
|
|
31
|
+
pattern_name: "Parallel AND (Dual-Signature Consensus)",
|
|
32
|
+
category: "execution",
|
|
33
|
+
semantic_intent: "Multiple parties must ALL contribute to advance. Pair threshold=N with N Forwards (weight=1 each). All must execute.",
|
|
34
|
+
match_keywords: ["and", "all", "dual-sig", "both confirm", "both must"],
|
|
35
|
+
schema_elements: {
|
|
36
|
+
threshold: 2,
|
|
37
|
+
forward_count: 2,
|
|
38
|
+
permission_model: "mixed",
|
|
39
|
+
pair_count: 1,
|
|
40
|
+
structure: "Pair: { threshold: N, forwards: [{ weight: 1, namedOperator: '' }, { weight: 1, permissionIndex: 2 }] }",
|
|
41
|
+
},
|
|
42
|
+
constraints: [
|
|
43
|
+
"threshold must equal the number of required Forwards",
|
|
44
|
+
"Each Forward must have a distinct permission model (no two identical)",
|
|
45
|
+
"If either party fails to sign, workflow stalls — consider adding timeout Guard",
|
|
46
|
+
"Each Forward counted once per session (repeated execution adds no weight)",
|
|
47
|
+
],
|
|
48
|
+
example: {
|
|
49
|
+
pair: {
|
|
50
|
+
prev_node: "Initiated",
|
|
51
|
+
next_node: "Approved",
|
|
52
|
+
threshold: 2,
|
|
53
|
+
forwards: [
|
|
54
|
+
{ name: "CustomerApprove", weight: 1, named_operator: "" },
|
|
55
|
+
{ name: "MerchantApprove", weight: 1, permission_index: 2 },
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "P-M-OR",
|
|
62
|
+
pattern_name: "Parallel OR (Any-One Execution)",
|
|
63
|
+
category: "execution",
|
|
64
|
+
semantic_intent: "Any one of multiple paths can advance the workflow. Multiple Pairs, each threshold=1.",
|
|
65
|
+
match_keywords: ["or", "any", "either"],
|
|
66
|
+
schema_elements: {
|
|
67
|
+
threshold: 1,
|
|
68
|
+
forward_count: 1,
|
|
69
|
+
permission_model: "single",
|
|
70
|
+
pair_count: "dynamic",
|
|
71
|
+
structure: "Multiple Pairs from same prev_node, each with threshold=1",
|
|
72
|
+
},
|
|
73
|
+
constraints: [
|
|
74
|
+
"Distinct next_node for each Pair (or distinct Forward)",
|
|
75
|
+
"If targets are different nodes, this becomes COMPETING topology",
|
|
76
|
+
"If targets are same node, alternative paths converge (FORKMERGE)",
|
|
77
|
+
],
|
|
78
|
+
example: {
|
|
79
|
+
pairs: [
|
|
80
|
+
{
|
|
81
|
+
prev_node: "Choice",
|
|
82
|
+
next_node: "PathA",
|
|
83
|
+
threshold: 1,
|
|
84
|
+
forwards: [{ name: "ChooseA", weight: 1, named_operator: "" }],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
prev_node: "Choice",
|
|
88
|
+
next_node: "PathB",
|
|
89
|
+
threshold: 1,
|
|
90
|
+
forwards: [{ name: "ChooseB", weight: 1, named_operator: "" }],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: "P-M-VOTE",
|
|
97
|
+
pattern_name: "Weighted Voting",
|
|
98
|
+
category: "execution",
|
|
99
|
+
semantic_intent: "Multiple parties vote with unequal weights. threshold=100, varied weights (e.g. 60+40). " +
|
|
100
|
+
"Guard extracts weight dynamically from Arbitration object.",
|
|
101
|
+
match_keywords: ["vote", "weight", "stakeholder"],
|
|
102
|
+
schema_elements: {
|
|
103
|
+
threshold: 100,
|
|
104
|
+
forward_count: "dynamic",
|
|
105
|
+
permission_model: "mixed",
|
|
106
|
+
pair_count: 1,
|
|
107
|
+
structure: "Pair: { threshold: 100, forwards: [{ weight: 60, permissionIndex: 2, guard: arb_voting_guard }, { weight: 8, namedOperator: 'member', guard: arb_voting_guard }] }",
|
|
108
|
+
},
|
|
109
|
+
constraints: [
|
|
110
|
+
"Guard MUST check arb.voted has [Signer] to prevent double-voting (R-X1-14 CRITICAL)",
|
|
111
|
+
"Weight is query-derived from Arbitration object (not hardcoded in Forward)",
|
|
112
|
+
"Competing Pair often added: Approved vs Rejected (timeout) — first-wins",
|
|
113
|
+
"Forward weight field is just session counter; actual weight from Guard",
|
|
114
|
+
],
|
|
115
|
+
example: {
|
|
116
|
+
pair: {
|
|
117
|
+
prev_node: "Voting",
|
|
118
|
+
next_node: "Approved",
|
|
119
|
+
threshold: 100,
|
|
120
|
+
forwards: [
|
|
121
|
+
{ name: "ChiefVote", weight: 60, permission_index: 2, guard: "arb_voting_guard" },
|
|
122
|
+
{ name: "MemberVote", weight: 8, named_operator: "member", guard: "arb_voting_guard" },
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: "P-M-HYBRID",
|
|
129
|
+
pattern_name: "Hybrid Mode (Key Party Required + Others Optional)",
|
|
130
|
+
category: "execution",
|
|
131
|
+
semantic_intent: "One key party must contribute, others are optional. threshold=5 with mixed weights (3+1+1).",
|
|
132
|
+
match_keywords: ["hybrid", "mixed", "key party"],
|
|
133
|
+
schema_elements: {
|
|
134
|
+
threshold: 5,
|
|
135
|
+
forward_count: 3,
|
|
136
|
+
permission_model: "mixed",
|
|
137
|
+
pair_count: 1,
|
|
138
|
+
structure: "Pair: { threshold: 5, forwards: [{ weight: 3, permissionIndex: 2 (key) }, { weight: 1, namedOperator: 'role1' }, { weight: 1, namedOperator: 'role2' }] }",
|
|
139
|
+
},
|
|
140
|
+
constraints: [
|
|
141
|
+
"Key party's weight must alone be insufficient (otherwise optional parties are meaningless)",
|
|
142
|
+
"Total weight of all Forwards must be >= threshold",
|
|
143
|
+
"Each Forward must have distinct permission model",
|
|
144
|
+
],
|
|
145
|
+
example: {
|
|
146
|
+
pair: {
|
|
147
|
+
prev_node: "Review",
|
|
148
|
+
next_node: "Approved",
|
|
149
|
+
threshold: 5,
|
|
150
|
+
forwards: [
|
|
151
|
+
{ name: "ManagerApprove", weight: 3, permission_index: 2 },
|
|
152
|
+
{ name: "EngineerApprove", weight: 1, named_operator: "engineer" },
|
|
153
|
+
{ name: "QAApprove", weight: 1, named_operator: "qa" },
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "P-M-LINEAR",
|
|
160
|
+
pattern_name: "Linear Flow (No Branches)",
|
|
161
|
+
category: "topology",
|
|
162
|
+
semantic_intent: "Workflow progresses in a straight line with no branches.",
|
|
163
|
+
match_keywords: ["linear", "straight", "no branches"],
|
|
164
|
+
schema_elements: {
|
|
165
|
+
threshold: 1,
|
|
166
|
+
forward_count: 1,
|
|
167
|
+
permission_model: "single",
|
|
168
|
+
pair_count: "dynamic",
|
|
169
|
+
structure: "Chain of Pairs: A->B->C->D->...->Terminal",
|
|
170
|
+
},
|
|
171
|
+
constraints: [
|
|
172
|
+
"Exactly one entry Pair (prev_node='')",
|
|
173
|
+
"Exactly one terminal node (no outgoing Pairs)",
|
|
174
|
+
"Each non-terminal node has exactly one outgoing Pair",
|
|
175
|
+
],
|
|
176
|
+
example: {
|
|
177
|
+
topology: "Entry -> A -> B -> C -> Terminal",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "P-M-FORKMERGE",
|
|
182
|
+
pattern_name: "Fork-Merge (Parallel Branches Converging)",
|
|
183
|
+
category: "topology",
|
|
184
|
+
semantic_intent: "Main flow forks into multiple parallel branches, then merges back to main flow.",
|
|
185
|
+
match_keywords: ["fork", "merge", "parallel"],
|
|
186
|
+
schema_elements: {
|
|
187
|
+
threshold: 1,
|
|
188
|
+
forward_count: "dynamic",
|
|
189
|
+
permission_model: "mixed",
|
|
190
|
+
pair_count: "dynamic",
|
|
191
|
+
structure: "ForkNode -> {BranchA, BranchB} -> MergeNode",
|
|
192
|
+
},
|
|
193
|
+
constraints: [
|
|
194
|
+
"Multiple Pairs from ForkNode (one per branch)",
|
|
195
|
+
"All branches must eventually reach MergeNode",
|
|
196
|
+
"MergeNode has multiple incoming Pairs (merge point)",
|
|
197
|
+
"Threshold at MergeNode determines if all branches must complete or just some",
|
|
198
|
+
],
|
|
199
|
+
example: {
|
|
200
|
+
topology: "ForkNode -> BranchA -> MergeNode; ForkNode -> BranchB -> MergeNode",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "P-M-COMPETING",
|
|
205
|
+
pattern_name: "Competing Pairs (Mutually Exclusive Branches)",
|
|
206
|
+
category: "topology",
|
|
207
|
+
semantic_intent: "Multiple Pairs from same node compete; first Pair to meet threshold wins, others abandoned.",
|
|
208
|
+
match_keywords: ["competing", "exclusive", "race"],
|
|
209
|
+
schema_elements: {
|
|
210
|
+
threshold: 1,
|
|
211
|
+
forward_count: 1,
|
|
212
|
+
permission_model: "single",
|
|
213
|
+
pair_count: "dynamic",
|
|
214
|
+
structure: "Same prev_node -> multiple next_nodes (each Pair independent)",
|
|
215
|
+
},
|
|
216
|
+
constraints: [
|
|
217
|
+
"Mutually exclusive — only one Pair can complete per session",
|
|
218
|
+
"First Pair to reach threshold wins",
|
|
219
|
+
"Other incomplete Pairs are abandoned",
|
|
220
|
+
"Verify no dead branches (a Pair that always loses to another)",
|
|
221
|
+
],
|
|
222
|
+
example: {
|
|
223
|
+
topology: "Shipped -> Received; Shipped -> Lost; Shipped -> Return (first wins)",
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
id: "P-M-PERM-SINGLE",
|
|
228
|
+
pattern_name: "Single Permission",
|
|
229
|
+
category: "permission",
|
|
230
|
+
semantic_intent: "Forward uses only one permission type: namedOperator OR permissionIndex.",
|
|
231
|
+
match_keywords: ["single permission"],
|
|
232
|
+
schema_elements: {
|
|
233
|
+
threshold: 1,
|
|
234
|
+
forward_count: 1,
|
|
235
|
+
permission_model: "single",
|
|
236
|
+
pair_count: 1,
|
|
237
|
+
structure: "Forward: { name, weight: 1, namedOperator: '<role>' | permissionIndex: <index> } (only one set)",
|
|
238
|
+
},
|
|
239
|
+
constraints: [
|
|
240
|
+
"Either namedOperator or permissionIndex is set (not both)",
|
|
241
|
+
"Empty namedOperator='' grants OrderHolder (order owner + agents)",
|
|
242
|
+
],
|
|
243
|
+
example: {
|
|
244
|
+
forward: { name: "Ship", weight: 1, permission_index: 2 },
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
id: "P-M-PERM-MIXED",
|
|
249
|
+
pattern_name: "Mixed Permission (Either-Or)",
|
|
250
|
+
category: "permission",
|
|
251
|
+
semantic_intent: "Forward allows EITHER permission to execute (internal staff OR external roles).",
|
|
252
|
+
match_keywords: ["mixed permission", "either"],
|
|
253
|
+
schema_elements: {
|
|
254
|
+
threshold: 1,
|
|
255
|
+
forward_count: 1,
|
|
256
|
+
permission_model: "mixed",
|
|
257
|
+
pair_count: 1,
|
|
258
|
+
structure: "Forward: { name, weight: 1, namedOperator: '<role>', permissionIndex: <index> } (both set)",
|
|
259
|
+
},
|
|
260
|
+
constraints: [
|
|
261
|
+
"Both namedOperator and permissionIndex are set",
|
|
262
|
+
"Executor needs EITHER permission — passing either check is sufficient",
|
|
263
|
+
"Use case: allow internal staff OR external role to execute the same Forward",
|
|
264
|
+
],
|
|
265
|
+
example: {
|
|
266
|
+
forward: { name: "Confirm", weight: 1, named_operator: "auditor", permission_index: 2 },
|
|
267
|
+
},
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: "P-M-CROSS-MACHINE",
|
|
271
|
+
pattern_name: "Cross-Machine Dependency",
|
|
272
|
+
category: "integration",
|
|
273
|
+
semantic_intent: "Machine B's Forward Guard queries Machine A's Progress to verify upstream completion.",
|
|
274
|
+
match_keywords: ["cross-machine", "supply chain", "upstream"],
|
|
275
|
+
schema_elements: {
|
|
276
|
+
threshold: 1,
|
|
277
|
+
forward_count: 1,
|
|
278
|
+
permission_model: "single",
|
|
279
|
+
pair_count: 1,
|
|
280
|
+
structure: "Forward: { guard: 'upstream_progress_guard', retained_submission: 'upstream_progress_id' }",
|
|
281
|
+
},
|
|
282
|
+
constraints: [
|
|
283
|
+
"Machine A MUST be published before Machine B (dependency order)",
|
|
284
|
+
"Guard uses convert_witness=100 to convert submitted Order/Progress ID into queryable Progress",
|
|
285
|
+
"Cross-Machine dependency is one-way (no cycles)",
|
|
286
|
+
"Dependency verification: indirect via progress::new -> assert_published (see 06 §14.6)",
|
|
287
|
+
"retained_submission stores upstream Progress ID for audit",
|
|
288
|
+
],
|
|
289
|
+
example: {
|
|
290
|
+
forward: {
|
|
291
|
+
name: "VerifyUpstream",
|
|
292
|
+
weight: 1,
|
|
293
|
+
permission_index: 2,
|
|
294
|
+
guard: "upstream_progress_guard",
|
|
295
|
+
retained_submission: "upstream_progress_id",
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
id: "P-M-ALLOCATION-INTEGRATED",
|
|
301
|
+
pattern_name: "Allocation-Integrated Terminal",
|
|
302
|
+
category: "integration",
|
|
303
|
+
semantic_intent: "Terminal node triggers Allocator to distribute funds. Allocation independent of Machine flow.",
|
|
304
|
+
match_keywords: ["allocation", "fund distribution", "terminal"],
|
|
305
|
+
schema_elements: {
|
|
306
|
+
threshold: 1,
|
|
307
|
+
forward_count: 1,
|
|
308
|
+
permission_model: "single",
|
|
309
|
+
pair_count: 1,
|
|
310
|
+
structure: "Terminal node -> Allocator entry (configured on Service order_allocators)",
|
|
311
|
+
},
|
|
312
|
+
constraints: [
|
|
313
|
+
"Terminal node must be referenced in Service order_allocators",
|
|
314
|
+
"Allocator Guard verifies progress.current == terminal_node_name",
|
|
315
|
+
"sharing.who determines fund recipient (Entity / OrderHolder / etc.)",
|
|
316
|
+
"Multiple Allocators can fire on different terminal nodes",
|
|
317
|
+
],
|
|
318
|
+
example: {
|
|
319
|
+
terminal_node: "Complete",
|
|
320
|
+
allocator: { trigger_node: "Complete", sharing_who: "Entity", recipient: "merchant_treasury" },
|
|
321
|
+
},
|
|
322
|
+
},
|
|
323
|
+
];
|
|
324
|
+
export const NODE_FIELD_EXPLANATIONS = [
|
|
325
|
+
{ field: "name", type: "string", required: true, semantic: "Node name (unique identifier)", constraint: "<=64 BCS bytes, globally unique" },
|
|
326
|
+
{ field: "description", type: "string", required: false, semantic: "Human-readable description", constraint: "<=MAX_DESCRIPTION_LENGTH" },
|
|
327
|
+
{ field: "b_pause", type: "boolean", required: false, semantic: "Whether node is paused (blocks execution)", constraint: "Default false" },
|
|
328
|
+
{ field: "b_submission", type: "boolean", required: false, semantic: "Whether submission is allowed at this node", constraint: "Used for retained_submission storage" },
|
|
329
|
+
];
|
|
330
|
+
export const PAIR_FIELD_EXPLANATIONS = [
|
|
331
|
+
{ field: "prev_node", type: "string", required: true, semantic: "Source node (empty '' = entry point)", constraint: "Must reference existing node or ''" },
|
|
332
|
+
{ field: "next_node", type: "string", required: true, semantic: "Target node", constraint: "Must reference existing node" },
|
|
333
|
+
{ field: "threshold", type: "number", required: true, semantic: "Required total forward weight to advance", constraint: ">=0, typically 1-100" },
|
|
334
|
+
{ field: "forwards", type: "array<Forward>", required: true, semantic: "List of Forwards in this Pair", constraint: "1-20 Forwards per Pair" },
|
|
335
|
+
];
|
|
336
|
+
export const FORWARD_FIELD_EXPLANATIONS = [
|
|
337
|
+
{ field: "name", type: "string", required: true, semantic: "Forward name (unique within Pair)", constraint: "<=64 BCS bytes, unique within Pair" },
|
|
338
|
+
{ field: "weight", type: "number", required: true, semantic: "Weight contribution to threshold", constraint: ">0, typically 1-100" },
|
|
339
|
+
{ field: "namedOperator", type: "string (optional)", required: false, semantic: "Named operator role ('' = OrderHolder)", constraint: "Optional, but Forward needs at least one permission" },
|
|
340
|
+
{ field: "permissionIndex", type: "number (optional)", required: false, semantic: "Permission index (custom or builtin)", constraint: "< Permission.indices.length" },
|
|
341
|
+
{ field: "guard", type: "address (optional)", required: false, semantic: "Guard object address for validation", constraint: "Must be CREATE-only Guard, already created" },
|
|
342
|
+
{ field: "retained_submission", type: "string (optional)", required: false, semantic: "Key for storing submitted values in history", constraint: "Uniquely located by (current_node, next_node, forward_name)" },
|
|
343
|
+
];
|
|
344
|
+
export function identifyExecutionMode(pair) {
|
|
345
|
+
const { threshold, forwards } = pair;
|
|
346
|
+
const fwdCount = forwards.length;
|
|
347
|
+
if (threshold === 1 && fwdCount === 1) {
|
|
348
|
+
return "P-M-SEQ (Sequential)";
|
|
349
|
+
}
|
|
350
|
+
if (threshold === fwdCount && fwdCount >= 2) {
|
|
351
|
+
const hasMixed = forwards.some((f) => f.permission_index !== undefined) &&
|
|
352
|
+
forwards.some((f) => f.named_operator !== undefined);
|
|
353
|
+
return hasMixed ? "P-M-AND (Parallel AND / Dual-Signature)" : "P-M-AND (Parallel AND)";
|
|
354
|
+
}
|
|
355
|
+
if (threshold === 100 && forwards.some((f) => f.weight < 50 && f.weight > 0)) {
|
|
356
|
+
return "P-M-VOTE (Weighted Voting)";
|
|
357
|
+
}
|
|
358
|
+
if (threshold < fwdCount && threshold > 1) {
|
|
359
|
+
return "P-M-HYBRID (Hybrid Mode)";
|
|
360
|
+
}
|
|
361
|
+
if (threshold === 1 && fwdCount >= 1) {
|
|
362
|
+
return "P-M-OR (Parallel OR) or P-M-SEQ (if single Forward)";
|
|
363
|
+
}
|
|
364
|
+
return "Unknown (manual review needed)";
|
|
365
|
+
}
|
|
366
|
+
export function identifyTopology(pairs) {
|
|
367
|
+
const fromNode = new Map();
|
|
368
|
+
const toNode = new Map();
|
|
369
|
+
for (const p of pairs) {
|
|
370
|
+
if (!fromNode.has(p.prev_node))
|
|
371
|
+
fromNode.set(p.prev_node, []);
|
|
372
|
+
fromNode.get(p.prev_node).push(p.next_node);
|
|
373
|
+
if (!toNode.has(p.next_node))
|
|
374
|
+
toNode.set(p.next_node, []);
|
|
375
|
+
toNode.get(p.next_node).push(p.prev_node);
|
|
376
|
+
}
|
|
377
|
+
for (const [prev, nexts] of fromNode) {
|
|
378
|
+
if (nexts.length > 1 && prev !== "") {
|
|
379
|
+
return "P-M-COMPETING (Competing Pairs)";
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
for (const [next, prevs] of toNode) {
|
|
383
|
+
if (prevs.length > 1) {
|
|
384
|
+
return "P-M-FORKMERGE (Fork-Merge)";
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return "P-M-LINEAR (Linear Flow)";
|
|
388
|
+
}
|
|
389
|
+
export function matchSemanticPattern(intent) {
|
|
390
|
+
const lower = intent.toLowerCase();
|
|
391
|
+
return SEMANTIC_TO_MACHINE_RULES.find((rule) => rule.match_keywords.some((kw) => lower.includes(kw.toLowerCase())));
|
|
392
|
+
}
|
|
393
|
+
export function explainForwardPermission(forward) {
|
|
394
|
+
const hasNamed = forward.named_operator !== undefined && forward.named_operator !== null;
|
|
395
|
+
const hasPerm = forward.permission_index !== undefined && forward.permission_index !== null;
|
|
396
|
+
if (hasNamed && hasPerm) {
|
|
397
|
+
const role = forward.named_operator === "" ? "OrderHolder" : `role "${forward.named_operator}"`;
|
|
398
|
+
return `Mixed permission: ${role} OR Permission index ${forward.permission_index} (either sufficient)`;
|
|
399
|
+
}
|
|
400
|
+
if (hasNamed) {
|
|
401
|
+
if (forward.named_operator === "") {
|
|
402
|
+
return "OrderHolder (order owner + agents)";
|
|
403
|
+
}
|
|
404
|
+
return `NamedOperator role "${forward.named_operator}"`;
|
|
405
|
+
}
|
|
406
|
+
if (hasPerm) {
|
|
407
|
+
return `Permission index ${forward.permission_index}`;
|
|
408
|
+
}
|
|
409
|
+
return "❌ INVALID: no permission set (Forward must have at least one of namedOperator or permissionIndex)";
|
|
410
|
+
}
|
|
411
|
+
export const MACHINE_CONSTRAINT_RULES = [
|
|
412
|
+
{ id: "MC-C-01", name: `Node count <= ${MAX_NODE_COUNT}`, description: "MAX_NODE_COUNT", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
413
|
+
{ id: "MC-C-02", name: `Pair count per node <= ${MAX_NODE_PAIR_COUNT}`, description: "MAX_NODE_PAIR_COUNT", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
414
|
+
{ id: "MC-C-03", name: `Forward count per Pair <= ${MAX_FORWARD_COUNT}`, description: "MAX_FORWARD_COUNT", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
415
|
+
{ id: "MC-C-04", name: "Node name unique", description: "name globally unique", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
416
|
+
{ id: "MC-C-05", name: "Forward name unique within Pair", description: "name unique within Pair", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
417
|
+
{ id: "MC-C-06", name: "Node name <= 64 BCS bytes", description: "MAX_NAME_LENGTH", category: "creation", verification_location: "common.ts", on_chain_enforced: true },
|
|
418
|
+
{ id: "MC-C-07", name: "Forward has at least one permission", description: "namedOperator or permissionIndex", category: "creation", verification_location: "wowok-machine SKILL", on_chain_enforced: false },
|
|
419
|
+
{ id: "MC-C-08", name: "permissionIndex valid", description: "< Permission.indices.length", category: "creation", verification_location: "permission.move", on_chain_enforced: true },
|
|
420
|
+
{ id: "MC-C-09", name: "Guard already created", description: "guard field references existing Guard", category: "creation", verification_location: "guard.move", on_chain_enforced: true },
|
|
421
|
+
{ id: "MC-C-10", name: "Guard immutable", description: "Guard.b_immutable == true", category: "creation", verification_location: "guard.move", on_chain_enforced: true },
|
|
422
|
+
{ id: "MC-C-11", name: "retained_submission index valid", description: "Corresponds to Guard table b_submission=true", category: "creation", verification_location: "guard.move", on_chain_enforced: true },
|
|
423
|
+
{ id: "MC-C-12", name: "prev_node references valid", description: "Points to existing node or ''", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
424
|
+
{ id: "MC-C-13", name: "threshold >= 0", description: "Non-negative", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
425
|
+
{ id: "MC-C-14", name: "weight > 0", description: "Positive", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
426
|
+
{ id: "MC-C-15", name: "description length", description: "<= MAX_DESCRIPTION_LENGTH", category: "creation", verification_location: "machine.move", on_chain_enforced: true },
|
|
427
|
+
{ id: "MC-C-16", name: "bReplace scope", description: "Acts on existing node's pairs list, not whole Machine", category: "node_operation", verification_location: "machine.move:405-443", on_chain_enforced: true },
|
|
428
|
+
{ id: "MC-C-17", name: "bReplace=false merge semantics", description: "Incremental merge by prev_node into existing pairs", category: "node_operation", verification_location: "machine.move:418-443", on_chain_enforced: true },
|
|
429
|
+
{ id: "MC-C-18", name: "Non-existing node append", description: "push_back new node (no clear triggered)", category: "node_operation", verification_location: "machine.move:418-443", on_chain_enforced: true },
|
|
430
|
+
{ id: "MC-C-19", name: "Full node replacement via file entry", description: "NodeJsonOrMarkdownFileSchema (not bReplace=true)", category: "node_operation", verification_location: "machine.ts:93-112", on_chain_enforced: false },
|
|
431
|
+
{ id: "MC-S-01", name: "At least one entry point", description: "Pair with prev_node=''", category: "structure", verification_location: "machine-topology.ts", on_chain_enforced: false },
|
|
432
|
+
{ id: "MC-S-02", name: "At least one terminal", description: "Node with no outgoing Pairs", category: "structure", verification_location: "machine-topology.ts", on_chain_enforced: false },
|
|
433
|
+
{ id: "MC-S-03", name: "No orphaned nodes", description: "All non-entry nodes have incoming Pair", category: "structure", verification_location: "machine-topology.ts", on_chain_enforced: false },
|
|
434
|
+
{ id: "MC-S-04", name: "No dead branches", description: "All thresholds achievable", category: "structure", verification_location: "machine-topology.ts", on_chain_enforced: false },
|
|
435
|
+
{ id: "MC-S-05", name: "DAG acyclic", description: "No cycle references", category: "structure", verification_location: "machine-topology.ts", on_chain_enforced: false },
|
|
436
|
+
{ id: "MC-P-01", name: "All Guards tested", description: "gen_passport passed", category: "publish", verification_location: "machine-confirm.ts", on_chain_enforced: false },
|
|
437
|
+
{ id: "MC-P-02", name: "Backup exported", description: "machineNode2file executed", category: "publish", verification_location: "machine-confirm.ts", on_chain_enforced: false },
|
|
438
|
+
{ id: "MC-P-03", name: "Testnet verified", description: "(recommended) testnet passed", category: "publish", verification_location: "machine-confirm.ts", on_chain_enforced: false },
|
|
439
|
+
{ id: "MC-P-04", name: "User 100% confirmed", description: "ConfirmGate passed", category: "publish", verification_location: "machine-confirm.ts", on_chain_enforced: false },
|
|
440
|
+
{ id: "MC-P-05", name: "Service created (if bound)", description: "Service exists", category: "publish", verification_location: "machine-context.ts", on_chain_enforced: false },
|
|
441
|
+
{ id: "MC-R-01", name: "Node ops fail after publish", description: "E_ALREADY_PUBLISHED", category: "runtime", verification_location: "machine.move", on_chain_enforced: true },
|
|
442
|
+
{ id: "MC-R-02", name: "Session accumulation correct", description: "weight accumulation logic", category: "runtime", verification_location: "progress.move", on_chain_enforced: true },
|
|
443
|
+
{ id: "MC-R-03", name: "Competing Pair first-wins", description: "First Pair to reach threshold wins", category: "runtime", verification_location: "progress.move", on_chain_enforced: true },
|
|
444
|
+
];
|
|
445
|
+
export function getConstraintsByCategory(category) {
|
|
446
|
+
return MACHINE_CONSTRAINT_RULES.filter((r) => r.category === category);
|
|
447
|
+
}
|
|
448
|
+
export function getConstraintById(id) {
|
|
449
|
+
return MACHINE_CONSTRAINT_RULES.find((r) => r.id === id);
|
|
450
|
+
}
|
|
451
|
+
export function getOnChainConstraints() {
|
|
452
|
+
return MACHINE_CONSTRAINT_RULES.filter((r) => r.on_chain_enforced);
|
|
453
|
+
}
|
|
454
|
+
export function getOffChainConstraints() {
|
|
455
|
+
return MACHINE_CONSTRAINT_RULES.filter((r) => !r.on_chain_enforced);
|
|
456
|
+
}
|
|
457
|
+
export const MACHINE_TRANSLATION_VERSION = "1.0.0";
|
|
458
|
+
export const MACHINE_PATTERNS_COUNT = SEMANTIC_TO_MACHINE_RULES.length;
|
|
459
|
+
export const MACHINE_CONSTRAINTS_COUNT = MACHINE_CONSTRAINT_RULES.length;
|
|
460
|
+
import { MAX_NODE_COUNT, MAX_NODE_PAIR_COUNT, MAX_FORWARD_COUNT, } from "./onchain-constants.js";
|
|
461
|
+
export function identifyNodeRole(node) {
|
|
462
|
+
const allPairs = node.all_pairs ?? [];
|
|
463
|
+
const outgoing = (node.pairs ?? allPairs).filter((p) => p.prev_node === node.name);
|
|
464
|
+
const incoming = allPairs.filter((p) => p.next_node === node.name);
|
|
465
|
+
const isEntry = allPairs.some((p) => p.prev_node === "" && p.next_node === node.name);
|
|
466
|
+
const isTerminal = outgoing.length === 0;
|
|
467
|
+
if (isEntry)
|
|
468
|
+
return "entry";
|
|
469
|
+
if (isTerminal)
|
|
470
|
+
return "terminal";
|
|
471
|
+
const nextNodes = new Set(outgoing.map((p) => p.next_node));
|
|
472
|
+
if (nextNodes.size > 1)
|
|
473
|
+
return "branch";
|
|
474
|
+
const prevNodes = new Set(incoming.map((p) => p.prev_node).filter((n) => n !== ""));
|
|
475
|
+
if (prevNodes.size > 1)
|
|
476
|
+
return "merge";
|
|
477
|
+
return "normal";
|
|
478
|
+
}
|
|
479
|
+
function explainGuardBinding(guardAddress) {
|
|
480
|
+
return {
|
|
481
|
+
address: guardAddress,
|
|
482
|
+
immutable_required: true,
|
|
483
|
+
note: `Guard ${guardAddress} validates this Forward's execution; ` +
|
|
484
|
+
`must be immutable (b_immutable=true) and pre-created on-chain.`,
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
export function explainNode(node) {
|
|
488
|
+
const outgoingPairs = node.pairs ?? [];
|
|
489
|
+
return {
|
|
490
|
+
name: node.name,
|
|
491
|
+
role: identifyNodeRole(node),
|
|
492
|
+
pairs: outgoingPairs.map((p) => explainPair(p)),
|
|
493
|
+
description: node.description,
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
export function explainPair(pair) {
|
|
497
|
+
return {
|
|
498
|
+
prev_node: pair.prev_node,
|
|
499
|
+
next_node: pair.next_node,
|
|
500
|
+
threshold: pair.threshold,
|
|
501
|
+
execution_pattern: identifyExecutionMode(pair),
|
|
502
|
+
forwards: pair.forwards.map((f) => explainForward(f)),
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
export function explainForward(forward) {
|
|
506
|
+
return {
|
|
507
|
+
name: forward.name,
|
|
508
|
+
permission: explainForwardPermission(forward),
|
|
509
|
+
weight: forward.weight,
|
|
510
|
+
guard: forward.guard ? explainGuardBinding(forward.guard) : null,
|
|
511
|
+
retained_submission: forward.retained_submission ?? null,
|
|
512
|
+
};
|
|
513
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { scanAllMcpSchemas, formatAuditReport, MCP_SCHEMA_AUDIT_VERSION } from './mcp-schema-audit.js';
|
|
2
|
+
import * as fs from 'fs';
|
|
3
|
+
import * as path from 'path';
|
|
4
|
+
console.log(`MCP Schema Audit v${MCP_SCHEMA_AUDIT_VERSION}`);
|
|
5
|
+
console.log('Auditing 4 layers: ts-sdk → Zod → Generated → Deployed ...');
|
|
6
|
+
const result = scanAllMcpSchemas();
|
|
7
|
+
console.log(`\nAudited ${result.census.length} tools, found ${result.total_findings} findings.`);
|
|
8
|
+
console.log(` Stubs: ${result.stub_count}, Full schemas: ${result.full_schema_count}`);
|
|
9
|
+
console.log(` any/unknown: ${result.any_unknown_instances.length} total (${result.fixable_any_count} fixable, ${result.legitimate_any_count} legitimate)`);
|
|
10
|
+
const report = formatAuditReport(result);
|
|
11
|
+
const outputPath = path.resolve('d:/wowok/wiki/market/GLM3/mcp-schema-audit-report.md');
|
|
12
|
+
fs.writeFileSync(outputPath, report, 'utf-8');
|
|
13
|
+
console.log(`\nReport written to ${outputPath}`);
|
|
14
|
+
console.log('\n=== Per-Tool Census ===');
|
|
15
|
+
console.log('Tool'.padEnd(28) + 'L3-Input'.padEnd(14) + 'L3-Output'.padEnd(14) + 'L4-Status'.padEnd(14) + 'L4-Props');
|
|
16
|
+
for (const c of result.census) {
|
|
17
|
+
const l3i = c.layer3_generated.input_exists ? `${(c.layer3_generated.input_size_bytes / 1024).toFixed(1)}KB` : 'MISSING';
|
|
18
|
+
const l3o = c.layer3_generated.output_exists ? `${(c.layer3_generated.output_size_bytes / 1024).toFixed(1)}KB` : 'MISSING';
|
|
19
|
+
const l4s = !c.layer4_deployed.file_exists ? 'MISSING' : c.layer4_deployed.is_stub ? 'STUB' : 'FULL';
|
|
20
|
+
console.log(c.name.padEnd(28) +
|
|
21
|
+
l3i.padEnd(14) +
|
|
22
|
+
l3o.padEnd(14) +
|
|
23
|
+
l4s.padEnd(14) +
|
|
24
|
+
c.layer4_deployed.properties_count);
|
|
25
|
+
}
|
|
26
|
+
console.log('\n=== Findings by Severity ===');
|
|
27
|
+
for (const sev of ['critical', 'high', 'medium', 'low', 'info']) {
|
|
28
|
+
const arr = result.findings_by_severity.get(sev) ?? [];
|
|
29
|
+
if (arr.length > 0)
|
|
30
|
+
console.log(` ${sev.padEnd(10)} ${arr.length}`);
|
|
31
|
+
}
|
|
32
|
+
console.log('\n=== Findings by Category ===');
|
|
33
|
+
for (const cat of ['stub_inconsistency', 'layer_parity', 'handler_types', 'output_coverage', 'generation_sync', 'reflection']) {
|
|
34
|
+
const arr = result.findings_by_category.get(cat) ?? [];
|
|
35
|
+
if (arr.length > 0)
|
|
36
|
+
console.log(` ${cat.padEnd(22)} ${arr.length}`);
|
|
37
|
+
}
|
|
38
|
+
console.log('\n=== any/unknown by Pattern ===');
|
|
39
|
+
const patternGroups = new Map();
|
|
40
|
+
for (const inst of result.any_unknown_instances) {
|
|
41
|
+
patternGroups.set(inst.pattern, (patternGroups.get(inst.pattern) ?? 0) + 1);
|
|
42
|
+
}
|
|
43
|
+
for (const [pattern, count] of [...patternGroups.entries()].sort((a, b) => b[1] - a[1])) {
|
|
44
|
+
console.log(` ${pattern.padEnd(24)} ${count}`);
|
|
45
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const DEPLOYED_TOOLS_DIR = "c:\\Users\\zhou\\.trae-cn\\mcps\\s_wowok-7838e181\\solo_agent\\mcp_wagent\\tools";
|
|
2
|
+
export declare const GENERATED_SCHEMAS_DIR = "d:\\wowok\\agent\\mcp\\dist\\schemas";
|
|
3
|
+
export declare const MCP_SRC_SCHEMA_DIR = "d:\\wowok\\agent\\mcp\\src\\schema";
|
|
4
|
+
export declare const MCP_SRC_TOOLS_DIR = "d:\\wowok\\agent\\mcp\\src\\tools";
|
|
5
|
+
export declare const GENERATION_SCRIPT = "d:\\wowok\\agent\\mcp\\scripts\\generate-json-schemas.ts";
|
|
6
|
+
export declare const TOOLS_INDEX_FILE = "d:\\wowok\\agent\\mcp\\src\\tools\\index.ts";
|
|
7
|
+
export declare const MCP_SCHEMA_AUDIT_VERSION = "1.0.0";
|
|
8
|
+
export interface ToolDescriptor {
|
|
9
|
+
name: string;
|
|
10
|
+
input_schema_export: string;
|
|
11
|
+
output_schema_export: string | null;
|
|
12
|
+
}
|
|
13
|
+
export declare const TOOLS_17: readonly ToolDescriptor[];
|
|
14
|
+
export type FindingSeverity = 'critical' | 'high' | 'medium' | 'low' | 'info';
|
|
15
|
+
export type FindingCategory = 'layer_census' | 'stub_inconsistency' | 'layer_parity' | 'any_unknown' | 'handler_types' | 'output_coverage' | 'generation_sync' | 'reflection';
|
|
16
|
+
export interface Finding {
|
|
17
|
+
rule_id: string;
|
|
18
|
+
severity: FindingSeverity;
|
|
19
|
+
category: FindingCategory;
|
|
20
|
+
tool_name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
location?: string;
|
|
23
|
+
fix?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface LayerCensus {
|
|
26
|
+
name: string;
|
|
27
|
+
layer2_zod: {
|
|
28
|
+
input_schema_export: string;
|
|
29
|
+
output_schema_export: string | null;
|
|
30
|
+
schema_dir: string;
|
|
31
|
+
};
|
|
32
|
+
layer3_generated: {
|
|
33
|
+
input_schema_file: string;
|
|
34
|
+
output_schema_file: string;
|
|
35
|
+
input_exists: boolean;
|
|
36
|
+
output_exists: boolean;
|
|
37
|
+
input_size_bytes: number;
|
|
38
|
+
output_size_bytes: number;
|
|
39
|
+
};
|
|
40
|
+
layer4_deployed: {
|
|
41
|
+
tool_descriptor_file: string;
|
|
42
|
+
file_exists: boolean;
|
|
43
|
+
is_stub: boolean;
|
|
44
|
+
properties_count: number;
|
|
45
|
+
required_count: number;
|
|
46
|
+
has_schema_hint: boolean;
|
|
47
|
+
has_additional_properties_false: boolean;
|
|
48
|
+
has_dollar_schema: boolean;
|
|
49
|
+
has_oneof: boolean;
|
|
50
|
+
has_anyof: boolean;
|
|
51
|
+
has_allof: boolean;
|
|
52
|
+
union_count: number;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export type AnyUnknownPattern = 'z.any()' | 'z.unknown()' | 'args: any' | 'Promise<any>' | 'Record<string, any>' | 'as any' | ': any' | '<any>';
|
|
56
|
+
export type AnyUnknownCategory = 'fixable' | 'legitimate' | 'external';
|
|
57
|
+
export interface AnyUnknownInstance {
|
|
58
|
+
file: string;
|
|
59
|
+
line: number;
|
|
60
|
+
code: string;
|
|
61
|
+
pattern: AnyUnknownPattern;
|
|
62
|
+
category: AnyUnknownCategory;
|
|
63
|
+
reason: string;
|
|
64
|
+
fix_suggestion?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface ScanResult {
|
|
67
|
+
census: LayerCensus[];
|
|
68
|
+
findings: Finding[];
|
|
69
|
+
any_unknown_instances: AnyUnknownInstance[];
|
|
70
|
+
findings_by_severity: Map<FindingSeverity, Finding[]>;
|
|
71
|
+
findings_by_category: Map<FindingCategory, Finding[]>;
|
|
72
|
+
total_findings: number;
|
|
73
|
+
fixable_any_count: number;
|
|
74
|
+
legitimate_any_count: number;
|
|
75
|
+
external_any_count: number;
|
|
76
|
+
stub_count: number;
|
|
77
|
+
full_schema_count: number;
|
|
78
|
+
}
|
|
79
|
+
export declare function loadLayer4Deployed(toolName: string): LayerCensus['layer4_deployed'] | null;
|
|
80
|
+
export declare function loadLayer3Generated(toolName: string): LayerCensus['layer3_generated'];
|
|
81
|
+
export declare function analyzeLayerCensus(): LayerCensus[];
|
|
82
|
+
export declare function analyzeDeployedStubInconsistency(census: LayerCensus[]): Finding[];
|
|
83
|
+
export declare function analyzeLayerParity(census: LayerCensus[]): Finding[];
|
|
84
|
+
export declare function analyzeAnyUnknownCensus(): AnyUnknownInstance[];
|
|
85
|
+
export declare function analyzeHandlerTypeSafety(instances: AnyUnknownInstance[]): Finding[];
|
|
86
|
+
export declare function analyzeOutputSchemaCoverage(census: LayerCensus[]): Finding[];
|
|
87
|
+
export declare function analyzeGenerationScriptSync(): Finding[];
|
|
88
|
+
export declare function analyzeSchemaQueryReflection(census: LayerCensus[]): Finding[];
|
|
89
|
+
export declare function scanAllMcpSchemas(): ScanResult;
|
|
90
|
+
export declare function formatAuditReport(result: ScanResult): string;
|