@wowok/agent-mcp 2.5.2 → 2.5.4

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 (110) hide show
  1. package/dist/customer/index.d.ts +2 -2
  2. package/dist/customer/index.js +1 -1
  3. package/dist/customer/info-puzzle.d.ts +39 -2
  4. package/dist/customer/info-puzzle.js +370 -29
  5. package/dist/customer/risk-assessment.js +51 -14
  6. package/dist/customer/types.d.ts +85 -0
  7. package/dist/index.js +46 -6
  8. package/dist/knowledge/guard-design-patterns.js +104 -1
  9. package/dist/knowledge/guard-ledger.js +3 -3
  10. package/dist/knowledge/guard-lint.js +3 -3
  11. package/dist/knowledge/guard-risk.js +23 -15
  12. package/dist/knowledge/guard-templates.js +174 -2
  13. package/dist/knowledge/guard-translation.js +3 -3
  14. package/dist/knowledge/index.d.ts +3 -0
  15. package/dist/knowledge/index.js +9 -0
  16. package/dist/knowledge/machine-context.d.ts +1 -1
  17. package/dist/knowledge/machine-context.js +21 -0
  18. package/dist/knowledge/machine-ledger.d.ts +1 -0
  19. package/dist/knowledge/machine-ledger.js +60 -37
  20. package/dist/knowledge/machine-risk.js +23 -0
  21. package/dist/knowledge/machine-templates.js +150 -164
  22. package/dist/knowledge/overrides-loader.d.ts +13 -0
  23. package/dist/knowledge/overrides-loader.js +67 -0
  24. package/dist/knowledge/payment-risk.d.ts +4 -0
  25. package/dist/knowledge/payment-risk.js +67 -0
  26. package/dist/knowledge/repository-confirm.d.ts +4 -0
  27. package/dist/knowledge/repository-confirm.js +44 -0
  28. package/dist/knowledge/repository-risk.d.ts +8 -2
  29. package/dist/knowledge/repository-risk.js +61 -0
  30. package/dist/knowledge/repository-translation.js +23 -0
  31. package/dist/knowledge/reward-templates.d.ts +1 -1
  32. package/dist/knowledge/reward-templates.js +77 -5
  33. package/dist/knowledge/scenario-modes.js +22 -5
  34. package/dist/knowledge/service-templates.js +38 -0
  35. package/dist/knowledge/treasury-templates.js +42 -0
  36. package/dist/knowledge/trust-metrics.d.ts +4 -0
  37. package/dist/knowledge/trust-metrics.js +67 -7
  38. package/dist/loop-engineering/context-collect.d.ts +7 -0
  39. package/dist/loop-engineering/context-collect.js +83 -0
  40. package/dist/loop-engineering/improve.d.ts +29 -0
  41. package/dist/loop-engineering/improve.js +178 -0
  42. package/dist/project/context-assembly.d.ts +16 -0
  43. package/dist/project/context-assembly.js +130 -0
  44. package/dist/project/deployment-doc.d.ts +115 -0
  45. package/dist/project/deployment-doc.js +595 -0
  46. package/dist/project/index.js +37 -1
  47. package/dist/project/migration.d.ts +22 -0
  48. package/dist/project/migration.js +125 -0
  49. package/dist/project/project-store.d.ts +110 -0
  50. package/dist/project/project-store.js +425 -0
  51. package/dist/project/rollback-policy.d.ts +45 -0
  52. package/dist/project/rollback-policy.js +290 -0
  53. package/dist/project/stage-gate.d.ts +49 -0
  54. package/dist/project/stage-gate.js +310 -0
  55. package/dist/schema/call/allocation.d.ts +5 -0
  56. package/dist/schema/call/arbitration.d.ts +59 -54
  57. package/dist/schema/call/base.d.ts +3 -0
  58. package/dist/schema/call/base.js +1 -0
  59. package/dist/schema/call/bridge.d.ts +24 -0
  60. package/dist/schema/call/contact.d.ts +5 -0
  61. package/dist/schema/call/demand.d.ts +53 -48
  62. package/dist/schema/call/guard.d.ts +15 -0
  63. package/dist/schema/call/machine.d.ts +10 -0
  64. package/dist/schema/call/order.d.ts +5 -0
  65. package/dist/schema/call/payment.d.ts +5 -0
  66. package/dist/schema/call/permission.d.ts +5 -0
  67. package/dist/schema/call/personal.d.ts +5 -0
  68. package/dist/schema/call/progress.d.ts +5 -0
  69. package/dist/schema/call/proof.d.ts +10 -0
  70. package/dist/schema/call/repository.d.ts +5 -0
  71. package/dist/schema/call/reward.d.ts +5 -0
  72. package/dist/schema/call/service.d.ts +5 -0
  73. package/dist/schema/call/treasury.d.ts +5 -0
  74. package/dist/schema/operations.d.ts +286 -76
  75. package/dist/schema/operations.js +24 -0
  76. package/dist/schema/project/index.d.ts +2633 -120
  77. package/dist/schema/project/index.js +622 -2
  78. package/dist/schema/query/index.d.ts +601 -0
  79. package/dist/schema/query/index.js +61 -0
  80. package/dist/schema/trust/index.d.ts +10 -10
  81. package/dist/schemas/bridge_operation.schema.json +4 -0
  82. package/dist/schemas/guard2file.schema.json +4 -0
  83. package/dist/schemas/index.json +1 -1
  84. package/dist/schemas/machineNode2file.schema.json +4 -0
  85. package/dist/schemas/onchain_operations.schema.json +20 -0
  86. package/dist/schemas/onchain_operations_allocation.schema.json +4 -0
  87. package/dist/schemas/onchain_operations_arbitration.schema.json +4 -0
  88. package/dist/schemas/onchain_operations_contact.schema.json +4 -0
  89. package/dist/schemas/onchain_operations_demand.schema.json +4 -0
  90. package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
  91. package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
  92. package/dist/schemas/onchain_operations_guard.schema.json +4 -0
  93. package/dist/schemas/onchain_operations_machine.schema.json +4 -0
  94. package/dist/schemas/onchain_operations_order.schema.json +4 -0
  95. package/dist/schemas/onchain_operations_payment.schema.json +4 -0
  96. package/dist/schemas/onchain_operations_permission.schema.json +4 -0
  97. package/dist/schemas/onchain_operations_personal.schema.json +4 -0
  98. package/dist/schemas/onchain_operations_progress.schema.json +4 -0
  99. package/dist/schemas/onchain_operations_proof.schema.json +4 -0
  100. package/dist/schemas/onchain_operations_repository.schema.json +4 -0
  101. package/dist/schemas/onchain_operations_reward.schema.json +4 -0
  102. package/dist/schemas/onchain_operations_service.schema.json +4 -0
  103. package/dist/schemas/onchain_operations_treasury.schema.json +4 -0
  104. package/dist/schemas/project_operation.output.json +1798 -0
  105. package/dist/schemas/project_operation.schema.json +132 -2
  106. package/dist/schemas/query_toolkit.output.json +407 -1
  107. package/dist/schemas/query_toolkit.schema.json +132 -0
  108. package/dist/tools/handlers/project.js +742 -1
  109. package/dist/tools/handlers/query.js +38 -2
  110. package/package.json +2 -2
