@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
|
@@ -196,6 +196,48 @@ function checkIdFromString(input) {
|
|
|
196
196
|
fix_hint: "Use 0/1/2, or 'None'/'Clock'/'Signer' (case-insensitive).",
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
+
function checkQuoteGuardIsDepended(input) {
|
|
200
|
+
if (!input.has_quote_guard) {
|
|
201
|
+
return { id: "C-REP-11", severity: "info", title: "quote_guard is_depended check", description: "Skipped: no quote_guard set.", passed: true };
|
|
202
|
+
}
|
|
203
|
+
const passed = input.quote_guard_is_depended === true;
|
|
204
|
+
return {
|
|
205
|
+
id: "C-REP-11",
|
|
206
|
+
severity: passed ? "info" : "block",
|
|
207
|
+
title: "quote_guard satisfies is_depended (immutable + rep=true + no relies)",
|
|
208
|
+
description: "When quote_guard is set, it MUST satisfy guard::is_depended (guard.move#L133-135): " +
|
|
209
|
+
"immutable=true, relies empty, rep=true. Move aborts with E_NEED_DEPENDENT_GUARD (repository.move#L422). " +
|
|
210
|
+
"VERIFIED: passport.rs#L545-612 — check_repository_quote_guard enforces this at query time. " +
|
|
211
|
+
"quote_guard is a RIGID verification requirement: any guard querying this Repository's data must satisfy it.",
|
|
212
|
+
passed,
|
|
213
|
+
evidence: passed ? "quote_guard is is_depended" : "quote_guard NOT is_depended (will abort)",
|
|
214
|
+
fix_hint: "Ensure the quote_guard Guard object has: immutable=true, relies=empty, rep=true.",
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function checkQuoteGuardSubscriptionDesign(input) {
|
|
218
|
+
if (!input.has_quote_guard) {
|
|
219
|
+
return { id: "C-REP-12", severity: "info", title: "quote_guard subscription design check", description: "Skipped: no quote_guard set.", passed: true };
|
|
220
|
+
}
|
|
221
|
+
const issues = [];
|
|
222
|
+
if (!input.quote_guard_verifies_payment)
|
|
223
|
+
issues.push("quote_guard does not verify Payment for subscription");
|
|
224
|
+
if (!input.has_owner_receive)
|
|
225
|
+
issues.push("Repository missing owner_receive for Payment revenue");
|
|
226
|
+
const passed = issues.length === 0;
|
|
227
|
+
return {
|
|
228
|
+
id: "C-REP-12",
|
|
229
|
+
severity: passed ? "info" : "warn",
|
|
230
|
+
title: "quote_guard data subscription design — Payment verification + owner_receive revenue",
|
|
231
|
+
description: "For data subscription pattern (Repository+quote_guard+Payment): " +
|
|
232
|
+
"(1) quote_guard should verify Payment (for_object matches Repository, amount meets subscription price); " +
|
|
233
|
+
"(2) Repository should have owner_receive<T> configured to accept Payment as subscription revenue " +
|
|
234
|
+
"(repository.move#L714-717). VERIFIED: passport.rs#L545-612. " +
|
|
235
|
+
"DESIGN: user submits Payment via Passport → quote_guard verifies → repository data query passes.",
|
|
236
|
+
passed,
|
|
237
|
+
evidence: passed ? "quote_guard subscription design complete" : issues.join("; "),
|
|
238
|
+
fix_hint: "Use tpl_repository_quote_guard_subscription (guard-templates.ts) as the design template.",
|
|
239
|
+
};
|
|
240
|
+
}
|
|
199
241
|
export function preCheckRepositoryOp(input) {
|
|
200
242
|
return [
|
|
201
243
|
checkPolicyCount(input),
|
|
@@ -208,6 +250,8 @@ export function preCheckRepositoryOp(input) {
|
|
|
208
250
|
checkRewardCount(input),
|
|
209
251
|
checkDataRemoveWithPassportSubmission(input),
|
|
210
252
|
checkIdFromString(input),
|
|
253
|
+
checkQuoteGuardIsDepended(input),
|
|
254
|
+
checkQuoteGuardSubscriptionDesign(input),
|
|
211
255
|
];
|
|
212
256
|
}
|
|
213
257
|
export function canProceedRepositoryOp(input) {
|
|
@@ -31,10 +31,16 @@ export interface RepositoryRiskCheckContext {
|
|
|
31
31
|
constants_synced?: boolean;
|
|
32
32
|
}
|
|
33
33
|
declare function normalizeIdFrom(v: number | string): number;
|
|
34
|
+
export interface RepositoryQuoteGuardContext {
|
|
35
|
+
has_quote_guard?: boolean;
|
|
36
|
+
quote_guard_is_depended?: boolean;
|
|
37
|
+
quote_guard_verifies_payment?: boolean;
|
|
38
|
+
has_owner_receive?: boolean;
|
|
39
|
+
}
|
|
34
40
|
export declare const REPOSITORY_RISK_RULES: {
|
|
35
41
|
rule: RepositoryRisk;
|
|
36
|
-
check: (ctx: RepositoryRiskCheckContext) => RepositoryRisk | null;
|
|
42
|
+
check: (ctx: RepositoryRiskCheckContext & RepositoryQuoteGuardContext) => RepositoryRisk | null;
|
|
37
43
|
}[];
|
|
38
|
-
export declare function checkRepositoryRisks(ctx: RepositoryRiskCheckContext): RepositoryRisk[];
|
|
44
|
+
export declare function checkRepositoryRisks(ctx: RepositoryRiskCheckContext & RepositoryQuoteGuardContext): RepositoryRisk[];
|
|
39
45
|
export declare function getRepositoryRiskById(id: string): RepositoryRisk | undefined;
|
|
40
46
|
export { normalizeIdFrom as parseIdFromForRiskCheck };
|
|
@@ -285,6 +285,65 @@ const R_REP_5_01 = {
|
|
|
285
285
|
return { ...R_REP_5_01.rule, evidence: "constants_synced=false" };
|
|
286
286
|
},
|
|
287
287
|
};
|
|
288
|
+
const R_REP_6_01 = {
|
|
289
|
+
rule: {
|
|
290
|
+
id: "R-REP-11",
|
|
291
|
+
level: "HIGH",
|
|
292
|
+
category: "policy",
|
|
293
|
+
title: "quote_guard must be is_depended (immutable + rep=true + no relies) — Move assert",
|
|
294
|
+
description: "Repository policy's quote_guard must satisfy guard::is_depended (guard.move#L133-135): " +
|
|
295
|
+
"immutable=true, relies empty, rep=true. This ensures the quote_guard is a stable, " +
|
|
296
|
+
"repository-querying guard that can be depended upon. Move aborts with " +
|
|
297
|
+
"E_NEED_DEPENDENT_GUARD (repository.move#L422) if the guard is not is_depended. " +
|
|
298
|
+
"VERIFIED: passport.rs#L545-612 (check_repository_quote_guard enforces this at query time).",
|
|
299
|
+
affected_stakeholders: ["creator", "reader"],
|
|
300
|
+
scenario: "Creator sets quote_guard to a Guard that is not is_depended (e.g., has relies or is mutable)",
|
|
301
|
+
mitigation: "Ensure the quote_guard Guard object has: immutable=true, relies=empty, rep=true. " +
|
|
302
|
+
"Use pattern.repository_quote_guard_subscription as the design template.",
|
|
303
|
+
related_move_error: "E_NEED_DEPENDENT_GUARD",
|
|
304
|
+
auto_fixable: false,
|
|
305
|
+
},
|
|
306
|
+
check: (ctx) => {
|
|
307
|
+
if (!ctx.has_quote_guard)
|
|
308
|
+
return null;
|
|
309
|
+
if (ctx.quote_guard_is_depended)
|
|
310
|
+
return null;
|
|
311
|
+
return { ...R_REP_6_01.rule, evidence: "quote_guard set but not is_depended (immutable + rep=true + no relies)" };
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
const R_REP_6_02 = {
|
|
315
|
+
rule: {
|
|
316
|
+
id: "R-REP-12",
|
|
317
|
+
level: "MEDIUM",
|
|
318
|
+
category: "knowledge",
|
|
319
|
+
title: "quote_guard data subscription design — verify Payment verification + owner_receive revenue",
|
|
320
|
+
description: "When using quote_guard for data subscription (Repository+quote_guard+Payment pattern), " +
|
|
321
|
+
"ensure: (1) quote_guard verifies Payment fields (for_object matches Repository, amount meets price), " +
|
|
322
|
+
"(2) Repository has owner_receive<T> configured to accept Payment as subscription revenue " +
|
|
323
|
+
"(repository.move#L714-717). VERIFIED: passport.rs#L545-612, repository.move#L714-717. " +
|
|
324
|
+
"DESIGN: quote_guard is a RIGID verification requirement — any guard querying this Repository's " +
|
|
325
|
+
"data MUST satisfy the quote_guard (see R-X1-10 in guard-risk.ts).",
|
|
326
|
+
affected_stakeholders: ["creator", "reader", "verifier"],
|
|
327
|
+
scenario: "Creator sets quote_guard but does not configure Payment verification or owner_receive",
|
|
328
|
+
mitigation: "1) Ensure quote_guard verifies Payment (for_object, amount); " +
|
|
329
|
+
"2) Configure Repository owner_receive<T> to accept subscription Payment revenue; " +
|
|
330
|
+
"3) Use pattern.repository_quote_guard_subscription (guard-design-patterns.ts) and " +
|
|
331
|
+
"tpl_repository_quote_guard_subscription (guard-templates.ts) as design templates.",
|
|
332
|
+
auto_fixable: false,
|
|
333
|
+
},
|
|
334
|
+
check: (ctx) => {
|
|
335
|
+
if (!ctx.has_quote_guard)
|
|
336
|
+
return null;
|
|
337
|
+
if (ctx.quote_guard_verifies_payment && ctx.has_owner_receive)
|
|
338
|
+
return null;
|
|
339
|
+
const missing = [];
|
|
340
|
+
if (!ctx.quote_guard_verifies_payment)
|
|
341
|
+
missing.push("quote_guard does not verify Payment");
|
|
342
|
+
if (!ctx.has_owner_receive)
|
|
343
|
+
missing.push("Repository missing owner_receive for revenue");
|
|
344
|
+
return { ...R_REP_6_02.rule, evidence: missing.join("; ") };
|
|
345
|
+
},
|
|
346
|
+
};
|
|
288
347
|
export const REPOSITORY_RISK_RULES = [
|
|
289
348
|
R_REP_1_01,
|
|
290
349
|
R_REP_2_01,
|
|
@@ -296,6 +355,8 @@ export const REPOSITORY_RISK_RULES = [
|
|
|
296
355
|
R_REP_1_04,
|
|
297
356
|
R_REP_1_05,
|
|
298
357
|
R_REP_5_01,
|
|
358
|
+
R_REP_6_01,
|
|
359
|
+
R_REP_6_02,
|
|
299
360
|
];
|
|
300
361
|
export function checkRepositoryRisks(ctx) {
|
|
301
362
|
const risks = [];
|
|
@@ -329,6 +329,29 @@ export const REPOSITORY_CONSTRAINT_RULES = [
|
|
|
329
329
|
failure_message: "Mode 5 routing missed if only id_from_submission is checked (P1-1 fix)",
|
|
330
330
|
related_field: "policies[].write_guard",
|
|
331
331
|
},
|
|
332
|
+
{
|
|
333
|
+
id: "REP_C_09",
|
|
334
|
+
name: "quote_guard must be is_depended (immutable + rep=true + no relies)",
|
|
335
|
+
description: "When quote_guard is set on a policy, it MUST satisfy guard::is_depended (guard.move#L133-135): " +
|
|
336
|
+
"immutable=true, relies empty, rep=true. Move aborts with E_NEED_DEPENDENT_GUARD (repository.move#L422). " +
|
|
337
|
+
"VERIFIED: passport.rs#L545-612 — check_repository_quote_guard enforces this when any guard queries " +
|
|
338
|
+
"this Repository's data (query 1167). quote_guard is a RIGID verification requirement.",
|
|
339
|
+
validation_logic: "quote_guard != null => guard.is_depended (immutable && relies.empty && rep)",
|
|
340
|
+
failure_message: "quote_guard must be is_depended — E_NEED_DEPENDENT_GUARD (repository.move#L422)",
|
|
341
|
+
related_field: "policies[].quote_guard",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
id: "REP_C_10",
|
|
345
|
+
name: "quote_guard data subscription design (Payment verification + owner_receive)",
|
|
346
|
+
description: "For data subscription pattern: (1) quote_guard should verify Payment (for_object matches Repository, " +
|
|
347
|
+
"amount meets subscription price); (2) Repository should have owner_receive<T> configured to accept " +
|
|
348
|
+
"Payment as subscription revenue (repository.move#L714-717). " +
|
|
349
|
+
"DESIGN: user submits Payment via Passport → quote_guard verifies → impack_list updated → repository " +
|
|
350
|
+
"data query passes. 'On-chain data is consumed by guard verifiers.'",
|
|
351
|
+
validation_logic: "quote_guard != null => quote_guard_verifies_payment && repository_has_owner_receive",
|
|
352
|
+
failure_message: "quote_guard subscription incomplete: missing Payment verification or owner_receive revenue",
|
|
353
|
+
related_field: "policies[].quote_guard",
|
|
354
|
+
},
|
|
332
355
|
];
|
|
333
356
|
function normalizeIdFrom(v) {
|
|
334
357
|
if (typeof v === "number")
|
|
@@ -13,7 +13,7 @@ export const SCENARIO_MODES = [
|
|
|
13
13
|
multi_tier_allocation: false,
|
|
14
14
|
},
|
|
15
15
|
machine_shape: [
|
|
16
|
-
{ name: "
|
|
16
|
+
{ name: "paid", role: "Entry: order created and paid via Service.buy(); Machine starts here" },
|
|
17
17
|
{ name: "delivering", role: "Provider submits deliverable (WIP hash)" },
|
|
18
18
|
{ name: "delivered", role: "Deliverable available for review" },
|
|
19
19
|
{ name: "accepted", role: "Customer signs acceptance" },
|
|
@@ -27,6 +27,7 @@ export const SCENARIO_MODES = [
|
|
|
27
27
|
{ template_id: "accept_guard_signer", host: "machine", purpose: "Only customer can sign acceptance" },
|
|
28
28
|
{ template_id: "withdraw_guard_permission", host: "machine", purpose: "Only provider can withdraw after acceptance" },
|
|
29
29
|
{ template_id: "refund_guard_signer", host: "machine", purpose: "Only customer can initiate refund" },
|
|
30
|
+
{ template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Delivery delay exception compensation via scene-bound Payment (§2.13)" },
|
|
30
31
|
],
|
|
31
32
|
allocator: {
|
|
32
33
|
recipient: "signer",
|
|
@@ -39,6 +40,7 @@ export const SCENARIO_MODES = [
|
|
|
39
40
|
"Use Service `setting_locked_time` to lock rules for the engagement duration",
|
|
40
41
|
"WIP hash on deliverable is mandatory — protects provider in disputes",
|
|
41
42
|
"Acceptance gate is the trust pivot — both parties must agree on criteria",
|
|
43
|
+
"NEW: Payment exception compensation for delivery delays — provider Treasury auto-compensates customer (§2.13)",
|
|
42
44
|
],
|
|
43
45
|
},
|
|
44
46
|
{
|
|
@@ -55,7 +57,7 @@ export const SCENARIO_MODES = [
|
|
|
55
57
|
multi_tier_allocation: false,
|
|
56
58
|
},
|
|
57
59
|
machine_shape: [
|
|
58
|
-
{ name: "
|
|
60
|
+
{ name: "deposit_paid", role: "Entry: deposit + rent paid via Service.buy(); Machine starts here" },
|
|
59
61
|
{ name: "handover_out", role: "Owner hands over item, records pre-rental WIP" },
|
|
60
62
|
{ name: "in_use", role: "Rental period active" },
|
|
61
63
|
{ name: "returned", role: "Customer returns item" },
|
|
@@ -69,6 +71,8 @@ export const SCENARIO_MODES = [
|
|
|
69
71
|
{ template_id: "inspect_guard_signer", host: "machine", purpose: "Only owner can submit inspection result" },
|
|
70
72
|
{ template_id: "refund_guard_permission", host: "machine", purpose: "Refund requires owner permission" },
|
|
71
73
|
{ template_id: "damage_guard_wip", host: "machine", purpose: "Damage claim requires pre+post WIP comparison" },
|
|
74
|
+
{ template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Return delay/damage exception compensation via scene-bound Payment (§2.13)" },
|
|
75
|
+
{ template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Weather/usage data oracle subscription (§2.11)" },
|
|
72
76
|
],
|
|
73
77
|
allocator: {
|
|
74
78
|
recipient: "entity",
|
|
@@ -81,6 +85,8 @@ export const SCENARIO_MODES = [
|
|
|
81
85
|
"Pre-rental WIP is non-negotiable — without it, damage claims fail",
|
|
82
86
|
"Deposit must be escrowed, not direct-transferred — enables fair deduction",
|
|
83
87
|
"Inspection gate prevents customer from denying damage",
|
|
88
|
+
"NEW: Payment exception compensation for return delays — Treasury withdraws scene-bound Payment (§2.13)",
|
|
89
|
+
"NEW: Repository quote_guard for weather/usage data subscription revenue (§2.11)",
|
|
84
90
|
],
|
|
85
91
|
},
|
|
86
92
|
{
|
|
@@ -97,7 +103,7 @@ export const SCENARIO_MODES = [
|
|
|
97
103
|
multi_tier_allocation: false,
|
|
98
104
|
},
|
|
99
105
|
machine_shape: [
|
|
100
|
-
{ name: "
|
|
106
|
+
{ name: "paid", role: "Entry: enrollment and tuition paid via Service.buy(); Machine starts here" },
|
|
101
107
|
{ name: "session_N", role: "Per-session attendance (1..N)" },
|
|
102
108
|
{ name: "completed", role: "All sessions delivered" },
|
|
103
109
|
{ name: "refunded", role: "Institution-approved refund" },
|
|
@@ -105,6 +111,7 @@ export const SCENARIO_MODES = [
|
|
|
105
111
|
guards: [
|
|
106
112
|
{ template_id: "attendance_guard_signer", host: "machine", purpose: "Per-session student attendance signature" },
|
|
107
113
|
{ template_id: "refund_guard_permission", host: "machine", purpose: "Institution approval OR arbiter for refund" },
|
|
114
|
+
{ template_id: "tpl_buy_guard_order_holder", host: "service", purpose: "Course module progressive unlock via supply chain sub-orders (§2.12)" },
|
|
108
115
|
],
|
|
109
116
|
allocator: {
|
|
110
117
|
recipient: "entity",
|
|
@@ -117,6 +124,8 @@ export const SCENARIO_MODES = [
|
|
|
117
124
|
"Use Service `setting_locked_time` to lock rules mid-semester (regulatory compliance)",
|
|
118
125
|
"Attendance Guard needs WIP hash for session content commitment",
|
|
119
126
|
"Per-session release requires threshold-based trigger",
|
|
127
|
+
"NEW: Supply chain sub-orders for course module progressive unlock — each module = sub-service with buy_guard verifying previous module completion (§2.12)",
|
|
128
|
+
"NEW: Repository for learning progress collaboration data — progress as key, session data as value (§2.10)",
|
|
120
129
|
],
|
|
121
130
|
},
|
|
122
131
|
{
|
|
@@ -133,7 +142,7 @@ export const SCENARIO_MODES = [
|
|
|
133
142
|
multi_tier_allocation: true,
|
|
134
143
|
},
|
|
135
144
|
machine_shape: [
|
|
136
|
-
{ name: "
|
|
145
|
+
{ name: "paid", role: "Entry: tour booked and paid (deposit + final) via Service.buy(); Machine starts here" },
|
|
137
146
|
{ name: "segment_D1", role: "Segment 1 (e.g., hotel check-in)" },
|
|
138
147
|
{ name: "segment_D2", role: "Segment 2 (e.g., guided tour)" },
|
|
139
148
|
{ name: "returned", role: "Trip completed, customer returns" },
|
|
@@ -143,6 +152,9 @@ export const SCENARIO_MODES = [
|
|
|
143
152
|
guards: [
|
|
144
153
|
{ template_id: "segment_guard_wip", host: "machine", purpose: "Per-segment arrival WIP (hotel check-in, etc.)" },
|
|
145
154
|
{ template_id: "refund_guard_permission", host: "machine", purpose: "Agency approval OR arbiter for trip interruption" },
|
|
155
|
+
{ template_id: "tpl_buy_guard_order_holder", host: "service", purpose: "Supply chain sub-orders for tour package segments (§2.12)" },
|
|
156
|
+
{ template_id: "tpl_payment_exception_compensation", host: "machine", purpose: "Trip delay/segment change exception compensation (§2.13)" },
|
|
157
|
+
{ template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Weather/travel data oracle subscription (§2.11)" },
|
|
146
158
|
],
|
|
147
159
|
allocator: {
|
|
148
160
|
recipient: "entity",
|
|
@@ -155,6 +167,9 @@ export const SCENARIO_MODES = [
|
|
|
155
167
|
"Multi-tier Allocation is WoWok's unique advantage over traditional travel platforms",
|
|
156
168
|
"segment_guard needs standardized WIP templates per segment type (hotel, transport, activity)",
|
|
157
169
|
"Multi-tier waterfall needs guard chaining validation",
|
|
170
|
+
"NEW: Supply chain sub-orders — each tour segment = sub-service with buy_guard verifying main tour order (§2.12)",
|
|
171
|
+
"NEW: Payment exception compensation for flight/segment delays (§2.13)",
|
|
172
|
+
"NEW: Repository quote_guard for weather/travel data subscription revenue (§2.11)",
|
|
158
173
|
],
|
|
159
174
|
},
|
|
160
175
|
{
|
|
@@ -171,7 +186,7 @@ export const SCENARIO_MODES = [
|
|
|
171
186
|
multi_tier_allocation: false,
|
|
172
187
|
},
|
|
173
188
|
machine_shape: [
|
|
174
|
-
{ name: "
|
|
189
|
+
{ name: "paid", role: "Entry: subscription paid and active via Service.buy(); Machine starts here" },
|
|
175
190
|
{ name: "charge_period_N", role: "Periodic charge (1..N)" },
|
|
176
191
|
{ name: "deliver_period_N", role: "Per-period delivery" },
|
|
177
192
|
{ name: "cancelled", role: "Subscriber cancels — takes effect next period" },
|
|
@@ -181,6 +196,7 @@ export const SCENARIO_MODES = [
|
|
|
181
196
|
{ template_id: "charge_guard_signer", host: "machine", purpose: "User confirms each charge — no auto-renew trap" },
|
|
182
197
|
{ template_id: "cancel_guard_signer", host: "machine", purpose: "User cancels anytime, next-period effective" },
|
|
183
198
|
{ template_id: "deliver_guard_wip", host: "machine", purpose: "Creator WIP hash per period — prevents content abandonment" },
|
|
199
|
+
{ template_id: "tpl_repository_quote_guard_subscription", host: "repository", purpose: "Creator publishes paid data (analytics, market data) with quote_guard subscription (§2.11)" },
|
|
184
200
|
],
|
|
185
201
|
allocator: {
|
|
186
202
|
recipient: "entity",
|
|
@@ -193,6 +209,7 @@ export const SCENARIO_MODES = [
|
|
|
193
209
|
"Pure digital — native WoWok soil",
|
|
194
210
|
"charge_guard needs periodic trigger (off-chain scheduler + on-chain Guard)",
|
|
195
211
|
"Targets indie creators, niche SaaS, paid newsletters",
|
|
212
|
+
"NEW: Repository quote_guard for creator data subscription revenue — creators publish paid data, users pay to access (§2.11)",
|
|
196
213
|
],
|
|
197
214
|
},
|
|
198
215
|
{
|
|
@@ -369,6 +369,44 @@ export const SERVICE_TEMPLATES = [
|
|
|
369
369
|
"Sales can still be updated post-publish (only allocator is locked)",
|
|
370
370
|
],
|
|
371
371
|
},
|
|
372
|
+
{
|
|
373
|
+
id: "T-S-09",
|
|
374
|
+
name: "Supply Chain Sub-order Service (milestone unlock via buy_guard)",
|
|
375
|
+
description: "Sub-service whose buy_guard verifies the user purchased the main service order. Each milestone = one sub-order. Enables supply chain composition: main service → multiple sub-services with conditional access.",
|
|
376
|
+
applicable_scenes: ["service_buy_guard"],
|
|
377
|
+
industry_tags: ["travel", "rental", "education", "freelance", "ecommerce", "supply_chain"],
|
|
378
|
+
params: [
|
|
379
|
+
{ name: "owner_address", type: "address", description: "Sub-service owner address", required: true },
|
|
380
|
+
{ name: "permission_address", type: "address", description: "Permission object address", required: true },
|
|
381
|
+
{ name: "description", type: "string", description: "Sub-service description (e.g., 'Hotel booking for tour package X')", required: true },
|
|
382
|
+
{ name: "main_service_address", type: "address", description: "Main Service object address (the parent service)", required: true },
|
|
383
|
+
{ name: "buy_guard_address", type: "address", description: "Guard address verifying main order ownership (order.owner==Signer AND order.service==main_service)", required: true },
|
|
384
|
+
{ name: "price", type: "number", description: "Sub-service price", required: true },
|
|
385
|
+
{ name: "machine_address", type: "address", description: "Machine object for sub-order workflow", required: true },
|
|
386
|
+
],
|
|
387
|
+
body: (p) => ({
|
|
388
|
+
object: null,
|
|
389
|
+
description: p.description,
|
|
390
|
+
service_type: "supply_chain_sub",
|
|
391
|
+
buy_guard: p.buy_guard_address,
|
|
392
|
+
price: p.price,
|
|
393
|
+
machine: p.machine_address,
|
|
394
|
+
permission: p.permission_address,
|
|
395
|
+
}),
|
|
396
|
+
notes: [
|
|
397
|
+
"VERIFIED: service.move#L173 (buy_guard: Option<address>), L263-268 (buy_with_passport evaluates buy_guard)",
|
|
398
|
+
"VERIFIER-EVIDENCE DESIGN: user submits main Order as evidence (b_submission=true), buy_guard verifies order.owner==Signer AND order.service==main_service_address",
|
|
399
|
+
"No parent_order field needed — relationship verified via buy_guard querying submitted Order fields",
|
|
400
|
+
"Each milestone = one sub-order with its own Service + buy_guard + Machine",
|
|
401
|
+
"Main flow Machine can branch to different sub-services based on node progression",
|
|
402
|
+
"Use tpl_buy_guard_order_holder (guard-templates.ts) for the buy_guard design",
|
|
403
|
+
],
|
|
404
|
+
post_publish_considerations: [
|
|
405
|
+
"buy_guard is mutable post-publish (can update the guard address)",
|
|
406
|
+
"If main service is unpublished, sub-service buy_guard will fail (order.service won't match)",
|
|
407
|
+
"Consider publishing main service before sub-services",
|
|
408
|
+
],
|
|
409
|
+
},
|
|
372
410
|
];
|
|
373
411
|
export const SERVICE_TEMPLATES_VERSION = "1.0.0";
|
|
374
412
|
export function getAllServiceTemplates() {
|
|
@@ -272,6 +272,48 @@ export const TREASURY_TEMPLATES = [
|
|
|
272
272
|
"Suitable for fee sinks, donation pools, or auto-forwarding revenue",
|
|
273
273
|
],
|
|
274
274
|
},
|
|
275
|
+
{
|
|
276
|
+
id: "T-T-07",
|
|
277
|
+
name: "Exception Compensation Treasury (scene-bound Payment withdraw)",
|
|
278
|
+
description: "Treasury for exception branch compensation: withdraws create scene-bound Payments with for_object + for_guard + index binding. Enables auto-compensation for delays, defects, or service exceptions.",
|
|
279
|
+
applicable_scenes: ["treasury_fund_collection", "treasury_um_delegation"],
|
|
280
|
+
industry_tags: ["retail", "travel", "rental", "freelance", "ecommerce"],
|
|
281
|
+
params: [
|
|
282
|
+
{ name: "treasury_name", type: "string", description: "Name for the new Treasury object", required: true },
|
|
283
|
+
{ name: "owner_address", type: "address", description: "Owner address (service provider, becomes admin)", required: true },
|
|
284
|
+
{ name: "coin_type", type: "coin_type", description: "Coin type T (e.g. 0x2::wow::WOW)", required: true },
|
|
285
|
+
{ name: "description", type: "string", description: "Treasury description (e.g., 'Compensation fund for delivery delays')", required: true },
|
|
286
|
+
{ name: "permission_name", type: "string", description: "Name for the new Permission object", required: true },
|
|
287
|
+
{ name: "withdrawer_address", type: "address", description: "Address authorized to withdraw compensations (can be same as owner)", required: true },
|
|
288
|
+
{ name: "external_withdraw_guard", type: "address", description: "Guard address for external_withdraw (verifies exception conditions + Payment binding)", required: true },
|
|
289
|
+
],
|
|
290
|
+
body: (p) => ({
|
|
291
|
+
object: {
|
|
292
|
+
name: p.treasury_name,
|
|
293
|
+
type_parameter: p.coin_type,
|
|
294
|
+
permission: {
|
|
295
|
+
name: p.permission_name,
|
|
296
|
+
description: `Permission for ${p.treasury_name}`,
|
|
297
|
+
indexes: [
|
|
298
|
+
{ index: 253, name: "TREASURY_DEPOSIT", mark: p.owner_address, description: "Owner deposits funds" },
|
|
299
|
+
{ index: 254, name: "TREASURY_WITHDRAW", mark: p.withdrawer_address, description: "Withdraw for exception compensation (creates scene-bound Payment)" },
|
|
300
|
+
{ index: 256, name: "TREASURY_EXTERNAL_WITHDRAW", mark: p.withdrawer_address, description: "External withdraw with guard (verifies exception + Payment binding)" },
|
|
301
|
+
{ index: 257, name: "TREASURY_OWNER_RECEIVE", mark: p.owner_address, description: "Owner receives remaining funds" },
|
|
302
|
+
],
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
description: p.description,
|
|
306
|
+
}),
|
|
307
|
+
notes: [
|
|
308
|
+
"VERIFIED: treasury.move#L249-264 (withdraw creates Payment via payment::new_singleton + from_object_set)",
|
|
309
|
+
"VERIFIED: treasury.move#L415-418 (withdraw<T> sends to recipient with PaymentInfo)",
|
|
310
|
+
"Payment created has PaymentInfo(for_object=order, for_guard=exception_guard, index=current_progress)",
|
|
311
|
+
"ANTI-REUSE: for_object + for_guard + index binds Payment to specific context (payment.move#L66-71)",
|
|
312
|
+
"VERIFIER-EVIDENCE: customer submits Payment via Passport, Guard verifies binding fields match",
|
|
313
|
+
"Use with tpl_payment_exception_compensation (guard-templates.ts) for the exception branch guard",
|
|
314
|
+
"Suitable for: delivery delay compensation, defect refund, service-level agreement penalties",
|
|
315
|
+
],
|
|
316
|
+
},
|
|
275
317
|
];
|
|
276
318
|
export const TREASURY_TEMPLATES_VERSION = "1.0.0";
|
|
277
319
|
export function getAllTreasuryTemplates() {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { AssembleContextResult } from "../project/context-assembly.js";
|
|
2
|
+
export interface ContextCollectionResult {
|
|
3
|
+
signature_recorded: boolean;
|
|
4
|
+
proposal_created: boolean;
|
|
5
|
+
proposal_id?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function collectContextExperience(result: AssembleContextResult, network: string): ContextCollectionResult;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { recordSignature } from "../experience/index.js";
|
|
2
|
+
import { persistImprovementQueue } from "./improve.js";
|
|
3
|
+
export function collectContextExperience(result, network) {
|
|
4
|
+
const objectTypes = extractObjectTypes(result.objects);
|
|
5
|
+
const hasEmbeddedHistory = !!result.embedded_history;
|
|
6
|
+
const hasEvents = !!result.events && result.events.length > 0;
|
|
7
|
+
const signature = {
|
|
8
|
+
intent: "assemble_context",
|
|
9
|
+
signals: {
|
|
10
|
+
object_types: objectTypes,
|
|
11
|
+
object_count: result.objects.length,
|
|
12
|
+
has_embedded_history: hasEmbeddedHistory,
|
|
13
|
+
has_events: hasEvents,
|
|
14
|
+
context_digest: result.context_digest,
|
|
15
|
+
network,
|
|
16
|
+
},
|
|
17
|
+
timestamp: Date.now(),
|
|
18
|
+
outcome: "success",
|
|
19
|
+
};
|
|
20
|
+
let signatureRecorded = false;
|
|
21
|
+
try {
|
|
22
|
+
recordSignature(signature);
|
|
23
|
+
signatureRecorded = true;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
}
|
|
27
|
+
let proposal;
|
|
28
|
+
if (objectTypes.length >= 3) {
|
|
29
|
+
proposal = {
|
|
30
|
+
proposal_id: `PROP-CTX-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
31
|
+
source_diagnosis_id: `CTX-${result.context_digest}`,
|
|
32
|
+
type: "description_rewrite",
|
|
33
|
+
priority: "P3",
|
|
34
|
+
automation: "semi",
|
|
35
|
+
apply_mode: "config_override",
|
|
36
|
+
override_category: "descriptions",
|
|
37
|
+
title: `Enrich assemble_context for ${objectTypes.join("+")} patterns`,
|
|
38
|
+
description: `Assembled context with ${objectTypes.length} object types (${objectTypes.join(", ")}). ` +
|
|
39
|
+
`Consider enriching the assemble_context action description to guide AI toward ` +
|
|
40
|
+
`common ${objectTypes.join("+")} business patterns.`,
|
|
41
|
+
target: "assemble_context",
|
|
42
|
+
proposed_change: {
|
|
43
|
+
action: "enrich_description",
|
|
44
|
+
object_types: objectTypes,
|
|
45
|
+
has_embedded_history: hasEmbeddedHistory,
|
|
46
|
+
has_events: hasEvents,
|
|
47
|
+
context_digest: result.context_digest,
|
|
48
|
+
},
|
|
49
|
+
evidence: {
|
|
50
|
+
context_digest: result.context_digest,
|
|
51
|
+
object_count: result.objects.length,
|
|
52
|
+
object_types: objectTypes,
|
|
53
|
+
network,
|
|
54
|
+
},
|
|
55
|
+
review_status: "pending",
|
|
56
|
+
ab_test_recommended: false,
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
persistImprovementQueue([proposal]);
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
signature_recorded: signatureRecorded,
|
|
66
|
+
proposal_created: !!proposal,
|
|
67
|
+
proposal_id: proposal?.proposal_id,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function extractObjectTypes(objects) {
|
|
71
|
+
const types = new Set();
|
|
72
|
+
for (const obj of objects) {
|
|
73
|
+
const data = obj?.data ?? obj;
|
|
74
|
+
const type = data?.type;
|
|
75
|
+
if (typeof type === "string") {
|
|
76
|
+
const match = type.match(/::(\w+)$/);
|
|
77
|
+
if (match) {
|
|
78
|
+
types.add(match[1]);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return Array.from(types);
|
|
83
|
+
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { DiagnosisReport } from "./diagnose.js";
|
|
2
2
|
export type ProposalType = "error_rule_addition" | "intent_rule_addition" | "description_rewrite" | "skill_creation" | "recovery_priority_adjustment" | "investigation" | "industry_update_application";
|
|
3
3
|
export type AutomationLevel = "full" | "semi" | "manual";
|
|
4
|
+
export type ApplyMode = "config_override" | "source_patch";
|
|
4
5
|
export interface ImprovementProposal {
|
|
5
6
|
proposal_id: string;
|
|
6
7
|
source_diagnosis_id: string;
|
|
7
8
|
type: ProposalType;
|
|
8
9
|
priority: string;
|
|
9
10
|
automation: AutomationLevel;
|
|
11
|
+
apply_mode: ApplyMode;
|
|
12
|
+
override_category?: OverrideCategory;
|
|
10
13
|
title: string;
|
|
11
14
|
description: string;
|
|
12
15
|
target: string;
|
|
@@ -14,7 +17,10 @@ export interface ImprovementProposal {
|
|
|
14
17
|
evidence: Record<string, unknown>;
|
|
15
18
|
review_status: "pending" | "approved" | "rejected" | "applied";
|
|
16
19
|
ab_test_recommended: boolean;
|
|
20
|
+
persisted_at?: string;
|
|
21
|
+
reviewed_at?: string;
|
|
17
22
|
}
|
|
23
|
+
export type OverrideCategory = "risk-thresholds" | "descriptions" | "industry-profiles" | "scenario-defaults" | "recovery-priorities";
|
|
18
24
|
export interface ImprovementReport {
|
|
19
25
|
report_id: string;
|
|
20
26
|
generated_date: string;
|
|
@@ -24,3 +30,26 @@ export interface ImprovementReport {
|
|
|
24
30
|
summary: string;
|
|
25
31
|
}
|
|
26
32
|
export declare function generateImprovements(report: DiagnosisReport): ImprovementReport;
|
|
33
|
+
export declare function persistImprovementQueue(proposals: ImprovementProposal[]): number;
|
|
34
|
+
export interface QueueFilter {
|
|
35
|
+
status?: "pending" | "approved" | "rejected" | "applied";
|
|
36
|
+
type?: string;
|
|
37
|
+
priority?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare function loadImprovementQueue(filter?: QueueFilter): ImprovementProposal[];
|
|
40
|
+
export declare function updateProposalReviewStatus(proposalId: string, newStatus: "approved" | "rejected" | "applied"): ImprovementProposal | undefined;
|
|
41
|
+
export declare function applyConfigOverride(proposal: ImprovementProposal): string;
|
|
42
|
+
export declare function produceSourcePatch(proposal: ImprovementProposal): string;
|
|
43
|
+
export interface FlywheelConfigSummary {
|
|
44
|
+
queue_path: string;
|
|
45
|
+
overrides_dir: string;
|
|
46
|
+
patches_dir: string;
|
|
47
|
+
total_proposals: number;
|
|
48
|
+
pending_count: number;
|
|
49
|
+
approved_count: number;
|
|
50
|
+
applied_count: number;
|
|
51
|
+
rejected_count: number;
|
|
52
|
+
override_files: string[];
|
|
53
|
+
recent_proposals: ImprovementProposal[];
|
|
54
|
+
}
|
|
55
|
+
export declare function getFlywheelConfigSummary(): FlywheelConfigSummary;
|