@wowok/agent-mcp 2.5.5 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +5 -3
  2. package/dist/config/runtime.js +3 -6
  3. package/dist/extensions/capability-manifest.d.ts +125 -0
  4. package/dist/extensions/capability-manifest.js +594 -0
  5. package/dist/extensions/constraint-registry.d.ts +24 -0
  6. package/dist/extensions/constraint-registry.js +196 -0
  7. package/dist/extensions/index.d.ts +12 -0
  8. package/dist/extensions/index.js +6 -0
  9. package/dist/extensions/metric-registry.d.ts +26 -0
  10. package/dist/extensions/metric-registry.js +257 -0
  11. package/dist/extensions/mode-evaluator.d.ts +15 -0
  12. package/dist/extensions/mode-evaluator.js +170 -0
  13. package/dist/extensions/modes.d.ts +2 -0
  14. package/dist/extensions/modes.js +407 -0
  15. package/dist/extensions/registry.d.ts +48 -0
  16. package/dist/extensions/registry.js +629 -0
  17. package/dist/extensions/types.d.ts +218 -0
  18. package/dist/extensions/types.js +1 -0
  19. package/dist/harness/checkpoint.js +2 -2
  20. package/dist/knowledge/deployment-scanner.d.ts +3 -0
  21. package/dist/knowledge/deployment-scanner.js +64 -3
  22. package/dist/knowledge/flywheel-loop.js +2 -5
  23. package/dist/knowledge/guard-risk.d.ts +13 -0
  24. package/dist/knowledge/guard-risk.js +57 -0
  25. package/dist/knowledge/guard-templates.js +278 -0
  26. package/dist/knowledge/machine-templates.js +20 -1
  27. package/dist/knowledge/overrides-loader.js +2 -4
  28. package/dist/knowledge/progress-ledger.js +3 -0
  29. package/dist/knowledge/progress-translation.js +5 -1
  30. package/dist/knowledge/service-confirm.d.ts +14 -5
  31. package/dist/knowledge/service-confirm.js +116 -8
  32. package/dist/knowledge/tool-constraints.js +6 -2
  33. package/dist/loop-engineering/improve.js +2 -4
  34. package/dist/project/deployment-bridge.d.ts +5 -0
  35. package/dist/project/deployment-bridge.js +119 -0
  36. package/dist/project/deployment-doc.d.ts +3 -0
  37. package/dist/project/deployment-doc.js +72 -10
  38. package/dist/project/evaluation.d.ts +2 -0
  39. package/dist/project/evaluation.js +578 -86
  40. package/dist/project/graph-builder.d.ts +4 -1
  41. package/dist/project/graph-builder.js +141 -63
  42. package/dist/project/graph.d.ts +1 -0
  43. package/dist/project/handlers.d.ts +221 -5
  44. package/dist/project/handlers.js +933 -14
  45. package/dist/project/index.js +2 -6
  46. package/dist/project/project-store.js +2 -5
  47. package/dist/project/stage-gate.d.ts +4 -0
  48. package/dist/project/stage-gate.js +64 -5
  49. package/dist/project/task-tracker.d.ts +26 -0
  50. package/dist/project/task-tracker.js +78 -0
  51. package/dist/safety/preview.js +16 -0
  52. package/dist/schema/call/allocation.d.ts +16 -16
  53. package/dist/schema/call/base.d.ts +21 -13
  54. package/dist/schema/call/base.js +27 -6
  55. package/dist/schema/call/bridge.d.ts +5 -5
  56. package/dist/schema/call/bridge.js +3 -1
  57. package/dist/schema/call/demand.d.ts +23 -31
  58. package/dist/schema/call/guard.js +1 -1
  59. package/dist/schema/call/machine.d.ts +402 -376
  60. package/dist/schema/call/order.d.ts +149 -228
  61. package/dist/schema/call/order.js +7 -3
  62. package/dist/schema/call/payment.d.ts +183 -3
  63. package/dist/schema/call/payment.js +21 -3
  64. package/dist/schema/call/personal.d.ts +241 -52
  65. package/dist/schema/call/progress.d.ts +53 -61
  66. package/dist/schema/call/progress.js +18 -4
  67. package/dist/schema/call/repository.d.ts +23 -31
  68. package/dist/schema/call/semantic.d.ts +1 -1
  69. package/dist/schema/call/semantic.js +30 -1
  70. package/dist/schema/call/service.d.ts +95 -119
  71. package/dist/schema/call/service.js +22 -1
  72. package/dist/schema/common/index.d.ts +11 -2
  73. package/dist/schema/common/index.js +43 -14
  74. package/dist/schema/config/index.d.ts +12 -12
  75. package/dist/schema/local/index.d.ts +140 -143
  76. package/dist/schema/local/index.js +44 -23
  77. package/dist/schema/messenger/index.d.ts +290 -62
  78. package/dist/schema/messenger/index.js +2 -2
  79. package/dist/schema/operations.d.ts +680 -545
  80. package/dist/schema/operations.js +22 -0
  81. package/dist/schema/project/index.d.ts +2064 -84
  82. package/dist/schema/project/index.js +354 -12
  83. package/dist/schema/query/index.d.ts +715 -354
  84. package/dist/schema/query/index.js +164 -31
  85. package/dist/schema/schema-query/index.d.ts +15 -3
  86. package/dist/schema/schema-query/index.js +23 -5
  87. package/dist/schema/trust/index.d.ts +8 -8
  88. package/dist/schema/utils/node-parser.js +7 -4
  89. package/dist/schema-query/index.d.ts +7 -1
  90. package/dist/schema-query/index.js +204 -4
  91. package/dist/schemas/account_operation.output.json +14 -22
  92. package/dist/schemas/account_operation.schema.json +11 -25
  93. package/dist/schemas/bridge_operation.output.json +6 -0
  94. package/dist/schemas/bridge_operation.schema.json +1 -1
  95. package/dist/schemas/guard-templates.json +379 -0
  96. package/dist/schemas/guard2file.schema.json +1 -1
  97. package/dist/schemas/index.json +1 -1
  98. package/dist/schemas/local_info_operation.output.json +6 -0
  99. package/dist/schemas/local_mark_operation.output.json +7 -1
  100. package/dist/schemas/local_mark_operation.schema.json +1 -1
  101. package/dist/schemas/machineNode2file.schema.json +1 -1
  102. package/dist/schemas/messenger_operation.schema.json +10 -10
  103. package/dist/schemas/onchain_events.output.json +1 -1
  104. package/dist/schemas/onchain_operations.schema.json +348 -296
  105. package/dist/schemas/onchain_operations_allocation.schema.json +34 -25
  106. package/dist/schemas/onchain_operations_arbitration.schema.json +8 -8
  107. package/dist/schemas/onchain_operations_contact.schema.json +8 -8
  108. package/dist/schemas/onchain_operations_demand.schema.json +8 -8
  109. package/dist/schemas/onchain_operations_gen_passport.schema.json +14 -14
  110. package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -2
  111. package/dist/schemas/onchain_operations_guard.schema.json +1 -1
  112. package/dist/schemas/onchain_operations_machine.schema.json +41 -33
  113. package/dist/schemas/onchain_operations_order.schema.json +71 -77
  114. package/dist/schemas/onchain_operations_payment.schema.json +141 -111
  115. package/dist/schemas/onchain_operations_permission.schema.json +2 -2
  116. package/dist/schemas/onchain_operations_personal.schema.json +7 -7
  117. package/dist/schemas/onchain_operations_progress.schema.json +8 -8
  118. package/dist/schemas/onchain_operations_proof.schema.json +7 -7
  119. package/dist/schemas/onchain_operations_repository.schema.json +8 -8
  120. package/dist/schemas/onchain_operations_reward.schema.json +10 -10
  121. package/dist/schemas/onchain_operations_service.schema.json +46 -35
  122. package/dist/schemas/onchain_operations_treasury.schema.json +8 -8
  123. package/dist/schemas/onchain_table_data.output.json +33 -25
  124. package/dist/schemas/onchain_table_data.schema.json +12 -12
  125. package/dist/schemas/project_operation.output.json +1352 -20
  126. package/dist/schemas/project_operation.schema.json +53 -4
  127. package/dist/schemas/query_toolkit.output.json +111 -82
  128. package/dist/schemas/query_toolkit.schema.json +9 -13
  129. package/dist/schemas/schema_query.output.json +7 -3
  130. package/dist/schemas/schema_query.schema.json +17 -3
  131. package/dist/telemetry/storage.js +2 -2
  132. package/dist/tools/handlers/local.js +20 -5
  133. package/dist/tools/handlers/onchain.js +36 -0
  134. package/dist/tools/handlers/project.js +72 -1
  135. package/dist/tools/handlers/query.js +27 -0
  136. package/dist/tools/handlers/schema-query.js +19 -0
  137. package/dist/tools/handlers/task-status.d.ts +170 -0
  138. package/dist/tools/handlers/task-status.js +55 -0
  139. package/dist/tools/handlers/wip.js +47 -1
  140. package/dist/tools/index.js +212 -8
  141. package/dist/tools/retry.d.ts +8 -0
  142. package/dist/tools/retry.js +85 -0
  143. package/dist/tools/wip-deploy-assist.d.ts +28 -0
  144. package/dist/tools/wip-deploy-assist.js +278 -0
  145. package/package.json +2 -2
  146. package/dist/schemas/guard-node-examples.md +0 -199