@@ -28,6 +28,9 @@ export interface WorkflowAnalysis {
28
28
  guard_gated_forwards: number;
29
29
  has_refund_path: boolean;
30
30
  has_arbitration_path: boolean;
31
+ has_arbitration_binding: boolean;
32
+ has_wonder_node: boolean;
33
+ has_dispute_anti_pattern: boolean;
31
34
  has_milestone_nodes: boolean;
32
35
  dead_end_nodes: string[];
33
36
  terminal_nodes: string[];
@@ -77,6 +80,82 @@ export interface MarketContext {
77
80
  price_percentile: number;
78
81
  supply_demand_ratio: number;
79
82
  }
83
+ export type UserMetricEvaluatorType = "threshold" | "ratio" | "boolean" | "presence" | "regex_match" | "custom_query";
84
+ export interface UserMetric {
85
+ name: string;
86
+ label: string;
87
+ evaluator: UserMetricEvaluatorType;
88
+ params: {
89
+ path?: string;
90
+ threshold?: number | string;
91
+ invert?: boolean;
92
+ min?: number;
93
+ max?: number;
94
+ pattern?: string;
95
+ query_key?: string;
96
+ };
97
+ weight: number;
98
+ advice_on_fail?: string;
99
+ advice_on_pass?: string;
100
+ }
101
+ export interface UserMetricsConfig {
102
+ version: number;
103
+ source_file?: string;
104
+ metrics: UserMetric[];
105
+ adjustment_cap?: number;
106
+ }
107
+ export interface UserMetricResult {
108
+ name: string;
109
+ label: string;
110
+ passed: boolean;
111
+ score: number;
112
+ observed_value?: string | number | boolean;
113
+ weight: number;
114
+ advice?: string;
115
+ }
116
+ export interface UserMetricsResult {
117
+ metrics: UserMetricResult[];
118
+ score: number;
119
+ adjustment: number;
120
+ source_file?: string;
121
+ evaluated_at: number;
122
+ }
123
+ export interface ServiceNestingEvaluation {
124
+ depth_reached: number;
125
+ truncated: boolean;
126
+ bindings: {
127
+ machine?: {
128
+ object_id: string;
129
+ published: boolean;
130
+ risk_level: "low" | "medium" | "high" | "critical";
131
+ issues: string[];
132
+ };
133
+ arbitrations: Array<{
134
+ object_id: string;
135
+ voting_guard_count: number;
136
+ fee_balance: string;
137
+ paused: boolean;
138
+ risk_level: "low" | "medium" | "high" | "critical";
139
+ issues: string[];
140
+ }>;
141
+ rewards: Array<{
142
+ object_id: string;
143
+ balance: string;
144
+ guard_count: number;
145
+ risk_level: "low" | "medium" | "high" | "critical";
146
+ issues: string[];
147
+ }>;
148
+ repositories: Array<{
149
+ object_id: string;
150
+ risk_level: "low" | "medium" | "high" | "critical";
151
+ issues: string[];
152
+ }>;
153
+ };
154
+ overall_risk_level: "low" | "medium" | "high" | "critical";
155
+ overall_risk_score: number;
156
+ total_bindings_evaluated: number;
157
+ evaluated_at: number;
158
+ }
80
159
  export interface InfoPuzzle {
81
160
  service_id: string;
82
161
  service_basics: ServiceBasics;
@@ -85,6 +164,8 @@ export interface InfoPuzzle {
85
164
  trust_signals?: TrustSignals;
86
165
  merchant_behavior?: MerchantBehavior;
87
166
  market_context?: MarketContext;
167
+ user_metrics?: UserMetricsResult;
168
+ service_nesting?: ServiceNestingEvaluation;
88
169
  completeness: number;
89
170
  gaps: string[];
90
171
  assembled_at: number;
@@ -107,8 +188,12 @@ export interface RiskDimensionScore {
107
188
  export type RiskLevel = "low" | "medium_low" | "medium_high" | "high";
108
189
  export interface RiskScore {
109
190
  total: number;
191
+ base_total: number;
110
192
  level: RiskLevel;
111
193
  dimensions: RiskDimensionScore[];
194
+ user_metrics_adjustment?: number;
195
+ service_nesting_risk?: number;
196
+ service_nesting_level?: "low" | "medium" | "high" | "critical";
112
197
  red_flags: string[];
113
198
  advice: string[];
114
199
  }
package/dist/index.js CHANGED
@@ -16,9 +16,37 @@ if (process.env.WOWOK_TELEMETRY === "false" || process.env.WOWOK_TELEMETRY === "
16
16
  }
17
17
  const SERVER_DESCRIPTION = `WoWok MCP Server - Making It Easy for AI Agents to Communicate, Collaborate, Trade, and Trust.
18
18
 
19
+ ## CRITICAL: Unified Single-Tool Architecture
20
+
21
+ This server exposes exactly ONE MCP tool: \`wowok\`. All 17 sub-tools are dispatched internally by the \`wowok\` handler.
22
+
23
+ ### Call Format
24
+ \`\`\`
25
+ wowok({ tool: "<sub-tool-name>", data: {<sub-tool parameters>} })
26
+ \`\`\`
27
+
28
+ Accepted aliases (deprecated): \`tool_name\`/\`name\` for \`tool\`, \`args\`/\`params\` for \`data\`. Inline params (e.g. \`{ tool: "schema_query", action: "list" }\`) are also auto-wrapped into \`data\`.
29
+
30
+ ### Schema-Gated Execution (Self-Correcting)
31
+ If your parameters don't match the sub-tool's schema, the response includes:
32
+ - \`result.status = "schema_mismatch"\`
33
+ - \`result.errors\` = specific validation errors
34
+ - \`schema.input\` = the correct JSON schema for the sub-tool
35
+ - \`schema.tool\` = which sub-tool this schema belongs to
36
+
37
+ Read the schema, fix your params, and retry. CACHE the schema in your context for future calls to the SAME sub-tool — you should only need to see each sub-tool's schema once per conversation. No separate \`schema_query\` call is needed for parameter correction.
38
+
39
+ ### Unified Response Envelope
40
+ \`\`\`
41
+ {
42
+ "result": { "status": "success|error|schema_mismatch", "data": <sub-tool output>, "errors": [...] },
43
+ "schema": null | { "input": <JSON schema>, "tool": "<sub-tool-name>" }
44
+ }
45
+ \`\`\`
46
+
19
47
  ## CRITICAL: Schema Discovery Rule
20
48
 
21
- When the current context does not contain a tool's input/output schema, or when you are uncertain whether the schema you have is complete and up-to-date, you MUST query it first before calling the tool. Use schema_query for operational tool schemas or wowok_buildin_info for protocol constants and reference data. Never guess schema parameters, query instruction IDs, or type codes — always retrieve them from the live server.
49
+ When the current context does not contain a sub-tool's input/output schema, or when you are uncertain whether the schema you have is complete and up-to-date, you MUST query it first before calling the sub-tool. Use \`wowok({ tool: "schema_query", data: { action: "get", name: "<sub-tool>" } })` + "`" + ` for operational sub-tool schemas or \`wowok({ tool: "wowok_buildin_info", data: { info: "..." } })\` for protocol constants and reference data. Never guess schema parameters, query instruction IDs, or type codes — always retrieve them from the live server.
22
50
 
23
51
  ## Token System Overview
24
52
 
@@ -64,10 +92,12 @@ Token amounts are HIGHLY SENSITIVE. Always:
64
92
  - Double-check large amount transactions
65
93
  - Never assume decimal places - use explicit token unit
66
94
 
67
- ## Tool Selection Guide
95
+ ## Sub-tool Selection Guide
68
96
 
69
- | User Intent | Correct Tool | Wrong Tool (Avoid) |
70
- |------------|--------------|-------------------|
97
+ All sub-tools are called via \`wowok({ tool: "<sub-tool>", data: {...} })\`. The table below helps pick the correct \`tool\` value.
98
+
99
+ | User Intent | Correct Sub-tool | Wrong Sub-tool (Avoid) |
100
+ |------------|------------------|------------------------|
71
101
  | Create service listing | onchain_operations (service) | query_toolkit |
72
102
  | Send coins to address | onchain_operations (payment) | account_operation |
73
103
  | Check my balance | query_toolkit (account_balance) | onchain_operations |
@@ -99,9 +129,13 @@ Token amounts are HIGHLY SENSITIVE. Always:
99
129
  | Send encrypted file via messenger | messenger_operation (send_file) | wip_file |
100
130
  | Generate Witness Timestamped Sequence (WTS) | messenger_operation (generate_wts) | wip_file |
101
131
  | Query protocol constants | wowok_buildin_info | query_toolkit |
102
- | Query tool schemas | schema_query | wowok_buildin_info |
132
+ | Query sub-tool schemas | schema_query | wowok_buildin_info |
133
+ | Cross-chain bridge (WOW<->EVM) | bridge_operation | onchain_operations |
134
+ | Project deployment workflow | project_operation | onchain_operations |
135
+ | Runtime service toggles | config_operation | — |
136
+ | Service trust/risk assessment | trust_score | query_toolkit |
103
137
 
104
- ## Local vs On-chain Operations
138
+ ## Sub-tool Categories
105
139
 
106
140
  ### LOCAL ONLY (Never touch blockchain):
107
141
  - account_operation
@@ -112,6 +146,7 @@ Token amounts are HIGHLY SENSITIVE. Always:
112
146
  - onchain_operations
113
147
  - messenger_operation (some operations)
114
148
  - wip_file (sign operation)
149
+ - bridge_operation
115
150
 
116
151
  ### QUERY (Read-only):
117
152
  - query_toolkit
@@ -120,6 +155,11 @@ Token amounts are HIGHLY SENSITIVE. Always:
120
155
  - schema_query
121
156
  - guard2file
122
157
  - machineNode2file
158
+
159
+ ### WORKFLOW (Project-level):
160
+ - project_operation
161
+ - config_operation
162
+ - trust_score
123
163
  `;
124
164
  const server = new McpServer(createServerConfig(packageJson, SERVER_DESCRIPTION), createCapabilitiesConfig());
125
165
  export { OnchainOperationsSchema, WipOperationsSchema, WatchQueryOperationsSchema, AccountOperationSchema, LocalMarkOperationSchema, LocalInfoOperationSchema, ProtocolInfoQuerySchema, CallOutputSchema, MessengerOperationInputSchema, MessengerOperationOutputSchema, };
@@ -93,7 +93,110 @@ export const GUARD_DESIGN_PATTERNS = [
93
93
  notes: [
94
94
  "Repository address declared as table constant",
95
95
  "Timestamp keys may need convert_number_address",
96
- "quote_guard = Some(addr) always fails in verify phase (impack_list empty) — use quote_guard = None",
96
+ "quote_guard context: fails in gen_passport (impack_list empty), works in on-chain business operations (see R-X1-10)",
97
+ ],
98
+ },
99
+ {
100
+ id: "pattern.repository_quote_guard_subscription",
101
+ business_requirement: "Repository data access requires payment proof (subscription revenue model)",
102
+ data_source: "SubmittedObject",
103
+ host: "repository_write",
104
+ verifier_level: "level3_scene_combined",
105
+ logic_summary: "Repository policy sets quote_guard (is_depended: immutable + rep=true). " +
106
+ "When a Guard queries this Repository's data (query 1167), check_repository_quote_guard verifies " +
107
+ "the quote_guard is in impack_list. The quote_guard itself verifies a submitted Payment " +
108
+ "(payment.info.for matches Repository, payment.amount meets subscription price). " +
109
+ "User submits Payment via Passport → quote_guard verified → added to impack_list → query 1167 passes.",
110
+ key_queries: ["repository.data", "payment.info.for", "payment.amount"],
111
+ mitigated_risks: ["R-X1-10"],
112
+ applicable_industries: ["subscription", "travel", "rental", "education"],
113
+ notes: [
114
+ "VERIFIED: passport.rs#L545-612 (check_repository_quote_guard), passport.rs#L758-769 (trigger at query_id==1167)",
115
+ "Repository.owner_receive<T> accepts Payment as subscription revenue (repository.move#L714-717)",
116
+ "quote_guard must be is_depended: immutable=true, relies empty, rep=true (guard.move#L133-135)",
117
+ "VERIFIER-EVIDENCE DESIGN: user submits valid Payment, quote_guard verifies Payment fields — no affiliation needed",
118
+ "gen_passport context: quote_guard fails (impack_list empty) — only use for on-chain business operations",
119
+ "Business model: data provider publishes weather/market/oracle data to Repository, " +
120
+ "users pay subscription to access data in their Machine flows",
121
+ ],
122
+ },
123
+ {
124
+ id: "pattern.supply_chain_suborder_verification",
125
+ business_requirement: "Sub-service purchase requires ownership of main service order (supply chain milestone unlock)",
126
+ data_source: "SubmittedObject",
127
+ host: "service_buy_guard",
128
+ verifier_level: "level2_identity_set",
129
+ logic_summary: "Sub-service buy_guard verifies submitted main Order: " +
130
+ "logic_and[logic_equal[query(order.owner), context(Signer)], logic_equal[query(order.service), identifier[N](main_service_address)]]. " +
131
+ "User submits main Order via Passport (b_submission=true), buy_guard verifies ownership + service match.",
132
+ key_queries: ["order.owner", "order.service"],
133
+ mitigated_risks: ["R-C3-05"],
134
+ applicable_industries: ["travel", "rental", "education", "freelance"],
135
+ notes: [
136
+ "VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence, buy_guard verifies order.owner==Signer AND order.service==main_service",
137
+ "Each milestone = one sub-order with its own Service + buy_guard referencing the main order",
138
+ "Main flow can branch to different sub-services based on Machine node progression",
139
+ "No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
140
+ "Enables supply chain composition: main service → multiple sub-services with conditional access",
141
+ ],
142
+ },
143
+ {
144
+ id: "pattern.payment_exception_compensation",
145
+ business_requirement: "Exception branch triggers compensation Payment (e.g., delivery delay > 30min auto-compensates customer)",
146
+ data_source: "SubmittedObject",
147
+ host: "machine_forward",
148
+ verifier_level: "level3_scene_combined",
149
+ logic_summary: "Exception forward guard verifies 4-dimensional anti-reuse binding: logic_and[" +
150
+ "logic_equal[query(payment.info.for), identifier[N](order_address)], " +
151
+ "logic_equal[query(payment.info.guard), identifier[N](this_guard_address)], " +
152
+ "logic_as_u256_ge[query(payment.amount), identifier[N](compensation_amount)], " +
153
+ "logic_as_u256_equal[query(payment.info.index), query(progress.history count)], " +
154
+ "logic_string_nocase_equal[query(payment.info.remark), query(progress.current)]]. " +
155
+ "Treasury withdraws to customer with PaymentInfo(for_object=order, for_guard=this, index=history_count_at_creation, remark=node_name). " +
156
+ "Customer submits Payment via Passport; guard verifies index matches current unique step (progress.history count, U64, monotonically increasing — unique even in cycles) AND remark matches current node name (progress.current, String — may repeat across cycles but bound to this step by index).",
157
+ key_queries: [
158
+ "payment.info.for",
159
+ "payment.info.guard",
160
+ "payment.info.index",
161
+ "payment.info.remark",
162
+ "payment.amount",
163
+ "progress.history count",
164
+ "progress.current",
165
+ ],
166
+ mitigated_risks: [],
167
+ applicable_industries: ["rental", "travel", "general", "freelance"],
168
+ notes: [
169
+ "VERIFIED: payment.move#L66-71 (PaymentInfo: for_object, for_guard, remark, index), payment.move#L82-86 (payment_info_with_guard)",
170
+ "VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
171
+ "Payment is freeze_object (immutable, payment.move#L160) — cannot be modified after creation",
172
+ "VERIFIED INDEX QUERY: progress.history count (id 1273, U64) — guard-ins.ts#L1228-1237. From progress.move L440-441 (session_accomplish pushes a new History entry) + L475/L482 (parent_table_vec::length returns current session id). This count is the unique monotonically increasing step index — even in cycles, each entry has a different count.",
173
+ "VERIFIED NODE NAME QUERY: progress.current (id 1253, String) — guard-ins.ts#L1025-1032. Returns the current node name. A node CAN be entered multiple times in cycles, so node name alone is NOT unique — it MUST be paired with progress.history count for uniqueness.",
174
+ "DESIGN INTENT (USER): to validate index (U64 type), use progress.history count (unique, non-repeating); to validate node name (may repeat in cycles), store it in PaymentInfo.remark and do string comparison with progress.current.",
175
+ "ANTI-REUSE 4-DIMENSIONAL BINDING: for_object (Order) + for_guard (Guard) + index (unique step via progress.history count) + remark (node name via progress.current). Same Payment cannot be reused in other contexts — at least one field will mismatch.",
176
+ "VERIFIER-EVIDENCE DESIGN: customer submits Payment, guard verifies binding fields match current context",
177
+ "Enables user-friendly exception handling: delay → auto-compensation → friendly branch flow",
178
+ "No affiliation registration needed — guard only verifies submitted Payment's field accuracy",
179
+ ],
180
+ },
181
+ {
182
+ id: "pattern.verifier_evidence_philosophy",
183
+ business_requirement: "Guard design philosophy: verifier provides evidence, guard verifies logic + data accuracy (NOT data discovery)",
184
+ data_source: "SubmittedObject",
185
+ host: "gen_passport",
186
+ verifier_level: "none",
187
+ logic_summary: "Guard is a PURE VERIFICATION engine. Participants submit evidence (Payment, Order, Proof, etc.) " +
188
+ "via Passport submissions (b_submission=true). Guard verifies: (1) logic completeness, (2) data usage accuracy. " +
189
+ "Guard does NOT discover/fetch objects via affiliation. Affiliation is for object lifecycle bookkeeping, " +
190
+ "NOT for guard data discovery.",
191
+ key_queries: [],
192
+ mitigated_risks: ["R-C3-05", "R-C3-06"],
193
+ notes: [
194
+ "CORE PRINCIPLE: Guard only validates submitted evidence — it never fetches data on its own",
195
+ "For Payment verification: user submits valid Payment → guard checks for_object/for_guard/index match",
196
+ "For multi-order verification: verifier submits Order data → guard checks service/owner relationships",
197
+ "For Repository access: user submits Payment → quote_guard verifies → impack_list updated → data query passes",
198
+ "Type 3 (SubmittedObject) data source class embodies this philosophy — b_submission=true entries",
199
+ "This pattern is foundational for all guard designs — always prefer verifier-evidence over complex object discovery",
97
200
  ],
98
201
  },
99
202
  {
@@ -215,9 +215,9 @@ export const GUARD_SCENES = [
215
215
  fail_result: "Passport generation fails; the user did not pass validation",
216
216
  submission_source: "Passport applicant (signer + credentials)",
217
217
  special_constraints: [
218
- "impack_list is always empty during the verify phase (only filled after result_for_permission)",
219
- "Therefore quote_guard (query 1167) always fails in the gen_passport flow (IMPACK_GUARD_NOT_FOUND)",
220
- "Only Repository queries with quote_guard==None can pass in gen_passport",
218
+ "quote_guard is a RIGID verification requirement when querying Repository data (query 1167)",
219
+ "Two-phase: passport generation scans guard + prepares quote_guard, passport verification re-checks + verifies",
220
+ "If quote_guard==None: Repository data is freely queryable (no access control)",
221
221
  "Guard can be created standalone (not bound to a specific Host Object)",
222
222
  "Guard can be depended on by other Guards via rely (requires rep=true)",
223
223
  "The Passport generated by gen_passport can be used as submission data for subsequent operations",
@@ -132,12 +132,12 @@ function checkSemanticErrors(json) {
132
132
  if (hasQuoteGuard) {
133
133
  diagnostics.push({
134
134
  code: "LE-06",
135
- message: "gen_passport scene uses quote_guard (will always fail)",
136
- severity: "error",
135
+ message: "repository.data query with quote_guard: rigid verification requirement — ensure Passport includes quote_guard verification with necessary submissions (e.g., Payment proof)",
136
+ severity: "info",
137
137
  source: "lint",
138
138
  location: { path: "/root" },
139
139
  fix: {
140
- description: "Remove quote_guard authentication, or switch to a query method that does not depend on impack_list",
140
+ description: "Ensure the quote_guard is verified: user submits Payment via Passport, quote_guard verifies Payment fields, repository data query passes",
141
141
  auto_fixable: false,
142
142
  },
143
143
  });
@@ -1461,7 +1461,7 @@ const RISK_RULES = [
1461
1461
  {
1462
1462
  id: "R-X1-10",
1463
1463
  data_source_class: "cross_type",
1464
- trigger: "Guard uses repository.data query (query 1167) and the Repository has quote_guard set",
1464
+ trigger: "Guard uses repository.data query (query 1167) and the Repository has quote_guard set — rigid verification requirement",
1465
1465
  check: (ctx) => {
1466
1466
  const str = rootStr(ctx);
1467
1467
  if (!(str.includes("repository") && str.includes('"query"')))
@@ -1469,22 +1469,30 @@ const RISK_RULES = [
1469
1469
  return {
1470
1470
  id: "R-X1-10",
1471
1471
  data_source_class: "cross_type",
1472
- level: "medium",
1472
+ level: "low",
1473
1473
  category: "impack_risk",
1474
- title: "repository.data query's quote_guard is invalid in the verify phase (impack_list is empty)",
1475
- description: "Guard queries repository.data (query 1167). According to passport.move#L289 and passport.rs implementation, " +
1476
- "the impack_list is always empty in the verify phase (only filled after result_for_permission).\n" +
1477
- "Therefore in check_repository_quote_guard (inside query 1167), " +
1478
- "if the Repository policy's quote_guard is Some(addr), " +
1479
- "since addr is not in the empty list, it will always report IMPACK_GUARD_NOT_FOUND.\n" +
1480
- "Only when quote_guard==None can query 1167 pass.\n" +
1481
- "This means: querying Repository data with a quote_guard in the Guard will always fail.",
1474
+ title: "repository.data quote_guard is a RIGID verification requirement (data subscription access control)",
1475
+ description: "When a Guard queries repository.data (query 1167), if the Repository policy has quote_guard set (Some(addr)), " +
1476
+ "then the quote_guard MUST be verified. This is a RIGID requirement — not context-dependent.\n\n" +
1477
+ "TWO-PHASE VERIFICATION MECHANISM (VERIFIED: passport.rs#L756-769, passport.rs#L545-612):\n" +
1478
+ " Phase 1 — Passport generation (scan guard): The system scans the Guard to identify that it queries repository data. " +
1479
+ "If the Repository has a quote_guard, the system prepares the quote_guard for verification (adds it to the required " +
1480
+ "verification set, populating impack_list).\n" +
1481
+ " Phase 2 — Passport verification: The system re-checks (a) is the quote_guard prepared/in impack_list? " +
1482
+ "(b) rigidly verify the quote_guard (e.g., verify Payment proof for subscription).\n\n" +
1483
+ "SEMANTIC INTENT: Any Guard that uses a Repository's data MUST satisfy that Repository's quote_guard. " +
1484
+ "This is the intended access control mechanism for data subscription — e.g., accessing weather data " +
1485
+ "requires payment proof verified by the quote_guard.\n\n" +
1486
+ "DESIGN PHILOSOPHY: On-chain data is consumed by guard verifiers. The quote_guard gates Repository data access, " +
1487
+ "enabling subscription revenue models. The Guard only verifies logic + data accuracy (verifier-evidence design).",
1482
1488
  affected_stakeholders: ["customer", "provider"],
1483
- scenario: "quote_guard invalidation: impack_list is empty in the verify phase, causing the 1167 query to always fail",
1484
- mitigation: "1) Confirm the queried Repository's quote_guard is None;" +
1485
- "2) If quote authentication is needed, modify the verify loop in the Move layer to maintain impack_list;" +
1486
- "3) Document this limitation clearly: Repositories with quote_guard cannot be queried in the Guard;" +
1487
- "4) Consider using other data sources instead of Repository.data query",
1489
+ scenario: "quote_guard rigid verification: any guard querying repository data must satisfy the repository's quote_guard (e.g., payment requirement)",
1490
+ mitigation: "1) This is an INTENDED capability, not a limitation — quote_guard enables data subscription access control;\n" +
1491
+ "2) When designing a Guard that queries Repository data with quote_guard: ensure the Passport includes " +
1492
+ "the quote_guard verification with necessary submissions (e.g., Payment proof);\n" +
1493
+ "3) Pattern: Repository with quote_guard for data subscription — quote_guard verifies Payment (for_object, for_guard, index), " +
1494
+ "user submits Payment via Passport, quote_guard verified in both phases, repository data query passes;\n" +
1495
+ "4) If quote_guard==None: no access control — Repository data is freely queryable",
1488
1496
  };
1489
1497
  },
1490
1498
  },
@@ -426,7 +426,7 @@ export const GUARD_TEMPLATES = [
426
426
  applicable_industries: ["ecommerce", "education", "travel", "subscription"],
427
427
  relevant_risks: ["R-C1-03", "R-X1-01", "R-X1-10"],
428
428
  creation_notes: [
429
- "Repository queries require quote_guard==None (otherwise impack_list is empty, causing IMPACK_GUARD_NOT_FOUND)",
429
+ "Repository with quote_guard: rigid verification — any guard querying this Repository's data MUST satisfy the quote_guard (see R-X1-10, pattern.repository_quote_guard_subscription)",
430
430
  "repository.data query returns U64 (record count), compared with identifier[1] (value 0)",
431
431
  "Reward guard is iterable; duplicate-claim protection requires rebuilding the Guard to update the Repository address",
432
432
  ],
@@ -561,13 +561,185 @@ export const GUARD_TEMPLATES = [
561
561
  relevant_risks: ["R-C1-01", "R-X1-10", "R-X1-13"],
562
562
  creation_notes: [
563
563
  "gen_passport is a standalone Guard; it does not bind a Host Object (host_object: Standalone)",
564
- "impack_list is always empty during the verify phase; quote_guard queries will always fail",
564
+ "quote_guard is a rigid requirement: if the Guard queries Repository data with quote_guard set, the quote_guard must be verified (see R-X1-10)",
565
565
  "The Guard can be depended on by other Guards via rely (requires rep=true)",
566
566
  "The generated Passport can be used as submission data for subsequent operations",
567
567
  ],
568
568
  example_use_case: "After the user passes identity verification, a Passport is generated; this Passport is then submitted as an identity credential in subsequent service purchases.",
569
569
  verifier_constraint_level: "level1_strict",
570
570
  },
571
+ {
572
+ id: "tpl_repository_quote_guard_subscription",
573
+ scene_id: "repository_write",
574
+ name: "Repository data subscription with payment verification",
575
+ description: "Repository quote_guard requires payment proof for data access. When any Guard queries this Repository's data (query 1167), the quote_guard is rigidly verified. Enables data subscription revenue model (e.g., weather data, market oracle data).",
576
+ recommended_patterns: ["P03", "P07"],
577
+ parameters: [
578
+ { name: "repository_address", type: "address", description: "Repository object address", required: true },
579
+ { name: "subscription_price", type: "number", description: "Subscription payment amount required for data access", required: true },
580
+ { name: "payment_for_object", type: "address", description: "Payment for_object (Repository address)", required: true },
581
+ ],
582
+ example_table: [
583
+ { identifier: 0, b_submission: false, value_type: "Address", value: "${repository_address}", name: "Repository address" },
584
+ { identifier: 1, b_submission: false, value_type: "U256", value: "${subscription_price}", name: "Subscription price" },
585
+ { identifier: 2, b_submission: true, value_type: "Address", name: "Submitted Payment (for_object verification)" },
586
+ { identifier: 3, b_submission: true, value_type: "U256", name: "Submitted Payment amount" },
587
+ ],
588
+ example_root: {
589
+ type: "logic_and",
590
+ nodes: [
591
+ {
592
+ type: "logic_equal",
593
+ nodes: [
594
+ { type: "query", query: "payment.info.for", object: { identifier: 2 } },
595
+ { type: "identifier", identifier: 0 },
596
+ ],
597
+ },
598
+ {
599
+ type: "logic_as_u256_ge",
600
+ nodes: [
601
+ { type: "query", query: "payment.amount", object: { identifier: 2 } },
602
+ { type: "identifier", identifier: 1 },
603
+ ],
604
+ },
605
+ ],
606
+ },
607
+ applicable_industries: ["subscription", "travel", "rental", "education"],
608
+ relevant_risks: ["R-X1-10"],
609
+ creation_notes: [
610
+ "VERIFIER-EVIDENCE DESIGN: user submits valid Payment via Passport (b_submission=true), quote_guard verifies Payment fields",
611
+ "quote_guard must be is_depended: immutable=true, relies empty, rep=true (guard.move#L133-135)",
612
+ "Repository.owner_receive<T> accepts Payment as subscription revenue (repository.move#L714-717)",
613
+ "Rigid verification: any guard querying this Repository's data MUST satisfy the quote_guard",
614
+ "Two-phase: passport generation scans + prepares, passport verification re-checks + verifies",
615
+ "VERIFIED QUERY NAMES: payment.info.for (id 1107, Address), payment.amount (id 1100, U256)",
616
+ ],
617
+ example_use_case: "Weather data provider publishes daily temperature data to Repository. Insurance Machine queries weather data; user must pay subscription (Payment) to access data in their insurance claim flow.",
618
+ verifier_constraint_level: "level3_scene_combined",
619
+ },
620
+ {
621
+ id: "tpl_buy_guard_order_holder",
622
+ scene_id: "service_buy_guard",
623
+ name: "Supply chain sub-order purchase verification",
624
+ description: "Sub-service buy_guard verifies the user owns a main service order. Enables supply chain milestone unlock: each milestone = one sub-order, sub-service only purchasable by users who bought the main service.",
625
+ recommended_patterns: ["P03", "P04"],
626
+ parameters: [
627
+ { name: "main_service_address", type: "address", description: "Main Service object address", required: true },
628
+ { name: "main_order_address", type: "address", description: "Submitted main Order address (b_submission=true)", required: false,
629
+ constraint: "If using P16 circular reference, use service name instead of address" },
630
+ ],
631
+ example_table: [
632
+ { identifier: 0, b_submission: false, value_type: "Address", value: "${main_service_address}", name: "Main service address" },
633
+ { identifier: 1, b_submission: true, value_type: "Address", name: "Submitted main Order (ownership verification)" },
634
+ ],
635
+ example_root: {
636
+ type: "logic_and",
637
+ nodes: [
638
+ {
639
+ type: "logic_equal",
640
+ nodes: [
641
+ { type: "query", query: "order.owner", object: { identifier: 1 } },
642
+ { type: "context", context: "Signer" },
643
+ ],
644
+ },
645
+ {
646
+ type: "logic_equal",
647
+ nodes: [
648
+ { type: "query", query: "order.service", object: { identifier: 1 } },
649
+ { type: "identifier", identifier: 0 },
650
+ ],
651
+ },
652
+ ],
653
+ },
654
+ applicable_industries: ["travel", "rental", "education", "freelance"],
655
+ relevant_risks: ["R-C3-05"],
656
+ creation_notes: [
657
+ "VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence (b_submission=true), buy_guard verifies ownership + service match",
658
+ "No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
659
+ "Each milestone = one sub-order with its own Service + buy_guard",
660
+ "Main flow can branch to different sub-services based on Machine node progression",
661
+ "VERIFIED QUERY NAMES: order.owner (id 1202, Address), order.service (id 1203, Address)",
662
+ ],
663
+ example_use_case: "Travel package: main service = tour booking. Sub-services = hotel, guide, transfer — each with buy_guard verifying the user purchased the main tour order.",
664
+ verifier_constraint_level: "level2_identity_set",
665
+ },
666
+ {
667
+ id: "tpl_payment_exception_compensation",
668
+ scene_id: "machine_forward_guard",
669
+ name: "Exception branch compensation Payment",
670
+ description: "Machine forward guard for exception handling: verifies a compensation Payment bound to specific order + guard + unique progress step (history count) + node name. Enables user-friendly exception branches (e.g., delivery delay > 30min triggers auto-compensation).",
671
+ recommended_patterns: ["P03", "P07", "P09"],
672
+ parameters: [
673
+ { name: "order_address", type: "address", description: "Order object address (Payment for_object target)", required: true },
674
+ { name: "this_guard_address", type: "address", description: "This guard's own address (Payment for_guard target)", required: true },
675
+ { name: "compensation_amount", type: "number", description: "Minimum compensation amount", required: true },
676
+ { name: "expected_node_name", type: "string", description: "Expected node name (stored in PaymentInfo.remark, compared with progress.current)", required: true },
677
+ ],
678
+ example_table: [
679
+ { identifier: 0, b_submission: false, value_type: "Address", value: "${order_address}", name: "Order address" },
680
+ { identifier: 1, b_submission: false, value_type: "Address", value: "${this_guard_address}", name: "This guard address" },
681
+ { identifier: 2, b_submission: false, value_type: "U256", value: "${compensation_amount}", name: "Compensation amount" },
682
+ { identifier: 3, b_submission: false, value_type: "String", value: "${expected_node_name}", name: "Expected node name (for remark comparison)" },
683
+ { identifier: 4, b_submission: true, value_type: "Address", name: "Submitted Payment (compensation proof)" },
684
+ ],
685
+ example_root: {
686
+ type: "logic_and",
687
+ nodes: [
688
+ {
689
+ type: "logic_equal",
690
+ nodes: [
691
+ { type: "query", query: "payment.info.for", object: { identifier: 4 } },
692
+ { type: "identifier", identifier: 0 },
693
+ ],
694
+ },
695
+ {
696
+ type: "logic_equal",
697
+ nodes: [
698
+ { type: "query", query: "payment.info.guard", object: { identifier: 4 } },
699
+ { type: "identifier", identifier: 1 },
700
+ ],
701
+ },
702
+ {
703
+ type: "logic_as_u256_ge",
704
+ nodes: [
705
+ { type: "query", query: "payment.amount", object: { identifier: 4 } },
706
+ { type: "identifier", identifier: 2 },
707
+ ],
708
+ },
709
+ {
710
+ type: "logic_as_u256_equal",
711
+ nodes: [
712
+ { type: "query", query: "payment.info.index", object: { identifier: 4 } },
713
+ { type: "query", query: "progress.history count" },
714
+ ],
715
+ },
716
+ {
717
+ type: "logic_string_nocase_equal",
718
+ nodes: [
719
+ { type: "query", query: "payment.info.remark", object: { identifier: 4 } },
720
+ { type: "query", query: "progress.current" },
721
+ ],
722
+ },
723
+ ],
724
+ },
725
+ applicable_industries: ["rental", "travel", "ecommerce", "freelance"],
726
+ relevant_risks: [],
727
+ creation_notes: [
728
+ "VERIFIED: payment.move#L66-71 (PaymentInfo: for_object, for_guard, remark, index), payment.move#L82-86 (payment_info_with_guard)",
729
+ "VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
730
+ "VERIFIED QUERY NAMES: payment.info.for (id 1107, Address), payment.info.guard (id 1109, Address), payment.info.index (id 1111, U64), payment.info.remark (id 1110, String), payment.amount (id 1100, U64; logic_as_u256_ge casts U64→U256 for comparison)",
731
+ "VERIFIED INDEX: progress.history count (id 1273, U64) = unique monotonically increasing step index (progress.move L440-441, L475, L482). Even in cycles, each entry has a different count.",
732
+ "VERIFIED NODE NAME: progress.current (id 1253, String) = current node name. A node can be entered multiple times in cycles, but the history count is unique each time.",
733
+ "DESIGN: payment.info.index stores the step index set by Treasury at creation time; progress.history count provides the current unique step. Comparing them ensures the Payment was created for THIS specific progress step.",
734
+ "DESIGN: payment.info.remark stores the node name; progress.current provides the current node name. Comparing them provides semantic verification of which node triggered the compensation.",
735
+ "ANTI-REUSE: 4-dimensional binding: for_object (Order) + for_guard (Guard) + index (unique step) + remark (node name). Same Payment cannot be reused in other contexts.",
736
+ "Payment is freeze_object (immutable) — cannot be modified after creation",
737
+ "VERIFIER-EVIDENCE DESIGN: customer submits Payment, guard verifies binding fields match current context",
738
+ "Treasury withdraws compensation with PaymentInfo(for_object=order, for_guard=this, index=history_count_at_creation, remark=node_name)",
739
+ ],
740
+ example_use_case: "Food delivery: if delivery delayed > 30min at node 'delayed' (history count=5), restaurant Treasury auto-compensates $5 to customer with PaymentInfo(for_object=order, for_guard=this, index=5, remark='delayed'). Customer submits Payment via Passport, guard verifies index matches current history count AND remark matches current node name.",
741
+ verifier_constraint_level: "level3_scene_combined",
742
+ },
571
743
  ];
572
744
  export function getTemplatesByScene(sceneId) {
573
745
  return GUARD_TEMPLATES.filter((t) => t.scene_id === sceneId);
@@ -448,9 +448,9 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
448
448
  tree_structure: "logic_and(query(1167: repository.data, object: { identifier: 0 }, parameters: [...]), [data validation condition])",
449
449
  },
450
450
  constraints: [
451
- "The quote_guard authentication of query 1167 always has empty impack_list during the verify phase",
452
- "Repository queries with quote_guard fail with IMPACK_GUARD_NOT_FOUND in the gen_passport flow",
453
- "Only passes when quote_guard==None",
451
+ "quote_guard is a RIGID verification requirement: any guard querying Repository data with quote_guard must satisfy it",
452
+ "Two-phase: passport generation scans/prepares quote_guard, passport verification re-checks + verifies (see R-X1-10)",
453
+ "If quote_guard==None: no access control — Repository data is freely queryable",
454
454
  "rep semantics: repository.data query does not depend on runtime submission, so rep=true",
455
455
  ],
456
456
  example: {
@@ -208,6 +208,9 @@ export { BRIDGE_RISK_RULES, BRIDGE_RISK_VERSION, checkBridgeRisks, getBridgeRisk
208
208
  export { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence, type ToolReferenceEntry, };
209
209
  export { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, type IndustryModeName, type ScenarioTraits, type ModeAllocatorStrategy, type ModeGuardRef, type ModeMachineNode, type ScenarioMode, type ModeComposition, };
210
210
  export { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, type GuardDataSourceClass, type VerifierConstraintLevel, type GuardHostObject, type GuardDesignPattern, type VerifierLevelGuidance, };
211
+ import { type OverrideConfig } from "./overrides-loader.js";
212
+ export declare function getKnowledgeOverrides(): OverrideConfig;
213
+ export declare function refreshKnowledgeOverrides(): OverrideConfig;
211
214
  export declare function getKnowledgeBase(): {
212
215
  version: {
213
216
  glossary: number;