@wowok/agent-mcp 2.4.3 → 2.5.0
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/config/runtime.d.ts +4 -0
- package/dist/config/runtime.js +29 -5
- package/dist/harness/auto-escalation.d.ts +27 -0
- package/dist/harness/auto-escalation.js +68 -0
- package/dist/index.js +21 -0
- package/dist/knowledge/allocation-confirm.d.ts +115 -0
- package/dist/knowledge/allocation-confirm.js +534 -0
- package/dist/knowledge/allocation-context.d.ts +58 -0
- package/dist/knowledge/allocation-context.js +249 -0
- package/dist/knowledge/allocation-ledger.d.ts +67 -0
- package/dist/knowledge/allocation-ledger.js +463 -0
- package/dist/knowledge/allocation-puzzle.d.ts +135 -0
- package/dist/knowledge/allocation-puzzle.js +298 -0
- package/dist/knowledge/allocation-risk.d.ts +78 -0
- package/dist/knowledge/allocation-risk.js +568 -0
- package/dist/knowledge/allocation-templates.d.ts +38 -0
- package/dist/knowledge/allocation-templates.js +970 -0
- package/dist/knowledge/allocation-translation.d.ts +72 -0
- package/dist/knowledge/allocation-translation.js +585 -0
- package/dist/knowledge/arb-risk.d.ts +37 -0
- package/dist/knowledge/arb-risk.js +210 -0
- package/dist/knowledge/arbitration-confirm.d.ts +135 -0
- package/dist/knowledge/arbitration-confirm.js +559 -0
- package/dist/knowledge/arbitration-context.d.ts +81 -0
- package/dist/knowledge/arbitration-context.js +505 -0
- package/dist/knowledge/arbitration-ledger.d.ts +62 -0
- package/dist/knowledge/arbitration-ledger.js +521 -0
- package/dist/knowledge/arbitration-puzzle.d.ts +84 -0
- package/dist/knowledge/arbitration-puzzle.js +304 -0
- package/dist/knowledge/arbitration-risk.d.ts +112 -0
- package/dist/knowledge/arbitration-risk.js +433 -0
- package/dist/knowledge/arbitration-templates.d.ts +38 -0
- package/dist/knowledge/arbitration-templates.js +276 -0
- package/dist/knowledge/arbitration-translation.d.ts +91 -0
- package/dist/knowledge/arbitration-translation.js +487 -0
- package/dist/knowledge/bridge-risk.d.ts +36 -0
- package/dist/knowledge/bridge-risk.js +263 -0
- package/dist/knowledge/contact-risk.d.ts +32 -0
- package/dist/knowledge/contact-risk.js +200 -0
- package/dist/knowledge/demand-confirm.d.ts +32 -0
- package/dist/knowledge/demand-confirm.js +206 -0
- package/dist/knowledge/demand-risk.d.ts +30 -0
- package/dist/knowledge/demand-risk.js +240 -0
- package/dist/knowledge/demand-translation.d.ts +55 -0
- package/dist/knowledge/demand-translation.js +354 -0
- package/dist/knowledge/deployment-scanner.d.ts +63 -0
- package/dist/knowledge/deployment-scanner.js +762 -0
- package/dist/knowledge/examples-scanner-cli.d.ts +1 -0
- package/dist/knowledge/examples-scanner-cli.js +26 -0
- package/dist/knowledge/examples-scanner.d.ts +121 -0
- package/dist/knowledge/examples-scanner.js +825 -0
- package/dist/knowledge/flywheel-loop.d.ts +3 -0
- package/dist/knowledge/flywheel-loop.js +32 -3
- package/dist/knowledge/glossary.js +3 -1
- package/dist/knowledge/guard-confirm.d.ts +86 -0
- package/dist/knowledge/guard-confirm.js +406 -0
- package/dist/knowledge/guard-context.d.ts +56 -0
- package/dist/knowledge/guard-context.js +287 -0
- package/dist/knowledge/guard-design-patterns.d.ts +37 -0
- package/dist/knowledge/guard-design-patterns.js +257 -0
- package/dist/knowledge/guard-puzzle.js +3 -2
- package/dist/knowledge/guard-risk.d.ts +1 -1
- package/dist/knowledge/guard-risk.js +12 -14
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +6 -5
- package/dist/knowledge/index.d.ts +342 -0
- package/dist/knowledge/index.js +344 -0
- package/dist/knowledge/machine-confirm.d.ts +102 -0
- package/dist/knowledge/machine-confirm.js +559 -0
- package/dist/knowledge/machine-context.d.ts +160 -0
- package/dist/knowledge/machine-context.js +812 -0
- package/dist/knowledge/machine-ledger.d.ts +41 -0
- package/dist/knowledge/machine-ledger.js +315 -0
- package/dist/knowledge/machine-puzzle.d.ts +206 -0
- package/dist/knowledge/machine-puzzle.js +494 -0
- package/dist/knowledge/machine-risk.d.ts +75 -0
- package/dist/knowledge/machine-risk.js +644 -0
- package/dist/knowledge/machine-templates.d.ts +92 -0
- package/dist/knowledge/machine-templates.js +1592 -0
- package/dist/knowledge/machine-topology.d.ts +57 -0
- package/dist/knowledge/machine-topology.js +234 -0
- package/dist/knowledge/machine-translation.d.ts +96 -0
- package/dist/knowledge/machine-translation.js +513 -0
- package/dist/knowledge/mcp-schema-audit-cli.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit-cli.js +45 -0
- package/dist/knowledge/mcp-schema-audit.d.ts +90 -0
- package/dist/knowledge/mcp-schema-audit.js +772 -0
- package/dist/knowledge/onchain-constants.d.ts +4 -0
- package/dist/knowledge/onchain-constants.js +35 -0
- package/dist/knowledge/order-confirm.d.ts +115 -0
- package/dist/knowledge/order-confirm.js +573 -0
- package/dist/knowledge/order-context.d.ts +66 -0
- package/dist/knowledge/order-context.js +390 -0
- package/dist/knowledge/order-ledger.d.ts +69 -0
- package/dist/knowledge/order-ledger.js +341 -0
- package/dist/knowledge/order-puzzle.d.ts +159 -0
- package/dist/knowledge/order-puzzle.js +255 -0
- package/dist/knowledge/order-risk.d.ts +66 -0
- package/dist/knowledge/order-risk.js +653 -0
- package/dist/knowledge/order-templates.d.ts +50 -0
- package/dist/knowledge/order-templates.js +368 -0
- package/dist/knowledge/order-translation.d.ts +78 -0
- package/dist/knowledge/order-translation.js +550 -0
- package/dist/knowledge/passport-confirm.d.ts +130 -0
- package/dist/knowledge/passport-confirm.js +531 -0
- package/dist/knowledge/passport-context.d.ts +59 -0
- package/dist/knowledge/passport-context.js +306 -0
- package/dist/knowledge/passport-ledger.d.ts +48 -0
- package/dist/knowledge/passport-ledger.js +282 -0
- package/dist/knowledge/passport-puzzle.d.ts +108 -0
- package/dist/knowledge/passport-puzzle.js +333 -0
- package/dist/knowledge/passport-risk.d.ts +70 -0
- package/dist/knowledge/passport-risk.js +450 -0
- package/dist/knowledge/passport-templates.d.ts +40 -0
- package/dist/knowledge/passport-templates.js +568 -0
- package/dist/knowledge/passport-translation.d.ts +68 -0
- package/dist/knowledge/passport-translation.js +516 -0
- package/dist/knowledge/payment-risk.d.ts +33 -0
- package/dist/knowledge/payment-risk.js +182 -0
- package/dist/knowledge/permission-confirm.d.ts +110 -0
- package/dist/knowledge/permission-confirm.js +426 -0
- package/dist/knowledge/permission-context.d.ts +58 -0
- package/dist/knowledge/permission-context.js +224 -0
- package/dist/knowledge/permission-ledger.d.ts +38 -0
- package/dist/knowledge/permission-ledger.js +403 -0
- package/dist/knowledge/permission-puzzle.d.ts +122 -0
- package/dist/knowledge/permission-puzzle.js +173 -0
- package/dist/knowledge/permission-risk.d.ts +76 -0
- package/dist/knowledge/permission-risk.js +411 -0
- package/dist/knowledge/permission-templates.d.ts +38 -0
- package/dist/knowledge/permission-templates.js +234 -0
- package/dist/knowledge/permission-translation.d.ts +57 -0
- package/dist/knowledge/permission-translation.js +350 -0
- package/dist/knowledge/personal-risk.d.ts +36 -0
- package/dist/knowledge/personal-risk.js +212 -0
- package/dist/knowledge/progress-confirm.d.ts +108 -0
- package/dist/knowledge/progress-confirm.js +456 -0
- package/dist/knowledge/progress-context.d.ts +123 -0
- package/dist/knowledge/progress-context.js +452 -0
- package/dist/knowledge/progress-ledger.d.ts +63 -0
- package/dist/knowledge/progress-ledger.js +327 -0
- package/dist/knowledge/progress-puzzle.d.ts +82 -0
- package/dist/knowledge/progress-puzzle.js +219 -0
- package/dist/knowledge/progress-risk.d.ts +74 -0
- package/dist/knowledge/progress-risk.js +461 -0
- package/dist/knowledge/progress-templates.d.ts +38 -0
- package/dist/knowledge/progress-templates.js +228 -0
- package/dist/knowledge/progress-translation.d.ts +52 -0
- package/dist/knowledge/progress-translation.js +401 -0
- package/dist/knowledge/proof-confirm.d.ts +31 -0
- package/dist/knowledge/proof-confirm.js +187 -0
- package/dist/knowledge/proof-risk.d.ts +33 -0
- package/dist/knowledge/proof-risk.js +207 -0
- package/dist/knowledge/proof-translation.d.ts +52 -0
- package/dist/knowledge/proof-translation.js +283 -0
- package/dist/knowledge/registrar-risk.d.ts +34 -0
- package/dist/knowledge/registrar-risk.js +217 -0
- package/dist/knowledge/repository-confirm.d.ts +36 -0
- package/dist/knowledge/repository-confirm.js +242 -0
- package/dist/knowledge/repository-risk.d.ts +40 -0
- package/dist/knowledge/repository-risk.js +312 -0
- package/dist/knowledge/repository-translation.d.ts +58 -0
- package/dist/knowledge/repository-translation.js +422 -0
- package/dist/knowledge/resource-risk.d.ts +32 -0
- package/dist/knowledge/resource-risk.js +157 -0
- package/dist/knowledge/reward-confirm.d.ts +113 -0
- package/dist/knowledge/reward-confirm.js +496 -0
- package/dist/knowledge/reward-context.d.ts +127 -0
- package/dist/knowledge/reward-context.js +504 -0
- package/dist/knowledge/reward-ledger.d.ts +96 -0
- package/dist/knowledge/reward-ledger.js +502 -0
- package/dist/knowledge/reward-puzzle.d.ts +97 -0
- package/dist/knowledge/reward-puzzle.js +288 -0
- package/dist/knowledge/reward-risk.d.ts +84 -0
- package/dist/knowledge/reward-risk.js +545 -0
- package/dist/knowledge/reward-translation.d.ts +58 -0
- package/dist/knowledge/reward-translation.js +501 -0
- package/dist/knowledge/safety-rules.js +11 -3
- package/dist/knowledge/scenario-modes.d.ts +53 -0
- package/dist/knowledge/scenario-modes.js +302 -0
- package/dist/knowledge/service-confirm.d.ts +152 -0
- package/dist/knowledge/service-confirm.js +699 -0
- package/dist/knowledge/service-context.d.ts +66 -0
- package/dist/knowledge/service-context.js +403 -0
- package/dist/knowledge/service-ledger.d.ts +71 -0
- package/dist/knowledge/service-ledger.js +609 -0
- package/dist/knowledge/service-puzzle.d.ts +158 -0
- package/dist/knowledge/service-puzzle.js +236 -0
- package/dist/knowledge/service-risk.d.ts +108 -0
- package/dist/knowledge/service-risk.js +615 -0
- package/dist/knowledge/service-templates.d.ts +39 -0
- package/dist/knowledge/service-templates.js +418 -0
- package/dist/knowledge/service-translation.d.ts +103 -0
- package/dist/knowledge/service-translation.js +622 -0
- package/dist/knowledge/tools-reference.d.ts +17 -0
- package/dist/knowledge/tools-reference.js +151 -0
- package/dist/knowledge/treasury-confirm.d.ts +133 -0
- package/dist/knowledge/treasury-confirm.js +512 -0
- package/dist/knowledge/treasury-context.d.ts +64 -0
- package/dist/knowledge/treasury-context.js +363 -0
- package/dist/knowledge/treasury-ledger.d.ts +42 -0
- package/dist/knowledge/treasury-ledger.js +300 -0
- package/dist/knowledge/treasury-puzzle.d.ts +163 -0
- package/dist/knowledge/treasury-puzzle.js +216 -0
- package/dist/knowledge/treasury-risk.d.ts +86 -0
- package/dist/knowledge/treasury-risk.js +440 -0
- package/dist/knowledge/treasury-templates.d.ts +38 -0
- package/dist/knowledge/treasury-templates.js +316 -0
- package/dist/knowledge/treasury-translation.d.ts +78 -0
- package/dist/knowledge/treasury-translation.js +498 -0
- package/dist/knowledge/util-risk.d.ts +30 -0
- package/dist/knowledge/util-risk.js +135 -0
- package/dist/project/business-puzzle.d.ts +47 -0
- package/dist/project/business-puzzle.js +372 -0
- package/dist/project/deployment-doc.d.ts +61 -0
- package/dist/project/deployment-doc.js +432 -0
- package/dist/project/risk-aggregator.d.ts +50 -0
- package/dist/project/risk-aggregator.js +280 -0
- package/dist/project/substep-trace.d.ts +130 -0
- package/dist/project/substep-trace.js +332 -0
- package/dist/schema/call/allocation.d.ts +34 -34
- package/dist/schema/call/arbitration.d.ts +141 -141
- package/dist/schema/call/base.d.ts +386 -386
- package/dist/schema/call/base.js +3 -3
- package/dist/schema/call/bridge-handler.d.ts +5 -2
- package/dist/schema/call/bridge.d.ts +159 -159
- package/dist/schema/call/contact.d.ts +110 -110
- package/dist/schema/call/demand.d.ts +76 -76
- package/dist/schema/call/handler.d.ts +2 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +58 -58
- package/dist/schema/call/order.d.ts +98 -110
- package/dist/schema/call/permission-handler.d.ts +5 -0
- package/dist/schema/call/permission-handler.js +54 -0
- package/dist/schema/call/permission.d.ts +108 -108
- package/dist/schema/call/personal.d.ts +14 -14
- package/dist/schema/call/progress.d.ts +57 -72
- package/dist/schema/call/progress.js +7 -4
- package/dist/schema/call/proof.d.ts +18 -18
- package/dist/schema/call/proof.js +12 -7
- package/dist/schema/call/repository.d.ts +154 -154
- package/dist/schema/call/reward.d.ts +55 -55
- package/dist/schema/call/service.d.ts +231 -231
- package/dist/schema/call/treasury.d.ts +93 -93
- package/dist/schema/config/index.d.ts +178 -5
- package/dist/schema/config/index.js +52 -1
- package/dist/schema/local/index.d.ts +3554 -836
- package/dist/schema/local/index.js +2 -1
- package/dist/schema/messenger/index.d.ts +162 -162
- package/dist/schema/operations.d.ts +1058 -1074
- package/dist/schema/operations.js +7 -1
- package/dist/schema/project/index.d.ts +1392 -6
- package/dist/schema/project/index.js +426 -2
- package/dist/schema/query/index.d.ts +672 -672
- package/dist/schema/schema-query/index.d.ts +23 -3
- package/dist/schema/schema-query/index.js +13 -2
- package/dist/schema/sync-layer4.d.ts +21 -0
- package/dist/schema/sync-layer4.js +261 -0
- package/dist/schema/trust/index.d.ts +26 -26
- package/dist/schemas/account_operation.output.json +718 -0
- package/dist/schemas/config_operation.output.json +173 -0
- package/dist/schemas/index.json +9 -1
- package/dist/schemas/local_info_operation.output.json +718 -0
- package/dist/schemas/local_mark_operation.output.json +718 -0
- package/dist/schemas/onchain_operations.output.json +3 -2
- package/dist/schemas/onchain_operations.schema.json +1802 -313
- package/dist/schemas/onchain_operations_allocation.schema.json +2 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
- package/dist/schemas/onchain_operations_contact.schema.json +2 -1
- package/dist/schemas/onchain_operations_demand.schema.json +2 -1
- package/dist/schemas/onchain_operations_gen_passport.schema.json +878 -872
- package/dist/schemas/onchain_operations_gen_proof.schema.json +273 -0
- package/dist/schemas/onchain_operations_guard.schema.json +584 -70
- package/dist/schemas/onchain_operations_machine.schema.json +2 -1
- package/dist/schemas/onchain_operations_order.schema.json +13 -9
- package/dist/schemas/onchain_operations_payment.schema.json +2 -1
- package/dist/schemas/onchain_operations_permission.schema.json +2 -1
- package/dist/schemas/onchain_operations_personal.schema.json +2 -1
- package/dist/schemas/onchain_operations_progress.schema.json +14 -10
- package/dist/schemas/onchain_operations_proof.schema.json +699 -0
- package/dist/schemas/onchain_operations_repository.schema.json +2 -1
- package/dist/schemas/onchain_operations_reward.schema.json +2 -1
- package/dist/schemas/onchain_operations_service.schema.json +2 -1
- package/dist/schemas/onchain_operations_treasury.schema.json +2 -1
- package/dist/schemas/onchain_table_data.schema.json +32 -1
- package/dist/schemas/project_operation.output.json +879 -0
- package/dist/schemas/project_operation.schema.json +473 -2
- package/dist/schemas/query_toolkit.output.json +14906 -6
- package/dist/schemas/schema_query.output.json +38 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/handlers/config.d.ts +1 -1
- package/dist/tools/handlers/config.js +21 -18
- package/dist/tools/handlers/file-export.d.ts +2 -2
- package/dist/tools/handlers/local.d.ts +3 -30
- package/dist/tools/handlers/local.js +14 -3
- package/dist/tools/handlers/messenger.d.ts +1 -1
- package/dist/tools/handlers/messenger.js +2 -1
- package/dist/tools/handlers/onchain.d.ts +1 -1
- package/dist/tools/handlers/onchain.js +24 -22
- package/dist/tools/handlers/project.d.ts +1 -1
- package/dist/tools/handlers/project.js +258 -18
- package/dist/tools/handlers/query.d.ts +4 -4
- package/dist/tools/handlers/schema-query.d.ts +1 -1
- package/dist/tools/handlers/schema-query.js +21 -20
- package/dist/tools/handlers/trust.d.ts +1 -1
- package/dist/tools/handlers/trust.js +2 -2
- package/dist/tools/handlers/wip.d.ts +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +55 -8
- package/dist/tools/rules-hook.d.ts +1 -1
- package/dist/tools/rules-hook.js +3 -2
- package/dist/tools/shared.d.ts +13 -22
- package/dist/tools/types.d.ts +5 -5
- package/dist/tools/wrap.d.ts +10 -2
- package/dist/tools/wrap.js +212 -0
- package/package.json +3 -3
|
@@ -0,0 +1,609 @@
|
|
|
1
|
+
export const SERVICE_PERMISSIONS = [
|
|
2
|
+
{ index: 300, name: "SERVICE_NEW", description: "Create new Service", governed_operation: "service::new", post_publish_mutability: "na" },
|
|
3
|
+
{ index: 301, name: "SERVICE_DESCRIPTION", description: "Modify Service description", governed_operation: "service::description_set", post_publish_mutability: "mutable" },
|
|
4
|
+
{ index: 303, name: "SERVICE_LOCATION", description: "Set Service location/URL", governed_operation: "service::location_set", post_publish_mutability: "mutable" },
|
|
5
|
+
{ index: 304, name: "SERVICE_REPOSITORY", description: "Add/remove Repository references", governed_operation: "service::repository_add/remove/clear", post_publish_mutability: "mutable" },
|
|
6
|
+
{ index: 305, name: "SERVICE_SALES", description: "Add/set/remove/clear sales items", governed_operation: "service::sales_add/set/remove/clear", post_publish_mutability: "mutable" },
|
|
7
|
+
{ index: 306, name: "SERVICE_MACHINE", description: "Bind/unbind Machine workflow template", governed_operation: "service::machine_set/machine_none", post_publish_mutability: "immutable" },
|
|
8
|
+
{ index: 307, name: "SERVICE_BUY_GUARD", description: "Set/clear buy Guard (post-publish mutable)", governed_operation: "service::buy_guard_set/buy_guard_none", post_publish_mutability: "mutable" },
|
|
9
|
+
{ index: 308, name: "SERVICE_ARBITRATION", description: "Add/remove Arbitration references", governed_operation: "service::arbitration_add/remove/clear", post_publish_mutability: "immutable" },
|
|
10
|
+
{ index: 309, name: "SERVICE_CUSTOMER_INFO_REQUIRED", description: "Set customer required info fields", governed_operation: "service::customer_required_set", post_publish_mutability: "mutable" },
|
|
11
|
+
{ index: 310, name: "SERVICE_PAUSE", description: "Pause/resume Service (block new orders)", governed_operation: "service::pause", post_publish_mutability: "mutable" },
|
|
12
|
+
{ index: 311, name: "SERVICE_PUBLISH", description: "Publish Service (IRREVERSIBLE)", governed_operation: "service::publish", post_publish_mutability: "one_shot" },
|
|
13
|
+
{ index: 312, name: "SERVICE_DISCOUNT", description: "Issue/discount_destroy discount coupons", governed_operation: "service::discount", post_publish_mutability: "mutable" },
|
|
14
|
+
{ index: 313, name: "SERVICE_ORDER_ALLOCATOR", description: "Set order allocator strategy", governed_operation: "service::order_allocators_set", post_publish_mutability: "immutable" },
|
|
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
|
+
{ index: 315, name: "SERVICE_COMPENSATION_FUND_DEPOSIT", description: "Deposit to compensation fund", governed_operation: "service::compensation_fund_add", post_publish_mutability: "mutable" },
|
|
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: "SERVICE_COMPENSATION_LOCKED_TIME_ADD", description: "Extend setting_lock_duration (only-increase)", governed_operation: "service::setting_lock_duration_add", post_publish_mutability: "mutable" },
|
|
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
|
+
{ index: 319, name: "SERVICE_OWNER_RECEIVE", description: "Receive Payment/objects to owner", governed_operation: "service::owner_receive", post_publish_mutability: "mutable" },
|
|
21
|
+
{ index: 320, name: "SERVICE_UM", description: "Bind/unbind Contact as UM", governed_operation: "service::um_set/um_none", post_publish_mutability: "mutable" },
|
|
22
|
+
];
|
|
23
|
+
export const SERVICE_ORDER_FLOW_STAGES = [
|
|
24
|
+
{
|
|
25
|
+
stage: 1,
|
|
26
|
+
name: "pre_check",
|
|
27
|
+
preconditions: [
|
|
28
|
+
"Service.bPublished == true (else E_SERVICE_NOT_PUBLISHED)",
|
|
29
|
+
"Service.bPaused == false (else E_SERVICE_PAUSED)",
|
|
30
|
+
"buy_guard (if set) added to guards[] list for verification",
|
|
31
|
+
],
|
|
32
|
+
side_effects: [],
|
|
33
|
+
always_executed: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
stage: 2,
|
|
37
|
+
name: "wip_verify",
|
|
38
|
+
preconditions: [
|
|
39
|
+
"buy.items non-empty",
|
|
40
|
+
"Each item.name matches a sale in Service.sales (else E_SALE_NOT_FOUND)",
|
|
41
|
+
"sale.suspension == false (else E_SALE_SUSPENDED)",
|
|
42
|
+
],
|
|
43
|
+
side_effects: [
|
|
44
|
+
"If buyer passes empty wip_hash, SDK auto-fills with sale.wip_hash",
|
|
45
|
+
"verifiedWipUrls Set avoids re-verifying same WIP URL across items",
|
|
46
|
+
"verify_wip() fetches WIP file and compares hash (else E_WIP_HASH_NOT_MATCH)",
|
|
47
|
+
],
|
|
48
|
+
always_executed: true,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
stage: 3,
|
|
52
|
+
name: "quote",
|
|
53
|
+
preconditions: [
|
|
54
|
+
"All items have valid sale + wip_hash match",
|
|
55
|
+
"stock >= purchase quantity (else E_STOCK_INSUFFICIENT)",
|
|
56
|
+
"discount object (if used) is valid and unexpired",
|
|
57
|
+
],
|
|
58
|
+
side_effects: [
|
|
59
|
+
"quote_imp() computes total price (with discount if applicable)",
|
|
60
|
+
"⚠️ Stock is deducted (split) — side effect is NOT auto-rolled-back on later failure",
|
|
61
|
+
"service::quote or service::quote_with_discount MoveCall",
|
|
62
|
+
],
|
|
63
|
+
always_executed: true,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
stage: 4,
|
|
67
|
+
name: "create_order",
|
|
68
|
+
preconditions: ["Quote object from stage 3", "Registrar + Clock objects available"],
|
|
69
|
+
side_effects: [
|
|
70
|
+
"service::buy or service::buy_with_passport MoveCall",
|
|
71
|
+
"Order object created (builder=customer, service=Service.id)",
|
|
72
|
+
"Order.id recorded for stages 5-7",
|
|
73
|
+
],
|
|
74
|
+
always_executed: true,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
stage: 5,
|
|
78
|
+
name: "create_allocation",
|
|
79
|
+
preconditions: [
|
|
80
|
+
"Service.order_allocators is Some (configured)",
|
|
81
|
+
"Order from stage 4",
|
|
82
|
+
"CoinParam for total_pay matches Service<T> type",
|
|
83
|
+
],
|
|
84
|
+
side_effects: [
|
|
85
|
+
"service::order_allocation MoveCall",
|
|
86
|
+
"Allocation object created (first-match-wins fund distribution)",
|
|
87
|
+
"Order.allocation = Allocation address",
|
|
88
|
+
],
|
|
89
|
+
always_executed: true,
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
stage: 6,
|
|
93
|
+
name: "create_progress",
|
|
94
|
+
preconditions: ["Service.machine is Some (machine bound)", "Order from stage 4", "Machine from Service.machine"],
|
|
95
|
+
side_effects: [
|
|
96
|
+
"service::order_progress MoveCall",
|
|
97
|
+
"Progress object created (Progress.machine = Service.machine, Progress.task = Order.id)",
|
|
98
|
+
],
|
|
99
|
+
always_executed: false,
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
stage: 7,
|
|
103
|
+
name: "post_actions",
|
|
104
|
+
preconditions: ["Order/Allocation/Progress objects from stages 4-6"],
|
|
105
|
+
side_effects: [
|
|
106
|
+
"agent_set (if order_new.agents provided)",
|
|
107
|
+
"order_required_info_update (if order_required_info provided)",
|
|
108
|
+
"owner_change (if transfer provided — sets new Order owner)",
|
|
109
|
+
"namedNewOrder / namedNewAllocation / namedNewProgress (local naming)",
|
|
110
|
+
],
|
|
111
|
+
always_executed: false,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
stage: 8,
|
|
115
|
+
name: "return_result",
|
|
116
|
+
preconditions: ["All preceding stages succeeded"],
|
|
117
|
+
side_effects: [
|
|
118
|
+
"Returns BuyResult { order, allocation?, progress? }",
|
|
119
|
+
"Caller proceeds to sign + submit transaction",
|
|
120
|
+
],
|
|
121
|
+
always_executed: true,
|
|
122
|
+
},
|
|
123
|
+
];
|
|
124
|
+
export const SERVICE_CROSS_OBJECT_BINDINGS = [
|
|
125
|
+
{ object: "Machine", field: "machine", required: false, locked_after_publish: true, notes: "Workflow template; post-publish immutable (F-S-20). Progress.machine inherits this value." },
|
|
126
|
+
{ object: "Guard", field: "buy_guard", required: false, locked_after_publish: false, notes: "Buyer eligibility guard; post-publish STILL MUTABLE (unusual — see F-S-26)" },
|
|
127
|
+
{ object: "Allocation", field: "order_allocators", required: true, locked_after_publish: true, notes: "Order fund distribution strategy; publish prerequisite (F-S-18). Post-publish immutable (F-S-22)." },
|
|
128
|
+
{ object: "Arbitration", field: "arbitrations", required: false, locked_after_publish: true, notes: "Dispute handlers; required if compensation_fund > 0 (F-S-19). Post-publish immutable (F-S-21)." },
|
|
129
|
+
{ object: "Repository", field: "repositories", required: false, locked_after_publish: false, notes: "Shared data stores; mutable post-publish" },
|
|
130
|
+
{ object: "Reward", field: "rewards", required: false, locked_after_publish: false, notes: "Marketing incentives; mutable but locked by setting_lock_duration (F-S-24)" },
|
|
131
|
+
{ object: "Contact", field: "um", required: false, locked_after_publish: false, notes: "User Manager (Contact object); mutable post-publish" },
|
|
132
|
+
{ object: "Treasury", field: "(indirect via order_allocators.sharing.who=Entity)", required: false, locked_after_publish: false, notes: "Treasury is referenced by Allocation.sharing.who, not by Service directly" },
|
|
133
|
+
];
|
|
134
|
+
export const SERVICE_SCENES = [
|
|
135
|
+
{
|
|
136
|
+
id: "service_retail",
|
|
137
|
+
name: "Retail e-commerce Service",
|
|
138
|
+
category: "retail",
|
|
139
|
+
permission_index_range: "300-320",
|
|
140
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
141
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
142
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
143
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
144
|
+
admin_operations: ["description_set", "location_set", "customer_required_set"],
|
|
145
|
+
permission_index_operations: [
|
|
146
|
+
"service::publish (311)",
|
|
147
|
+
"service::pause (310)",
|
|
148
|
+
"service::sales_add/set/remove/clear (305)",
|
|
149
|
+
"service::order_allocators_set (313)",
|
|
150
|
+
"service::buy_guard_set (307)",
|
|
151
|
+
"service::discount (312)",
|
|
152
|
+
],
|
|
153
|
+
mutable_after_publish: {
|
|
154
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
155
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
156
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
157
|
+
sales: true, description: true, location: true, repositories: true,
|
|
158
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
159
|
+
},
|
|
160
|
+
publish_prerequisites: [
|
|
161
|
+
"order_allocators must be set (F-S-18, E_NO_ALLOCATOR)",
|
|
162
|
+
"If compensation_fund > 0, arbitrations must be non-empty (F-S-19)",
|
|
163
|
+
],
|
|
164
|
+
common_patterns: [
|
|
165
|
+
"Multi-tier pricing via sales[] (Standard/Premium/Enterprise)",
|
|
166
|
+
"WIP hash per sale item for tamper-proof product info",
|
|
167
|
+
"buy_guard for KYC whitelist during pre-sale, then null for public sale",
|
|
168
|
+
"compensation_fund deposited before publish + arbitrations configured",
|
|
169
|
+
],
|
|
170
|
+
recommended_templates: ["T-S-01", "T-S-06"],
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: "service_rental",
|
|
174
|
+
name: "Rental Service (short/long-term)",
|
|
175
|
+
category: "rental",
|
|
176
|
+
permission_index_range: "300-320",
|
|
177
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
178
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
179
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
180
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
181
|
+
admin_operations: ["description_set", "location_set"],
|
|
182
|
+
permission_index_operations: [
|
|
183
|
+
"service::publish (311)",
|
|
184
|
+
"service::sales_add/set (305)",
|
|
185
|
+
"service::machine_set (306) — for rental workflow",
|
|
186
|
+
"service::arbitration_add (308) — for deposit disputes",
|
|
187
|
+
],
|
|
188
|
+
mutable_after_publish: {
|
|
189
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
190
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
191
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
192
|
+
sales: true, description: true, location: true, repositories: true,
|
|
193
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
194
|
+
},
|
|
195
|
+
publish_prerequisites: [
|
|
196
|
+
"order_allocators must be set",
|
|
197
|
+
"machine recommended (rental workflow with deposit/return stages)",
|
|
198
|
+
"arbitrations recommended (deposit refund disputes)",
|
|
199
|
+
],
|
|
200
|
+
common_patterns: [
|
|
201
|
+
"Machine workflow with 'Deposit → Use → Return → Refund' nodes",
|
|
202
|
+
"compensation_fund holds deposit guarantees",
|
|
203
|
+
"buy_guard verifies renter identity/KYC",
|
|
204
|
+
"stock=1 per rental item (unique items)",
|
|
205
|
+
],
|
|
206
|
+
recommended_templates: ["T-S-02", "T-S-04"],
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: "service_subscription",
|
|
210
|
+
name: "Subscription Service (recurring)",
|
|
211
|
+
category: "subscription",
|
|
212
|
+
permission_index_range: "300-320",
|
|
213
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
214
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
215
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
216
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
217
|
+
admin_operations: ["description_set", "location_set"],
|
|
218
|
+
permission_index_operations: [
|
|
219
|
+
"service::publish (311)",
|
|
220
|
+
"service::sales_add/set (305)",
|
|
221
|
+
"service::discount (312) — promotional rates",
|
|
222
|
+
"service::reward_add (318) — loyalty rewards",
|
|
223
|
+
],
|
|
224
|
+
mutable_after_publish: {
|
|
225
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
226
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
227
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
228
|
+
sales: true, description: true, location: true, repositories: true,
|
|
229
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
230
|
+
},
|
|
231
|
+
publish_prerequisites: ["order_allocators must be set"],
|
|
232
|
+
common_patterns: [
|
|
233
|
+
"Tiered plans (Free/Pro/Enterprise) as sales[]",
|
|
234
|
+
"Discount coupons for trial periods",
|
|
235
|
+
"Rewards for long-term subscribers",
|
|
236
|
+
"Renewal handled by repeat orders (no native recurring billing)",
|
|
237
|
+
],
|
|
238
|
+
recommended_templates: ["T-S-03"],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
id: "service_workflow",
|
|
242
|
+
name: "Workflow-bound Service (machine-bound)",
|
|
243
|
+
category: "workflow",
|
|
244
|
+
permission_index_range: "300-320",
|
|
245
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
246
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
247
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
248
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
249
|
+
admin_operations: ["description_set", "location_set"],
|
|
250
|
+
permission_index_operations: [
|
|
251
|
+
"service::machine_set (306) — bind workflow",
|
|
252
|
+
"service::publish (311)",
|
|
253
|
+
"service::order_allocators_set (313)",
|
|
254
|
+
],
|
|
255
|
+
mutable_after_publish: {
|
|
256
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
257
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
258
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
259
|
+
sales: true, description: true, location: true, repositories: true,
|
|
260
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
261
|
+
},
|
|
262
|
+
publish_prerequisites: [
|
|
263
|
+
"order_allocators must be set",
|
|
264
|
+
"machine must be published before binding",
|
|
265
|
+
"machine recommended for any multi-stage service delivery",
|
|
266
|
+
],
|
|
267
|
+
common_patterns: [
|
|
268
|
+
"Machine defines Pay → Confirm → Deliver → Sign-off nodes",
|
|
269
|
+
"Progress created per order (stage 6 of buy flow)",
|
|
270
|
+
"Named operators assigned per Forward in Machine",
|
|
271
|
+
"Service.paused does NOT affect already-created Progress (existing orders continue)",
|
|
272
|
+
],
|
|
273
|
+
recommended_templates: ["T-S-04"],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: "service_arbitration",
|
|
277
|
+
name: "Arbitration-bound Service (dispute-ready)",
|
|
278
|
+
category: "arbitration",
|
|
279
|
+
permission_index_range: "300-320",
|
|
280
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
281
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
282
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
283
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
284
|
+
admin_operations: ["description_set"],
|
|
285
|
+
permission_index_operations: [
|
|
286
|
+
"service::arbitration_add (308)",
|
|
287
|
+
"service::compensation_fund_add (315)",
|
|
288
|
+
"service::setting_lock_duration_add (317)",
|
|
289
|
+
"service::publish (311)",
|
|
290
|
+
],
|
|
291
|
+
mutable_after_publish: {
|
|
292
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
293
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
294
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
295
|
+
sales: true, description: true, location: true, repositories: true,
|
|
296
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
297
|
+
},
|
|
298
|
+
publish_prerequisites: [
|
|
299
|
+
"If compensation_fund > 0, arbitrations must be non-empty (F-S-19)",
|
|
300
|
+
"Arbitration objects must be created before binding",
|
|
301
|
+
"compensation_fund_add before publish recommended (else post-publish deposit still possible)",
|
|
302
|
+
],
|
|
303
|
+
common_patterns: [
|
|
304
|
+
"2-3 Arbitration objects (different arb committees for different dispute types)",
|
|
305
|
+
"compensation_fund deposited as % of expected order volume",
|
|
306
|
+
"setting_lock_duration extended by owner to build customer trust",
|
|
307
|
+
"compensation_claim triggered by arbitration result (not by Service directly)",
|
|
308
|
+
],
|
|
309
|
+
recommended_templates: ["T-S-05", "T-S-06"],
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
id: "service_compensation_fund",
|
|
313
|
+
name: "Compensation Fund Service (embedded balance)",
|
|
314
|
+
category: "compensation_fund",
|
|
315
|
+
permission_index_range: "300-320",
|
|
316
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
317
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
318
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
319
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
320
|
+
admin_operations: ["description_set"],
|
|
321
|
+
permission_index_operations: [
|
|
322
|
+
"service::compensation_fund_add (315) — deposit",
|
|
323
|
+
"service::compensation_fund_withdraw (314) — withdraw (locked)",
|
|
324
|
+
"service::compensation_fund_receive (316) — receive (locked)",
|
|
325
|
+
"service::setting_lock_duration_add (317) — extend lock",
|
|
326
|
+
],
|
|
327
|
+
mutable_after_publish: {
|
|
328
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
329
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
330
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
331
|
+
sales: true, description: true, location: true, repositories: true,
|
|
332
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
333
|
+
},
|
|
334
|
+
publish_prerequisites: [
|
|
335
|
+
"compensation_fund > 0 → arbitrations non-empty (F-S-19)",
|
|
336
|
+
"compensation_fund coin type must match Service<T> type parameter",
|
|
337
|
+
],
|
|
338
|
+
common_patterns: [
|
|
339
|
+
"Fund inflow: compensation_fund_add (315) — always mutable",
|
|
340
|
+
"Fund outflow: compensation_fund_withdraw (314) — requires bPaused + lock_duration expired",
|
|
341
|
+
"Fund receive: compensation_fund_receive (316) — locked by duration",
|
|
342
|
+
"Fund consumer: arbitration::compensation_claim (driven by arb result)",
|
|
343
|
+
"Distinct from Treasury: Service-internal, arbitration-bound, lock-protected",
|
|
344
|
+
],
|
|
345
|
+
recommended_templates: ["T-S-06"],
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
id: "service_reward",
|
|
349
|
+
name: "Reward-attached Service (marketing)",
|
|
350
|
+
category: "reward",
|
|
351
|
+
permission_index_range: "300-320",
|
|
352
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
353
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
354
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
355
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
356
|
+
admin_operations: ["description_set"],
|
|
357
|
+
permission_index_operations: [
|
|
358
|
+
"service::reward_add/remove/clear (318) — locked by duration",
|
|
359
|
+
"service::discount (312)",
|
|
360
|
+
"service::publish (311)",
|
|
361
|
+
],
|
|
362
|
+
mutable_after_publish: {
|
|
363
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
364
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
365
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
366
|
+
sales: true, description: true, location: true, repositories: true,
|
|
367
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
368
|
+
},
|
|
369
|
+
publish_prerequisites: ["order_allocators must be set"],
|
|
370
|
+
common_patterns: [
|
|
371
|
+
"Rewards added post-publish (still allowed, but locked by duration)",
|
|
372
|
+
"Reward objects must exist before binding (queryObjectsWithType validation)",
|
|
373
|
+
"MAX_REWARD_COUNT = 20 per Service",
|
|
374
|
+
"Reward removal also locked by duration (protects customer expectations)",
|
|
375
|
+
],
|
|
376
|
+
recommended_templates: ["T-S-08"],
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
id: "service_arbitration_binding",
|
|
380
|
+
name: "Arbitration Binding Service (post-publish immutable)",
|
|
381
|
+
category: "arbitration",
|
|
382
|
+
permission_index_range: "300-320",
|
|
383
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
384
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
385
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
386
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
387
|
+
admin_operations: ["description_set"],
|
|
388
|
+
permission_index_operations: [
|
|
389
|
+
"service::arbitration_add (308) — pre-publish only",
|
|
390
|
+
"service::arbitration_remove (308) — pre-publish only",
|
|
391
|
+
"service::arbitration_clear (308) — pre-publish only",
|
|
392
|
+
"service::publish (311)",
|
|
393
|
+
],
|
|
394
|
+
mutable_after_publish: {
|
|
395
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
396
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
397
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
398
|
+
sales: true, description: true, location: true, repositories: true,
|
|
399
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
400
|
+
},
|
|
401
|
+
publish_prerequisites: [
|
|
402
|
+
"MAX_ARBITRATION_COUNT = 20 per Service (F-S-04)",
|
|
403
|
+
"Each Arbitration object must be valid (queryObjectsWithType validation)",
|
|
404
|
+
"Arbitration bound = locked post-publish (F-S-21). To change: create new Service.",
|
|
405
|
+
],
|
|
406
|
+
common_patterns: [
|
|
407
|
+
"Pre-publish: set 1-3 Arbitration objects for different dispute scopes",
|
|
408
|
+
"Post-publish: immutable — clone Service if change needed",
|
|
409
|
+
"⚠️ Data inconsistency: dynamic-pricing.ts marks arbitrations as mutable, but SDK blocks it (F-S-21)",
|
|
410
|
+
],
|
|
411
|
+
recommended_templates: ["T-S-05"],
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
id: "service_buy_guard",
|
|
415
|
+
name: "Buy Guard Service (post-publish mutable guard)",
|
|
416
|
+
category: "buy_guard",
|
|
417
|
+
permission_index_range: "300-320",
|
|
418
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
419
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
420
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
421
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
422
|
+
admin_operations: ["description_set"],
|
|
423
|
+
permission_index_operations: [
|
|
424
|
+
"service::buy_guard_set (307) — bind guard",
|
|
425
|
+
"service::buy_guard_none (307) — clear guard",
|
|
426
|
+
"service::publish (311)",
|
|
427
|
+
],
|
|
428
|
+
mutable_after_publish: {
|
|
429
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
430
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
431
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
432
|
+
sales: true, description: true, location: true, repositories: true,
|
|
433
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
434
|
+
},
|
|
435
|
+
publish_prerequisites: ["order_allocators must be set"],
|
|
436
|
+
common_patterns: [
|
|
437
|
+
"Pre-sale phase: buy_guard = whitelist Guard (KYC verified buyers only)",
|
|
438
|
+
"Public sale: buy_guard = null (anyone can buy)",
|
|
439
|
+
"Restricted phase: buy_guard = KYC Guard (compliance)",
|
|
440
|
+
"⚠️ buy_guard is the ONLY publish-locked-field exception — still mutable post-publish",
|
|
441
|
+
"buy_guard verification happens at Stage 1 of buy flow (pre_check)",
|
|
442
|
+
],
|
|
443
|
+
recommended_templates: ["T-S-01"],
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: "service_order_allocator",
|
|
447
|
+
name: "Order Allocator Service (fund distribution config)",
|
|
448
|
+
category: "order_allocator",
|
|
449
|
+
permission_index_range: "300-320",
|
|
450
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
451
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
452
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
453
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
454
|
+
admin_operations: ["description_set"],
|
|
455
|
+
permission_index_operations: [
|
|
456
|
+
"service::order_allocators_set (313) — pre-publish only",
|
|
457
|
+
"service::publish (311) — requires order_allocators (F-S-18)",
|
|
458
|
+
],
|
|
459
|
+
mutable_after_publish: {
|
|
460
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
461
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
462
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
463
|
+
sales: true, description: true, location: true, repositories: true,
|
|
464
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
465
|
+
},
|
|
466
|
+
publish_prerequisites: [
|
|
467
|
+
"order_allocators MUST be set (F-S-18, E_NO_ALLOCATOR)",
|
|
468
|
+
"Allocators.sharing.who can reference Treasury addresses (indirect Treasury binding)",
|
|
469
|
+
"MAX_SHARING_COUNT = 100 per allocator",
|
|
470
|
+
],
|
|
471
|
+
common_patterns: [
|
|
472
|
+
"Multi-party split: merchant 80% / platform 10% / logistics 10%",
|
|
473
|
+
"Threshold-based: different allocators for different order sizes",
|
|
474
|
+
"Guard-bound allocator: allocation execution requires Guard verification",
|
|
475
|
+
"Post-publish immutable — clone Service to change allocation strategy",
|
|
476
|
+
],
|
|
477
|
+
recommended_templates: ["T-S-08"],
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
id: "service_dynamic_pricing",
|
|
481
|
+
name: "Dynamic Pricing Service (discount-driven)",
|
|
482
|
+
category: "dynamic_pricing",
|
|
483
|
+
permission_index_range: "300-320",
|
|
484
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
485
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
486
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
487
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
488
|
+
admin_operations: ["description_set"],
|
|
489
|
+
permission_index_operations: [
|
|
490
|
+
"service::discount (312) — issue coupons",
|
|
491
|
+
"service::sales_add/set (305) — adjust base prices",
|
|
492
|
+
"service::sales_remove (305) — remove deprecated SKUs",
|
|
493
|
+
],
|
|
494
|
+
mutable_after_publish: {
|
|
495
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
496
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
497
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
498
|
+
sales: true, description: true, location: true, repositories: true,
|
|
499
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
500
|
+
},
|
|
501
|
+
publish_prerequisites: ["order_allocators must be set"],
|
|
502
|
+
common_patterns: [
|
|
503
|
+
"Discount types: 0=rates (basis points, per 10000), 1=minus (direct deduction)",
|
|
504
|
+
"MAX_DISCOUNT_COUNT_ONCE = 1000 per issue call",
|
|
505
|
+
"MAX_DISCOUNT_RECEIVER_ONCE = 1000 receivers per call",
|
|
506
|
+
"MAX_DISCOUNT_TOTAL_COUNT = 20000 total coupons",
|
|
507
|
+
"discount_destroy: holder-only (no SERVICE_DISCOUNT permission needed)",
|
|
508
|
+
],
|
|
509
|
+
recommended_templates: ["T-S-07"],
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
id: "service_multi_allocator",
|
|
513
|
+
name: "Multi-Allocator Service (tiered fund distribution)",
|
|
514
|
+
category: "multi_allocator",
|
|
515
|
+
permission_index_range: "300-320",
|
|
516
|
+
builtin_indexes: SERVICE_PERMISSIONS,
|
|
517
|
+
cross_object_bindings: SERVICE_CROSS_OBJECT_BINDINGS,
|
|
518
|
+
order_flow_stages: SERVICE_ORDER_FLOW_STAGES,
|
|
519
|
+
owner_operations: ["um_set", "builder (transfer)"],
|
|
520
|
+
admin_operations: ["description_set"],
|
|
521
|
+
permission_index_operations: [
|
|
522
|
+
"service::order_allocators_set (313) — pre-publish only",
|
|
523
|
+
"service::publish (311)",
|
|
524
|
+
],
|
|
525
|
+
mutable_after_publish: {
|
|
526
|
+
machine: false, arbitrations: false, order_allocators: false,
|
|
527
|
+
buy_guard: true, rewards: "locked_by_duration",
|
|
528
|
+
compensation_fund_withdraw: "locked_by_duration", compensation_fund_receive: "locked_by_duration",
|
|
529
|
+
sales: true, description: true, location: true, repositories: true,
|
|
530
|
+
customer_required: true, discount: true, um: true, pause: true,
|
|
531
|
+
},
|
|
532
|
+
publish_prerequisites: [
|
|
533
|
+
"order_allocators MUST be set",
|
|
534
|
+
"Each allocator has its own Guard + sharing + threshold",
|
|
535
|
+
"First-match-wins: first allocator whose threshold is met handles the order",
|
|
536
|
+
],
|
|
537
|
+
common_patterns: [
|
|
538
|
+
"Tier 1 (small orders): single-recipient allocator (low fee)",
|
|
539
|
+
"Tier 2 (medium orders): two-recipient split (merchant + platform)",
|
|
540
|
+
"Tier 3 (large orders): three-recipient split (merchant + platform + logistics)",
|
|
541
|
+
"Each tier can have its own Guard for execution authorization",
|
|
542
|
+
],
|
|
543
|
+
recommended_templates: ["T-S-08"],
|
|
544
|
+
},
|
|
545
|
+
];
|
|
546
|
+
export const SERVICE_LEDGER_VERSION = "1.0.0";
|
|
547
|
+
export function getScenesByCategory(category) {
|
|
548
|
+
return SERVICE_SCENES.filter(s => s.category === category);
|
|
549
|
+
}
|
|
550
|
+
export function findSceneById(id) {
|
|
551
|
+
return SERVICE_SCENES.find(s => s.id === id);
|
|
552
|
+
}
|
|
553
|
+
export function getServicePermissionByIndex(index) {
|
|
554
|
+
return SERVICE_PERMISSIONS.find(p => p.index === index);
|
|
555
|
+
}
|
|
556
|
+
export function isServicePermission(index) {
|
|
557
|
+
return getServicePermissionByIndex(index) !== undefined;
|
|
558
|
+
}
|
|
559
|
+
export function getPermissionsByMutability(mutability) {
|
|
560
|
+
return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === mutability);
|
|
561
|
+
}
|
|
562
|
+
export function getImmutablePostPublishPermissions() {
|
|
563
|
+
return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === "immutable" || p.post_publish_mutability === "one_shot");
|
|
564
|
+
}
|
|
565
|
+
export function getLockedByDurationPermissions() {
|
|
566
|
+
return SERVICE_PERMISSIONS.filter(p => p.post_publish_mutability === "locked_by_duration");
|
|
567
|
+
}
|
|
568
|
+
export function inferSceneFromIntent(intent) {
|
|
569
|
+
const lower = intent.toLowerCase();
|
|
570
|
+
const categoryKeywords = [
|
|
571
|
+
["retail", "retail"], ["ecommerce", "retail"],
|
|
572
|
+
["rental", "rental"], ["rent", "rental"], ["short-term rental", "rental"], ["long-term rental", "rental"],
|
|
573
|
+
["subscription", "subscription"], ["subscribe", "subscription"],
|
|
574
|
+
["workflow", "workflow"], ["machine-bound", "workflow"],
|
|
575
|
+
["arbitration", "arbitration"], ["dispute", "arbitration"],
|
|
576
|
+
["compensation", "compensation_fund"], ["compensation_fund", "compensation_fund"],
|
|
577
|
+
["reward", "reward"], ["marketing", "reward"],
|
|
578
|
+
["buy_guard", "buy_guard"], ["kyc", "buy_guard"], ["whitelist", "buy_guard"],
|
|
579
|
+
["allocator", "order_allocator"],
|
|
580
|
+
["discount", "dynamic_pricing"], ["coupon", "dynamic_pricing"],
|
|
581
|
+
["multi-allocator", "multi_allocator"], ["tiered", "multi_allocator"],
|
|
582
|
+
];
|
|
583
|
+
for (const [kw, cat] of categoryKeywords) {
|
|
584
|
+
if (lower.includes(kw)) {
|
|
585
|
+
const scenes = getScenesByCategory(cat);
|
|
586
|
+
if (scenes.length > 0)
|
|
587
|
+
return scenes[0];
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
if (lower.includes("service")) {
|
|
591
|
+
return findSceneById("service_retail");
|
|
592
|
+
}
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
export function getAllServiceScenes() {
|
|
596
|
+
return [...SERVICE_SCENES];
|
|
597
|
+
}
|
|
598
|
+
export function getServiceScenesCount() {
|
|
599
|
+
return SERVICE_SCENES.length;
|
|
600
|
+
}
|
|
601
|
+
export function getServicePermissionsCount() {
|
|
602
|
+
return SERVICE_PERMISSIONS.length;
|
|
603
|
+
}
|
|
604
|
+
export function getOrderFlowStage(stage) {
|
|
605
|
+
return SERVICE_ORDER_FLOW_STAGES.find(s => s.stage === stage);
|
|
606
|
+
}
|
|
607
|
+
export function getCrossObjectBindings() {
|
|
608
|
+
return [...SERVICE_CROSS_OBJECT_BINDINGS];
|
|
609
|
+
}
|