@wowok/agent-mcp 2.7.1 → 2.7.2
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/index.js +1 -1
- package/dist/config/runtime.js +1 -238
- package/dist/customer/customer-advice.js +1 -130
- package/dist/customer/index.js +1 -11
- package/dist/customer/industry-risks.js +1 -438
- package/dist/customer/info-puzzle.js +1 -681
- package/dist/customer/order-monitor.js +1 -328
- package/dist/customer/order-strategy.js +1 -373
- package/dist/customer/post-purchase.js +1 -351
- package/dist/customer/preorder-compare.js +1 -34
- package/dist/customer/reminder-system.js +1 -316
- package/dist/customer/risk-assessment.js +1 -397
- package/dist/customer/types.js +1 -13
- package/dist/customer/user-preferences.js +1 -460
- package/dist/evaluation/arbitration-game.d.ts +9 -2
- package/dist/evaluation/arbitration-game.js +1 -48
- package/dist/evaluation/builtins/demand-match.js +1 -153
- package/dist/evaluation/builtins/index.js +1 -10
- package/dist/evaluation/builtins/service-risk.js +1 -55
- package/dist/evaluation/capability.js +1 -13
- package/dist/evaluation/composer.js +1 -40
- package/dist/evaluation/engine.js +1 -175
- package/dist/evaluation/extract.js +1 -115
- package/dist/evaluation/game-strategy.d.ts +27 -0
- package/dist/evaluation/game-strategy.js +1 -0
- package/dist/evaluation/gap.js +1 -100
- package/dist/evaluation/index.d.ts +1 -0
- package/dist/evaluation/index.js +1 -11
- package/dist/evaluation/node-game.d.ts +31 -3
- package/dist/evaluation/node-game.js +1 -57
- package/dist/evaluation/region.js +1 -36
- package/dist/evaluation/types.d.ts +1 -0
- package/dist/evaluation/types.js +1 -1
- package/dist/evaluation/user-injection.js +1 -27
- package/dist/experience/experience-reuse.js +1 -103
- package/dist/experience/index.js +1 -5
- package/dist/experience/intent-distill.js +1 -83
- package/dist/experience/realtime-feedback.js +1 -94
- package/dist/experience/types.js +1 -1
- package/dist/experience/user-profile.js +1 -171
- package/dist/extensions/business-modules.js +1 -287
- package/dist/extensions/capability-manifest.js +1 -781
- package/dist/extensions/constraint-registry.js +1 -198
- package/dist/extensions/index.js +1 -6
- package/dist/extensions/metric-registry.js +1 -257
- package/dist/extensions/mode-evaluator.js +1 -170
- package/dist/extensions/modes.js +1 -499
- package/dist/extensions/registry.js +1 -717
- package/dist/extensions/types.js +1 -1
- package/dist/harness/auto-escalation.js +1 -68
- package/dist/harness/checkpoint.js +1 -129
- package/dist/harness/index.js +1 -78
- package/dist/harness/plan.js +1 -315
- package/dist/harness/recover.js +1 -139
- package/dist/harness/types.js +1 -1
- package/dist/harness/verify.js +1 -237
- package/dist/index.js +1 -273
- package/dist/intent/enrich.js +1 -67
- package/dist/intent/index.js +1 -60
- package/dist/intent/matcher.js +1 -81
- package/dist/intent/store.js +1 -55
- package/dist/intent/types.js +1 -10
- package/dist/knowledge/acquisition-flywheel.js +1 -192
- package/dist/knowledge/allocation-confirm.js +1 -534
- package/dist/knowledge/allocation-context.js +1 -249
- package/dist/knowledge/allocation-ledger.js +1 -463
- package/dist/knowledge/allocation-puzzle.js +1 -298
- package/dist/knowledge/allocation-risk.js +1 -568
- package/dist/knowledge/allocation-templates.js +1 -970
- package/dist/knowledge/allocation-translation.js +1 -585
- package/dist/knowledge/arb-risk.js +1 -210
- package/dist/knowledge/arbitration-confirm.js +1 -559
- package/dist/knowledge/arbitration-context.js +1 -505
- package/dist/knowledge/arbitration-ledger.js +1 -521
- package/dist/knowledge/arbitration-puzzle.js +1 -304
- package/dist/knowledge/arbitration-risk.js +1 -423
- package/dist/knowledge/arbitration-templates.js +1 -276
- package/dist/knowledge/arbitration-translation.js +1 -487
- package/dist/knowledge/arbitration-trust.js +1 -117
- package/dist/knowledge/audit-rules.js +1 -141
- package/dist/knowledge/bridge-risk.js +1 -263
- package/dist/knowledge/contact-risk.js +1 -200
- package/dist/knowledge/contact-templates.js +1 -60
- package/dist/knowledge/demand-confirm.js +1 -206
- package/dist/knowledge/demand-matching.js +1 -132
- package/dist/knowledge/demand-risk.js +1 -240
- package/dist/knowledge/demand-translation.js +1 -354
- package/dist/knowledge/deployment-scanner.js +1 -823
- package/dist/knowledge/dynamic-pricing.js +1 -87
- package/dist/knowledge/examples-scanner-cli.js +1 -26
- package/dist/knowledge/examples-scanner.js +1 -843
- package/dist/knowledge/flywheel-loop.js +1 -404
- package/dist/knowledge/fund-layer.js +1 -973
- package/dist/knowledge/glossary.js +1 -211
- package/dist/knowledge/guard-confirm.js +1 -406
- package/dist/knowledge/guard-context.js +1 -287
- package/dist/knowledge/guard-design-patterns.js +1 -360
- package/dist/knowledge/guard-ledger.js +1 -260
- package/dist/knowledge/guard-lint.js +1 -670
- package/dist/knowledge/guard-migration.js +1 -228
- package/dist/knowledge/guard-puzzle.js +1 -805
- package/dist/knowledge/guard-render.js +1 -700
- package/dist/knowledge/guard-risk.js +1 -1879
- package/dist/knowledge/guard-submission-prompt.js +1 -171
- package/dist/knowledge/guard-templates.js +1 -1105
- package/dist/knowledge/guard-translation.js +1 -1119
- package/dist/knowledge/index.js +1 -436
- package/dist/knowledge/industry-evolution.js +1 -323
- package/dist/knowledge/industry-generalizer.js +1 -381
- package/dist/knowledge/industry-registry.js +1 -174
- package/dist/knowledge/intent-metrics.d.ts +4 -3
- package/dist/knowledge/intent-metrics.js +1 -566
- package/dist/knowledge/machine-confirm.js +1 -559
- package/dist/knowledge/machine-context.js +1 -833
- package/dist/knowledge/machine-ledger.js +1 -338
- package/dist/knowledge/machine-puzzle.js +1 -494
- package/dist/knowledge/machine-render.js +1 -565
- package/dist/knowledge/machine-risk.js +1 -669
- package/dist/knowledge/machine-templates.js +1 -1597
- package/dist/knowledge/machine-topology.js +1 -234
- package/dist/knowledge/machine-translation.js +1 -513
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -45
- package/dist/knowledge/mcp-schema-audit.js +1 -777
- package/dist/knowledge/onchain-constants.js +1 -35
- package/dist/knowledge/order-confirm.js +1 -573
- package/dist/knowledge/order-context.js +1 -390
- package/dist/knowledge/order-ledger.js +1 -341
- package/dist/knowledge/order-puzzle.js +1 -255
- package/dist/knowledge/order-risk.js +1 -653
- package/dist/knowledge/order-templates.js +1 -368
- package/dist/knowledge/order-translation.js +1 -550
- package/dist/knowledge/overrides-loader.js +1 -65
- package/dist/knowledge/passport-confirm.js +1 -531
- package/dist/knowledge/passport-context.js +1 -306
- package/dist/knowledge/passport-ledger.js +1 -282
- package/dist/knowledge/passport-puzzle.js +1 -333
- package/dist/knowledge/passport-risk.js +1 -450
- package/dist/knowledge/passport-templates.js +1 -568
- package/dist/knowledge/passport-translation.js +1 -516
- package/dist/knowledge/payment-risk.js +1 -249
- package/dist/knowledge/permission-confirm.js +1 -426
- package/dist/knowledge/permission-context.js +1 -224
- package/dist/knowledge/permission-ledger.js +1 -403
- package/dist/knowledge/permission-puzzle.js +1 -173
- package/dist/knowledge/permission-risk.js +1 -411
- package/dist/knowledge/permission-templates.js +1 -234
- package/dist/knowledge/permission-translation.js +1 -350
- package/dist/knowledge/personal-risk.js +1 -212
- package/dist/knowledge/process-model.js +1 -160
- package/dist/knowledge/progress-confirm.js +1 -456
- package/dist/knowledge/progress-context.js +1 -452
- package/dist/knowledge/progress-ledger.js +1 -330
- package/dist/knowledge/progress-puzzle.js +1 -219
- package/dist/knowledge/progress-risk.js +1 -461
- package/dist/knowledge/progress-templates.js +1 -228
- package/dist/knowledge/progress-translation.js +1 -405
- package/dist/knowledge/proof-confirm.js +1 -187
- package/dist/knowledge/proof-risk.js +1 -207
- package/dist/knowledge/proof-translation.js +1 -283
- package/dist/knowledge/registrar-risk.js +1 -217
- package/dist/knowledge/repository-confirm.js +1 -286
- package/dist/knowledge/repository-risk.js +1 -373
- package/dist/knowledge/repository-translation.js +1 -445
- package/dist/knowledge/reputation-rules.js +1 -99
- package/dist/knowledge/resource-risk.js +1 -157
- package/dist/knowledge/reward-confirm.js +1 -526
- package/dist/knowledge/reward-context.js +1 -504
- package/dist/knowledge/reward-ledger.js +1 -502
- package/dist/knowledge/reward-puzzle.js +1 -300
- package/dist/knowledge/reward-risk.js +1 -627
- package/dist/knowledge/reward-templates.js +1 -197
- package/dist/knowledge/reward-translation.js +1 -501
- package/dist/knowledge/safety-rules.js +1 -404
- package/dist/knowledge/scenario-modes.js +1 -321
- package/dist/knowledge/service-confirm.js +1 -807
- package/dist/knowledge/service-context.js +1 -403
- package/dist/knowledge/service-ledger.js +1 -609
- package/dist/knowledge/service-puzzle.js +1 -236
- package/dist/knowledge/service-risk.js +1 -651
- package/dist/knowledge/service-templates.js +1 -456
- package/dist/knowledge/service-translation.js +1 -622
- package/dist/knowledge/template-registry.js +1 -353
- package/dist/knowledge/tool-constraints.js +1 -195
- package/dist/knowledge/tools-reference.js +1 -178
- package/dist/knowledge/treasury-confirm.js +1 -512
- package/dist/knowledge/treasury-context.js +1 -363
- package/dist/knowledge/treasury-ledger.js +1 -300
- package/dist/knowledge/treasury-puzzle.js +1 -216
- package/dist/knowledge/treasury-risk.js +1 -440
- package/dist/knowledge/treasury-templates.js +1 -358
- package/dist/knowledge/treasury-translation.js +1 -498
- package/dist/knowledge/trust-metrics.js +1 -198
- package/dist/knowledge/util-risk.js +1 -135
- package/dist/loop-engineering/aggregate.js +1 -132
- package/dist/loop-engineering/context-collect.js +1 -83
- package/dist/loop-engineering/diagnose.js +1 -273
- package/dist/loop-engineering/improve.js +1 -405
- package/dist/loop-engineering/index.js +1 -4
- package/dist/loop-engineering/pipeline.js +1 -56
- package/dist/mode-market/index.js +1 -3
- package/dist/mode-market/registry.js +1 -124
- package/dist/mode-market/review.js +1 -214
- package/dist/mode-market/submission.js +1 -85
- package/dist/participation/collaborator-interest.d.ts +23 -0
- package/dist/participation/collaborator-interest.js +1 -0
- package/dist/participation/customer-interest.d.ts +25 -0
- package/dist/participation/customer-interest.js +1 -0
- package/dist/participation/merchant-interest.js +1 -100
- package/dist/participation/radar-core.d.ts +13 -3
- package/dist/participation/radar-core.js +1 -269
- package/dist/participation/supplier-interest.d.ts +25 -0
- package/dist/participation/supplier-interest.js +1 -0
- package/dist/persona/analyzer.js +1 -66
- package/dist/persona/bridge.js +1 -86
- package/dist/persona/defaults.js +1 -195
- package/dist/persona/experience-bridge.js +1 -23
- package/dist/persona/index.js +1 -71
- package/dist/persona/model.js +1 -111
- package/dist/persona/store.js +1 -62
- package/dist/persona/types.d.ts +3 -1
- package/dist/persona/types.js +1 -5
- package/dist/project/business-puzzle.js +1 -383
- package/dist/project/context-assembly.js +1 -254
- package/dist/project/deployment-bridge.js +1 -120
- package/dist/project/deployment-doc.js +1 -1126
- package/dist/project/edit-planner.js +1 -1342
- package/dist/project/evaluation.js +1 -2011
- package/dist/project/game-theory.js +1 -177
- package/dist/project/graph-builder.js +1 -656
- package/dist/project/graph.js +1 -340
- package/dist/project/handlers.js +1 -1784
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.js +1 -301
- package/dist/project/intent-analyzer.js +1 -149
- package/dist/project/machine-nodes.js +1 -36
- package/dist/project/merchant-guide.js +1 -264
- package/dist/project/migration.js +1 -125
- package/dist/project/mode-actions.js +1 -309
- package/dist/project/namespace.js +1 -206
- package/dist/project/participation-radar.js +1 -428
- package/dist/project/pipeline-actions.js +1 -109
- package/dist/project/project-store.js +1 -422
- package/dist/project/query.js +1 -153
- package/dist/project/reverse-mapping.d.ts +34 -0
- package/dist/project/reverse-mapping.js +1 -0
- package/dist/project/risk-aggregator.js +1 -295
- package/dist/project/rollback-policy.js +1 -290
- package/dist/project/semantic-assembler.js +1 -345
- package/dist/project/semantic-graph.js +1 -292
- package/dist/project/stage-gate.js +1 -369
- package/dist/project/substep-trace.js +1 -332
- package/dist/project/task-tracker.js +1 -78
- package/dist/role/derivation.d.ts +18 -0
- package/dist/role/derivation.js +1 -0
- package/dist/role/index.d.ts +5 -0
- package/dist/role/index.js +1 -0
- package/dist/role/model.d.ts +8 -0
- package/dist/role/model.js +1 -0
- package/dist/role/resolution.d.ts +11 -0
- package/dist/role/resolution.js +1 -0
- package/dist/role/types.d.ts +11 -0
- package/dist/role/types.js +1 -0
- package/dist/rules.js +1 -52
- package/dist/safety/confirm-gate.js +1 -88
- package/dist/safety/index.js +1 -3
- package/dist/safety/preview.js +1 -52
- package/dist/schema/call/allocation.js +1 -34
- package/dist/schema/call/arbitration.js +1 -113
- package/dist/schema/call/base.d.ts +15 -15
- package/dist/schema/call/base.js +1 -370
- package/dist/schema/call/bridge-handler.js +1 -265
- package/dist/schema/call/bridge.d.ts +7 -7
- package/dist/schema/call/bridge.js +1 -458
- package/dist/schema/call/contact.js +1 -37
- package/dist/schema/call/demand.js +1 -47
- package/dist/schema/call/guard.js +1 -161
- package/dist/schema/call/handler.js +1 -322
- package/dist/schema/call/index.js +1 -20
- package/dist/schema/call/machine.js +1 -193
- package/dist/schema/call/order.js +1 -35
- package/dist/schema/call/payment.js +1 -37
- package/dist/schema/call/permission-handler.js +1 -54
- package/dist/schema/call/permission.js +1 -105
- package/dist/schema/call/personal.js +1 -78
- package/dist/schema/call/progress.js +1 -47
- package/dist/schema/call/proof.js +1 -33
- package/dist/schema/call/repository.js +1 -77
- package/dist/schema/call/reward.js +1 -30
- package/dist/schema/call/semantic.js +1 -1679
- package/dist/schema/call/service.js +1 -184
- package/dist/schema/call/treasury.js +1 -71
- package/dist/schema/common/index.js +1 -407
- package/dist/schema/config/index.js +1 -68
- package/dist/schema/evaluation/index.d.ts +213 -16
- package/dist/schema/evaluation/index.js +1 -356
- package/dist/schema/index.js +1 -17
- package/dist/schema/intent-radar/index.d.ts +13 -13
- package/dist/schema/intent-radar/index.js +1 -89
- package/dist/schema/local/index.d.ts +21 -21
- package/dist/schema/local/index.js +1 -927
- package/dist/schema/local/wip.js +1 -187
- package/dist/schema/messenger/index.d.ts +7 -7
- package/dist/schema/messenger/index.js +1 -475
- package/dist/schema/operations.d.ts +7 -7
- package/dist/schema/operations.js +1 -520
- package/dist/schema/persona/index.d.ts +54 -54
- package/dist/schema/persona/index.js +1 -148
- package/dist/schema/project/index.d.ts +94 -48
- package/dist/schema/project/index.js +1 -2057
- package/dist/schema/query/index.d.ts +423 -7
- package/dist/schema/query/index.js +1 -1646
- package/dist/schema/schema-query/index.js +1 -104
- package/dist/schema/schema-version.js +1 -76
- package/dist/schema/sync-layer4.js +1 -286
- package/dist/schema/task-status.js +1 -36
- package/dist/schema/trust/index.js +1 -314
- package/dist/schema/utils/guard-parser.js +1 -419
- package/dist/schema/utils/guard-query-utils.js +1 -46
- package/dist/schema/utils/node-parser.js +1 -369
- package/dist/schema/utils/object-type-utils.js +1 -35
- package/dist/schema/utils/permission-index-utils.js +1 -7
- package/dist/schema/utils/permission-machine-check.js +1 -121
- package/dist/schema/utils/skills-recommendation.js +1 -77
- package/dist/schema-query/index.js +1 -810
- package/dist/schemas/account_operation.output.json +5 -2
- package/dist/schemas/bridge_operation.output.json +5 -2
- package/dist/schemas/evaluation_operation.output.json +112 -7
- package/dist/schemas/evaluation_operation.schema.json +93 -6
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/intent_radar.output.json +4 -1
- package/dist/schemas/intent_radar.schema.json +4 -1
- package/dist/schemas/local_info_operation.output.json +5 -2
- package/dist/schemas/local_mark_operation.output.json +5 -2
- package/dist/schemas/messenger_operation.output.json +5 -2
- package/dist/schemas/onchain_events.output.json +5 -2
- package/dist/schemas/onchain_operations.output.json +5 -2
- package/dist/schemas/onchain_operations.schema.json +4 -4
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/onchain_table_data.output.json +6 -3
- package/dist/schemas/persona_operation.output.json +4 -1
- package/dist/schemas/persona_operation.schema.json +4 -1
- package/dist/schemas/project_operation.output.json +28 -8
- package/dist/schemas/query_toolkit.output.json +8 -5
- package/dist/schemas/wowok_buildin_info.output.json +132 -0
- package/dist/schemas/wowok_buildin_info.schema.json +14 -0
- package/dist/telemetry/index.js +1 -112
- package/dist/telemetry/redact.js +1 -23
- package/dist/telemetry/storage.js +1 -80
- package/dist/tools/handlers/bridge.js +1 -1
- package/dist/tools/handlers/config.js +1 -74
- package/dist/tools/handlers/evaluation.js +1 -123
- package/dist/tools/handlers/file-export.js +1 -90
- package/dist/tools/handlers/intent-radar.js +1 -76
- package/dist/tools/handlers/local.js +1 -53
- package/dist/tools/handlers/messenger.js +1 -188
- package/dist/tools/handlers/onchain.js +1 -1180
- package/dist/tools/handlers/persona.js +1 -89
- package/dist/tools/handlers/project.js +1 -211
- package/dist/tools/handlers/query.js +1 -434
- package/dist/tools/handlers/schema-query.js +1 -176
- package/dist/tools/handlers/task-status.js +1 -26
- package/dist/tools/handlers/trust.js +1 -380
- package/dist/tools/handlers/wip.js +1 -90
- package/dist/tools/index.js +1 -1382
- package/dist/tools/retry.js +1 -85
- package/dist/tools/rules-hook.js +1 -23
- package/dist/tools/shared.js +1 -130
- package/dist/tools/types.js +1 -1
- package/dist/tools/upgrade-check.d.ts +19 -0
- package/dist/tools/upgrade-check.js +1 -0
- package/dist/tools/wip-deploy-assist.js +1 -306
- package/dist/tools/wrap.js +1 -500
- package/package.json +4 -2
|
@@ -1,622 +1 @@
|
|
|
1
|
-
import { MAX_SALE_COUNT, MAX_REPOSITORY_COUNT, MAX_ARBITRATION_COUNT, MAX_DISCOUNT_COUNT_ONCE, MAX_DISCOUNT_TOTAL_COUNT, MAX_WIP_LENGTH, MAX_WIP_HASH_LENGTH, } from "@wowok/wowok";
|
|
2
|
-
import { isServicePermission, getServicePermissionByIndex, } from "./service-ledger.js";
|
|
3
|
-
export const SEMANTIC_TO_SCHEMA_RULES = [
|
|
4
|
-
{
|
|
5
|
-
id: "P-S-01",
|
|
6
|
-
pattern_name: "Create new Service",
|
|
7
|
-
semantic_intent: "Create a new Service<T> with owner, permission, description, coin type",
|
|
8
|
-
match_keywords: ["create", "new", "open"],
|
|
9
|
-
schema_fields: ["object(null)", "description", "permission", "owner", "coin_type"],
|
|
10
|
-
example_json: {
|
|
11
|
-
object: null,
|
|
12
|
-
description: "My retail shop",
|
|
13
|
-
permission: "0xPERMISSION_ADDRESS",
|
|
14
|
-
},
|
|
15
|
-
reverse_explanation: "object=null indicates creation; permission must be a valid Permission object owned by signer",
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
id: "P-S-02",
|
|
19
|
-
pattern_name: "Modify description / location / customer_required",
|
|
20
|
-
semantic_intent: "Update Service metadata fields (mutable pre and post publish)",
|
|
21
|
-
match_keywords: ["describe", "locate", "customer_required", "update", "modify"],
|
|
22
|
-
schema_fields: ["object", "description", "location", "customer_required"],
|
|
23
|
-
example_json: {
|
|
24
|
-
object: "0xSERVICE_ADDRESS",
|
|
25
|
-
description: "Updated description",
|
|
26
|
-
location: "Shanghai",
|
|
27
|
-
customer_required: ["name", "phone"],
|
|
28
|
-
},
|
|
29
|
-
reverse_explanation: "These fields are always mutable. customer_required is a string[] of field names buyers must provide at order time.",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: "P-S-03",
|
|
33
|
-
pattern_name: "Manage sales items (add/set/remove/clear)",
|
|
34
|
-
semantic_intent: "Add product SKUs, update prices/stock, remove deprecated items, or clear all",
|
|
35
|
-
match_keywords: ["sales", "product", "sku", "inventory", "price"],
|
|
36
|
-
schema_fields: ["object", "sales"],
|
|
37
|
-
example_json: {
|
|
38
|
-
object: "0xSERVICE_ADDRESS",
|
|
39
|
-
sales: {
|
|
40
|
-
op: "add",
|
|
41
|
-
sales: [
|
|
42
|
-
{ name: "standard", price: "1000000000", stock: 100, wip: "https://ipfs/wip", wip_hash: "abcd...64" },
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
reverse_explanation: "sales.op=add appends; set replaces matching name; remove deletes by name; clear empties all. wip_hash is REQUIRED for tamper protection.",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
id: "P-S-04",
|
|
50
|
-
pattern_name: "Bind/unbind Machine workflow",
|
|
51
|
-
semantic_intent: "Bind a Machine workflow template to Service (post-publish immutable)",
|
|
52
|
-
match_keywords: ["machine", "workflow", "bind machine"],
|
|
53
|
-
schema_fields: ["object", "machine"],
|
|
54
|
-
example_json: {
|
|
55
|
-
object: "0xSERVICE_ADDRESS",
|
|
56
|
-
machine: "0xMACHINE_ADDRESS",
|
|
57
|
-
},
|
|
58
|
-
reverse_explanation: "machine=<address> binds; machine=null unbinds (pre-publish only). Once published, machine is immutable (F-S-20). Progress inherits this binding.",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
id: "P-S-05",
|
|
62
|
-
pattern_name: "Set/clear buy Guard",
|
|
63
|
-
semantic_intent: "Set buyer eligibility Guard (KYC/whitelist) or clear it",
|
|
64
|
-
match_keywords: ["buy_guard", "kyc", "whitelist"],
|
|
65
|
-
schema_fields: ["object", "buy_guard"],
|
|
66
|
-
example_json: {
|
|
67
|
-
object: "0xSERVICE_ADDRESS",
|
|
68
|
-
buy_guard: "0xGUARD_ADDRESS",
|
|
69
|
-
},
|
|
70
|
-
reverse_explanation: "buy_guard is the ONLY field still mutable post-publish (F-S-26 exception). Pre-sale: set to whitelist; public sale: set to null.",
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: "P-S-06",
|
|
74
|
-
pattern_name: "Manage arbitrations (add/remove/clear)",
|
|
75
|
-
semantic_intent: "Bind Arbitration objects for dispute handling (post-publish immutable)",
|
|
76
|
-
match_keywords: ["arbitration", "arbitrator", "dispute"],
|
|
77
|
-
schema_fields: ["object", "arbitrations"],
|
|
78
|
-
example_json: {
|
|
79
|
-
object: "0xSERVICE_ADDRESS",
|
|
80
|
-
arbitrations: { op: "add", objects: ["0xARB_ADDRESS"] },
|
|
81
|
-
},
|
|
82
|
-
reverse_explanation: "Required when compensation_fund > 0 (F-S-19). Post-publish immutable (F-S-21). Use 1-3 Arbitration objects covering different scopes.",
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
id: "P-S-07",
|
|
86
|
-
pattern_name: "Manage repositories (add/remove/clear)",
|
|
87
|
-
semantic_intent: "Bind Repository objects (data stores) — mutable post-publish",
|
|
88
|
-
match_keywords: ["repository", "data store", "storage", "data source"],
|
|
89
|
-
schema_fields: ["object", "repositories"],
|
|
90
|
-
example_json: {
|
|
91
|
-
object: "0xSERVICE_ADDRESS",
|
|
92
|
-
repositories: { op: "add", objects: ["0xREPO_ADDRESS"] },
|
|
93
|
-
},
|
|
94
|
-
reverse_explanation: "Mutable post-publish. SDK validates ObjectType.Repository via queryObjectsWithType. Max 100 (MAX_REPOSITORY_COUNT).",
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
id: "P-S-08",
|
|
98
|
-
pattern_name: "Manage rewards (add/remove/clear)",
|
|
99
|
-
semantic_intent: "Bind Reward objects for marketing incentives (locked by setting_lock_duration)",
|
|
100
|
-
match_keywords: ["reward", "incentive", "marketing"],
|
|
101
|
-
schema_fields: ["object", "rewards"],
|
|
102
|
-
example_json: {
|
|
103
|
-
object: "0xSERVICE_ADDRESS",
|
|
104
|
-
rewards: { op: "add", objects: ["0xREWARD_ADDRESS"] },
|
|
105
|
-
},
|
|
106
|
-
reverse_explanation: "Mutable but locked by setting_lock_duration (F-S-24). Cannot be removed until lock expires. Max 20 (MAX_REWARD_COUNT).",
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: "P-S-09",
|
|
110
|
-
pattern_name: "Set order_allocators",
|
|
111
|
-
semantic_intent: "Configure fund distribution strategy (publish prerequisite, post-publish immutable)",
|
|
112
|
-
match_keywords: ["allocator", "order_allocators"],
|
|
113
|
-
schema_fields: ["object", "order_allocators"],
|
|
114
|
-
example_json: {
|
|
115
|
-
object: "0xSERVICE_ADDRESS",
|
|
116
|
-
order_allocators: [
|
|
117
|
-
{
|
|
118
|
-
threshold: "0",
|
|
119
|
-
sharing: [
|
|
120
|
-
{ who: { Object: "0xOWNER" }, weight: 80 },
|
|
121
|
-
{ who: { Object: "0xPLATFORM" }, weight: 20 },
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
},
|
|
126
|
-
reverse_explanation: "MANDATORY before publish (F-S-18, E_NO_ALLOCATOR). First-match-wins: first allocator whose threshold <= order value handles distribution. Post-publish immutable (F-S-22).",
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
id: "P-S-10",
|
|
130
|
-
pattern_name: "Pause/resume Service",
|
|
131
|
-
semantic_intent: "Block new orders (pause) or resume accepting orders",
|
|
132
|
-
match_keywords: ["pause", "resume"],
|
|
133
|
-
schema_fields: ["object", "pause"],
|
|
134
|
-
example_json: {
|
|
135
|
-
object: "0xSERVICE_ADDRESS",
|
|
136
|
-
pause: true,
|
|
137
|
-
},
|
|
138
|
-
reverse_explanation: "pause=true blocks new orders (E_SERVICE_PAUSED); pause=false resumes. Existing Progress continues normally. compensation_fund_withdraw requires paused=true.",
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
id: "P-S-11",
|
|
142
|
-
pattern_name: "Publish Service (IRREVERSIBLE)",
|
|
143
|
-
semantic_intent: "Publish Service — makes it buyable. One-shot, cannot revert.",
|
|
144
|
-
match_keywords: ["publish", "go live", "release"],
|
|
145
|
-
schema_fields: ["object", "publish"],
|
|
146
|
-
example_json: {
|
|
147
|
-
object: "0xSERVICE_ADDRESS",
|
|
148
|
-
publish: true,
|
|
149
|
-
},
|
|
150
|
-
reverse_explanation: "⚠️ IRREVERSIBLE. Requires SERVICE_PUBLISH (311) permission. Prerequisites: order_allocators set; if compensation_fund > 0, arbitrations non-empty. Locks machine/arbitrations/order_allocators forever.",
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
id: "P-S-12",
|
|
154
|
-
pattern_name: "Issue/destroy discount coupons",
|
|
155
|
-
semantic_intent: "Issue promotional discount coupons or destroy (redeem) them",
|
|
156
|
-
match_keywords: ["discount", "coupon"],
|
|
157
|
-
schema_fields: ["object", "discount"],
|
|
158
|
-
example_json: {
|
|
159
|
-
object: "0xSERVICE_ADDRESS",
|
|
160
|
-
discount: {
|
|
161
|
-
name: "SUMMER10",
|
|
162
|
-
discount_type: 0,
|
|
163
|
-
data: 1000,
|
|
164
|
-
count: 100,
|
|
165
|
-
receivers: ["0xUSER1", "0xUSER2"],
|
|
166
|
-
expire_at: 1735689600000,
|
|
167
|
-
},
|
|
168
|
-
},
|
|
169
|
-
reverse_explanation: "discount_type=0 rates (basis points, per 10000), 1=minus (direct deduction). Max 1000 per call (MAX_DISCOUNT_COUNT_ONCE), 20000 total (MAX_DISCOUNT_TOTAL_COUNT). discount_destroy is holder-only.",
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
id: "P-S-13",
|
|
173
|
-
pattern_name: "Compensation fund operations (add/withdraw/receive)",
|
|
174
|
-
semantic_intent: "Deposit to compensation_fund, withdraw (locked), or receive (locked)",
|
|
175
|
-
match_keywords: ["compensation_fund", "compensation", "deposit", "withdraw"],
|
|
176
|
-
schema_fields: ["object", "compensation_fund_add", "compensation_fund_withdraw", "compensation_fund_receive"],
|
|
177
|
-
example_json: {
|
|
178
|
-
object: "0xSERVICE_ADDRESS",
|
|
179
|
-
compensation_fund_add: { balance: "1000000000" },
|
|
180
|
-
},
|
|
181
|
-
reverse_explanation: "add=always mutable; withdraw/receive locked by setting_lock_duration AND requires bPaused=true. Internal Balance<T>, distinct from Treasury.",
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
id: "P-S-14",
|
|
185
|
-
pattern_name: "Extend setting_lock_duration",
|
|
186
|
-
semantic_intent: "Add milliseconds to setting_lock_duration (only-increase mechanism)",
|
|
187
|
-
match_keywords: ["setting_lock_duration", "lock_duration", "lock period", "extend lock"],
|
|
188
|
-
schema_fields: ["object", "setting_lock_duration_add"],
|
|
189
|
-
example_json: {
|
|
190
|
-
object: "0xSERVICE_ADDRESS",
|
|
191
|
-
setting_lock_duration_add: 2592000000,
|
|
192
|
-
},
|
|
193
|
-
reverse_explanation: "Only-increase (safe_add). Default 2592000000ms (30 days). Affects rewards/compensation_fund_withdraw/compensation_fund_receive mutability windows.",
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
id: "P-S-15",
|
|
197
|
-
pattern_name: "Buy (8-stage composite order flow)",
|
|
198
|
-
semantic_intent: "Customer places order — atomic creation of Order + Allocation + Progress",
|
|
199
|
-
match_keywords: ["buy", "order", "purchase"],
|
|
200
|
-
schema_fields: ["object", "order_new"],
|
|
201
|
-
example_json: {
|
|
202
|
-
object: "0xSERVICE_ADDRESS",
|
|
203
|
-
order_new: {
|
|
204
|
-
buy: {
|
|
205
|
-
items: [{ name: "standard", wip_hash: "abcd...64", count: 1 }],
|
|
206
|
-
discount: "0xDISCOUNT_ADDRESS",
|
|
207
|
-
total_pay: "1000000000",
|
|
208
|
-
passport: null,
|
|
209
|
-
},
|
|
210
|
-
order_required_info: { name: "Alice", phone: "+86..." },
|
|
211
|
-
agents: ["0xAGENT1"],
|
|
212
|
-
transfer: null,
|
|
213
|
-
},
|
|
214
|
-
},
|
|
215
|
-
reverse_explanation: "8 stages: pre_check → wip_verify → quote (deducts stock!) → create_order → create_allocation → create_progress → post_actions → return_result. Stock deduction is NOT rolled back on later failure.",
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: "P-S-16",
|
|
219
|
-
pattern_name: "Transfer ownership (IRREVERSIBLE)",
|
|
220
|
-
semantic_intent: "Transfer Service ownership to a new address",
|
|
221
|
-
match_keywords: ["transfer", "handover"],
|
|
222
|
-
schema_fields: ["object", "builder"],
|
|
223
|
-
example_json: {
|
|
224
|
-
object: "0xSERVICE_ADDRESS",
|
|
225
|
-
builder: "0xNEW_OWNER",
|
|
226
|
-
},
|
|
227
|
-
reverse_explanation: "⚠️ IRREVERSIBLE. Original owner loses ALL control. New owner inherits permission, compensation_fund, all bindings. Export JSON before transfer.",
|
|
228
|
-
},
|
|
229
|
-
];
|
|
230
|
-
export const SCHEMA_TO_SEMANTIC_RULES = [
|
|
231
|
-
{
|
|
232
|
-
element_type: "field",
|
|
233
|
-
type_name: "object",
|
|
234
|
-
semantic_explanation: "Service object address. STRING=operate existing; null/omitted=create new",
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
element_type: "field",
|
|
238
|
-
type_name: "description",
|
|
239
|
-
semantic_explanation: "Human-readable Service description. Mutable pre/post publish. Max 4000 chars.",
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
element_type: "field",
|
|
243
|
-
type_name: "location",
|
|
244
|
-
semantic_explanation: "Geographic location of the service (city/region). Mutable. Index 303 (SERVICE_LOCATION).",
|
|
245
|
-
},
|
|
246
|
-
{
|
|
247
|
-
element_type: "field",
|
|
248
|
-
type_name: "customer_required",
|
|
249
|
-
semantic_explanation: "String[] of field names buyers must provide at order time (e.g. ['name','phone']). Mutable. Index 309.",
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
element_type: "field",
|
|
253
|
-
type_name: "sales",
|
|
254
|
-
semantic_explanation: "Product SKU list. op=add/set/remove/clear. Each sale has name/price/stock/wip/wip_hash. Index 305 (SERVICE_SALES).",
|
|
255
|
-
},
|
|
256
|
-
{
|
|
257
|
-
element_type: "field",
|
|
258
|
-
type_name: "machine",
|
|
259
|
-
semantic_explanation: "Machine workflow template binding. ⚠️ IMMUTABLE post-publish (F-S-20). Index 306 (SERVICE_MACHINE).",
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
element_type: "field",
|
|
263
|
-
type_name: "buy_guard",
|
|
264
|
-
semantic_explanation: "Buyer eligibility Guard. ⚠️ UNUSUAL: still mutable post-publish (F-S-26 exception). Index 307 (SERVICE_BUY_GUARD).",
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
element_type: "field",
|
|
268
|
-
type_name: "arbitrations",
|
|
269
|
-
semantic_explanation: "Arbitration object list. Required if compensation_fund > 0. ⚠️ IMMUTABLE post-publish (F-S-21). Index 308.",
|
|
270
|
-
},
|
|
271
|
-
{
|
|
272
|
-
element_type: "field",
|
|
273
|
-
type_name: "repositories",
|
|
274
|
-
semantic_explanation: "Repository object list. Mutable. Max 100 (MAX_REPOSITORY_COUNT). Index 304 (SERVICE_REPOSITORY).",
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
element_type: "field",
|
|
278
|
-
type_name: "rewards",
|
|
279
|
-
semantic_explanation: "Reward object list. Mutable but locked by setting_lock_duration (F-S-24). Max 20 (MAX_REWARD_COUNT). Index 318.",
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
element_type: "field",
|
|
283
|
-
type_name: "order_allocators",
|
|
284
|
-
semantic_explanation: "Fund distribution strategy. ⚠️ MANDATORY for publish (F-S-18). IMMUTABLE post-publish (F-S-22). Index 313.",
|
|
285
|
-
},
|
|
286
|
-
{
|
|
287
|
-
element_type: "field",
|
|
288
|
-
type_name: "discount",
|
|
289
|
-
semantic_explanation: "Discount coupon issuance. discount_type=0 rates, 1=minus. Index 312 (SERVICE_DISCOUNT).",
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
element_type: "field",
|
|
293
|
-
type_name: "pause",
|
|
294
|
-
semantic_explanation: "true=pause (block new orders); false=resume. Existing Progress unaffected. Index 310 (SERVICE_PAUSE).",
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
element_type: "field",
|
|
298
|
-
type_name: "publish",
|
|
299
|
-
semantic_explanation: "⚠️ IRREVERSIBLE one-shot. Requires prerequisites. Locks 3 fields forever. Index 311 (SERVICE_PUBLISH).",
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
element_type: "field",
|
|
303
|
-
type_name: "compensation_fund_add",
|
|
304
|
-
semantic_explanation: "Deposit to internal Balance<T>. Always mutable. Index 315. Distinct from Treasury.",
|
|
305
|
-
},
|
|
306
|
-
{
|
|
307
|
-
element_type: "field",
|
|
308
|
-
type_name: "compensation_fund_withdraw",
|
|
309
|
-
semantic_explanation: "Withdraw from internal Balance<T>. Requires bPaused=true + lock_duration expired. Index 314. Locked by duration (F-S-25).",
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
element_type: "field",
|
|
313
|
-
type_name: "compensation_fund_receive",
|
|
314
|
-
semantic_explanation: "Receive compensation_fund (for arbitration payouts). Locked by setting_lock_duration. Index 316.",
|
|
315
|
-
},
|
|
316
|
-
{
|
|
317
|
-
element_type: "field",
|
|
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
|
-
},
|
|
321
|
-
{
|
|
322
|
-
element_type: "field",
|
|
323
|
-
type_name: "order_new",
|
|
324
|
-
semantic_explanation: "Composite buy operation. Triggers 8-stage flow: pre_check → wip_verify → quote → create_order/allocation/progress → post_actions → return_result.",
|
|
325
|
-
},
|
|
326
|
-
{
|
|
327
|
-
element_type: "field",
|
|
328
|
-
type_name: "builder",
|
|
329
|
-
semantic_explanation: "Transfer ownership. ⚠️ IRREVERSIBLE. Original owner loses ALL control.",
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
element_type: "field",
|
|
333
|
-
type_name: "um",
|
|
334
|
-
semantic_explanation: "User Manager (Contact object). Mutable. Index 320 (SERVICE_UM).",
|
|
335
|
-
},
|
|
336
|
-
{
|
|
337
|
-
element_type: "field",
|
|
338
|
-
type_name: "owner_receive",
|
|
339
|
-
semantic_explanation: "Receive Payment/objects to owner. Index 319 (SERVICE_OWNER_RECEIVE).",
|
|
340
|
-
},
|
|
341
|
-
{
|
|
342
|
-
element_type: "op",
|
|
343
|
-
type_name: "add",
|
|
344
|
-
semantic_explanation: "Append new items (sales/arbitrations/repositories/rewards). Additive, does not replace.",
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
element_type: "op",
|
|
348
|
-
type_name: "set",
|
|
349
|
-
semantic_explanation: "Replace existing item by name (sales) or replace entire list (repositories/rewards/arbitrations).",
|
|
350
|
-
},
|
|
351
|
-
{
|
|
352
|
-
element_type: "op",
|
|
353
|
-
type_name: "remove",
|
|
354
|
-
semantic_explanation: "Remove specific items by name (sales) or address (repositories/rewards/arbitrations).",
|
|
355
|
-
},
|
|
356
|
-
{
|
|
357
|
-
element_type: "op",
|
|
358
|
-
type_name: "clear",
|
|
359
|
-
semantic_explanation: "Remove all items from the list.",
|
|
360
|
-
},
|
|
361
|
-
];
|
|
362
|
-
export const SERVICE_CONSTRAINT_RULES = [
|
|
363
|
-
{
|
|
364
|
-
id: "MC-S-01",
|
|
365
|
-
category: "structural",
|
|
366
|
-
rule: `Service builtin permission indexes must be in range 300-320 (302 reserved/commented)`,
|
|
367
|
-
applies_to: ["permission table.index (when applied to Service)"],
|
|
368
|
-
},
|
|
369
|
-
{
|
|
370
|
-
id: "MC-S-02",
|
|
371
|
-
category: "structural",
|
|
372
|
-
rule: `sales count <= MAX_SALE_COUNT (${MAX_SALE_COUNT})`,
|
|
373
|
-
applies_to: ["sales.sales"],
|
|
374
|
-
},
|
|
375
|
-
{
|
|
376
|
-
id: "MC-S-03",
|
|
377
|
-
category: "structural",
|
|
378
|
-
rule: `repositories count <= MAX_REPOSITORY_COUNT (${MAX_REPOSITORY_COUNT})`,
|
|
379
|
-
applies_to: ["repositories.objects"],
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
id: "MC-S-04",
|
|
383
|
-
category: "structural",
|
|
384
|
-
rule: `arbitrations count <= MAX_ARBITRATION_COUNT (${MAX_ARBITRATION_COUNT})`,
|
|
385
|
-
applies_to: ["arbitrations.objects"],
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
id: "MC-S-05",
|
|
389
|
-
category: "structural",
|
|
390
|
-
rule: `rewards count <= MAX_REWARD_COUNT (20)`,
|
|
391
|
-
applies_to: ["rewards.objects"],
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
id: "MC-S-06",
|
|
395
|
-
category: "structural",
|
|
396
|
-
rule: `customer_required count <= 10, each item length <= 20`,
|
|
397
|
-
applies_to: ["customer_required"],
|
|
398
|
-
},
|
|
399
|
-
{
|
|
400
|
-
id: "MC-S-07",
|
|
401
|
-
category: "structural",
|
|
402
|
-
rule: `wip URL length <= MAX_WIP_LENGTH (${MAX_WIP_LENGTH})`,
|
|
403
|
-
applies_to: ["sales.sales[].wip"],
|
|
404
|
-
},
|
|
405
|
-
{
|
|
406
|
-
id: "MC-S-08",
|
|
407
|
-
category: "structural",
|
|
408
|
-
rule: `wip_hash length <= MAX_WIP_HASH_LENGTH (${MAX_WIP_HASH_LENGTH}) — sha256 hex (64 chars, no prefix)`,
|
|
409
|
-
applies_to: ["sales.sales[].wip_hash", "order_new.buy.items[].wip_hash"],
|
|
410
|
-
},
|
|
411
|
-
{
|
|
412
|
-
id: "MC-S-09",
|
|
413
|
-
category: "semantic",
|
|
414
|
-
rule: `wip_hash must NOT be empty when wip URL is set (tamper protection)`,
|
|
415
|
-
applies_to: ["sales.sales[]"],
|
|
416
|
-
},
|
|
417
|
-
{
|
|
418
|
-
id: "MC-S-10",
|
|
419
|
-
category: "authority",
|
|
420
|
-
rule: `publish requires order_allocators set (F-S-18, E_NO_ALLOCATOR)`,
|
|
421
|
-
applies_to: ["publish", "order_allocators"],
|
|
422
|
-
},
|
|
423
|
-
{
|
|
424
|
-
id: "MC-S-11",
|
|
425
|
-
category: "authority",
|
|
426
|
-
rule: `publish with compensation_fund > 0 requires arbitrations non-empty (F-S-19, E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)`,
|
|
427
|
-
applies_to: ["publish", "arbitrations", "compensation_fund_add"],
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
id: "MC-S-12",
|
|
431
|
-
category: "lifecycle",
|
|
432
|
-
rule: `machine IMMUTABLE post-publish (F-S-20) — SDK checkNotPublished() blocks`,
|
|
433
|
-
applies_to: ["machine"],
|
|
434
|
-
},
|
|
435
|
-
{
|
|
436
|
-
id: "MC-S-13",
|
|
437
|
-
category: "lifecycle",
|
|
438
|
-
rule: `arbitrations IMMUTABLE post-publish (F-S-21) — SDK checkNotPublished() blocks`,
|
|
439
|
-
applies_to: ["arbitrations"],
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
id: "MC-S-14",
|
|
443
|
-
category: "lifecycle",
|
|
444
|
-
rule: `order_allocators IMMUTABLE post-publish (F-S-22) — SDK checkNotPublished() blocks`,
|
|
445
|
-
applies_to: ["order_allocators"],
|
|
446
|
-
},
|
|
447
|
-
{
|
|
448
|
-
id: "MC-S-15",
|
|
449
|
-
category: "lifecycle",
|
|
450
|
-
rule: `bPublished is IRREVERSIBLE (one-shot, cannot revert to false) — to 'reset', create new Service`,
|
|
451
|
-
applies_to: ["publish"],
|
|
452
|
-
},
|
|
453
|
-
{
|
|
454
|
-
id: "MC-S-16",
|
|
455
|
-
category: "lifecycle",
|
|
456
|
-
rule: `setting_lock_duration only-increase (safe_add) — cannot be decreased; protects customers`,
|
|
457
|
-
applies_to: ["setting_lock_duration_add"],
|
|
458
|
-
},
|
|
459
|
-
{
|
|
460
|
-
id: "MC-S-17",
|
|
461
|
-
category: "lifecycle",
|
|
462
|
-
rule: `compensation_fund_withdraw requires bPaused=true AND setting_lock_duration expired (F-S-25, F-S-26)`,
|
|
463
|
-
applies_to: ["compensation_fund_withdraw", "pause"],
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
id: "MC-S-18",
|
|
467
|
-
category: "semantic",
|
|
468
|
-
rule: `discount count <= MAX_DISCOUNT_TOTAL_COUNT (${MAX_DISCOUNT_TOTAL_COUNT}); per-call <= MAX_DISCOUNT_COUNT_ONCE (${MAX_DISCOUNT_COUNT_ONCE})`,
|
|
469
|
-
applies_to: ["discount.count"],
|
|
470
|
-
},
|
|
471
|
-
{
|
|
472
|
-
id: "MC-S-19",
|
|
473
|
-
category: "semantic",
|
|
474
|
-
rule: `buy_guard is the ONLY field still mutable post-publish (F-S-26 exception) — all other guarded fields are immutable`,
|
|
475
|
-
applies_to: ["buy_guard"],
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
id: "MC-S-20",
|
|
479
|
-
category: "authority",
|
|
480
|
-
rule: `Ownership transfer (builder) is IRREVERSIBLE — new owner inherits permission + compensation_fund + all bindings`,
|
|
481
|
-
applies_to: ["builder"],
|
|
482
|
-
},
|
|
483
|
-
];
|
|
484
|
-
export const SERVICE_TRANSLATION_VERSION = "1.0.0";
|
|
485
|
-
export function matchSemanticPattern(userIntent) {
|
|
486
|
-
const lower = userIntent.toLowerCase();
|
|
487
|
-
return SEMANTIC_TO_SCHEMA_RULES.filter(rule => rule.match_keywords.some(kw => lower.includes(kw.toLowerCase())));
|
|
488
|
-
}
|
|
489
|
-
export function explainServiceCallData(data) {
|
|
490
|
-
const lines = [];
|
|
491
|
-
if (data.object === null || data.object === undefined) {
|
|
492
|
-
lines.push("Operation: CREATE new Service");
|
|
493
|
-
}
|
|
494
|
-
else {
|
|
495
|
-
lines.push(`Operation: MODIFY existing Service at ${data.object}`);
|
|
496
|
-
}
|
|
497
|
-
if (data.description)
|
|
498
|
-
lines.push(`- Set description: "${data.description}"`);
|
|
499
|
-
if (data.location)
|
|
500
|
-
lines.push(`- Set location: ${data.location}`);
|
|
501
|
-
if (data.customer_required)
|
|
502
|
-
lines.push(`- Customer required fields: [${data.customer_required.join(", ")}]`);
|
|
503
|
-
if (data.sales) {
|
|
504
|
-
const s = data.sales;
|
|
505
|
-
if (s.op === "clear") {
|
|
506
|
-
lines.push(`- Sales: CLEAR all items`);
|
|
507
|
-
}
|
|
508
|
-
else if (s.op === "remove") {
|
|
509
|
-
lines.push(`- Sales REMOVE: [${s.sales_name.join(", ")}]`);
|
|
510
|
-
}
|
|
511
|
-
else {
|
|
512
|
-
lines.push(`- Sales ${s.op.toUpperCase()}: ${s.sales.length} item(s)`);
|
|
513
|
-
for (const item of s.sales) {
|
|
514
|
-
const hashInfo = item.wip_hash ? ` hash=${item.wip_hash.slice(0, 8)}...` : " ⚠️NO_HASH";
|
|
515
|
-
lines.push(` • ${item.name} price=${item.price ?? "?"} stock=${item.stock ?? "?"}${hashInfo}`);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
if (data.machine !== undefined) {
|
|
520
|
-
lines.push(data.machine === null ? `- Machine: unbind (pre-publish only)` : `- Machine: bind ${data.machine}`);
|
|
521
|
-
}
|
|
522
|
-
if (data.buy_guard !== undefined) {
|
|
523
|
-
lines.push(data.buy_guard === null ? `- Buy Guard: clear` : `- Buy Guard: set ${data.buy_guard} [mutable post-publish]`);
|
|
524
|
-
}
|
|
525
|
-
if (data.arbitrations) {
|
|
526
|
-
const a = data.arbitrations;
|
|
527
|
-
if (a.op === "clear") {
|
|
528
|
-
lines.push(`- Arbitrations: CLEAR (pre-publish only)`);
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
lines.push(`- Arbitrations ${a.op.toUpperCase()}: ${a.objects.length} object(s)`);
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
if (data.repositories) {
|
|
535
|
-
const r = data.repositories;
|
|
536
|
-
if (r.op === "clear") {
|
|
537
|
-
lines.push(`- Repositories: CLEAR`);
|
|
538
|
-
}
|
|
539
|
-
else {
|
|
540
|
-
lines.push(`- Repositories ${r.op.toUpperCase()}: ${r.objects.length} object(s)`);
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (data.rewards) {
|
|
544
|
-
const r = data.rewards;
|
|
545
|
-
if (r.op === "clear") {
|
|
546
|
-
lines.push(`- Rewards: CLEAR (locked by duration)`);
|
|
547
|
-
}
|
|
548
|
-
else {
|
|
549
|
-
lines.push(`- Rewards ${r.op.toUpperCase()}: ${r.objects.length} object(s) [locked by duration]`);
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
if (data.order_allocators !== undefined) {
|
|
553
|
-
lines.push(`- Order Allocators: ${data.order_allocators ? "configured" : "(clear)"} [immutable post-publish]`);
|
|
554
|
-
}
|
|
555
|
-
if (data.discount) {
|
|
556
|
-
const d = data.discount;
|
|
557
|
-
const typeName = d.discount_type === 0 ? "rates (basis points, per 10000)" : "minus (direct deduction)";
|
|
558
|
-
lines.push(`- Discount: ${d.name} type=${typeName} data=${d.data} count=${d.count}`);
|
|
559
|
-
}
|
|
560
|
-
if (data.pause !== undefined) {
|
|
561
|
-
lines.push(`- Pause: ${data.pause ? "PAUSE (block new orders)" : "RESUME"}`);
|
|
562
|
-
}
|
|
563
|
-
if (data.publish) {
|
|
564
|
-
lines.push(`- ⚠️ PUBLISH (IRREVERSIBLE — locks machine/arbitrations/order_allocators forever)`);
|
|
565
|
-
}
|
|
566
|
-
if (data.compensation_fund_add) {
|
|
567
|
-
lines.push(`- Compensation fund deposit: ${data.compensation_fund_add.balance} (internal Balance<T>)`);
|
|
568
|
-
}
|
|
569
|
-
if (data.compensation_fund_withdraw) {
|
|
570
|
-
lines.push(`- ⚠️ Compensation fund withdraw (requires bPaused=true + lock_duration expired)`);
|
|
571
|
-
}
|
|
572
|
-
if (data.compensation_fund_receive) {
|
|
573
|
-
lines.push(`- Compensation fund receive (locked by duration)`);
|
|
574
|
-
}
|
|
575
|
-
if (data.setting_lock_duration_add !== undefined) {
|
|
576
|
-
lines.push(`- Setting lock duration +${data.setting_lock_duration_add}ms (only-increase)`);
|
|
577
|
-
}
|
|
578
|
-
if (data.order_new) {
|
|
579
|
-
const o = data.order_new;
|
|
580
|
-
lines.push(`- ⚠️ ORDER NEW (8-stage composite flow):`);
|
|
581
|
-
lines.push(` Items: ${o.buy.items.length}`);
|
|
582
|
-
lines.push(` Total pay: ${o.buy.total_pay}`);
|
|
583
|
-
if (o.buy.discount)
|
|
584
|
-
lines.push(` Discount: ${o.buy.discount}`);
|
|
585
|
-
lines.push(` Stages: pre_check → wip_verify → quote (deducts stock!) → create_order/allocation/progress → return`);
|
|
586
|
-
}
|
|
587
|
-
if (data.builder) {
|
|
588
|
-
lines.push(`- ⚠️ TRANSFER ownership to ${data.builder} (IRREVERSIBLE)`);
|
|
589
|
-
}
|
|
590
|
-
if (data.um !== undefined) {
|
|
591
|
-
lines.push(data.um === null ? `- UM: revoke` : `- UM: set to ${data.um}`);
|
|
592
|
-
}
|
|
593
|
-
if (data.owner_receive) {
|
|
594
|
-
lines.push(`- Owner receive: receive Payment/objects to owner`);
|
|
595
|
-
}
|
|
596
|
-
return lines.join("\n");
|
|
597
|
-
}
|
|
598
|
-
export function explainField(fieldName) {
|
|
599
|
-
return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "field" && r.type_name === fieldName);
|
|
600
|
-
}
|
|
601
|
-
export function explainOp(opName) {
|
|
602
|
-
return SCHEMA_TO_SEMANTIC_RULES.find(r => r.element_type === "op" && r.type_name === opName);
|
|
603
|
-
}
|
|
604
|
-
export function getConstraintsByCategory(category) {
|
|
605
|
-
return SERVICE_CONSTRAINT_RULES.filter(r => r.category === category);
|
|
606
|
-
}
|
|
607
|
-
export function explainServicePermissionIndex(index) {
|
|
608
|
-
if (isServicePermission(index)) {
|
|
609
|
-
const entry = getServicePermissionByIndex(index);
|
|
610
|
-
if (!entry)
|
|
611
|
-
return `Unknown Service permission (${index})`;
|
|
612
|
-
const mutabilityNote = entry.post_publish_mutability === "immutable"
|
|
613
|
-
? " [IMMUTABLE post-publish]"
|
|
614
|
-
: entry.post_publish_mutability === "one_shot"
|
|
615
|
-
? " [ONE-SHOT, irreversible]"
|
|
616
|
-
: entry.post_publish_mutability === "locked_by_duration"
|
|
617
|
-
? " [locked by setting_lock_duration]"
|
|
618
|
-
: "";
|
|
619
|
-
return `${entry.name} (${index}) — ${entry.description}${mutabilityNote}`;
|
|
620
|
-
}
|
|
621
|
-
return `Non-Service permission (${index}) — verify against host object's index range`;
|
|
622
|
-
}
|
|
1
|
+
import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{isServicePermission,getServicePermissionByIndex}from'./service-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-S-01','pattern_name':'Create\x20new\x20Service','semantic_intent':'Create\x20a\x20new\x20Service<T>\x20with\x20owner,\x20permission,\x20description,\x20coin\x20type','match_keywords':['create','new','open'],'schema_fields':['object(null)','description','permission','owner','coin_type'],'example_json':{'object':null,'description':'My\x20retail\x20shop','permission':'0xPERMISSION_ADDRESS'},'reverse_explanation':'object=null\x20indicates\x20creation;\x20permission\x20must\x20be\x20a\x20valid\x20Permission\x20object\x20owned\x20by\x20signer'},{'id':'P-S-02','pattern_name':'Modify\x20description\x20/\x20location\x20/\x20customer_required','semantic_intent':'Update\x20Service\x20metadata\x20fields\x20(mutable\x20pre\x20and\x20post\x20publish)','match_keywords':['describe','locate','customer_required','update','modify'],'schema_fields':['object','description','location','customer_required'],'example_json':{'object':'0xSERVICE_ADDRESS','description':'Updated\x20description','location':'Shanghai','customer_required':['name','phone']},'reverse_explanation':'These\x20fields\x20are\x20always\x20mutable.\x20customer_required\x20is\x20a\x20string[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time.'},{'id':'P-S-03','pattern_name':'Manage\x20sales\x20items\x20(add/set/remove/clear)','semantic_intent':'Add\x20product\x20SKUs,\x20update\x20prices/stock,\x20remove\x20deprecated\x20items,\x20or\x20clear\x20all','match_keywords':['sales','product','sku','inventory','price'],'schema_fields':['object','sales'],'example_json':{'object':'0xSERVICE_ADDRESS','sales':{'op':'add','sales':[{'name':'standard','price':'1000000000','stock':0x64,'wip':'https://ipfs/wip','wip_hash':'abcd...64'}]}},'reverse_explanation':'sales.op=add\x20appends;\x20set\x20replaces\x20matching\x20name;\x20remove\x20deletes\x20by\x20name;\x20clear\x20empties\x20all.\x20wip_hash\x20is\x20REQUIRED\x20for\x20tamper\x20protection.'},{'id':'P-S-04','pattern_name':'Bind/unbind\x20Machine\x20workflow','semantic_intent':'Bind\x20a\x20Machine\x20workflow\x20template\x20to\x20Service\x20(post-publish\x20immutable)','match_keywords':['machine','workflow','bind\x20machine'],'schema_fields':['object','machine'],'example_json':{'object':'0xSERVICE_ADDRESS','machine':'0xMACHINE_ADDRESS'},'reverse_explanation':'machine=<address>\x20binds;\x20machine=null\x20unbinds\x20(pre-publish\x20only).\x20Once\x20published,\x20machine\x20is\x20immutable\x20(F-S-20).\x20Progress\x20inherits\x20this\x20binding.'},{'id':'P-S-05','pattern_name':'Set/clear\x20buy\x20Guard','semantic_intent':'Set\x20buyer\x20eligibility\x20Guard\x20(KYC/whitelist)\x20or\x20clear\x20it','match_keywords':['buy_guard','kyc','whitelist'],'schema_fields':['object','buy_guard'],'example_json':{'object':'0xSERVICE_ADDRESS','buy_guard':'0xGUARD_ADDRESS'},'reverse_explanation':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Pre-sale:\x20set\x20to\x20whitelist;\x20public\x20sale:\x20set\x20to\x20null.'},{'id':'P-S-06','pattern_name':'Manage\x20arbitrations\x20(add/remove/clear)','semantic_intent':'Bind\x20Arbitration\x20objects\x20for\x20dispute\x20handling\x20(post-publish\x20immutable)','match_keywords':['arbitration','arbitrator','dispute'],'schema_fields':['object','arbitrations'],'example_json':{'object':'0xSERVICE_ADDRESS','arbitrations':{'op':'add','objects':['0xARB_ADDRESS']}},'reverse_explanation':'Required\x20when\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).\x20Use\x201-3\x20Arbitration\x20objects\x20covering\x20different\x20scopes.'},{'id':'P-S-07','pattern_name':'Manage\x20repositories\x20(add/remove/clear)','semantic_intent':'Bind\x20Repository\x20objects\x20(data\x20stores)\x20—\x20mutable\x20post-publish','match_keywords':['repository','data\x20store','storage','data\x20source'],'schema_fields':['object','repositories'],'example_json':{'object':'0xSERVICE_ADDRESS','repositories':{'op':'add','objects':['0xREPO_ADDRESS']}},'reverse_explanation':'Mutable\x20post-publish.\x20SDK\x20validates\x20ObjectType.Repository\x20via\x20queryObjectsWithType.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).'},{'id':'P-S-08','pattern_name':'Manage\x20rewards\x20(add/remove/clear)','semantic_intent':'Bind\x20Reward\x20objects\x20for\x20marketing\x20incentives\x20(locked\x20by\x20setting_lock_duration)','match_keywords':['reward','incentive','marketing'],'schema_fields':['object','rewards'],'example_json':{'object':'0xSERVICE_ADDRESS','rewards':{'op':'add','objects':['0xREWARD_ADDRESS']}},'reverse_explanation':'Mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24).\x20Cannot\x20be\x20removed\x20until\x20lock\x20expires.\x20Max\x2020\x20(MAX_REWARD_COUNT).'},{'id':'P-S-09','pattern_name':'Set\x20order_allocators','semantic_intent':'Configure\x20fund\x20distribution\x20strategy\x20(publish\x20prerequisite,\x20post-publish\x20immutable)','match_keywords':['allocator','order_allocators'],'schema_fields':['object','order_allocators'],'example_json':{'object':'0xSERVICE_ADDRESS','order_allocators':[{'threshold':'0','sharing':[{'who':{'Object':'0xOWNER'},'weight':0x50},{'who':{'Object':'0xPLATFORM'},'weight':0x14}]}]},'reverse_explanation':'MANDATORY\x20before\x20publish\x20(F-S-18,\x20E_NO_ALLOCATOR).\x20First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20<=\x20order\x20value\x20handles\x20distribution.\x20Post-publish\x20immutable\x20(F-S-22).'},{'id':'P-S-10','pattern_name':'Pause/resume\x20Service','semantic_intent':'Block\x20new\x20orders\x20(pause)\x20or\x20resume\x20accepting\x20orders','match_keywords':['pause','resume'],'schema_fields':['object','pause'],'example_json':{'object':'0xSERVICE_ADDRESS','pause':!![]},'reverse_explanation':'pause=true\x20blocks\x20new\x20orders\x20(E_SERVICE_PAUSED);\x20pause=false\x20resumes.\x20Existing\x20Progress\x20continues\x20normally.\x20compensation_fund_withdraw\x20requires\x20paused=true.'},{'id':'P-S-11','pattern_name':'Publish\x20Service\x20(IRREVERSIBLE)','semantic_intent':'Publish\x20Service\x20—\x20makes\x20it\x20buyable.\x20One-shot,\x20cannot\x20revert.','match_keywords':['publish','go\x20live','release'],'schema_fields':['object','publish'],'example_json':{'object':'0xSERVICE_ADDRESS','publish':!![]},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Requires\x20SERVICE_PUBLISH\x20(311)\x20permission.\x20Prerequisites:\x20order_allocators\x20set;\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty.\x20Locks\x20machine/arbitrations/order_allocators\x20forever.'},{'id':'P-S-12','pattern_name':'Issue/destroy\x20discount\x20coupons','semantic_intent':'Issue\x20promotional\x20discount\x20coupons\x20or\x20destroy\x20(redeem)\x20them','match_keywords':['discount','coupon'],'schema_fields':['object','discount'],'example_json':{'object':'0xSERVICE_ADDRESS','discount':{'name':'SUMMER10','discount_type':0x0,'data':0x3e8,'count':0x64,'receivers':['0xUSER1','0xUSER2'],'expire_at':0x1941f297c00}},'reverse_explanation':'discount_type=0\x20rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction).\x20Max\x201000\x20per\x20call\x20(MAX_DISCOUNT_COUNT_ONCE),\x2020000\x20total\x20(MAX_DISCOUNT_TOTAL_COUNT).\x20discount_destroy\x20is\x20holder-only.'},{'id':'P-S-13','pattern_name':'Compensation\x20fund\x20operations\x20(add/withdraw/receive)','semantic_intent':'Deposit\x20to\x20compensation_fund,\x20withdraw\x20(locked),\x20or\x20receive\x20(locked)','match_keywords':['compensation_fund','compensation','deposit','withdraw'],'schema_fields':['object','compensation_fund_add','compensation_fund_withdraw','compensation_fund_receive'],'example_json':{'object':'0xSERVICE_ADDRESS','compensation_fund_add':{'balance':'1000000000'}},'reverse_explanation':'add=always\x20mutable;\x20withdraw/receive\x20locked\x20by\x20setting_lock_duration\x20AND\x20requires\x20bPaused=true.\x20Internal\x20Balance<T>,\x20distinct\x20from\x20Treasury.'},{'id':'P-S-14','pattern_name':'Extend\x20setting_lock_duration','semantic_intent':'Add\x20milliseconds\x20to\x20setting_lock_duration\x20(only-increase\x20mechanism)','match_keywords':['setting_lock_duration','lock_duration','lock\x20period','extend\x20lock'],'schema_fields':['object','setting_lock_duration_add'],'example_json':{'object':'0xSERVICE_ADDRESS','setting_lock_duration_add':0x9a7ec800},'reverse_explanation':'Only-increase\x20(safe_add).\x20Default\x202592000000ms\x20(30\x20days).\x20Affects\x20rewards/compensation_fund_withdraw/compensation_fund_receive\x20mutability\x20windows.'},{'id':'P-S-15','pattern_name':'Buy\x20(8-stage\x20composite\x20order\x20flow)','semantic_intent':'Customer\x20places\x20order\x20—\x20atomic\x20creation\x20of\x20Order\x20+\x20Allocation\x20+\x20Progress','match_keywords':['buy','order','purchase'],'schema_fields':['object','order_new'],'example_json':{'object':'0xSERVICE_ADDRESS','order_new':{'buy':{'items':[{'name':'standard','wip_hash':'abcd...64','count':0x1}],'discount':'0xDISCOUNT_ADDRESS','total_pay':'1000000000','passport':null},'order_required_info':{'name':'Alice','phone':'+86...'},'agents':['0xAGENT1'],'transfer':null}},'reverse_explanation':'8\x20stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order\x20→\x20create_allocation\x20→\x20create_progress\x20→\x20post_actions\x20→\x20return_result.\x20Stock\x20deduction\x20is\x20NOT\x20rolled\x20back\x20on\x20later\x20failure.'},{'id':'P-S-16','pattern_name':'Transfer\x20ownership\x20(IRREVERSIBLE)','semantic_intent':'Transfer\x20Service\x20ownership\x20to\x20a\x20new\x20address','match_keywords':['transfer','handover'],'schema_fields':['object','builder'],'example_json':{'object':'0xSERVICE_ADDRESS','builder':'0xNEW_OWNER'},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20permission,\x20compensation_fund,\x20all\x20bindings.\x20Export\x20JSON\x20before\x20transfer.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Service\x20object\x20address.\x20STRING=operate\x20existing;\x20null/omitted=create\x20new'},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20Service\x20description.\x20Mutable\x20pre/post\x20publish.\x20Max\x204000\x20chars.'},{'element_type':'field','type_name':'location','semantic_explanation':'Geographic\x20location\x20of\x20the\x20service\x20(city/region).\x20Mutable.\x20Index\x20303\x20(SERVICE_LOCATION).'},{'element_type':'field','type_name':'customer_required','semantic_explanation':'String[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time\x20(e.g.\x20[\x27name\x27,\x27phone\x27]).\x20Mutable.\x20Index\x20309.'},{'element_type':'field','type_name':'sales','semantic_explanation':'Product\x20SKU\x20list.\x20op=add/set/remove/clear.\x20Each\x20sale\x20has\x20name/price/stock/wip/wip_hash.\x20Index\x20305\x20(SERVICE_SALES).'},{'element_type':'field','type_name':'machine','semantic_explanation':'Machine\x20workflow\x20template\x20binding.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-20).\x20Index\x20306\x20(SERVICE_MACHINE).'},{'element_type':'field','type_name':'buy_guard','semantic_explanation':'Buyer\x20eligibility\x20Guard.\x20⚠️\x20UNUSUAL:\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Index\x20307\x20(SERVICE_BUY_GUARD).'},{'element_type':'field','type_name':'arbitrations','semantic_explanation':'Arbitration\x20object\x20list.\x20Required\x20if\x20compensation_fund\x20>\x200.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-21).\x20Index\x20308.'},{'element_type':'field','type_name':'repositories','semantic_explanation':'Repository\x20object\x20list.\x20Mutable.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).\x20Index\x20304\x20(SERVICE_REPOSITORY).'},{'element_type':'field','type_name':'rewards','semantic_explanation':'Reward\x20object\x20list.\x20Mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24).\x20Max\x2020\x20(MAX_REWARD_COUNT).\x20Index\x20318.'},{'element_type':'field','type_name':'order_allocators','semantic_explanation':'Fund\x20distribution\x20strategy.\x20⚠️\x20MANDATORY\x20for\x20publish\x20(F-S-18).\x20IMMUTABLE\x20post-publish\x20(F-S-22).\x20Index\x20313.'},{'element_type':'field','type_name':'discount','semantic_explanation':'Discount\x20coupon\x20issuance.\x20discount_type=0\x20rates,\x201=minus.\x20Index\x20312\x20(SERVICE_DISCOUNT).'},{'element_type':'field','type_name':'pause','semantic_explanation':'true=pause\x20(block\x20new\x20orders);\x20false=resume.\x20Existing\x20Progress\x20unaffected.\x20Index\x20310\x20(SERVICE_PAUSE).'},{'element_type':'field','type_name':'publish','semantic_explanation':'⚠️\x20IRREVERSIBLE\x20one-shot.\x20Requires\x20prerequisites.\x20Locks\x203\x20fields\x20forever.\x20Index\x20311\x20(SERVICE_PUBLISH).'},{'element_type':'field','type_name':'compensation_fund_add','semantic_explanation':'Deposit\x20to\x20internal\x20Balance<T>.\x20Always\x20mutable.\x20Index\x20315.\x20Distinct\x20from\x20Treasury.'},{'element_type':'field','type_name':'compensation_fund_withdraw','semantic_explanation':'Withdraw\x20from\x20internal\x20Balance<T>.\x20Requires\x20bPaused=true\x20+\x20lock_duration\x20expired.\x20Index\x20314.\x20Locked\x20by\x20duration\x20(F-S-25).'},{'element_type':'field','type_name':'compensation_fund_receive','semantic_explanation':'Receive\x20compensation_fund\x20(for\x20arbitration\x20payouts).\x20Locked\x20by\x20setting_lock_duration.\x20Index\x20316.'},{'element_type':'field','type_name':'setting_lock_duration_add','semantic_explanation':'Extend\x20setting_lock_duration\x20(only-increase,\x20safe_add).\x20Index\x20317\x20(SERVICE_COMPENSATION_LOCK_DURATION_ADD).'},{'element_type':'field','type_name':'order_new','semantic_explanation':'Composite\x20buy\x20operation.\x20Triggers\x208-stage\x20flow:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20→\x20create_order/allocation/progress\x20→\x20post_actions\x20→\x20return_result.'},{'element_type':'field','type_name':'builder','semantic_explanation':'Transfer\x20ownership.\x20⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.'},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object).\x20Mutable.\x20Index\x20320\x20(SERVICE_UM).'},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Receive\x20Payment/objects\x20to\x20owner.\x20Index\x20319\x20(SERVICE_OWNER_RECEIVE).'},{'element_type':'op','type_name':'add','semantic_explanation':'Append\x20new\x20items\x20(sales/arbitrations/repositories/rewards).\x20Additive,\x20does\x20not\x20replace.'},{'element_type':'op','type_name':'set','semantic_explanation':'Replace\x20existing\x20item\x20by\x20name\x20(sales)\x20or\x20replace\x20entire\x20list\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'remove','semantic_explanation':'Remove\x20specific\x20items\x20by\x20name\x20(sales)\x20or\x20address\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'clear','semantic_explanation':'Remove\x20all\x20items\x20from\x20the\x20list.'}];export const SERVICE_CONSTRAINT_RULES=[{'id':'MC-S-01','category':'structural','rule':'Service\x20builtin\x20permission\x20indexes\x20must\x20be\x20in\x20range\x20300-320\x20(302\x20reserved/commented)','applies_to':['permission\x20table.index\x20(when\x20applied\x20to\x20Service)']},{'id':'MC-S-02','category':'structural','rule':'sales\x20count\x20<=\x20MAX_SALE_COUNT\x20('+MAX_SALE_COUNT+')','applies_to':['sales.sales']},{'id':'MC-S-03','category':'structural','rule':'repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20('+MAX_REPOSITORY_COUNT+')','applies_to':['repositories.objects']},{'id':'MC-S-04','category':'structural','rule':'arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20('+MAX_ARBITRATION_COUNT+')','applies_to':['arbitrations.objects']},{'id':'MC-S-05','category':'structural','rule':'rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','applies_to':['rewards.objects']},{'id':'MC-S-06','category':'structural','rule':'customer_required\x20count\x20<=\x2010,\x20each\x20item\x20length\x20<=\x2020','applies_to':['customer_required']},{'id':'MC-S-07','category':'structural','rule':'wip\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20('+MAX_WIP_LENGTH+')','applies_to':['sales.sales[].wip']},{'id':'MC-S-08','category':'structural','rule':'wip_hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20('+MAX_WIP_HASH_LENGTH+')\x20—\x20sha256\x20hex\x20(64\x20chars,\x20no\x20prefix)','applies_to':['sales.sales[].wip_hash','order_new.buy.items[].wip_hash']},{'id':'MC-S-09','category':'semantic','rule':'wip_hash\x20must\x20NOT\x20be\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','applies_to':['sales.sales[]']},{'id':'MC-S-10','category':'authority','rule':'publish\x20requires\x20order_allocators\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','applies_to':['publish','order_allocators']},{'id':'MC-S-11','category':'authority','rule':'publish\x20with\x20compensation_fund\x20>\x200\x20requires\x20arbitrations\x20non-empty\x20(F-S-19,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','applies_to':['publish','arbitrations','compensation_fund_add']},{'id':'MC-S-12','category':'lifecycle','rule':'machine\x20IMMUTABLE\x20post-publish\x20(F-S-20)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['machine']},{'id':'MC-S-13','category':'lifecycle','rule':'arbitrations\x20IMMUTABLE\x20post-publish\x20(F-S-21)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['arbitrations']},{'id':'MC-S-14','category':'lifecycle','rule':'order_allocators\x20IMMUTABLE\x20post-publish\x20(F-S-22)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['order_allocators']},{'id':'MC-S-15','category':'lifecycle','rule':'bPublished\x20is\x20IRREVERSIBLE\x20(one-shot,\x20cannot\x20revert\x20to\x20false)\x20—\x20to\x20\x27reset\x27,\x20create\x20new\x20Service','applies_to':['publish']},{'id':'MC-S-16','category':'lifecycle','rule':'setting_lock_duration\x20only-increase\x20(safe_add)\x20—\x20cannot\x20be\x20decreased;\x20protects\x20customers','applies_to':['setting_lock_duration_add']},{'id':'MC-S-17','category':'lifecycle','rule':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20AND\x20setting_lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','applies_to':['compensation_fund_withdraw','pause']},{'id':'MC-S-18','category':'semantic','rule':'discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20('+MAX_DISCOUNT_TOTAL_COUNT+');\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20('+MAX_DISCOUNT_COUNT_ONCE+')','applies_to':['discount.count']},{'id':'MC-S-19','category':'semantic','rule':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception)\x20—\x20all\x20other\x20guarded\x20fields\x20are\x20immutable','applies_to':['buy_guard']},{'id':'MC-S-20','category':'authority','rule':'Ownership\x20transfer\x20(builder)\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20inherits\x20permission\x20+\x20compensation_fund\x20+\x20all\x20bindings','applies_to':['builder']}];export const SERVICE_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainServiceCallData(b){const c=[];b['object']===null||b['object']===undefined?c['push']('Operation:\x20CREATE\x20new\x20Service'):c['push']('Operation:\x20MODIFY\x20existing\x20Service\x20at\x20'+b['object']);if(b['description'])c['push']('-\x20Set\x20description:\x20\x22'+b['description']+'\x22');if(b['location'])c['push']('-\x20Set\x20location:\x20'+b['location']);if(b['customer_required'])c['push']('-\x20Customer\x20required\x20fields:\x20['+b['customer_required']['join'](',\x20')+']');if(b['sales']){const e=b['sales'];if(e['op']==='clear')c['push']('-\x20Sales:\x20CLEAR\x20all\x20items');else{if(e['op']==='remove')c['push']('-\x20Sales\x20REMOVE:\x20['+e['sales_name']['join'](',\x20')+']');else{c['push']('-\x20Sales\x20'+e['op']['toUpperCase']()+':\x20'+e['sales']['length']+'\x20item(s)');for(const f of e['sales']){const g=f['wip_hash']?'\x20hash='+f['wip_hash']['slice'](0x0,0x8)+'...':'\x20⚠️NO_HASH';c['push']('\x20\x20\x20\x20•\x20'+f['name']+'\x20price='+(f['price']??'?')+'\x20stock='+(f['stock']??'?')+g);}}}}b['machine']!==undefined&&c['push'](b['machine']===null?'-\x20Machine:\x20unbind\x20(pre-publish\x20only)':'-\x20Machine:\x20bind\x20'+b['machine']);b['buy_guard']!==undefined&&c['push'](b['buy_guard']===null?'-\x20Buy\x20Guard:\x20clear':'-\x20Buy\x20Guard:\x20set\x20'+b['buy_guard']+'\x20[mutable\x20post-publish]');if(b['arbitrations']){const h=b['arbitrations'];h['op']==='clear'?c['push']('-\x20Arbitrations:\x20CLEAR\x20(pre-publish\x20only)'):c['push']('-\x20Arbitrations\x20'+h['op']['toUpperCase']()+':\x20'+h['objects']['length']+'\x20object(s)');}if(b['repositories']){const i=b['repositories'];i['op']==='clear'?c['push']('-\x20Repositories:\x20CLEAR'):c['push']('-\x20Repositories\x20'+i['op']['toUpperCase']()+':\x20'+i['objects']['length']+'\x20object(s)');}if(b['rewards']){const j=b['rewards'];j['op']==='clear'?c['push']('-\x20Rewards:\x20CLEAR\x20(locked\x20by\x20duration)'):c['push']('-\x20Rewards\x20'+j['op']['toUpperCase']()+':\x20'+j['objects']['length']+'\x20object(s)\x20[locked\x20by\x20duration]');}b['order_allocators']!==undefined&&c['push']('-\x20Order\x20Allocators:\x20'+(b['order_allocators']?'configured':'(clear)')+'\x20[immutable\x20post-publish]');if(b['discount']){const k=b['discount'],l=k['discount_type']===0x0?'rates\x20(basis\x20points,\x20per\x2010000)':'minus\x20(direct\x20deduction)';c['push']('-\x20Discount:\x20'+k['name']+'\x20type='+l+'\x20data='+k['data']+'\x20count='+k['count']);}b['pause']!==undefined&&c['push']('-\x20Pause:\x20'+(b['pause']?'PAUSE\x20(block\x20new\x20orders)':'RESUME'));b['publish']&&c['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE\x20—\x20locks\x20machine/arbitrations/order_allocators\x20forever)');b['compensation_fund_add']&&c['push']('-\x20Compensation\x20fund\x20deposit:\x20'+b['compensation_fund_add']['balance']+'\x20(internal\x20Balance<T>)');b['compensation_fund_withdraw']&&c['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20bPaused=true\x20+\x20lock_duration\x20expired)');b['compensation_fund_receive']&&c['push']('-\x20Compensation\x20fund\x20receive\x20(locked\x20by\x20duration)');b['setting_lock_duration_add']!==undefined&&c['push']('-\x20Setting\x20lock\x20duration\x20+'+b['setting_lock_duration_add']+'ms\x20(only-increase)');if(b['order_new']){const m=b['order_new'];c['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20composite\x20flow):'),c['push']('\x20\x20\x20\x20Items:\x20'+m['buy']['items']['length']),c['push']('\x20\x20\x20\x20Total\x20pay:\x20'+m['buy']['total_pay']);if(m['buy']['discount'])c['push']('\x20\x20\x20\x20Discount:\x20'+m['buy']['discount']);c['push']('\x20\x20\x20\x20Stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order/allocation/progress\x20→\x20return');}return b['builder']&&c['push']('-\x20⚠️\x20TRANSFER\x20ownership\x20to\x20'+b['builder']+'\x20(IRREVERSIBLE)'),b['um']!==undefined&&c['push'](b['um']===null?'-\x20UM:\x20revoke':'-\x20UM:\x20set\x20to\x20'+b['um']),b['owner_receive']&&c['push']('-\x20Owner\x20receive:\x20receive\x20Payment/objects\x20to\x20owner'),c['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function getConstraintsByCategory(a){return SERVICE_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainServicePermissionIndex(a){if(isServicePermission(a)){const b=getServicePermissionByIndex(a);if(!b)return'Unknown\x20Service\x20permission\x20('+a+')';const c=b['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE\x20post-publish]':b['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT,\x20irreversible]':b['post_publish_mutability']==='locked_by_duration'?'\x20[locked\x20by\x20setting_lock_duration]':'';return b['name']+'\x20('+a+')\x20—\x20'+b['description']+c;}return'Non-Service\x20permission\x20('+a+')\x20—\x20verify\x20against\x20host\x20object\x27s\x20index\x20range';}
|