@wowok/agent-mcp 2.6.1 → 2.6.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.
- package/dist/customer/customer-advice.d.ts +31 -0
- package/dist/customer/customer-advice.js +129 -0
- package/dist/customer/index.d.ts +2 -0
- package/dist/customer/index.js +2 -0
- package/dist/customer/info-puzzle.d.ts +9 -2
- package/dist/customer/info-puzzle.js +34 -7
- package/dist/customer/order-monitor.d.ts +2 -0
- package/dist/customer/order-monitor.js +3 -2
- package/dist/customer/post-purchase.d.ts +2 -0
- package/dist/customer/post-purchase.js +6 -5
- package/dist/customer/preorder-compare.d.ts +24 -0
- package/dist/customer/preorder-compare.js +34 -0
- package/dist/customer/reminder-system.d.ts +2 -0
- package/dist/customer/reminder-system.js +2 -1
- package/dist/customer/risk-assessment.js +30 -7
- package/dist/customer/types.d.ts +7 -0
- package/dist/examples/arbitration-dispute-create.json +41 -0
- package/dist/examples/arbitration-vote-weighted.json +35 -0
- package/dist/examples/arbitration-voting-guard-add.json +38 -0
- package/dist/examples/demand-present-service.json +33 -0
- package/dist/examples/gen-passport-verify-guard.json +48 -0
- package/dist/examples/guard-template-balance-check.json +59 -0
- package/dist/examples/guard-template-time-lock.json +60 -0
- package/dist/examples/insurance-guard-claim-timelock.json +75 -0
- package/dist/examples/insurance-guard-withdraw-allocation.json +96 -0
- package/dist/examples/insurance-machine-create-publish.json +75 -0
- package/dist/examples/insurance-service-allocators-publish.json +56 -0
- package/dist/examples/machine-multisig-threshold.json +86 -0
- package/dist/examples/machine-template-7node-rental.json +119 -0
- package/dist/examples/payment-scenario-bound.json +45 -0
- package/dist/examples/rental-ziroom-machine-create.json +149 -0
- package/dist/examples/rental-ziroom-permission-create.json +42 -0
- package/dist/examples/rental-ziroom-service-create.json +89 -0
- package/dist/examples/retail-adv-guard-customer-win-create.json +80 -0
- package/dist/examples/retail-adv-guard-messenger-proof-create.json +65 -0
- package/dist/examples/retail-adv-guard-reward-timeout-create.json +92 -0
- package/dist/examples/retail-adv-reward-guard-add.json +51 -0
- package/dist/examples/retail-myshop-allocation-activate.json +55 -0
- package/dist/examples/retail-myshop-arbitration-create.json +40 -0
- package/dist/examples/retail-myshop-contact-create.json +43 -0
- package/dist/examples/retail-myshop-order-create.json +56 -0
- package/dist/examples/retail-myshop-progress-operate.json +38 -0
- package/dist/examples/retail-myshop-reward-create.json +35 -0
- package/dist/examples/retail-myshop-service-create.json +88 -0
- package/dist/examples/service-discount-issue.json +46 -0
- package/dist/examples/threebody-guard-create.json +56 -0
- package/dist/examples/threebody-machine-create.json +72 -0
- package/dist/examples/threebody-permission-create.json +38 -0
- package/dist/examples/threebody-service-allocators.json +49 -0
- package/dist/examples/travel-guard-time-lock.json +69 -0
- package/dist/examples/travel-guard-weather-oracle.json +70 -0
- package/dist/examples/travel-machine-create.json +136 -0
- package/dist/examples/travel-repository-create.json +47 -0
- package/dist/examples/travel-service-create.json +102 -0
- package/dist/examples/travel-treasury-create.json +34 -0
- package/dist/examples/treasury-deposit.json +37 -0
- package/dist/examples/treasury-withdraw.json +38 -0
- package/dist/extensions/business-modules.d.ts +49 -0
- package/dist/extensions/business-modules.js +287 -0
- package/dist/extensions/capability-manifest.js +216 -29
- package/dist/extensions/constraint-registry.js +21 -19
- package/dist/extensions/metric-registry.js +14 -14
- package/dist/extensions/mode-evaluator.js +16 -16
- package/dist/extensions/modes.js +141 -49
- package/dist/extensions/registry.d.ts +16 -9
- package/dist/extensions/registry.js +132 -44
- package/dist/extensions/types.d.ts +2 -0
- package/dist/index.js +50 -0
- package/dist/knowledge/deployment-scanner.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +138 -0
- package/dist/knowledge/fund-layer.js +969 -0
- package/dist/knowledge/guard-render.d.ts +57 -0
- package/dist/knowledge/guard-render.js +700 -0
- package/dist/knowledge/guard-submission-prompt.d.ts +31 -0
- package/dist/knowledge/guard-submission-prompt.js +171 -0
- package/dist/knowledge/guard-templates.d.ts +10 -0
- package/dist/knowledge/guard-templates.js +50 -0
- package/dist/knowledge/index.d.ts +2 -2
- package/dist/knowledge/index.js +2 -2
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-render.d.ts +41 -0
- package/dist/knowledge/machine-render.js +565 -0
- package/dist/knowledge/machine-risk.js +4 -1
- package/dist/knowledge/machine-templates.js +4 -4
- package/dist/knowledge/progress-context.js +1 -1
- package/dist/knowledge/progress-ledger.js +3 -3
- package/dist/knowledge/progress-templates.js +1 -1
- package/dist/knowledge/progress-translation.js +1 -1
- package/dist/knowledge/reward-confirm.js +2 -2
- package/dist/knowledge/reward-puzzle.js +1 -1
- package/dist/knowledge/reward-risk.js +9 -9
- package/dist/knowledge/reward-templates.js +2 -2
- package/dist/knowledge/safety-rules.d.ts +83 -1
- package/dist/knowledge/safety-rules.js +166 -2
- package/dist/knowledge/scenario-modes.d.ts +1 -1
- package/dist/knowledge/scenario-modes.js +13 -11
- package/dist/knowledge/service-confirm.d.ts +1 -1
- package/dist/knowledge/service-confirm.js +3 -3
- package/dist/knowledge/service-context.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.d.ts +1 -1
- package/dist/knowledge/service-risk.js +3 -3
- package/dist/knowledge/service-templates.js +2 -2
- package/dist/knowledge/service-translation.d.ts +1 -1
- package/dist/knowledge/service-translation.js +7 -7
- package/dist/knowledge/template-registry.d.ts +48 -0
- package/dist/knowledge/template-registry.js +341 -0
- package/dist/knowledge/tool-constraints.js +6 -6
- package/dist/knowledge/tools-reference.js +11 -8
- package/dist/participation/merchant-interest.d.ts +32 -0
- package/dist/participation/merchant-interest.js +100 -0
- package/dist/participation/radar-core.d.ts +104 -0
- package/dist/participation/radar-core.js +269 -0
- package/dist/project/context-assembly.js +8 -0
- package/dist/project/deployment-bridge.js +6 -5
- package/dist/project/deployment-doc.js +5 -5
- package/dist/project/edit-planner.d.ts +123 -0
- package/dist/project/edit-planner.js +1342 -0
- package/dist/project/evaluation.d.ts +36 -0
- package/dist/project/evaluation.js +734 -68
- package/dist/project/game-theory.d.ts +43 -0
- package/dist/project/game-theory.js +177 -0
- package/dist/project/graph-builder.js +7 -1
- package/dist/project/handlers.d.ts +137 -2
- package/dist/project/handlers.js +423 -51
- package/dist/project/intent-analyzer.d.ts +71 -0
- package/dist/project/intent-analyzer.js +149 -0
- package/dist/project/machine-nodes.d.ts +2 -0
- package/dist/project/machine-nodes.js +36 -0
- package/dist/project/merchant-guide.d.ts +165 -0
- package/dist/project/merchant-guide.js +264 -0
- package/dist/project/mode-actions.d.ts +199 -0
- package/dist/project/mode-actions.js +309 -0
- package/dist/project/participation-radar.d.ts +18 -0
- package/dist/project/participation-radar.js +428 -0
- package/dist/project/pipeline-actions.d.ts +101 -0
- package/dist/project/pipeline-actions.js +109 -0
- package/dist/project/semantic-graph.d.ts +95 -0
- package/dist/project/semantic-graph.js +245 -0
- package/dist/project/stage-gate.js +4 -4
- package/dist/schema/call/allocation.d.ts +11 -11
- package/dist/schema/call/allocation.js +13 -3
- package/dist/schema/call/arbitration.d.ts +21 -21
- package/dist/schema/call/arbitration.js +30 -9
- package/dist/schema/call/base.d.ts +2 -2
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +127 -127
- package/dist/schema/call/bridge.js +12 -12
- package/dist/schema/call/contact.d.ts +3 -3
- package/dist/schema/call/contact.js +2 -2
- package/dist/schema/call/demand.d.ts +3 -3
- package/dist/schema/call/demand.js +2 -2
- package/dist/schema/call/guard.d.ts +11 -11
- package/dist/schema/call/guard.js +2 -2
- package/dist/schema/call/machine.d.ts +2072 -679
- package/dist/schema/call/machine.js +51 -5
- package/dist/schema/call/order.d.ts +7 -7
- package/dist/schema/call/order.js +3 -6
- package/dist/schema/call/payment.d.ts +3 -3
- package/dist/schema/call/permission.d.ts +3 -3
- package/dist/schema/call/permission.js +2 -2
- package/dist/schema/call/personal.d.ts +337 -3
- package/dist/schema/call/personal.js +10 -0
- package/dist/schema/call/progress.d.ts +177 -9
- package/dist/schema/call/progress.js +7 -3
- package/dist/schema/call/proof.d.ts +6 -6
- package/dist/schema/call/repository.d.ts +3 -3
- package/dist/schema/call/repository.js +2 -2
- package/dist/schema/call/reward.d.ts +57 -57
- package/dist/schema/call/reward.js +3 -3
- package/dist/schema/call/semantic.js +48 -2
- package/dist/schema/call/service.d.ts +285 -113
- package/dist/schema/call/service.js +92 -28
- package/dist/schema/call/treasury.d.ts +57 -57
- package/dist/schema/call/treasury.js +3 -3
- package/dist/schema/common/index.d.ts +2 -0
- package/dist/schema/common/index.js +46 -10
- package/dist/schema/local/index.js +5 -1
- package/dist/schema/messenger/index.js +4 -1
- package/dist/schema/operations.d.ts +1318 -317
- package/dist/schema/operations.js +76 -7
- package/dist/schema/project/index.d.ts +5662 -164
- package/dist/schema/project/index.js +1136 -5
- package/dist/schema/query/index.d.ts +580 -19
- package/dist/schema/query/index.js +88 -36
- package/dist/schema/schema-query/index.d.ts +59 -3
- package/dist/schema/schema-query/index.js +45 -6
- package/dist/schema/trust/index.d.ts +1012 -6
- package/dist/schema/trust/index.js +212 -11
- package/dist/schema/utils/node-parser.js +13 -0
- package/dist/schema/utils/object-type-utils.d.ts +12 -0
- package/dist/schema/utils/object-type-utils.js +35 -0
- package/dist/schema/utils/permission-machine-check.d.ts +49 -0
- package/dist/schema/utils/permission-machine-check.js +121 -0
- package/dist/schema/utils/skills-recommendation.d.ts +2 -0
- package/dist/schema/utils/skills-recommendation.js +77 -0
- package/dist/schema-query/index.d.ts +17 -1
- package/dist/schema-query/index.js +359 -3
- package/dist/schemas/account_operation.schema.json +1 -1
- package/dist/schemas/bridge_operation.schema.json +14 -7
- package/dist/schemas/guard2file.schema.json +2 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/machineNode2file.schema.json +2 -0
- package/dist/schemas/messenger_operation.schema.json +1 -1
- package/dist/schemas/onchain_events.output.json +1 -1
- package/dist/schemas/onchain_operations.output.json +2820 -0
- package/dist/schemas/onchain_operations.schema.json +255 -65
- package/dist/schemas/onchain_operations_allocation.schema.json +7 -6
- package/dist/schemas/onchain_operations_arbitration.schema.json +14 -10
- package/dist/schemas/onchain_operations_contact.schema.json +4 -3
- package/dist/schemas/onchain_operations_demand.schema.json +4 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +4 -2
- package/dist/schemas/onchain_operations_gen_proof.schema.json +2 -0
- package/dist/schemas/onchain_operations_guard.schema.json +579 -1
- package/dist/schemas/onchain_operations_machine.schema.json +5 -4
- package/dist/schemas/onchain_operations_order.schema.json +7 -6
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +3 -2
- package/dist/schemas/onchain_operations_personal.schema.json +37 -0
- package/dist/schemas/onchain_operations_progress.schema.json +91 -4
- package/dist/schemas/onchain_operations_proof.schema.json +2 -1
- package/dist/schemas/onchain_operations_repository.schema.json +4 -3
- package/dist/schemas/onchain_operations_reward.schema.json +7 -6
- package/dist/schemas/onchain_operations_service.schema.json +80 -19
- package/dist/schemas/onchain_operations_treasury.schema.json +5 -4
- package/dist/schemas/onchain_table_data.output.json +1 -1
- package/dist/schemas/onchain_table_data.schema.json +10 -9
- package/dist/schemas/project_operation.output.json +3318 -57
- package/dist/schemas/project_operation.schema.json +728 -4
- package/dist/schemas/query_toolkit.output.json +16 -16
- package/dist/schemas/query_toolkit.schema.json +40 -3
- package/dist/schemas/schema_query.output.json +65 -2
- package/dist/schemas/schema_query.schema.json +31 -5
- package/dist/schemas/trust_score.output.json +392 -1
- package/dist/schemas/trust_score.schema.json +275 -1
- package/dist/schemas/wowok_buildin_info.output.json +81 -8
- package/dist/schemas/wowok_buildin_info.schema.json +46 -2
- package/dist/tools/handlers/onchain.js +636 -6
- package/dist/tools/handlers/project.js +71 -2
- package/dist/tools/handlers/query.js +117 -2
- package/dist/tools/handlers/schema-query.js +65 -1
- package/dist/tools/handlers/trust.js +192 -6
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.js +229 -15
- package/dist/tools/wrap.js +194 -15
- package/package.json +2 -2
|
@@ -184,7 +184,7 @@ export function validateConstraints(puzzle) {
|
|
|
184
184
|
constraint_id: "F-R-09",
|
|
185
185
|
severity: "HIGH",
|
|
186
186
|
message: "Guard's expected progress.current value does not match business intent — " +
|
|
187
|
-
"praise reward (
|
|
187
|
+
"praise reward (praise/wonder) must check 'wonder' node, not 'completed'. " +
|
|
188
188
|
"Guard is immutable after creation; mismatch requires full rebuild.",
|
|
189
189
|
});
|
|
190
190
|
}
|
|
@@ -472,7 +472,7 @@ const R_R_5_03 = {
|
|
|
472
472
|
const R_R_6_01 = {
|
|
473
473
|
id: "R-R-6-01",
|
|
474
474
|
category: "business_semantic",
|
|
475
|
-
trigger: "intent mentions praise
|
|
475
|
+
trigger: "intent mentions praise/positive-review but Guard checks non-wonder progress node",
|
|
476
476
|
check: (ctx) => {
|
|
477
477
|
if (!ctx.user_intent_phrases || ctx.user_intent_phrases.length === 0)
|
|
478
478
|
return null;
|
|
@@ -480,8 +480,8 @@ const R_R_6_01 = {
|
|
|
480
480
|
return null;
|
|
481
481
|
const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
|
|
482
482
|
const praiseKeywords = [
|
|
483
|
-
"
|
|
484
|
-
"positive review", "satisfaction reward", "
|
|
483
|
+
"praise", "wonder", "thumbs_up",
|
|
484
|
+
"positive review", "satisfaction reward", "praise reward",
|
|
485
485
|
];
|
|
486
486
|
const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
|
|
487
487
|
if (!isPraiseIntent)
|
|
@@ -495,10 +495,10 @@ const R_R_6_01 = {
|
|
|
495
495
|
level: "HIGH",
|
|
496
496
|
category: "business_semantic",
|
|
497
497
|
title: `Guard checks progress=="${expected}" but intent indicates praise reward (wonder node)`,
|
|
498
|
-
description: `User intent mentions praise
|
|
498
|
+
description: `User intent mentions praise/positive-review/wonder, which maps to the 'wonder' progress node ` +
|
|
499
499
|
`(customer gives positive review AFTER service completion). But the Guard's table bakes ` +
|
|
500
500
|
`expected state="${expected}", allowing reward claim at the wrong lifecycle stage. ` +
|
|
501
|
-
`This violates the business semantics: "
|
|
501
|
+
`This violates the business semantics: "praise reward" should only be claimable AFTER the ` +
|
|
502
502
|
`customer advances to the 'wonder' node, not before. ` +
|
|
503
503
|
`Guard is immutable — fixing this requires creating a new Guard + Reward pair.`,
|
|
504
504
|
affected_stakeholders: ["owner", "service_provider", "claimer"],
|
|
@@ -526,8 +526,8 @@ const R_R_6_02 = {
|
|
|
526
526
|
return null;
|
|
527
527
|
const intentLower = ctx.user_intent_phrases.join(" ").toLowerCase();
|
|
528
528
|
const praiseKeywords = [
|
|
529
|
-
"
|
|
530
|
-
"positive review", "satisfaction reward", "
|
|
529
|
+
"praise", "wonder", "thumbs_up",
|
|
530
|
+
"positive review", "satisfaction reward", "praise reward",
|
|
531
531
|
];
|
|
532
532
|
const isPraiseIntent = praiseKeywords.some(kw => intentLower.includes(kw.toLowerCase()));
|
|
533
533
|
if (isPraiseIntent)
|
|
@@ -538,12 +538,12 @@ const R_R_6_02 = {
|
|
|
538
538
|
category: "business_semantic",
|
|
539
539
|
title: "Guard checks wonder node but intent does not mention praise",
|
|
540
540
|
description: `Guard's expected progress state is "wonder" (positive-review node), but the user intent ` +
|
|
541
|
-
`does not mention any praise
|
|
541
|
+
`does not mention any praise/positive-review keyword. This may be a copy-paste from a wonder_praise ` +
|
|
542
542
|
`template without adjusting the Guard for the actual business semantics. If this is a ` +
|
|
543
543
|
`general feedback reward (wonder_feedback), this is fine. Otherwise, verify the node choice.`,
|
|
544
544
|
affected_stakeholders: ["owner"],
|
|
545
545
|
scenario: "Designer copies wonder_praise template but actually wants a completion-based reward",
|
|
546
|
-
mitigation: "Verify: if intent is praise reward, add '
|
|
546
|
+
mitigation: "Verify: if intent is praise reward, add 'praise/positive review' to description. " +
|
|
547
547
|
"If intent is completion-based reward, change Guard to check 'completed' node.",
|
|
548
548
|
evidence: `expected_state="wonder", intent="${intentLower}" (no praise keyword)`,
|
|
549
549
|
auto_fixable: false,
|
|
@@ -165,13 +165,13 @@ export function listRewardTemplates() {
|
|
|
165
165
|
export function suggestRewardTemplate(intent) {
|
|
166
166
|
const lower = intent.toLowerCase();
|
|
167
167
|
if (lower.includes("wonder") || lower.includes("praise") || lower.includes("thumbs_up")
|
|
168
|
-
|| lower.includes("
|
|
168
|
+
|| lower.includes("praise") || lower.includes("positive review")
|
|
169
169
|
|| lower.includes("satisfaction reward")) {
|
|
170
170
|
return getRewardTemplate("wonder_praise");
|
|
171
171
|
}
|
|
172
172
|
if (lower.includes("feedback") || lower.includes("review collection")
|
|
173
173
|
|| lower.includes("no_wonder") || lower.includes("thumbs_down")
|
|
174
|
-
|| lower.includes("
|
|
174
|
+
|| lower.includes("complaint") || lower.includes("both sentiment")) {
|
|
175
175
|
return getRewardTemplate("wonder_feedback");
|
|
176
176
|
}
|
|
177
177
|
if (lower.includes("first order") || lower.includes("new") || lower.includes("first")) {
|
|
@@ -33,4 +33,86 @@ export declare function getAmountThreshold(): bigint;
|
|
|
33
33
|
export declare function formatAmount(value: string | bigint, precision?: bigint): string;
|
|
34
34
|
export declare function collectDefaultWarnings(env: any, data: any): string[];
|
|
35
35
|
export declare const CONFIRMATION_RULES: ConfirmationRule[];
|
|
36
|
-
export declare
|
|
36
|
+
export declare function extractAmount(data: any): string | null;
|
|
37
|
+
export type ReuseRecommendation = "always_reuse" | "strongly_recommended" | "recommended" | "optional";
|
|
38
|
+
export interface ObjectReuseRule {
|
|
39
|
+
rule_id: string;
|
|
40
|
+
object_type: string;
|
|
41
|
+
recommendation: ReuseRecommendation;
|
|
42
|
+
reason: string;
|
|
43
|
+
ask_user: string;
|
|
44
|
+
}
|
|
45
|
+
export declare const OBJECT_REUSE_RULES: readonly ObjectReuseRule[];
|
|
46
|
+
export declare const CREATE_VS_MODIFY_PATTERN: {
|
|
47
|
+
readonly reuse_form: "string";
|
|
48
|
+
readonly create_form: "object";
|
|
49
|
+
readonly resolution_api: "GetObjectExisted";
|
|
50
|
+
readonly note: "String reference = REUSE (name resolution failure is a hard error); object shape = CREATE (always).";
|
|
51
|
+
};
|
|
52
|
+
export interface ImmutabilityRule {
|
|
53
|
+
rule_id: string;
|
|
54
|
+
object_type: string;
|
|
55
|
+
trigger: "create" | "publish";
|
|
56
|
+
immutable_fields: string[];
|
|
57
|
+
mutable_after?: string[];
|
|
58
|
+
message: string;
|
|
59
|
+
}
|
|
60
|
+
export declare const IMMUTABILITY_RULES: readonly ImmutabilityRule[];
|
|
61
|
+
export type OperationClass = "LOCAL_ONLY" | "ONCHAIN" | "QUERY" | "ENCRYPTED";
|
|
62
|
+
export declare const OPERATION_TYPE_CLASSIFICATION: Record<OperationClass, readonly string[]>;
|
|
63
|
+
export interface OperationClassMeta {
|
|
64
|
+
gas: boolean;
|
|
65
|
+
confirmation_required: boolean;
|
|
66
|
+
note: string;
|
|
67
|
+
}
|
|
68
|
+
export declare const OPERATION_CLASS_META: Record<OperationClass, OperationClassMeta>;
|
|
69
|
+
export declare function classifyTool(toolName: string): OperationClass | undefined;
|
|
70
|
+
export declare const NAMING_CONVENTIONS: {
|
|
71
|
+
readonly scheme: "<projectPrefix>_<type>_<purpose>_<version>";
|
|
72
|
+
readonly parts: {
|
|
73
|
+
readonly project_prefix: {
|
|
74
|
+
readonly example: "shopFunny_";
|
|
75
|
+
readonly purpose: "Prevents cross-project collisions";
|
|
76
|
+
};
|
|
77
|
+
readonly type_prefix: {
|
|
78
|
+
readonly example: "machine_ / guard_ / service_";
|
|
79
|
+
readonly purpose: "Clarifies object type";
|
|
80
|
+
};
|
|
81
|
+
readonly purpose_suffix: {
|
|
82
|
+
readonly example: "serviceWithdraw";
|
|
83
|
+
readonly purpose: "Describes function";
|
|
84
|
+
};
|
|
85
|
+
readonly version_suffix: {
|
|
86
|
+
readonly example: "_v2";
|
|
87
|
+
readonly purpose: "Enables iteration without replaceExistName";
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
readonly entry_id: {
|
|
91
|
+
readonly pattern: "^<object_type>:<name>$";
|
|
92
|
+
readonly example: "service:myshop_service";
|
|
93
|
+
};
|
|
94
|
+
readonly replace_exist_name: {
|
|
95
|
+
readonly default: false;
|
|
96
|
+
readonly false_effect: "Throws error if name is in use — safe default";
|
|
97
|
+
readonly true_effect: "Existing object/account with the same name is suspended/unbound to free the name";
|
|
98
|
+
readonly account_default_forbidden: "replaceExistName:true on the default account (name='') is FORBIDDEN — use suspend() explicitly";
|
|
99
|
+
readonly recommendation: "DISCOURAGED — prefer versioned names (_v1, _v2) for production";
|
|
100
|
+
};
|
|
101
|
+
readonly recommendations: readonly ["Always provide tags on object creation for filtering and management", "Use names as primary identifiers; use short address form (0x1234...def) only for display", "All cross-object references (Guard tables, Service bindings, Machine forwards) use NAMES — resolved per-network at build time"];
|
|
102
|
+
};
|
|
103
|
+
export interface SafetyRiskItem {
|
|
104
|
+
rule_id: string;
|
|
105
|
+
severity: "info" | "warn";
|
|
106
|
+
message: string;
|
|
107
|
+
}
|
|
108
|
+
export declare function checkObjectReuseRules(planned: readonly {
|
|
109
|
+
object_type: string;
|
|
110
|
+
is_new: boolean;
|
|
111
|
+
name?: string;
|
|
112
|
+
}[]): SafetyRiskItem[];
|
|
113
|
+
export declare function checkImmutabilityRules(ops: readonly {
|
|
114
|
+
object_type: string;
|
|
115
|
+
trigger: "create" | "publish";
|
|
116
|
+
name?: string;
|
|
117
|
+
}[]): SafetyRiskItem[];
|
|
118
|
+
export declare const SAFETY_RULES_VERSION = 2;
|
|
@@ -217,7 +217,7 @@ export const CONFIRMATION_RULES = [
|
|
|
217
217
|
bypass_on_explicit_intent: ["test guard", "testing guard", "gen passport", "generate passport"],
|
|
218
218
|
},
|
|
219
219
|
];
|
|
220
|
-
function extractAmount(data) {
|
|
220
|
+
export function extractAmount(data) {
|
|
221
221
|
if (!data)
|
|
222
222
|
return null;
|
|
223
223
|
const candidates = [
|
|
@@ -237,4 +237,168 @@ function extractAmount(data) {
|
|
|
237
237
|
}
|
|
238
238
|
return null;
|
|
239
239
|
}
|
|
240
|
-
export const
|
|
240
|
+
export const OBJECT_REUSE_RULES = [
|
|
241
|
+
{
|
|
242
|
+
rule_id: "REUSE-001",
|
|
243
|
+
object_type: "permission",
|
|
244
|
+
recommendation: "strongly_recommended",
|
|
245
|
+
reason: "Centralized permission control across all services",
|
|
246
|
+
ask_user: "Do you have an existing Permission to reuse? Provide the name or ID.",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
rule_id: "REUSE-002",
|
|
250
|
+
object_type: "machine",
|
|
251
|
+
recommendation: "recommended",
|
|
252
|
+
reason: "Save design time for similar processes",
|
|
253
|
+
ask_user: "Do you have an existing Machine whose workflow fits? Provide the name or ID.",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
rule_id: "REUSE-003",
|
|
257
|
+
object_type: "guard",
|
|
258
|
+
recommendation: "recommended",
|
|
259
|
+
reason: "Avoid redundant validation rules",
|
|
260
|
+
ask_user: "Do you have an existing Guard with matching validation logic? Provide the name or ID.",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
rule_id: "REUSE-004",
|
|
264
|
+
object_type: "contact",
|
|
265
|
+
recommendation: "recommended",
|
|
266
|
+
reason: "Single point of customer-service management",
|
|
267
|
+
ask_user: "Do you have an existing Contact for customer service? Provide the name or ID.",
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
rule_id: "REUSE-005",
|
|
271
|
+
object_type: "arbitration",
|
|
272
|
+
recommendation: "always_reuse",
|
|
273
|
+
reason: "Customers choose from established arbiters; creating a new Arbitration is an operator-level decision",
|
|
274
|
+
ask_user: "Which existing Arbitration service should disputes route to? Provide the name or ID.",
|
|
275
|
+
},
|
|
276
|
+
];
|
|
277
|
+
export const CREATE_VS_MODIFY_PATTERN = {
|
|
278
|
+
reuse_form: "string",
|
|
279
|
+
create_form: "object",
|
|
280
|
+
resolution_api: "GetObjectExisted",
|
|
281
|
+
note: "String reference = REUSE (name resolution failure is a hard error); object shape = CREATE (always).",
|
|
282
|
+
};
|
|
283
|
+
export const IMMUTABILITY_RULES = [
|
|
284
|
+
{
|
|
285
|
+
rule_id: "IMMUT-001",
|
|
286
|
+
object_type: "machine",
|
|
287
|
+
trigger: "publish",
|
|
288
|
+
immutable_fields: ["nodes", "pairs", "forwards"],
|
|
289
|
+
message: "Machine topology is immutable after publish — verify all nodes/forwards via machineNode2file BEFORE publishing",
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
rule_id: "IMMUT-002",
|
|
293
|
+
object_type: "service",
|
|
294
|
+
trigger: "publish",
|
|
295
|
+
immutable_fields: ["machine", "order_allocators", "arbitrations"],
|
|
296
|
+
mutable_after: ["sales"],
|
|
297
|
+
message: "Service.machine, order_allocators and arbitrations are frozen after publish; sales remains fully modifiable (L3) without pause",
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
rule_id: "IMMUT-003",
|
|
301
|
+
object_type: "guard",
|
|
302
|
+
trigger: "create",
|
|
303
|
+
immutable_fields: ["table", "root", "rely"],
|
|
304
|
+
message: "Guard is CREATE-only and immutable — cannot be edited or deleted after creation. To change: export via guard2file → edit → CREATE new → rebind",
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
export const OPERATION_TYPE_CLASSIFICATION = {
|
|
308
|
+
LOCAL_ONLY: [
|
|
309
|
+
"account_operation",
|
|
310
|
+
"local_mark_operation",
|
|
311
|
+
"local_info_operation",
|
|
312
|
+
"project_operation",
|
|
313
|
+
"config_operation",
|
|
314
|
+
],
|
|
315
|
+
ONCHAIN: [
|
|
316
|
+
"onchain_operations",
|
|
317
|
+
"wip_file",
|
|
318
|
+
"bridge_operation",
|
|
319
|
+
"messenger_operation",
|
|
320
|
+
],
|
|
321
|
+
QUERY: [
|
|
322
|
+
"query_toolkit",
|
|
323
|
+
"onchain_table_data",
|
|
324
|
+
"onchain_events",
|
|
325
|
+
"guard2file",
|
|
326
|
+
"machineNode2file",
|
|
327
|
+
"schema_query",
|
|
328
|
+
"wowok_buildin_info",
|
|
329
|
+
"trust_score",
|
|
330
|
+
],
|
|
331
|
+
ENCRYPTED: [
|
|
332
|
+
"messenger_operation",
|
|
333
|
+
],
|
|
334
|
+
};
|
|
335
|
+
export const OPERATION_CLASS_META = {
|
|
336
|
+
LOCAL_ONLY: { gas: false, confirmation_required: false, note: "Local state only — no gas, no confirmation needed" },
|
|
337
|
+
ONCHAIN: { gas: true, confirmation_required: true, note: "On-chain write — gas consumed, explicit user confirmation REQUIRED before execution" },
|
|
338
|
+
QUERY: { gas: false, confirmation_required: false, note: "Read-only — no gas, no confirmation needed" },
|
|
339
|
+
ENCRYPTED: { gas: false, confirmation_required: false, note: "Local encryption — no gas, no confirmation needed" },
|
|
340
|
+
};
|
|
341
|
+
export function classifyTool(toolName) {
|
|
342
|
+
if (OPERATION_TYPE_CLASSIFICATION.ENCRYPTED.includes(toolName))
|
|
343
|
+
return "ENCRYPTED";
|
|
344
|
+
for (const cls of ["LOCAL_ONLY", "ONCHAIN", "QUERY"]) {
|
|
345
|
+
if (OPERATION_TYPE_CLASSIFICATION[cls].includes(toolName))
|
|
346
|
+
return cls;
|
|
347
|
+
}
|
|
348
|
+
return undefined;
|
|
349
|
+
}
|
|
350
|
+
export const NAMING_CONVENTIONS = {
|
|
351
|
+
scheme: "<projectPrefix>_<type>_<purpose>_<version>",
|
|
352
|
+
parts: {
|
|
353
|
+
project_prefix: { example: "shopFunny_", purpose: "Prevents cross-project collisions" },
|
|
354
|
+
type_prefix: { example: "machine_ / guard_ / service_", purpose: "Clarifies object type" },
|
|
355
|
+
purpose_suffix: { example: "serviceWithdraw", purpose: "Describes function" },
|
|
356
|
+
version_suffix: { example: "_v2", purpose: "Enables iteration without replaceExistName" },
|
|
357
|
+
},
|
|
358
|
+
entry_id: { pattern: "^<object_type>:<name>$", example: "service:myshop_service" },
|
|
359
|
+
replace_exist_name: {
|
|
360
|
+
default: false,
|
|
361
|
+
false_effect: "Throws error if name is in use — safe default",
|
|
362
|
+
true_effect: "Existing object/account with the same name is suspended/unbound to free the name",
|
|
363
|
+
account_default_forbidden: "replaceExistName:true on the default account (name='') is FORBIDDEN — use suspend() explicitly",
|
|
364
|
+
recommendation: "DISCOURAGED — prefer versioned names (_v1, _v2) for production",
|
|
365
|
+
},
|
|
366
|
+
recommendations: [
|
|
367
|
+
"Always provide tags on object creation for filtering and management",
|
|
368
|
+
"Use names as primary identifiers; use short address form (0x1234...def) only for display",
|
|
369
|
+
"All cross-object references (Guard tables, Service bindings, Machine forwards) use NAMES — resolved per-network at build time",
|
|
370
|
+
],
|
|
371
|
+
};
|
|
372
|
+
export function checkObjectReuseRules(planned) {
|
|
373
|
+
const risks = [];
|
|
374
|
+
for (const p of planned) {
|
|
375
|
+
if (!p.is_new)
|
|
376
|
+
continue;
|
|
377
|
+
const rule = OBJECT_REUSE_RULES.find((r) => r.object_type === p.object_type);
|
|
378
|
+
if (!rule)
|
|
379
|
+
continue;
|
|
380
|
+
if (rule.recommendation === "always_reuse" || rule.recommendation === "strongly_recommended") {
|
|
381
|
+
risks.push({
|
|
382
|
+
rule_id: rule.rule_id,
|
|
383
|
+
severity: rule.recommendation === "always_reuse" ? "warn" : "info",
|
|
384
|
+
message: `Creating NEW ${p.object_type}${p.name ? ` "${p.name}"` : ""} — reuse is ${rule.recommendation}: ${rule.reason}. ${rule.ask_user}`,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return risks;
|
|
389
|
+
}
|
|
390
|
+
export function checkImmutabilityRules(ops) {
|
|
391
|
+
const risks = [];
|
|
392
|
+
for (const op of ops) {
|
|
393
|
+
const rule = IMMUTABILITY_RULES.find((r) => r.object_type === op.object_type && r.trigger === op.trigger);
|
|
394
|
+
if (!rule)
|
|
395
|
+
continue;
|
|
396
|
+
risks.push({
|
|
397
|
+
rule_id: rule.rule_id,
|
|
398
|
+
severity: "warn",
|
|
399
|
+
message: `${op.object_type}${op.name ? ` "${op.name}"` : ""} ${op.trigger}: ${rule.message}. Immutable: [${rule.immutable_fields.join(", ")}]${rule.mutable_after ? `. Still mutable: [${rule.mutable_after.join(", ")}]` : ""}`,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
return risks;
|
|
403
|
+
}
|
|
404
|
+
export const SAFETY_RULES_VERSION = 2;
|
|
@@ -50,4 +50,4 @@ export declare function getScenarioMode(name: IndustryModeName): ScenarioMode |
|
|
|
50
50
|
export declare function listScenarioModes(): ScenarioMode[];
|
|
51
51
|
export declare function getShippedModes(): ScenarioMode[];
|
|
52
52
|
export declare function getModeCompositions(name: IndustryModeName): ModeComposition[];
|
|
53
|
-
export declare const SCENARIO_MODES_VERSION =
|
|
53
|
+
export declare const SCENARIO_MODES_VERSION = 2;
|
|
@@ -18,8 +18,7 @@ export const SCENARIO_MODES = [
|
|
|
18
18
|
{ name: "delivered", role: "Deliverable available for review" },
|
|
19
19
|
{ name: "accepted", role: "Customer signs acceptance" },
|
|
20
20
|
{ name: "completed", role: "Funds released to provider" },
|
|
21
|
-
{ name: "
|
|
22
|
-
{ name: "cancelled", role: "Pre-delivery cancellation" },
|
|
21
|
+
{ name: "cancelled", role: "Pre-delivery cancellation — triggers refund Allocator" },
|
|
23
22
|
],
|
|
24
23
|
guards: [
|
|
25
24
|
{ template_id: "buy_guard_identity", host: "service", purpose: "Customer identity check on purchase" },
|
|
@@ -33,13 +32,14 @@ export const SCENARIO_MODES = [
|
|
|
33
32
|
recipient: "signer",
|
|
34
33
|
count: 2,
|
|
35
34
|
mode: "amount",
|
|
36
|
-
description: "100% to provider on
|
|
35
|
+
description: "100% to provider on completed; 100% refund to customer on cancelled (refund Allocator, off-Machine fund routing per R-M1-11)",
|
|
37
36
|
},
|
|
38
37
|
key_risk: "Customer never accepts delivery — provider cannot get paid",
|
|
39
38
|
build_notes: [
|
|
40
39
|
"Use Service `setting_locked_time` to lock rules for the engagement duration",
|
|
41
40
|
"WIP hash on deliverable is mandatory — protects provider in disputes",
|
|
42
41
|
"Acceptance gate is the trust pivot — both parties must agree on criteria",
|
|
42
|
+
"R-M1-11: no 'refunded'/'disputed'/'arb' nodes — refunds route via Allocator (100% to OrderHolder) triggered by 'cancelled', disputes via Arbitration",
|
|
43
43
|
"NEW: Payment exception compensation for delivery delays — provider Treasury auto-compensates customer (§2.13)",
|
|
44
44
|
],
|
|
45
45
|
},
|
|
@@ -62,8 +62,9 @@ export const SCENARIO_MODES = [
|
|
|
62
62
|
{ name: "in_use", role: "Rental period active" },
|
|
63
63
|
{ name: "returned", role: "Customer returns item" },
|
|
64
64
|
{ name: "inspected", role: "Owner inspects returned item" },
|
|
65
|
-
{ name: "
|
|
66
|
-
{ name: "
|
|
65
|
+
{ name: "return_approved", role: "No damage — triggers deposit refund Allocator (100% to customer)" },
|
|
66
|
+
{ name: "damage_confirmed", role: "Damage confirmed via pre+post WIP diff — triggers deposit deduction Allocator" },
|
|
67
|
+
{ name: "completed", role: "Rental finalized — triggers rent Allocator (rent to owner)" },
|
|
67
68
|
],
|
|
68
69
|
guards: [
|
|
69
70
|
{ template_id: "deposit_guard_amount", host: "service", purpose: "Verify deposit amount matches listing" },
|
|
@@ -78,13 +79,14 @@ export const SCENARIO_MODES = [
|
|
|
78
79
|
recipient: "entity",
|
|
79
80
|
count: 3,
|
|
80
81
|
mode: "amount",
|
|
81
|
-
description: "Rent to owner; refund to customer; deduction to owner (
|
|
82
|
+
description: "Rent to owner on completed; deposit refund to customer on return_approved; deposit deduction to owner on damage_confirmed (fund routing via Allocator per R-M1-11)",
|
|
82
83
|
},
|
|
83
84
|
key_risk: "Owner claims damage without pre-rental WIP — customer loses deposit unfairly",
|
|
84
85
|
build_notes: [
|
|
85
86
|
"Pre-rental WIP is non-negotiable — without it, damage claims fail",
|
|
86
87
|
"Deposit must be escrowed, not direct-transferred — enables fair deduction",
|
|
87
88
|
"Inspection gate prevents customer from denying damage",
|
|
89
|
+
"R-M1-11: no 'deposit_refunded'/'deposit_deducted'/'refunded' nodes — deposit refund/deduction flows through Allocator triggered by return_approved/damage_confirmed business states",
|
|
88
90
|
"NEW: Payment exception compensation for return delays — Treasury withdraws scene-bound Payment (§2.13)",
|
|
89
91
|
"NEW: Repository quote_guard for weather/usage data subscription revenue (§2.11)",
|
|
90
92
|
],
|
|
@@ -106,7 +108,7 @@ export const SCENARIO_MODES = [
|
|
|
106
108
|
{ name: "paid", role: "Entry: enrollment and tuition paid via Service.buy(); Machine starts here" },
|
|
107
109
|
{ name: "session_N", role: "Per-session attendance (1..N)" },
|
|
108
110
|
{ name: "completed", role: "All sessions delivered" },
|
|
109
|
-
{ name: "
|
|
111
|
+
{ name: "withdrawn", role: "Enrollment cancelled mid-course — triggers unearned-tuition refund Allocator" },
|
|
110
112
|
],
|
|
111
113
|
guards: [
|
|
112
114
|
{ template_id: "attendance_guard_signer", host: "machine", purpose: "Per-session student attendance signature" },
|
|
@@ -117,7 +119,7 @@ export const SCENARIO_MODES = [
|
|
|
117
119
|
recipient: "entity",
|
|
118
120
|
count: 1,
|
|
119
121
|
mode: "amount",
|
|
120
|
-
description: "1/N of tuition released per session attendance; unearned portion
|
|
122
|
+
description: "1/N of tuition released per session attendance; unearned portion refunded to student via Allocator on withdrawn (per R-M1-11)",
|
|
121
123
|
},
|
|
122
124
|
key_risk: "Tutoring institutions run away with prepaid tuition",
|
|
123
125
|
build_notes: [
|
|
@@ -147,7 +149,7 @@ export const SCENARIO_MODES = [
|
|
|
147
149
|
{ name: "segment_D2", role: "Segment 2 (e.g., guided tour)" },
|
|
148
150
|
{ name: "returned", role: "Trip completed, customer returns" },
|
|
149
151
|
{ name: "completed", role: "All segments delivered, funds released" },
|
|
150
|
-
{ name: "
|
|
152
|
+
{ name: "interrupted", role: "Trip interrupted — triggers refund Allocator (undelivered segments) or Arbitration" },
|
|
151
153
|
],
|
|
152
154
|
guards: [
|
|
153
155
|
{ template_id: "segment_guard_wip", host: "machine", purpose: "Per-segment arrival WIP (hotel check-in, etc.)" },
|
|
@@ -160,7 +162,7 @@ export const SCENARIO_MODES = [
|
|
|
160
162
|
recipient: "entity",
|
|
161
163
|
count: 3,
|
|
162
164
|
mode: "amount",
|
|
163
|
-
description: "Deposit 20% to agency, final 80% to agency, then agency-side Allocation splits to hotel/guide/driver per segment",
|
|
165
|
+
description: "Deposit 20% to agency, final 80% to agency, then agency-side Allocation splits to hotel/guide/driver per segment; undelivered segments refunded to customer via Allocator on interrupted (per R-M1-11)",
|
|
164
166
|
},
|
|
165
167
|
key_risk: "Paid in full then service shrinks — multi-tier transparency prevents this",
|
|
166
168
|
build_notes: [
|
|
@@ -316,4 +318,4 @@ export function getShippedModes() {
|
|
|
316
318
|
export function getModeCompositions(name) {
|
|
317
319
|
return MODE_COMPOSITIONS.filter((c) => c.modes.includes(name));
|
|
318
320
|
}
|
|
319
|
-
export const SCENARIO_MODES_VERSION =
|
|
321
|
+
export const SCENARIO_MODES_VERSION = 2;
|
|
@@ -111,7 +111,7 @@ export interface ServiceJsonForConfirm {
|
|
|
111
111
|
};
|
|
112
112
|
compensation_fund_withdraw?: unknown;
|
|
113
113
|
compensation_fund_receive?: unknown;
|
|
114
|
-
|
|
114
|
+
setting_lock_duration_add?: number;
|
|
115
115
|
order_new?: {
|
|
116
116
|
buy: {
|
|
117
117
|
items: Array<{
|
|
@@ -263,7 +263,7 @@ function adaptRiskAssessment(input) {
|
|
|
263
263
|
order_allocators: input.service_json.order_allocators,
|
|
264
264
|
buy_guard: input.service_json.buy_guard,
|
|
265
265
|
compensation_fund_add: input.service_json.compensation_fund_add,
|
|
266
|
-
|
|
266
|
+
setting_lock_duration_add: input.service_json.setting_lock_duration_add,
|
|
267
267
|
compensation_fund_receive: input.service_json.compensation_fund_receive,
|
|
268
268
|
owner_receive: input.service_json.owner_receive,
|
|
269
269
|
pause: input.service_json.pause,
|
|
@@ -761,8 +761,8 @@ function generateConfirmationText(input, checklist, assessment) {
|
|
|
761
761
|
lines.push(`- Compensation fund deposit: ${data.compensation_fund_add.balance}`);
|
|
762
762
|
if (data.compensation_fund_withdraw)
|
|
763
763
|
lines.push(`- ⚠️ Compensation fund withdraw (requires paused + lock expired)`);
|
|
764
|
-
if (data.
|
|
765
|
-
lines.push(`- Setting lock +${data.
|
|
764
|
+
if (data.setting_lock_duration_add !== undefined)
|
|
765
|
+
lines.push(`- Setting lock +${data.setting_lock_duration_add}ms`);
|
|
766
766
|
if (data.order_new)
|
|
767
767
|
lines.push(`- ⚠️ ORDER NEW (8-stage flow, stock deducted at quote)`);
|
|
768
768
|
if (data.builder)
|
|
@@ -58,7 +58,7 @@ export function buildServiceContext(input) {
|
|
|
58
58
|
order_allocators: input.service_json.order_allocators,
|
|
59
59
|
buy_guard: input.service_json.buy_guard,
|
|
60
60
|
compensation_fund_add: input.service_json.compensation_fund_add,
|
|
61
|
-
|
|
61
|
+
setting_lock_duration_add: input.service_json.setting_lock_duration_add,
|
|
62
62
|
compensation_fund_receive: input.service_json.compensation_fund_receive,
|
|
63
63
|
owner_receive: input.service_json.owner_receive,
|
|
64
64
|
pause: input.service_json.pause,
|
|
@@ -15,7 +15,7 @@ export const SERVICE_PERMISSIONS = [
|
|
|
15
15
|
{ index: 314, name: "SERVICE_COMPENSATION_FUND_WITHDRAW", description: "Withdraw compensation fund (lock_duration)", governed_operation: "service::compensation_fund_withdraw", post_publish_mutability: "locked_by_duration" },
|
|
16
16
|
{ index: 315, name: "SERVICE_COMPENSATION_FUND_DEPOSIT", description: "Deposit to compensation fund", governed_operation: "service::compensation_fund_add", post_publish_mutability: "mutable" },
|
|
17
17
|
{ index: 316, name: "SERVICE_COMPENSATION_FUND_RECEIVE", description: "Receive compensation fund (lock_duration)", governed_operation: "service::compensation_fund_receive", post_publish_mutability: "locked_by_duration" },
|
|
18
|
-
{ index: 317, name: "
|
|
18
|
+
{ index: 317, name: "SERVICE_COMPENSATION_LOCK_DURATION_ADD", description: "Extend setting_lock_duration (only-increase)", governed_operation: "service::setting_lock_duration_add", post_publish_mutability: "mutable" },
|
|
19
19
|
{ index: 318, name: "SERVICE_REWARD", description: "Add/remove Reward references (locked)", governed_operation: "service::reward_add/remove/clear", post_publish_mutability: "locked_by_duration" },
|
|
20
20
|
{ index: 319, name: "SERVICE_OWNER_RECEIVE", description: "Receive Payment/objects to owner", governed_operation: "service::owner_receive", post_publish_mutability: "mutable" },
|
|
21
21
|
{ index: 320, name: "SERVICE_UM", description: "Bind/unbind Contact as UM", governed_operation: "service::um_set/um_none", post_publish_mutability: "mutable" },
|
|
@@ -65,7 +65,7 @@ export interface ServiceRiskCheckContext {
|
|
|
65
65
|
compensation_fund_add?: {
|
|
66
66
|
balance: string | number;
|
|
67
67
|
};
|
|
68
|
-
|
|
68
|
+
setting_lock_duration_add?: number;
|
|
69
69
|
compensation_fund_receive?: unknown;
|
|
70
70
|
owner_receive?: unknown;
|
|
71
71
|
pause?: boolean;
|
|
@@ -370,18 +370,18 @@ const R_S_4_02 = {
|
|
|
370
370
|
category: "lifecycle",
|
|
371
371
|
trigger: "setting_lock_duration add — only-increase mechanism",
|
|
372
372
|
check: (ctx) => {
|
|
373
|
-
if (ctx.
|
|
373
|
+
if (ctx.setting_lock_duration_add === undefined)
|
|
374
374
|
return null;
|
|
375
375
|
return {
|
|
376
376
|
id: "R-S-4-02",
|
|
377
377
|
level: "MEDIUM",
|
|
378
378
|
category: "lifecycle",
|
|
379
379
|
title: "setting_lock_duration can only INCREASE",
|
|
380
|
-
description: `Adding ${ctx.
|
|
380
|
+
description: `Adding ${ctx.setting_lock_duration_add} ms to setting_lock_duration. New value = old + input (safe_add). Cannot be decreased — protects customers from owner reducing lock to withdraw compensation_fund faster.`,
|
|
381
381
|
affected_stakeholders: ["owner", "customer"],
|
|
382
382
|
scenario: "Owner extends lock period to build trust",
|
|
383
383
|
mitigation: "Ensure extension is intentional. Lock affects rewards/compensation_fund_withdraw/compensation_fund_receive.",
|
|
384
|
-
evidence: `add_ms=${ctx.
|
|
384
|
+
evidence: `add_ms=${ctx.setting_lock_duration_add}`,
|
|
385
385
|
};
|
|
386
386
|
},
|
|
387
387
|
};
|
|
@@ -191,7 +191,7 @@ export const SERVICE_TEMPLATES = [
|
|
|
191
191
|
permission: p.permission_address,
|
|
192
192
|
arbitrations: { op: "add", objects: p.arbitration_addresses },
|
|
193
193
|
compensation_fund_add: { balance: p.compensation_fund_balance },
|
|
194
|
-
|
|
194
|
+
setting_lock_duration_add: p.setting_lock_duration_ms,
|
|
195
195
|
sales: { op: "add", sales: p.service_items },
|
|
196
196
|
order_allocators: [
|
|
197
197
|
{
|
|
@@ -234,7 +234,7 @@ export const SERVICE_TEMPLATES = [
|
|
|
234
234
|
permission: p.permission_address,
|
|
235
235
|
arbitrations: { op: "add", objects: p.arbitration_addresses },
|
|
236
236
|
compensation_fund_add: { balance: p.initial_deposit },
|
|
237
|
-
|
|
237
|
+
setting_lock_duration_add: p.lock_duration_ms,
|
|
238
238
|
sales: { op: "add", sales: p.service_items },
|
|
239
239
|
order_allocators: [
|
|
240
240
|
{
|
|
@@ -185,10 +185,10 @@ export const SEMANTIC_TO_SCHEMA_RULES = [
|
|
|
185
185
|
pattern_name: "Extend setting_lock_duration",
|
|
186
186
|
semantic_intent: "Add milliseconds to setting_lock_duration (only-increase mechanism)",
|
|
187
187
|
match_keywords: ["setting_lock_duration", "lock_duration", "lock period", "extend lock"],
|
|
188
|
-
schema_fields: ["object", "
|
|
188
|
+
schema_fields: ["object", "setting_lock_duration_add"],
|
|
189
189
|
example_json: {
|
|
190
190
|
object: "0xSERVICE_ADDRESS",
|
|
191
|
-
|
|
191
|
+
setting_lock_duration_add: 2592000000,
|
|
192
192
|
},
|
|
193
193
|
reverse_explanation: "Only-increase (safe_add). Default 2592000000ms (30 days). Affects rewards/compensation_fund_withdraw/compensation_fund_receive mutability windows.",
|
|
194
194
|
},
|
|
@@ -315,8 +315,8 @@ export const SCHEMA_TO_SEMANTIC_RULES = [
|
|
|
315
315
|
},
|
|
316
316
|
{
|
|
317
317
|
element_type: "field",
|
|
318
|
-
type_name: "
|
|
319
|
-
semantic_explanation: "Extend setting_lock_duration (only-increase, safe_add). Index 317 (
|
|
318
|
+
type_name: "setting_lock_duration_add",
|
|
319
|
+
semantic_explanation: "Extend setting_lock_duration (only-increase, safe_add). Index 317 (SERVICE_COMPENSATION_LOCK_DURATION_ADD).",
|
|
320
320
|
},
|
|
321
321
|
{
|
|
322
322
|
element_type: "field",
|
|
@@ -454,7 +454,7 @@ export const SERVICE_CONSTRAINT_RULES = [
|
|
|
454
454
|
id: "MC-S-16",
|
|
455
455
|
category: "lifecycle",
|
|
456
456
|
rule: `setting_lock_duration only-increase (safe_add) — cannot be decreased; protects customers`,
|
|
457
|
-
applies_to: ["
|
|
457
|
+
applies_to: ["setting_lock_duration_add"],
|
|
458
458
|
},
|
|
459
459
|
{
|
|
460
460
|
id: "MC-S-17",
|
|
@@ -572,8 +572,8 @@ export function explainServiceCallData(data) {
|
|
|
572
572
|
if (data.compensation_fund_receive) {
|
|
573
573
|
lines.push(`- Compensation fund receive (locked by duration)`);
|
|
574
574
|
}
|
|
575
|
-
if (data.
|
|
576
|
-
lines.push(`- Setting lock duration +${data.
|
|
575
|
+
if (data.setting_lock_duration_add !== undefined) {
|
|
576
|
+
lines.push(`- Setting lock duration +${data.setting_lock_duration_add}ms (only-increase)`);
|
|
577
577
|
}
|
|
578
578
|
if (data.order_new) {
|
|
579
579
|
const o = data.order_new;
|