@@ -0,0 +1,218 @@
1
+ import type { ProjectObjectType } from "../project/namespace.js";
2
+ import type { IndustryTraits, IndustrySource } from "../knowledge/industry-registry.js";
3
+ import type { AcquisitionFlywheel } from "../knowledge/acquisition-flywheel.js";
4
+ import type { IndustryRiskCheck, IndustryNeed } from "../customer/industry-risks.js";
5
+ import type { ModeMachineNode, ModeGuardRef, ModeAllocatorStrategy } from "../knowledge/scenario-modes.js";
6
+ export type { ProjectObjectType, IndustryTraits, IndustrySource, AcquisitionFlywheel, IndustryRiskCheck, IndustryNeed, ModeMachineNode, ModeGuardRef, ModeAllocatorStrategy, };
7
+ export interface ProjectContext {
8
+ project_id?: string;
9
+ prefix: string;
10
+ network: "testnet" | "mainnet" | "both";
11
+ business_intent?: string;
12
+ version?: string;
13
+ testnet_test_passed?: boolean;
14
+ industry?: string;
15
+ }
16
+ export interface Blueprint {
17
+ context: ProjectContext;
18
+ objects: BlueprintObject[];
19
+ edges: BlueprintEdge[];
20
+ steps: BlueprintStep[];
21
+ scenarios?: BlueprintScenario[];
22
+ industry_source: string;
23
+ applied_template: string;
24
+ validation?: {
25
+ errors: string[];
26
+ warnings: string[];
27
+ };
28
+ }
29
+ export interface BlueprintObject {
30
+ entry_id: string;
31
+ object_type: ProjectObjectType;
32
+ name: string;
33
+ config: Record<string, unknown>;
34
+ publish_required: boolean;
35
+ status: "draft" | "deployed";
36
+ description?: string;
37
+ }
38
+ export interface BlueprintEdge {
39
+ from: string;
40
+ to: string;
41
+ edge_kind: string;
42
+ field_path: string;
43
+ required_at_publish: boolean;
44
+ }
45
+ export interface BlueprintStep {
46
+ step: number;
47
+ object_type: ProjectObjectType;
48
+ operation: "create" | "publish";
49
+ substep_count: number;
50
+ depends_on: number[];
51
+ entry_id: string;
52
+ network_phase: "testnet" | "mainnet" | "both";
53
+ }
54
+ export interface BlueprintScenario {
55
+ scenario_id: string;
56
+ description: string;
57
+ primary_object: string;
58
+ supporting_objects: string[];
59
+ }
60
+ export type RiskAppetite = "conservative" | "balanced" | "aggressive";
61
+ export interface ExpectedBenefit {
62
+ metric: string;
63
+ expected_value: string;
64
+ evidence: string;
65
+ }
66
+ export interface ModeRiskConstraints {
67
+ require_arbitration: boolean;
68
+ require_compensation_fund: boolean;
69
+ require_wip_evidence: boolean;
70
+ max_single_transaction?: number;
71
+ other_constraints?: string[];
72
+ }
73
+ export interface ModeApplicableConditions {
74
+ business_scale: "small" | "medium" | "large";
75
+ min_daily_orders?: number;
76
+ other_conditions?: string[];
77
+ }
78
+ export interface ConfigOverrideRule {
79
+ object_type: string;
80
+ field_path: string;
81
+ value?: unknown;
82
+ condition?: {
83
+ intent_contains?: string;
84
+ context_field?: string;
85
+ matches?: unknown;
86
+ then_value: unknown;
87
+ else_value?: unknown;
88
+ };
89
+ }
90
+ export interface IndustryMode {
91
+ name: string;
92
+ display_name: string;
93
+ version: string;
94
+ source: IndustrySource;
95
+ traits: IndustryTraits;
96
+ machine_shape: ModeMachineNode[];
97
+ guards: ModeGuardRef[];
98
+ allocator: ModeAllocatorStrategy;
99
+ risk_checks: IndustryRiskCheck[];
100
+ needs: IndustryNeed[];
101
+ flywheel: AcquisitionFlywheel;
102
+ key_risk: string;
103
+ build_notes?: string[];
104
+ capabilities_used: string[];
105
+ config_overrides?: Record<string, Record<string, unknown>>;
106
+ config_override_rules?: ConfigOverrideRule[];
107
+ expected_benefits: ExpectedBenefit[];
108
+ risk_appetite: RiskAppetite;
109
+ risk_constraints: ModeRiskConstraints;
110
+ applicable_conditions: ModeApplicableConditions;
111
+ similar_industries?: string[];
112
+ novel_capabilities?: string[];
113
+ }
114
+ export interface UserDefinedMode extends IndustryMode {
115
+ owner: string;
116
+ source: IndustrySource;
117
+ derived_from?: string;
118
+ custom_metrics?: BaseMetric[];
119
+ custom_constraints?: ModeConstraint[];
120
+ evolution_history?: Array<{
121
+ version: string;
122
+ changed_at: number;
123
+ changes: string[];
124
+ }>;
125
+ }
126
+ export interface IndustryModeRegistration {
127
+ mode: IndustryMode;
128
+ aliases?: string[];
129
+ enabled: boolean;
130
+ registered_at: number;
131
+ }
132
+ export type DeriveModeOptions = Partial<UserDefinedMode>;
133
+ export type EvolveModeOptions = Partial<UserDefinedMode>;
134
+ export type MetricType = "risk" | "benefit";
135
+ export type MetricScale = "level" | "numeric" | "percentage";
136
+ export type MetricValue = string | number;
137
+ export type CapabilityMetricValue = Record<string, Record<string, MetricValue>>;
138
+ export interface BaseMetric {
139
+ metric_id: string;
140
+ display_name: string;
141
+ description: string;
142
+ type: MetricType;
143
+ scale: MetricScale;
144
+ weight?: number;
145
+ scope: "builtin" | "custom";
146
+ owner?: string;
147
+ }
148
+ export interface MetricEvaluationDetail {
149
+ metric_id: string;
150
+ display_name: string;
151
+ value: MetricValue;
152
+ normalized_score: number;
153
+ weight: number;
154
+ }
155
+ export interface MetricEvaluation {
156
+ risk_score: number;
157
+ benefit_score: number;
158
+ metric_details: MetricEvaluationDetail[];
159
+ }
160
+ export type ConstraintSeverity = "hard" | "soft";
161
+ export type ConstraintViolationAction = "block" | "warn" | "log";
162
+ export type ConstraintRule = {
163
+ type: "capability_required";
164
+ capability_id: string;
165
+ } | {
166
+ type: "capability_forbidden";
167
+ capability_id: string;
168
+ } | {
169
+ type: "numeric_limit";
170
+ field: string;
171
+ max?: number;
172
+ min?: number;
173
+ } | {
174
+ type: "condition_required";
175
+ condition: string;
176
+ ai_evaluated: true;
177
+ };
178
+ export interface ModeConstraint {
179
+ constraint_id: string;
180
+ display_name: string;
181
+ description: string;
182
+ rule: ConstraintRule;
183
+ severity: ConstraintSeverity;
184
+ on_violation: ConstraintViolationAction;
185
+ scope: "builtin" | "custom";
186
+ owner?: string;
187
+ }
188
+ export interface ConstraintViolation {
189
+ constraint_id: string;
190
+ display_name: string;
191
+ violation: string;
192
+ severity: ConstraintSeverity;
193
+ action: ConstraintViolationAction;
194
+ recommendation: string;
195
+ }
196
+ export interface ModeEvaluation {
197
+ applicable: boolean;
198
+ risk_score: number;
199
+ benefit_score: number;
200
+ risk_benefit_ratio: number;
201
+ capability_conflicts: string[];
202
+ violated_constraints: string[];
203
+ unmet_conditions: string[];
204
+ recommendations: string[];
205
+ }
206
+ export interface ModeMigrationEvaluation {
207
+ feasibility_score: number;
208
+ source_risk_score: number;
209
+ target_risk_score: number;
210
+ source_benefit_score: number;
211
+ target_benefit_score: number;
212
+ risk_delta: number;
213
+ benefit_delta: number;
214
+ added_capabilities: string[];
215
+ removed_capabilities: string[];
216
+ conflicting_capabilities: string[];
217
+ recommendations: string[];
218
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { existsSync, mkdirSync, writeFileSync, readFileSync, readdirSync, unlinkSync, openSync, closeSync } from "fs";
2
2
  import { join } from "path";
3
- import { homedir } from "os";
4
- const CHECKPOINT_ROOT = join(homedir(), ".wowok", "checkpoints");
3
+ import { getWowMcpDir } from "@wowok/wowok";
4
+ const CHECKPOINT_ROOT = join(getWowMcpDir(), "checkpoints");
5
5
  function getTaskDir(taskId) {
6
6
  return join(CHECKPOINT_ROOT, taskId);
7
7
  }
@@ -44,6 +44,8 @@ export interface DeploymentScanResult {
44
44
  D16_no_critical_risk: "pass" | "fail";
45
45
  D17_no_high_risk: "pass" | "fail";
46
46
  D18_completeness_checklist: "pass" | "fail";
47
+ D19_machine_entry_forward: "pass" | "fail";
48
+ D20_service_compensation_fund: "pass" | "fail";
47
49
  };
48
50
  scanned_at: number;
49
51
  scanner_version: string;
@@ -56,6 +58,7 @@ export declare function analyzePermissionIndexRange(input: DeploymentScanInput):
56
58
  export declare function analyzeScenarioCoverage(input: DeploymentScanInput): Finding[];
57
59
  export declare function analyzeVerificationChecklist(input: DeploymentScanInput): Finding[];
58
60
  export declare function analyzeDeployableReadiness(input: DeploymentScanInput): Finding[];
61
+ export declare function analyzeMachineAndServiceReadiness(input: DeploymentScanInput): Finding[];
59
62
  export declare function scanDeployment(input: DeploymentScanInput): DeploymentScanResult;
60
63
  export declare function isReady(scan: DeploymentScanResult): boolean;
61
64
  export declare function isBlocked(scan: DeploymentScanResult): boolean;
@@ -25,7 +25,7 @@ function fromDeploymentDocInput(input) {
25
25
  for (let i = 1; i <= 5; i++)
26
26
  mainnet_verification.set(`V-M-${String(i).padStart(2, "0")}`, false);
27
27
  const completeness_checklist = new Map();
28
- for (let i = 1; i <= 18; i++)
28
+ for (let i = 1; i <= 20; i++)
29
29
  completeness_checklist.set(`D-${String(i).padStart(2, "0")}`, false);
30
30
  return {
31
31
  project_name: input.project_prefix, version, namespace_tag,
@@ -529,7 +529,7 @@ export function analyzeScenarioCoverage(input) {
529
529
  }
530
530
  const TESTNET_VERIFICATION_ITEMS = ["V-T-01", "V-T-02", "V-T-03", "V-T-04", "V-T-05", "V-T-06", "V-T-07", "V-T-08", "V-T-09", "V-T-10", "V-T-11"];
531
531
  const MAINNET_VERIFICATION_ITEMS = ["V-M-01", "V-M-02", "V-M-03", "V-M-04", "V-M-05"];
532
- const COMPLETENESS_CHECK_IDS = Array.from({ length: 18 }, (_, i) => `D-${String(i + 1).padStart(2, "0")}`);
532
+ const COMPLETENESS_CHECK_IDS = Array.from({ length: 20 }, (_, i) => `D-${String(i + 1).padStart(2, "0")}`);
533
533
  export function analyzeVerificationChecklist(input) {
534
534
  const findings = [];
535
535
  try {
@@ -623,6 +623,64 @@ function resolveRiskResult(input) {
623
623
  }
624
624
  return undefined;
625
625
  }
626
+ function extractMachinePairs(block) {
627
+ const data = block.data;
628
+ if (!data)
629
+ return [];
630
+ const node = data.node;
631
+ if (!node || typeof node !== "object")
632
+ return [];
633
+ const nodes = node.nodes;
634
+ if (!Array.isArray(nodes))
635
+ return [];
636
+ return nodes.filter((n) => {
637
+ if (!n || typeof n !== "object")
638
+ return false;
639
+ const pairs = n.pairs;
640
+ return Array.isArray(pairs);
641
+ }).flatMap((n) => n.pairs ?? []);
642
+ }
643
+ export function analyzeMachineAndServiceReadiness(input) {
644
+ const findings = [];
645
+ try {
646
+ const doc = normalizeInput(input);
647
+ if (!doc)
648
+ return [];
649
+ const allBlocks = [...doc.testnet_blocks, ...doc.mainnet_blocks];
650
+ for (const block of allBlocks) {
651
+ if (block.operation_type !== "machine")
652
+ continue;
653
+ const pairs = extractMachinePairs(block);
654
+ if (pairs.length === 0)
655
+ continue;
656
+ const entryPairs = pairs.filter((p) => p.prev_node === "");
657
+ for (const pair of entryPairs) {
658
+ const forwardsLen = Array.isArray(pair.forwards) ? pair.forwards.length : 0;
659
+ if (forwardsLen === 0) {
660
+ add(findings, "D-19", "critical", `Machine in step ${block.step} (${block.env.network ?? "?"}) has an entry node (prev_node="") with no forwards. ` +
661
+ `Progress created from this Machine will be permanently stuck at current="" (P0-2 root cause).`, `${block.env.network ?? "?"} step ${block.step}`, `Add at least one forward to the entry node's pairs. Example: pairs: [{prev_node: "", forwards: [{next_node: "Ordered", ...}]}]`);
662
+ }
663
+ }
664
+ }
665
+ const serviceBlocks = allBlocks.filter((b) => b.operation_type === "service");
666
+ if (serviceBlocks.length > 0) {
667
+ const blocksWithFundAdd = serviceBlocks.filter((b) => {
668
+ const data = b.data;
669
+ return data?.compensation_fund_add != null;
670
+ });
671
+ if (blocksWithFundAdd.length === 0) {
672
+ add(findings, "D-20", "warning", `No Service block in the deployment doc includes a compensation_fund_add step. ` +
673
+ `Without deposit, arbitration rulings that award refunds to buyers cannot be paid out from the Service. ` +
674
+ `Industries like freelance may not require this (info), but rental/travel/education typically do.`, "§3.2 / §4.2 Service blocks", `Add a compensation_fund_add step for the Service (e.g., data.compensation_fund_add = {balance: <amount>}). ` +
675
+ `Recommended: 5× the max single-order amount (P1-1 evaluation rule).`);
676
+ }
677
+ }
678
+ }
679
+ catch (err) {
680
+ add(findings, "D-19", "warning", `analyzeMachineAndServiceReadiness failed: ${err.message}`);
681
+ }
682
+ return findings;
683
+ }
626
684
  export function scanDeployment(input) {
627
685
  const allFindings = [
628
686
  ...analyzeObjectDependencyCompleteness(input),
@@ -633,6 +691,7 @@ export function scanDeployment(input) {
633
691
  ...analyzeScenarioCoverage(input),
634
692
  ...analyzeVerificationChecklist(input),
635
693
  ...analyzeDeployableReadiness(input),
694
+ ...analyzeMachineAndServiceReadiness(input),
636
695
  ];
637
696
  return {
638
697
  project_name: input.project_name,
@@ -666,6 +725,8 @@ function computeChecks(findings) {
666
725
  D16_no_critical_risk: has("D-16") ? "fail" : "pass",
667
726
  D17_no_high_risk: has("D-17") ? "fail" : "pass",
668
727
  D18_completeness_checklist: has("D-18") ? "fail" : "pass",
728
+ D19_machine_entry_forward: has("D-19") ? "fail" : "pass",
729
+ D20_service_compensation_fund: has("D-20") ? "fail" : "pass",
669
730
  };
670
731
  }
671
732
  function computeCoverage(input) {
@@ -726,7 +787,7 @@ export function summarizeScan(scan) {
726
787
  L.push(`| testnet steps | ${scan.coverage.testnet_steps} |`);
727
788
  L.push(`| mainnet steps | ${scan.coverage.mainnet_steps} |`);
728
789
  L.push(`| verification items | ${scan.coverage.verification_items} |`, "");
729
- L.push("## Checks (D-01 ~ D-18)", "", "| Check ID | Status |", "|----------|--------|");
790
+ L.push("## Checks (D-01 ~ D-20)", "", "| Check ID | Status |", "|----------|--------|");
730
791
  const entries = Object.entries(scan.checks);
731
792
  for (const [id, status] of entries)
732
793
  L.push(`| ${id} | ${status === "pass" ? "✅ pass" : "❌ fail"} |`);
@@ -3,7 +3,7 @@ import { getIndustryProfile, resolveIndustryName } from "./industry-registry.js"
3
3
  import { evaluateIndustryHealthByIntent, suggestIndustryUpdateByIntent, getRoleAdvice, filterSuggestionsByRole, getIntentProfile, } from "./intent-metrics.js";
4
4
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
5
5
  import { dirname, join } from "path";
6
- import { homedir } from "os";
6
+ import { getWowMcpDir } from "@wowok/wowok";
7
7
  export const FLYWHEEL_LOOP_VERSION = 2;
8
8
  const MIN_SIGNALS_FOR_EVOLUTION = 10;
9
9
  const DEFAULT_SCHEDULE = {
@@ -287,10 +287,7 @@ export function getIndustryEvolutionStatus(industry) {
287
287
  }
288
288
  export const EVOLUTION_STATE_VERSION = 1;
289
289
  function evolutionStateFilePath() {
290
- const dir = process.env.WOWOK_CONFIG_DIR
291
- ? process.env.WOWOK_CONFIG_DIR
292
- : join(homedir(), ".wowok");
293
- return join(dir, "evolution-state.json");
290
+ return join(getWowMcpDir(), "evolution-state.json");
294
291
  }
295
292
  export function saveEvolutionState() {
296
293
  const path = evolutionStateFilePath();
@@ -1,4 +1,17 @@
1
1
  import type { GuardScene } from "./guard-ledger.js";
2
+ export declare const GUARD_COGNITIVE_PRINCIPLES: readonly [{
3
+ readonly id: "P1";
4
+ readonly title: "Guard validation always precedes the operation";
5
+ readonly statement: string;
6
+ readonly code_evidence: string;
7
+ readonly legitimate_exception: string;
8
+ readonly scope: "Applies when a Guard queries state of the SAME object the operation mutates.";
9
+ }, {
10
+ readonly id: "P2";
11
+ readonly title: "Guard is CREATE-only and immutable";
12
+ readonly statement: string;
13
+ readonly scope: "Applies to all Guard lifecycle decisions.";
14
+ }];
2
15
  export type GuardStakeholder = "customer" | "provider" | "arbitrator" | "claimant" | "system";
3
16
  export type RiskLevel = "critical" | "high" | "medium" | "low";
4
17
  export type DataSourceClass = "type1_onchain_constant" | "type2_witness_derived" | "type3_submitted_object" | "type4_system_context" | "cross_type";
@@ -1,4 +1,24 @@
1
1
  import { GUARDQUERY } from "@wowok/wowok";
2
+ export const GUARD_COGNITIVE_PRINCIPLES = [
3
+ {
4
+ id: "P1",
5
+ title: "Guard validation always precedes the operation",
6
+ statement: "Guard validation ALWAYS occurs BEFORE the operation it guards. " +
7
+ "A Guard must NOT depend on data that the current operation will modify.",
8
+ code_evidence: "progress.move next_with_passport_imp: result_for_guard (line 471) " +
9
+ "runs before session_accomplish (line 481) which sets self.current (line 443).",
10
+ legitimate_exception: "Querying progress.current of a DIFFERENT Progress object (cross-machine) " +
11
+ "is safe and reasonable — that progress is not modified by the current operation.",
12
+ scope: "Applies when a Guard queries state of the SAME object the operation mutates.",
13
+ },
14
+ {
15
+ id: "P2",
16
+ title: "Guard is CREATE-only and immutable",
17
+ statement: "After creation, Guard table/root/rely cannot be modified. " +
18
+ "To change logic, create a new Guard and rebind references.",
19
+ scope: "Applies to all Guard lifecycle decisions.",
20
+ },
21
+ ];
2
22
  function rootStr(ctx) {
3
23
  return JSON.stringify(ctx.root).toLowerCase();
4
24
  }
@@ -1681,6 +1701,43 @@ const RISK_RULES = [
1681
1701
  };
1682
1702
  },
1683
1703
  },
1704
+ {
1705
+ id: "R-X1-15",
1706
+ data_source_class: "cross_type",
1707
+ trigger: "Guard root contains a progress.current query (id=1253 or name='progress.current'); " +
1708
+ "if bound to a forward of the SAME Progress object, the guard evaluates before state transition",
1709
+ check: (ctx) => {
1710
+ const queryIds = extractQueryIds(ctx.root);
1711
+ if (!queryIds.includes(1253))
1712
+ return null;
1713
+ return {
1714
+ id: "R-X1-15",
1715
+ data_source_class: "cross_type",
1716
+ level: "medium",
1717
+ category: "logic_gap",
1718
+ title: "Guard queries progress.current — verify it is NOT the same Progress object the hosting operation mutates",
1719
+ description: "Cognitive Principle P1: Guard validation ALWAYS occurs BEFORE the operation. " +
1720
+ "This Guard contains a progress.current query. If this Guard is bound to a forward " +
1721
+ "of the SAME Progress object it queries, the Guard will see the PRE-transition value " +
1722
+ "(source node, not target node) and may always fail. " +
1723
+ "Querying a DIFFERENT Progress object (e.g. another Machine's progress) is a valid " +
1724
+ "and reasonable design pattern — the principle does not apply in that case. " +
1725
+ "Allocator-bound guards are also unaffected because allocation.alloc() runs AFTER " +
1726
+ "the state transition completes.",
1727
+ affected_stakeholders: ["provider"],
1728
+ scenario: "Forward guard checks progress.current == target_node of the same Progress — " +
1729
+ "always fails because guard runs before session_accomplish sets the new current node",
1730
+ mitigation: "1) If this Guard queries the SAME Progress object the forward operates on: " +
1731
+ "remove the guard from the forward, bind it ONLY to the Allocator (which runs after transition); " +
1732
+ "OR change the check to verify the SOURCE node instead of the target node. " +
1733
+ "2) If this Guard queries a DIFFERENT Progress object (cross-machine): no action needed — " +
1734
+ "this is a legitimate pattern. " +
1735
+ "3) Refer to GUARD_COGNITIVE_PRINCIPLES P1 for the full principle and code evidence.",
1736
+ evidence: `Root contains progress.current query (id=1253). ` +
1737
+ `Query IDs detected: [${queryIds.join(", ")}].`,
1738
+ };
1739
+ },
1740
+ },
1684
1741
  ];
1685
1742
  function deriveStakeholders(sceneId) {
1686
1743
  switch (sceneId) {