@wowok/agent-mcp 2.5.2 → 2.5.3
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/index.js +46 -6
- package/dist/knowledge/guard-design-patterns.js +104 -1
- package/dist/knowledge/guard-ledger.js +3 -3
- package/dist/knowledge/guard-lint.js +3 -3
- package/dist/knowledge/guard-risk.js +23 -15
- package/dist/knowledge/guard-templates.js +174 -2
- package/dist/knowledge/guard-translation.js +3 -3
- package/dist/knowledge/index.d.ts +3 -0
- package/dist/knowledge/index.js +9 -0
- package/dist/knowledge/machine-context.d.ts +1 -1
- package/dist/knowledge/machine-context.js +21 -0
- package/dist/knowledge/machine-ledger.d.ts +1 -0
- package/dist/knowledge/machine-ledger.js +31 -11
- package/dist/knowledge/machine-templates.js +32 -78
- package/dist/knowledge/overrides-loader.d.ts +13 -0
- package/dist/knowledge/overrides-loader.js +67 -0
- package/dist/knowledge/payment-risk.d.ts +4 -0
- package/dist/knowledge/payment-risk.js +67 -0
- package/dist/knowledge/repository-confirm.d.ts +4 -0
- package/dist/knowledge/repository-confirm.js +44 -0
- package/dist/knowledge/repository-risk.d.ts +8 -2
- package/dist/knowledge/repository-risk.js +61 -0
- package/dist/knowledge/repository-translation.js +23 -0
- package/dist/knowledge/scenario-modes.js +22 -5
- package/dist/knowledge/service-templates.js +38 -0
- package/dist/knowledge/treasury-templates.js +42 -0
- package/dist/loop-engineering/context-collect.d.ts +7 -0
- package/dist/loop-engineering/context-collect.js +83 -0
- package/dist/loop-engineering/improve.d.ts +29 -0
- package/dist/loop-engineering/improve.js +178 -0
- package/dist/project/context-assembly.d.ts +16 -0
- package/dist/project/context-assembly.js +130 -0
- package/dist/project/deployment-doc.d.ts +115 -0
- package/dist/project/deployment-doc.js +595 -0
- package/dist/project/index.js +37 -1
- package/dist/project/migration.d.ts +22 -0
- package/dist/project/migration.js +125 -0
- package/dist/project/project-store.d.ts +110 -0
- package/dist/project/project-store.js +425 -0
- package/dist/project/rollback-policy.d.ts +45 -0
- package/dist/project/rollback-policy.js +290 -0
- package/dist/project/stage-gate.d.ts +49 -0
- package/dist/project/stage-gate.js +310 -0
- package/dist/schema/call/allocation.d.ts +5 -0
- package/dist/schema/call/arbitration.d.ts +5 -0
- package/dist/schema/call/base.d.ts +3 -0
- package/dist/schema/call/base.js +1 -0
- package/dist/schema/call/bridge.d.ts +24 -0
- package/dist/schema/call/contact.d.ts +5 -0
- package/dist/schema/call/demand.d.ts +5 -0
- package/dist/schema/call/guard.d.ts +15 -0
- package/dist/schema/call/machine.d.ts +10 -0
- package/dist/schema/call/order.d.ts +5 -0
- package/dist/schema/call/payment.d.ts +5 -0
- package/dist/schema/call/permission.d.ts +5 -0
- package/dist/schema/call/personal.d.ts +5 -0
- package/dist/schema/call/progress.d.ts +5 -0
- package/dist/schema/call/proof.d.ts +10 -0
- package/dist/schema/call/repository.d.ts +5 -0
- package/dist/schema/call/reward.d.ts +5 -0
- package/dist/schema/call/service.d.ts +5 -0
- package/dist/schema/call/treasury.d.ts +5 -0
- package/dist/schema/operations.d.ts +210 -0
- package/dist/schema/operations.js +24 -0
- package/dist/schema/project/index.d.ts +2619 -106
- package/dist/schema/project/index.js +622 -2
- package/dist/schema/query/index.d.ts +601 -0
- package/dist/schema/query/index.js +61 -0
- package/dist/schemas/bridge_operation.schema.json +4 -0
- package/dist/schemas/guard2file.schema.json +4 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +4 -0
- package/dist/schemas/onchain_operations.schema.json +20 -0
- package/dist/schemas/onchain_operations_allocation.schema.json +4 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +4 -0
- package/dist/schemas/onchain_operations_contact.schema.json +4 -0
- package/dist/schemas/onchain_operations_demand.schema.json +4 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_guard.schema.json +4 -0
- package/dist/schemas/onchain_operations_machine.schema.json +4 -0
- package/dist/schemas/onchain_operations_order.schema.json +4 -0
- package/dist/schemas/onchain_operations_payment.schema.json +4 -0
- package/dist/schemas/onchain_operations_permission.schema.json +4 -0
- package/dist/schemas/onchain_operations_personal.schema.json +4 -0
- package/dist/schemas/onchain_operations_progress.schema.json +4 -0
- package/dist/schemas/onchain_operations_proof.schema.json +4 -0
- package/dist/schemas/onchain_operations_repository.schema.json +4 -0
- package/dist/schemas/onchain_operations_reward.schema.json +4 -0
- package/dist/schemas/onchain_operations_service.schema.json +4 -0
- package/dist/schemas/onchain_operations_treasury.schema.json +4 -0
- package/dist/schemas/project_operation.output.json +1798 -0
- package/dist/schemas/project_operation.schema.json +132 -2
- package/dist/schemas/query_toolkit.output.json +407 -1
- package/dist/schemas/query_toolkit.schema.json +132 -0
- package/dist/tools/handlers/project.js +742 -1
- package/dist/tools/handlers/query.js +38 -2
- package/package.json +2 -2
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
|
-
##
|
|
95
|
+
## Sub-tool Selection Guide
|
|
68
96
|
|
|
69
|
-
|
|
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
|
-
##
|
|
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
|
|
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
|
-
"
|
|
219
|
-
"
|
|
220
|
-
"
|
|
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: "
|
|
136
|
-
severity: "
|
|
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: "
|
|
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: "
|
|
1472
|
+
level: "low",
|
|
1473
1473
|
category: "impack_risk",
|
|
1474
|
-
title: "repository.data
|
|
1475
|
-
description: "Guard queries repository.data (query 1167)
|
|
1476
|
-
"the
|
|
1477
|
-
"
|
|
1478
|
-
"
|
|
1479
|
-
"
|
|
1480
|
-
"
|
|
1481
|
-
"
|
|
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
|
|
1484
|
-
mitigation: "1)
|
|
1485
|
-
"2)
|
|
1486
|
-
"
|
|
1487
|
-
"
|
|
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
|
|
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
|
-
"
|
|
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
|
-
"
|
|
452
|
-
"
|
|
453
|
-
"
|
|
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;
|
package/dist/knowledge/index.js
CHANGED
|
@@ -208,6 +208,15 @@ export { BRIDGE_RISK_RULES, BRIDGE_RISK_VERSION, checkBridgeRisks, getBridgeRisk
|
|
|
208
208
|
export { TOOLS_REFERENCE, getToolReference, searchToolReference, getToolSequence, };
|
|
209
209
|
export { SCENARIO_MODES, SCENARIO_MODES_VERSION, MODE_COMPOSITIONS, matchScenarioMode, inferScenarioTraits, getScenarioMode, listScenarioModes, getShippedModes, getModeCompositions, };
|
|
210
210
|
export { GUARD_DESIGN_PATTERNS, GUARD_DESIGN_PATTERNS_VERSION, VERIFIER_LEVEL_GUIDANCE, getGuardDesignPattern, searchGuardDesignPatterns, getPatternsByHost, getPatternsByIndustry, getPatternsByDataSourceClass, getVerifierLevelGuidance, suggestPatternForRequirement, };
|
|
211
|
+
import { loadOverrides as loadOverridesFromDisk } from "./overrides-loader.js";
|
|
212
|
+
let KNOWLEDGE_OVERRIDES = loadOverridesFromDisk();
|
|
213
|
+
export function getKnowledgeOverrides() {
|
|
214
|
+
return KNOWLEDGE_OVERRIDES;
|
|
215
|
+
}
|
|
216
|
+
export function refreshKnowledgeOverrides() {
|
|
217
|
+
KNOWLEDGE_OVERRIDES = loadOverridesFromDisk(true);
|
|
218
|
+
return KNOWLEDGE_OVERRIDES;
|
|
219
|
+
}
|
|
211
220
|
export function getKnowledgeBase() {
|
|
212
221
|
return {
|
|
213
222
|
version: {
|
|
@@ -8,7 +8,7 @@ import { type ChecklistResult } from "./machine-confirm.js";
|
|
|
8
8
|
import { type GuardScene } from "./guard-ledger.js";
|
|
9
9
|
export declare const MACHINE_CONTEXT_VERSION = "1.0.0";
|
|
10
10
|
export interface VerificationNote {
|
|
11
|
-
topic: "bReplace" | "um" | "consensus_repositories" | "namedOperator_assignment" | "cross_machine_dependency";
|
|
11
|
+
topic: "bReplace" | "um" | "consensus_repositories" | "namedOperator_assignment" | "cross_machine_dependency" | "first_node_semantics_service_bound";
|
|
12
12
|
judgment: "YES" | "PARTIAL" | "NO";
|
|
13
13
|
verified_semantic: string;
|
|
14
14
|
code_reference: string;
|
|
@@ -52,6 +52,23 @@ export const MACHINE_VERIFICATION_NOTES = [
|
|
|
52
52
|
code_reference: "progress.move (progress::new, assert_published) + guard.move (convert_witness)",
|
|
53
53
|
affected_modes: ["cross_machine", "pre_publish_check"],
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
topic: "first_node_semantics_service_bound",
|
|
57
|
+
judgment: "YES",
|
|
58
|
+
verified_semantic: "For Service-bound Machines, the entry node (prev_node='' target) represents a " +
|
|
59
|
+
"POST-PAYMENT state, because Service.buy() performs quote + buy (payment) + " +
|
|
60
|
+
"order_allocation + order_progress ATOMICALLY in a single transaction. The Machine " +
|
|
61
|
+
"must NOT include separate 'Order', 'Pay', 'Reserve', or 'Subscribe' nodes — those " +
|
|
62
|
+
"actions are handled by the Service layer before the Progress (Machine instance) " +
|
|
63
|
+
"is created. All nodes after entry represent ORDER PROCESSING stages (fulfillment, " +
|
|
64
|
+
"delivery, confirmation, review, refund), NOT payment actions. Correct entry node " +
|
|
65
|
+
"examples: 'Paid', 'DepositPaid', 'Active'. Incorrect: 'OrderCreated', 'Reserved', " +
|
|
66
|
+
"'Subscribed'. See machine-ledger.ts first_node_semantics field per scene and " +
|
|
67
|
+
"machine-templates.ts example_nodes/example_pairs for the canonical structure.",
|
|
68
|
+
code_reference: "ts-sdk\\packages\\wowok\\src\\w\\call\\service.ts (buy: quote -> buy -> order_allocation -> order_progress) " +
|
|
69
|
+
"+ machine-ledger.ts (first_node_semantics field) + machine-templates.ts (example_nodes)",
|
|
70
|
+
affected_modes: ["initial_design", "mid_design_review", "pre_publish_check"],
|
|
71
|
+
},
|
|
55
72
|
];
|
|
56
73
|
export function getMachineKnowledgeSnapshot() {
|
|
57
74
|
const verifiedYes = MACHINE_VERIFICATION_NOTES.filter((n) => n.judgment === "YES").length;
|
|
@@ -632,7 +649,11 @@ function buildPromptHints(ctx) {
|
|
|
632
649
|
hints.push("Start by confirming the matched scene and selecting a template.");
|
|
633
650
|
if (ctx.matched_scene) {
|
|
634
651
|
hints.push(`Scene "${ctx.matched_scene.name}" recommends patterns: ${ctx.matched_scene.recommended_patterns.join(", ")}.`);
|
|
652
|
+
if (ctx.matched_scene.first_node_semantics) {
|
|
653
|
+
hints.push(`First-node semantics: ${ctx.matched_scene.first_node_semantics}`);
|
|
654
|
+
}
|
|
635
655
|
}
|
|
656
|
+
hints.push("⚠ First node convention: For Service-bound Machines, the entry node (prev_node='' target) MUST represent a POST-PAYMENT state (e.g. 'Paid', 'DepositPaid'). Do NOT add 'Order'/'Pay'/'Reserve'/'Subscribe' nodes — Service.buy() handles payment atomically before Progress is created.");
|
|
636
657
|
if (ctx.suggested_templates.length > 0) {
|
|
637
658
|
hints.push(`Top template suggestion: ${ctx.suggested_templates[0].id} (${ctx.suggested_templates[0].name}).`);
|
|
638
659
|
}
|