@wowok/agent-mcp 2.7.7 → 2.7.10
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/README.md +2 -2
- package/dist/config/runtime.d.ts +1 -1
- package/dist/config/runtime.js +1 -1
- package/dist/customer/index.d.ts +3 -4
- package/dist/customer/index.js +1 -1
- package/dist/customer/info-puzzle.js +1 -1
- package/dist/customer/order-monitor.d.ts +0 -9
- package/dist/customer/order-monitor.js +1 -1
- package/dist/customer/order-strategy.d.ts +0 -19
- package/dist/customer/order-strategy.js +1 -1
- package/dist/customer/reminder-system.d.ts +0 -5
- package/dist/customer/reminder-system.js +1 -1
- package/dist/evaluation/game-strategy.js +1 -1
- package/dist/evaluation/injection.d.ts +6 -0
- package/dist/evaluation/injection.js +1 -0
- package/dist/evaluation/node-game.js +1 -1
- package/dist/examples/machine-multisig-threshold.json +1 -0
- package/dist/examples/rental-ziroom-machine-create.json +1 -2
- package/dist/examples/rental-ziroom-permission-create.json +1 -2
- package/dist/examples/rental-ziroom-service-create.json +1 -2
- package/dist/experience/experience-reuse.js +1 -1
- package/dist/experience/index.d.ts +2 -1
- package/dist/experience/index.js +1 -1
- package/dist/experience/persistence-config.d.ts +6 -0
- package/dist/experience/persistence-config.js +1 -0
- package/dist/experience/persistence.d.ts +21 -0
- package/dist/experience/persistence.js +1 -0
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/experience/user-profile.js +1 -1
- package/dist/extensions/business-modules.d.ts +1 -1
- package/dist/extensions/capability-manifest.d.ts +1 -1
- package/dist/extensions/types.d.ts +1 -1
- package/dist/goal/GoalClassifier.d.ts +17 -0
- package/dist/goal/GoalClassifier.js +1 -0
- package/dist/goal/GoalEngine.d.ts +120 -0
- package/dist/goal/GoalEngine.js +1 -0
- package/dist/goal/GoalStore.d.ts +27 -0
- package/dist/goal/GoalStore.js +1 -0
- package/dist/goal/plan-approval.d.ts +5 -0
- package/dist/goal/plan-approval.js +1 -0
- package/dist/goal/types.d.ts +76 -0
- package/dist/goal/types.js +1 -0
- package/dist/harness/index.d.ts +2 -7
- package/dist/harness/index.js +1 -1
- package/dist/harness/plan.d.ts +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/harness/types.d.ts +1 -36
- package/dist/harness/verify.js +1 -1
- package/dist/index.js +1 -1
- package/dist/intent/enrich.js +1 -1
- package/dist/intent/matcher.js +1 -1
- package/dist/intent/types.d.ts +1 -1
- package/dist/intent/types.js +1 -1
- package/dist/knowledge/account-marks.d.ts +35 -0
- package/dist/knowledge/account-marks.js +1 -0
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +3 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/contract-invariants.d.ts +53 -0
- package/dist/knowledge/contract-invariants.js +1 -0
- package/dist/knowledge/dynamic-pricing.d.ts +0 -2
- package/dist/knowledge/dynamic-pricing.js +1 -1
- package/dist/knowledge/event-semantics.d.ts +20 -0
- package/dist/knowledge/event-semantics.js +1 -0
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/glossary.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +19 -0
- package/dist/knowledge/goal-completion.js +1 -0
- package/dist/knowledge/guard-submission-prompt.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/immutability.d.ts +11 -0
- package/dist/knowledge/immutability.js +1 -0
- package/dist/knowledge/index.d.ts +13 -6
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/intent-metrics.d.ts +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +37 -0
- package/dist/knowledge/jsonrpc-enum.js +1 -0
- package/dist/knowledge/machine-confirm.js +1 -1
- package/dist/knowledge/machine-risk.js +1 -1
- package/dist/knowledge/machine-topology.d.ts +11 -0
- package/dist/knowledge/machine-topology.js +1 -1
- package/dist/knowledge/machine-translation.js +1 -1
- package/dist/knowledge/market-metrics.d.ts +11 -0
- package/dist/knowledge/market-metrics.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.d.ts +1 -0
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/messenger-guard-guidance.d.ts +17 -0
- package/dist/knowledge/messenger-guard-guidance.js +1 -0
- package/dist/knowledge/operation-dictionary.d.ts +18 -0
- package/dist/knowledge/operation-dictionary.js +1 -0
- package/dist/knowledge/passport-confirm.js +1 -1
- package/dist/knowledge/passport-puzzle.js +1 -1
- package/dist/knowledge/passport-translation.js +1 -1
- package/dist/knowledge/proof-risk.js +1 -1
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-risk.js +1 -1
- package/dist/knowledge/service-translation.js +1 -1
- package/dist/knowledge/supply-chain.d.ts +24 -0
- package/dist/knowledge/supply-chain.js +1 -0
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/trust-metrics.d.ts +27 -2
- package/dist/knowledge/trust-metrics.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +22 -0
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/knowledge/workspace-lists.d.ts +56 -0
- package/dist/knowledge/workspace-lists.js +1 -0
- package/dist/loop-engineering/context-collect.d.ts +1 -1
- package/dist/monitor/EventRouter.d.ts +10 -0
- package/dist/monitor/EventRouter.js +1 -0
- package/dist/monitor/EventStore.d.ts +98 -0
- package/dist/monitor/EventStore.js +1 -0
- package/dist/monitor/MonitorLoop.d.ts +79 -0
- package/dist/monitor/MonitorLoop.js +1 -0
- package/dist/monitor/ProblemBridge.d.ts +32 -0
- package/dist/monitor/ProblemBridge.js +1 -0
- package/dist/monitor/ScopeResolver.d.ts +59 -0
- package/dist/monitor/ScopeResolver.js +1 -0
- package/dist/monitor/SubscriptionStore.d.ts +13 -0
- package/dist/monitor/SubscriptionStore.js +1 -0
- package/dist/monitor/normalize.d.ts +8 -0
- package/dist/monitor/normalize.js +1 -0
- package/dist/monitor/types.d.ts +89 -0
- package/dist/monitor/types.js +1 -0
- package/dist/participation/radar-core.d.ts +0 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/persona/address-format.d.ts +6 -0
- package/dist/persona/address-format.js +1 -0
- package/dist/persona/analyzer.js +1 -1
- package/dist/persona/distill-goal.d.ts +20 -0
- package/dist/persona/distill-goal.js +1 -0
- package/dist/persona/index.d.ts +5 -0
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.js +1 -1
- package/dist/persona/types.d.ts +1 -1
- package/dist/persona/types.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -0
- package/dist/{project → playbooks/service-build}/context-assembly.d.ts +9 -4
- package/dist/playbooks/service-build/context-assembly.js +1 -0
- package/dist/{project → playbooks/service-build}/game-theory.d.ts +1 -1
- package/dist/playbooks/service-build/index.d.ts +14 -0
- package/dist/playbooks/service-build/index.js +1 -0
- package/dist/{project → playbooks/service-build}/intent-analyzer.d.ts +1 -1
- package/dist/playbooks/service-build/intent-analyzer.js +1 -0
- package/dist/playbooks/service-build/machine-nodes.d.ts +25 -0
- package/dist/playbooks/service-build/machine-nodes.js +1 -0
- package/dist/playbooks/service-build/machine-panorama.d.ts +43 -0
- package/dist/playbooks/service-build/machine-panorama.js +1 -0
- package/dist/{project → playbooks/service-build}/merchant-guide.d.ts +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -0
- package/dist/{project → playbooks/service-build}/mode-actions.d.ts +2 -2
- package/dist/playbooks/service-build/mode-actions.js +1 -0
- package/dist/playbooks/service-build/namespace.d.ts +2 -0
- package/dist/playbooks/service-build/namespace.js +1 -0
- package/dist/playbooks/service-build/object-panorama.d.ts +178 -0
- package/dist/playbooks/service-build/object-panorama.js +1 -0
- package/dist/playbooks/service-build/object-type.d.ts +1 -0
- package/dist/playbooks/service-build/object-type.js +1 -0
- package/dist/{project → playbooks/service-build}/participation-radar.d.ts +4 -5
- package/dist/playbooks/service-build/participation-radar.js +1 -0
- package/dist/{project → playbooks/service-build}/pipeline-actions.d.ts +9 -9
- package/dist/playbooks/service-build/pipeline-actions.js +1 -0
- package/dist/playbooks/service-build/process.d.ts +6 -0
- package/dist/playbooks/service-build/process.js +1 -0
- package/dist/playbooks/service-build/risk-aggregator.js +1 -0
- package/dist/{project → playbooks/service-build}/semantic-graph.d.ts +2 -2
- package/dist/playbooks/service-build/service-panorama.d.ts +164 -0
- package/dist/playbooks/service-build/service-panorama.js +1 -0
- package/dist/review/arb.d.ts +6 -0
- package/dist/review/arb.js +1 -0
- package/dist/review/demand.d.ts +3 -0
- package/dist/review/demand.js +1 -0
- package/dist/review/index.d.ts +3 -0
- package/dist/review/index.js +1 -0
- package/dist/review/machine.d.ts +3 -0
- package/dist/review/machine.js +1 -0
- package/dist/review/order.d.ts +9 -0
- package/dist/review/order.js +1 -0
- package/dist/review/progress.d.ts +3 -0
- package/dist/review/progress.js +1 -0
- package/dist/review/repository.d.ts +3 -0
- package/dist/review/repository.js +1 -0
- package/dist/review/service.d.ts +5 -0
- package/dist/review/service.js +1 -0
- package/dist/review/types.d.ts +156 -0
- package/dist/review/types.js +1 -0
- package/dist/role/derivation.d.ts +19 -2
- package/dist/role/derivation.js +1 -1
- package/dist/role/index.d.ts +2 -2
- package/dist/role/index.js +1 -1
- package/dist/role/model.js +1 -1
- package/dist/role/resolution.d.ts +16 -0
- package/dist/role/resolution.js +1 -1
- package/dist/role/types.d.ts +1 -1
- package/dist/role/types.js +1 -1
- package/dist/rules.d.ts +2 -2
- package/dist/rules.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/safety/index.d.ts +1 -1
- package/dist/safety/index.js +1 -1
- package/dist/safety/preview.d.ts +1 -0
- package/dist/safety/preview.js +1 -1
- package/dist/schema/call/allocation.d.ts +2 -1
- package/dist/schema/call/arbitration.d.ts +5 -4
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +17 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +11 -4
- package/dist/schema/call/contact.d.ts +2 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/demand.d.ts +2 -1
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +6 -3
- package/dist/schema/call/handler.d.ts +0 -3
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +4 -2
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +2 -1
- package/dist/schema/call/payment.d.ts +2 -1
- package/dist/schema/call/permission.d.ts +2 -1
- package/dist/schema/call/personal.d.ts +39 -1
- package/dist/schema/call/personal.js +1 -1
- package/dist/schema/call/progress.d.ts +2 -1
- package/dist/schema/call/proof.d.ts +4 -2
- package/dist/schema/call/repository.d.ts +6 -5
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +2 -13
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.d.ts +3 -2
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +2 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +2 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +146 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +317 -0
- package/dist/schema/goal/index.js +1 -0
- package/dist/schema/goal/planning.d.ts +465 -0
- package/dist/schema/goal/planning.js +1 -0
- package/dist/schema/index.d.ts +2 -2
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +265 -1
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/industry-pack/modes.d.ts +268 -0
- package/dist/schema/industry-pack/modes.js +1 -0
- package/dist/schema/intent-radar/index.d.ts +30 -3
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +9 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +54 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +1147 -94
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +18 -0
- package/dist/schema/permission/index.js +1 -1
- package/dist/schema/persona/index.d.ts +40 -0
- package/dist/schema/persona/index.js +1 -1
- package/dist/schema/query/bi.d.ts +783 -0
- package/dist/schema/query/bi.js +1 -0
- package/dist/schema/query/index.d.ts +1471 -208
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/trust/index.d.ts +17 -0
- package/dist/schema/trust/index.js +1 -1
- package/dist/schema/utils/skills-recommendation.d.ts +0 -1
- package/dist/schema/utils/skills-recommendation.js +1 -1
- package/dist/schema/watch/index.d.ts +204 -0
- package/dist/schema/watch/index.js +1 -0
- package/dist/schema/workflow/index.d.ts +301 -0
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -5
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +7 -4
- package/dist/schemas/bridge_operation.schema.json +37 -21
- package/dist/schemas/config_operation.output.json +1 -1
- package/dist/schemas/config_operation.schema.json +1 -1
- package/dist/schemas/evaluation_operation.output.json +276 -1
- package/dist/schemas/evaluation_operation.schema.json +307 -0
- package/dist/schemas/goal_operation.schema.json +1016 -0
- package/dist/schemas/guard2file.schema.json +9 -5
- package/dist/schemas/index.json +22 -11
- package/dist/schemas/industry_pack_operation.output.json +898 -0
- package/dist/schemas/industry_pack_operation.schema.json +217 -2
- package/dist/schemas/intent_radar.output.json +20 -2
- package/dist/schemas/intent_radar.schema.json +10 -1
- package/dist/schemas/local_info_operation.output.json +7 -4
- package/dist/schemas/local_mark_operation.output.json +7 -4
- package/dist/schemas/machineNode2file.schema.json +9 -5
- package/dist/schemas/messenger_operation.output.json +107 -4
- package/dist/schemas/messenger_operation.schema.json +98 -0
- package/dist/schemas/monitor_events.output.json +1435 -0
- package/dist/schemas/monitor_events.schema.json +85 -0
- package/dist/schemas/monitor_subscription.output.json +1462 -0
- package/dist/schemas/monitor_subscription.schema.json +327 -0
- package/dist/schemas/onchain_events.output.json +241 -18
- package/dist/schemas/onchain_events.schema.json +20 -0
- package/dist/schemas/onchain_operations.output.json +12 -7
- package/dist/schemas/onchain_operations.schema.json +570 -478
- package/dist/schemas/onchain_operations_allocation.schema.json +14 -10
- package/dist/schemas/onchain_operations_arbitration.schema.json +17 -12
- package/dist/schemas/onchain_operations_contact.schema.json +13 -9
- package/dist/schemas/onchain_operations_demand.schema.json +13 -9
- package/dist/schemas/onchain_operations_gen_passport.schema.json +9 -5
- package/dist/schemas/onchain_operations_gen_proof.schema.json +9 -5
- package/dist/schemas/onchain_operations_guard.schema.json +9 -5
- package/dist/schemas/onchain_operations_machine.schema.json +17 -13
- package/dist/schemas/onchain_operations_order.schema.json +12 -8
- package/dist/schemas/onchain_operations_payment.schema.json +10 -6
- package/dist/schemas/onchain_operations_permission.schema.json +12 -8
- package/dist/schemas/onchain_operations_personal.schema.json +47 -5
- package/dist/schemas/onchain_operations_progress.schema.json +12 -8
- package/dist/schemas/onchain_operations_proof.schema.json +9 -5
- package/dist/schemas/onchain_operations_repository.schema.json +295 -310
- package/dist/schemas/onchain_operations_reward.schema.json +17 -13
- package/dist/schemas/onchain_operations_service.schema.json +21 -17
- package/dist/schemas/onchain_operations_treasury.schema.json +17 -13
- package/dist/schemas/onchain_table_data.output.json +4125 -239
- package/dist/schemas/onchain_table_data.schema.json +326 -15
- package/dist/schemas/permission_operation.output.json +32 -0
- package/dist/schemas/permission_operation.schema.json +6 -2
- package/dist/schemas/persona_operation.output.json +145 -0
- package/dist/schemas/persona_operation.schema.json +28 -2
- package/dist/schemas/query_toolkit.output.json +3384 -2040
- package/dist/schemas/query_toolkit.schema.json +548 -9
- package/dist/schemas/trust_score.output.json +38 -0
- package/dist/schemas/trust_score.schema.json +32 -0
- package/dist/schemas/watch_operation.output.json +827 -0
- package/dist/schemas/watch_operation.schema.json +145 -0
- package/dist/schemas/workflow_operation.output.json +263 -5
- package/dist/schemas/workflow_operation.schema.json +599 -4
- package/dist/task/ProcessStore.d.ts +81 -0
- package/dist/task/ProcessStore.js +1 -0
- package/dist/task/playbook.d.ts +11 -0
- package/dist/task/playbook.js +1 -0
- package/dist/task/stage-gate.d.ts +22 -0
- package/dist/task/stage-gate.js +1 -0
- package/dist/{project → task}/substep-trace.d.ts +6 -45
- package/dist/task/types.d.ts +120 -0
- package/dist/task/types.js +1 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/goal.d.ts +4 -0
- package/dist/tools/handlers/goal.js +1 -0
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/intent-radar.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/monitor.d.ts +26 -0
- package/dist/tools/handlers/monitor.js +1 -0
- package/dist/tools/handlers/network.d.ts +1 -0
- package/dist/tools/handlers/network.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/permission.js +1 -1
- package/dist/tools/handlers/persona.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/trust.d.ts +14 -0
- package/dist/tools/handlers/trust.js +1 -1
- package/dist/tools/handlers/watch.d.ts +2 -0
- package/dist/tools/handlers/watch.js +1 -0
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.d.ts +4 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/shared.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +5 -4
- package/dist/customer/post-purchase.d.ts +0 -44
- package/dist/customer/post-purchase.js +0 -1
- package/dist/harness/checkpoint.d.ts +0 -8
- package/dist/harness/checkpoint.js +0 -1
- package/dist/knowledge/deployment-scanner.d.ts +0 -66
- package/dist/knowledge/deployment-scanner.js +0 -1
- package/dist/project/business-puzzle.js +0 -1
- package/dist/project/context-assembly.js +0 -1
- package/dist/project/deployment-bridge.d.ts +0 -5
- package/dist/project/deployment-bridge.js +0 -1
- package/dist/project/deployment-doc.d.ts +0 -190
- package/dist/project/deployment-doc.js +0 -1
- package/dist/project/edit-planner.d.ts +0 -123
- package/dist/project/edit-planner.js +0 -1
- package/dist/project/evaluation-fix.spec.d.ts +0 -1
- package/dist/project/evaluation-fix.spec.js +0 -1
- package/dist/project/evaluation.d.ts +0 -127
- package/dist/project/evaluation.js +0 -1
- package/dist/project/graph-builder.d.ts +0 -51
- package/dist/project/graph-builder.js +0 -1
- package/dist/project/graph.d.ts +0 -70
- package/dist/project/graph.js +0 -1
- package/dist/project/handlers.d.ts +0 -540
- package/dist/project/handlers.js +0 -1
- package/dist/project/index.d.ts +0 -91
- package/dist/project/index.js +0 -1
- package/dist/project/intent-analyzer.js +0 -1
- package/dist/project/machine-nodes.d.ts +0 -2
- package/dist/project/machine-nodes.js +0 -1
- package/dist/project/merchant-guide.js +0 -1
- package/dist/project/migration.d.ts +0 -22
- package/dist/project/migration.js +0 -1
- package/dist/project/mode-actions.js +0 -1
- package/dist/project/namespace.d.ts +0 -72
- package/dist/project/namespace.js +0 -1
- package/dist/project/participation-radar.js +0 -1
- package/dist/project/pipeline-actions.js +0 -1
- package/dist/project/project-store.d.ts +0 -110
- package/dist/project/project-store.js +0 -1
- package/dist/project/query.d.ts +0 -43
- package/dist/project/query.js +0 -1
- package/dist/project/risk-aggregator.js +0 -1
- package/dist/project/rollback-policy.d.ts +0 -45
- package/dist/project/rollback-policy.js +0 -1
- package/dist/project/semantic-assembler.d.ts +0 -93
- package/dist/project/semantic-assembler.js +0 -1
- package/dist/project/stage-gate.d.ts +0 -53
- package/dist/project/stage-gate.js +0 -1
- package/dist/project/task-tracker.d.ts +0 -26
- package/dist/project/task-tracker.js +0 -1
- package/dist/schema/project/index.d.ts +0 -2015
- package/dist/schema/project/index.js +0 -1
- package/dist/schema/task-status.d.ts +0 -62
- package/dist/schema/task-status.js +0 -1
- package/dist/schemas/project_operation.output.json +0 -7877
- package/dist/schemas/project_operation.schema.json +0 -1133
- package/dist/schemas/query_task_status.output.json +0 -211
- package/dist/schemas/query_task_status.schema.json +0 -18
- package/dist/tools/handlers/project.d.ts +0 -2
- package/dist/tools/handlers/project.js +0 -1
- package/dist/tools/handlers/task-status.d.ts +0 -2
- package/dist/tools/handlers/task-status.js +0 -1
- /package/dist/{project → playbooks/service-build}/business-puzzle.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/game-theory.js +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/reverse-mapping.js +0 -0
- /package/dist/{project → playbooks/service-build}/risk-aggregator.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/semantic-graph.js +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/workflow-design-assessment.js +0 -0
- /package/dist/{project → task}/substep-trace.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{PASSPORT_ERROR_CODES,MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT}from'./passport-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-PASS-01','pattern_name':'Create\x20Passport','semantic_intent':'Create\x20a\x20new\x20verification\x20carrier\x20object\x20bound\x20to\x20the\x20current\x20transaction','match_keywords':['create','new','passport','instantiate'],'schema_fields':['(SubmissionCall)'],'example_json':{'type':'submission','guard':[],'submission':[]},'reverse_explanation':'Passport\x20created\x20via\x20passport::new(clock,\x20ctx).\x20tx_hash\x20bound\x20to\x20tx_context::digest(ctx).\x20No\x20Guard\x20added\x20yet.'},{'id':'P-PASS-02','pattern_name':'Add\x20impack\x20Guard','semantic_intent':'Add\x20a\x20Guard\x20that\x20affects\x20the\x20final\x20verification\x20result\x20(impack=true)','match_keywords':['impack','affect','decisive','critical\x20guard'],'schema_fields':['guard[].object','guard[].impack=true'],'example_json':{'guard':[{'object':'kyc_guard','impack':!![]}],'submission':[{'guard':'kyc_guard','submission':[{'identifier':0x0,'value':'0x1234...','value_type':'address'}]}]},'reverse_explanation':'guard[].impack=true\x20marks\x20this\x20Guard\x20as\x20affecting\x20final\x20result.\x20At\x20least\x201\x20impack\x20Guard\x20required\x20(else\x20E_IMPACK_GUARD_NOT_FOUND).\x20Failure\x20aborts\x20overall\x20result\x20to\x20false.'},{'id':'P-PASS-03','pattern_name':'Add\x20non-impack\x20Guard','semantic_intent':'Add\x20a\x20Guard\x20that\x20only\x20records\x20per-Guard\x20result\x20(impack=false)','match_keywords':['non-impack','record','audit','log'],'schema_fields':['guard[].object','guard[].impack=false'],'example_json':{'guard':[{'object':'audit_log_guard','impack':![]}],'submission':[]},'reverse_explanation':'guard[].impack=false\x20marks\x20this\x20Guard\x20as\x20audit-only.\x20Its\x20result\x20is\x20recorded\x20but\x20does\x20NOT\x20affect\x20final\x20result.\x20Useful\x20for\x20logging\x20/\x20secondary\x20checks.'},{'id':'P-PASS-04','pattern_name':'Add\x20Guard\x20with\x20relies\x20dependency','semantic_intent':'Add\x20a\x20Guard\x20that\x20depends\x20on\x20other\x20Guards\x20(AND/OR\x20logic)','match_keywords':['relies','depend','dependency','and','or'],'schema_fields':['guard[].object','guard[].impack','(relies\x20read\x20from\x20Guard\x20object)'],'example_json':{'guard':[{'object':'guard_a','impack':!![]},{'object':'guard_b','impack':!![]}],'submission':[]},'reverse_explanation':'relies\x20is\x20read\x20from\x20guard::relies(guard)\x20—\x20NOT\x20set\x20in\x20Passport\x20JSON.\x20Must\x20add\x20relied\x20Guards\x20first\x20(E_RELIES_GUARD_NOT_ADDED).\x20relies_logic_and=true=AND,\x20false=OR.\x20No\x20transitive\x20dependencies\x20allowed.'},{'id':'P-PASS-05','pattern_name':'Verify\x20Passport\x20(one-time)','semantic_intent':'Trigger\x20one-time\x20verification\x20of\x20all\x20Guards;\x20result\x20is\x20immutable\x20after\x20this\x20call','match_keywords':['verify','validation','submit'],'schema_fields':['(verify\x20operation)'],'example_json':{'operation':'verify'},'reverse_explanation':'passport::verify(self,\x20ctx).\x20One-time\x20—\x20has_verified\x20set\x20to\x20true.\x20Computes\x20per-Guard\x20result\x20via\x20relies\x20logic,\x20then\x20impack\x20Guards\x20decide\x20final\x20result.\x20Aborts\x20E_HAS_VERIFIED\x20if\x20called\x20twice.'},{'id':'P-PASS-06','pattern_name':'Freeze\x20Passport\x20(permanent)','semantic_intent':'Permanently\x20freeze\x20the\x20Passport\x20as\x20immutable\x20(cannot\x20be\x20destroyed\x20after)','match_keywords':['freeze','freezen','permanent'],'schema_fields':['(freezen\x20operation)'],'example_json':{'operation':'freezen'},'reverse_explanation':'passport::freezen(self)\x20calls\x20transfer::freeze_object(self).\x20Passport\x20becomes\x20immutable\x20and\x20publicly\x20readable.\x20Cannot\x20be\x20destroyed\x20after\x20freezing.\x20SDK\x20exports\x20as\x20`freeze`\x20(correct\x20spelling).'},{'id':'P-PASS-07','pattern_name':'Query\x20result','semantic_intent':'Get\x20the\x20final\x20verification\x20result\x20(requires\x20has_verified=true\x20+\x20tx_hash\x20match)','match_keywords':['result','query','outcome'],'schema_fields':['(result\x20query)'],'example_json':{'operation':'result_query'},'reverse_explanation':'passport::result(self,\x20ctx)\x20:\x20bool.\x20Aborts\x20E_NOT_VERIFIED\x20(5)\x20if\x20not\x20yet\x20verified;\x20E_TX_NOT_MATCH\x20(8)\x20if\x20called\x20from\x20a\x20different\x20transaction.\x20Must\x20be\x20called\x20in\x20the\x20same\x20tx\x20as\x20verify().'},{'id':'P-PASS-08','pattern_name':'Query\x20specific\x20Guard\x20result\x20(result_for_guard)','semantic_intent':'Hard-verify\x20that\x20a\x20specific\x20impack\x20Guard\x20passed\x20(aborts\x20E_VERIFY_FAILED\x20if\x20not)','match_keywords':['result_for_guard','hard-verify','specific\x20guard'],'schema_fields':['(result_for_guard\x20query)'],'example_json':{'operation':'result_for_guard','guard':'kyc_guard'},'reverse_explanation':'passport::result_for_guard(self,\x20guard,\x20ctx).\x20Aborts\x20E_NOT_IMPACK_GUARD\x20(6)\x20if\x20guard\x20is\x20not\x20impack;\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false.\x20Used\x20by\x20consumers\x20to\x20enforce\x20specific\x20Guard\x20checks.'},{'id':'P-PASS-09','pattern_name':'Query\x20impack\x20Guard\x20list\x20(result_for_permission)','semantic_intent':'Get\x20the\x20list\x20of\x20impack\x20Guard\x20addresses\x20(lazy-filled\x20on\x20first\x20call)','match_keywords':['result_for_permission','impack\x20list','impack\x20addresses'],'schema_fields':['(result_for_permission\x20query)'],'example_json':{'operation':'result_for_permission'},'reverse_explanation':'passport::result_for_permission(self,\x20ctx)\x20:\x20vector<address>.\x20Lazy-fills\x20self.impack\x20on\x20first\x20call.\x20Aborts\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false.\x20Used\x20by\x20Permission/Allocation\x20to\x20get\x20authorized\x20Guard\x20list.'},{'id':'P-PASS-10','pattern_name':'Get\x20submission\x20value','semantic_intent':'Read\x20the\x20submitted\x20value\x20for\x20a\x20(guard,\x20identifier)\x20pair','match_keywords':['submission_get','read','fetch\x20submission'],'schema_fields':['(submission_get\x20query)'],'example_json':{'operation':'submission_get','guard':'voting_guard','identifier':0x0},'reverse_explanation':'passport::submission_get(self,\x20guard,\x20identifier)\x20:\x20vector<u8>.\x20Read-only\x20—\x20no\x20tx_hash\x20check.\x20Returns\x20the\x20BCS-encoded\x20value.\x20Aborts\x20E_SUBMISSION_NOT_FOUND\x20(10)\x20if\x20no\x20entry\x20exists.'},{'id':'P-PASS-11','pattern_name':'Destroy\x20Passport','semantic_intent':'Permanently\x20delete\x20the\x20Passport\x20to\x20release\x20storage\x20(must\x20be\x20before\x20freeze)','match_keywords':['destroy','delete','remove'],'schema_fields':['(destroy\x20operation)'],'example_json':{'operation':'destroy'},'reverse_explanation':'passport::destroy(self)\x20calls\x20object::delete(id).\x20Must\x20be\x20called\x20BEFORE\x20freeze\x20(frozen\x20objects\x20are\x20immutable,\x20cannot\x20be\x20destroyed).\x20Move\x20ownership\x20protects:\x20only\x20signer\x20holding\x20the\x20object\x20can\x20call.'},{'id':'P-PASS-12','pattern_name':'Clear\x20all\x20Guards\x20(pre-verify\x20only)','semantic_intent':'Remove\x20all\x20Guards\x20from\x20Passport\x20(only\x20allowed\x20before\x20verify)','match_keywords':['guard_clear','clear','reset'],'schema_fields':['(guard_clear\x20operation)'],'example_json':{'operation':'guard_clear'},'reverse_explanation':'passport::guard_clear(self,\x20ctx).\x20Aborts\x20E_HAS_VERIFIED\x20(4)\x20if\x20already\x20verified;\x20E_DIGEST_NOT_MATCH\x20(11)\x20if\x20tx_hash\x20mismatch.\x20Useful\x20for\x20resetting\x20configuration\x20before\x20verify.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Passport\x20object\x20reference\x20(address).\x20For\x20create,\x20no\x20object\x20yet;\x20for\x20operate,\x20the\x20existing\x20Passport\x20address.'},{'element_type':'field','type_name':'guard','semantic_explanation':'Array\x20of\x20{object,\x20impack}.\x20Each\x20entry\x20references\x20a\x20Guard\x20object\x20and\x20marks\x20whether\x20it\x20affects\x20final\x20result.\x20Count\x20≤\x20MAX_GUARD_COUNT_PASSPORT=20.'},{'element_type':'field','type_name':'guard[].object','semantic_explanation':'Guard\x20object\x20address.\x20Must\x20be\x20unique\x20within\x20the\x20Passport\x20(duplicate\x20addresses\x20overwrite\x20existing\x20config).\x20Resolved\x20via\x20LocalMark\x20before\x20on-chain\x20call.'},{'element_type':'field','type_name':'guard[].impack','semantic_explanation':'Boolean.\x20true=affects\x20final\x20result\x20(at\x20least\x201\x20required);\x20false=audit-only.\x20impack\x20Guards\x20failing\x20→\x20overall\x20result=false\x20immediately.'},{'element_type':'field','type_name':'submission','semantic_explanation':'Array\x20of\x20{guard,\x20submission[]}.\x20Each\x20submission\x20is\x20{identifier,\x20value,\x20value_type}.\x20identifier\x20is\x20u8\x20(0-255)\x20matching\x20Guard.table[].identifier.'},{'element_type':'field','type_name':'submission[].identifier','semantic_explanation':'u8\x20(0-255).\x20References\x20Guard.table[identifier].\x20Must\x20be\x20marked\x20b_submission=true\x20in\x20the\x20Guard.'},{'element_type':'field','type_name':'submission[].value','semantic_explanation':'Value\x20matching\x20submission[].value_type.\x20BCS-serialized\x20on-chain;\x20total\x20serialized\x20size\x20per\x20submission\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes.'},{'element_type':'field','type_name':'submission[].value_type','semantic_explanation':'Type\x20string:\x20\x27address\x27\x20|\x20\x27u64\x27\x20|\x20\x27bool\x27\x20|\x20\x27string\x27\x20|\x20\x27vector<u8>\x27\x20etc.\x20Must\x20match\x20Guard.table[identifier].value_type.'},{'element_type':'op','type_name':'create\x20(new)','semantic_explanation':'passport::new(clock,\x20ctx)\x20→\x20Passport.\x20Binds\x20tx_hash\x20=\x20tx_context::digest(ctx).\x20signer\x20=\x20tx_context::sender(ctx).\x20time\x20=\x20clock::timestamp_ms(clock).'},{'element_type':'op','type_name':'guard_add','semantic_explanation':'passport::guard_add(self,\x20guard,\x20identifiers,\x20values,\x20impack,\x20ctx).\x20Pre-verify\x20only.\x20Reads\x20guard::relies(guard)\x20for\x20dependency\x20info.\x20Aborts\x20E_RELIES_GUARD_NOT_ADDED\x20if\x20relies\x20missing.'},{'element_type':'op','type_name':'verify','semantic_explanation':'passport::verify(self,\x20ctx)\x20:\x20bool.\x20One-time.\x20Computes\x20per-Guard\x20result\x20via\x20relies,\x20then\x20impack\x20Guards\x20decide\x20final\x20result.\x20Sets\x20has_verified=true.'},{'element_type':'op','type_name':'freezen','semantic_explanation':'passport::freezen(self).\x20Permanent\x20freeze\x20(transfer::freeze_object).\x20Cannot\x20destroy\x20after.\x20Historical\x20typo:\x20Move\x20function\x20name\x20is\x20\x27freezen\x27\x20(not\x20\x27freeze\x27),\x20retained\x20for\x20compatibility.\x20SDK\x20exports\x20as\x20`freeze`.'},{'element_type':'op','type_name':'destroy','semantic_explanation':'passport::destroy(self).\x20Releases\x20storage\x20(object::delete).\x20Must\x20be\x20before\x20freeze.\x20Move\x20ownership\x20protects:\x20only\x20object\x20holder\x20can\x20call.'},{'element_type':'impack','type_name':'impack=true','semantic_explanation':'Guard\x20affects\x20final\x20result.\x20At\x20least\x201\x20required\x20(E_IMPACK_GUARD_NOT_FOUND).\x20Failure\x20→\x20overall\x20result=false,\x20immediate\x20return.'},{'element_type':'impack','type_name':'impack=false','semantic_explanation':'Guard\x20is\x20audit-only.\x20Per-Guard\x20result\x20is\x20recorded\x20but\x20does\x20NOT\x20affect\x20final\x20result.\x20Useful\x20for\x20logging\x20/\x20secondary\x20checks.'},{'element_type':'relies_logic','type_name':'AND\x20(relies_logic_and=true)','semantic_explanation':'All\x20relied\x20Guards\x20must\x20pass.\x20Short-circuits\x20on\x20first\x20false.\x20Initial\x20value\x20=\x20true;\x20result\x20=\x20true\x20AND\x20rely1.result\x20AND\x20rely2.result\x20...'},{'element_type':'relies_logic','type_name':'OR\x20(relies_logic_and=false)','semantic_explanation':'Any\x20relied\x20Guard\x20may\x20pass.\x20Short-circuits\x20on\x20first\x20true.\x20Initial\x20value\x20=\x20false;\x20result\x20=\x20false\x20OR\x20rely1.result\x20OR\x20rely2.result\x20...'},{'element_type':'lifecycle','type_name':'new\x20→\x20guard_add\x20→\x20verify\x20→\x20use\x20→\x20freeze/destroy','semantic_explanation':'5-stage\x20lifecycle.\x20verify\x20is\x20one-time.\x20freeze\x20and\x20destroy\x20are\x20mutually\x20exclusive\x20terminal\x20states.\x20All\x20write\x20ops\x20(guard_add/verify)\x20require\x20tx_hash\x20match.'}];export const PASSPORT_CONSTRAINT_RULES=[{'id':'T-PASS-01','category':'structural','rule':'Passport\x20is\x20created\x20via\x20the\x20SubmissionCall\x20mechanism,\x20not\x20the\x20standard\x20Call\x20pattern\x20(schema/call/base.ts\x20SubmissionCallSchema)','applies_to':['SubmissionCall','passport::new']},{'id':'T-PASS-02','category':'logic','rule':'Guards\x20with\x20guard[].impack=true\x20decide\x20the\x20final\x20result;\x20at\x20least\x201\x20impack\x20Guard\x20is\x20required\x20(E_IMPACK_GUARD_NOT_FOUND=9)','applies_to':['guard[].impack','verify\x20operation']},{'id':'T-PASS-03','category':'logic','rule':'Depended-on\x20Guards\x20must\x20be\x20added\x20first\x20(topological\x20order);\x20guard_add\x20checks\x20relies,\x20missing\x20relies\x20aborts\x20E_RELIES_GUARD_NOT_ADDED=2','applies_to':['guard_add\x20operation','guard::relies(guard)']},{'id':'T-PASS-04','category':'lifecycle','rule':'After\x20verify,\x20config\x20cannot\x20be\x20modified\x20(has_verified\x20is\x20one-time);\x20second\x20calls\x20to\x20guard_add/guard_clear/verify\x20abort\x20E_HAS_VERIFIED=4','applies_to':['verify\x20operation','has_verified\x20field']},{'id':'T-PASS-05','category':'lifecycle','rule':'tx_hash\x20binding\x20ensures\x20Passport\x20cannot\x20be\x20reused\x20across\x20transactions;\x20write\x20functions\x20and\x20result\x20queries\x20check\x20tx_hash\x20match','applies_to':['tx_hash\x20field','guard_add','verify','result']},{'id':'T-PASS-06','category':'structural','rule':'submission\x20data\x20must\x20match\x20Guard\x20identifier\x20type;\x20BCS\x20serialization\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes','applies_to':['submission[].value_type','submission[].identifier']},{'id':'T-PASS-07','category':'lifecycle','rule':'result\x20query\x20must\x20be\x20in\x20the\x20same\x20transaction\x20(tx_hash\x20matches\x20current\x20transaction);\x20otherwise\x20E_TX_NOT_MATCH=8','applies_to':['result\x20operation','result_for_guard','result_for_permission']},{'id':'T-PASS-08','category':'lifecycle','rule':'After\x20freeze,\x20Passport\x20is\x20permanently\x20retained\x20(cannot\x20be\x20destroyed);\x20freezen\x20calls\x20transfer::freeze_object','applies_to':['freezen\x20operation','destroy\x20operation']},{'id':'T-PASS-09','category':'lifecycle','rule':'destroy\x20must\x20happen\x20before\x20freeze\x20(destroyable\x20when\x20not\x20frozen);\x20after\x20freezing\x20the\x20object\x20becomes\x20immutable\x20and\x20cannot\x20be\x20received\x20by\x20value','applies_to':['destroy\x20operation','freezen\x20operation']},{'id':'T-PASS-10','category':'operational','rule':'explainPassport\x20must\x20translate\x20impack\x20and\x20result\x20status;\x20use\x20passport.object\x20(not\x20passport.id)\x20as\x20the\x20object\x20identifier','applies_to':['explainPassport\x20function','ObjectPassportSchema']},{'id':'T-PASS-11','category':'logic','rule':'relies\x20logic\x20(AND/OR)\x20must\x20be\x20reflected\x20in\x20explainPassport;\x20relies_logic_and=true=AND,\x20false=OR','applies_to':['explainPassport\x20function','guard::relies(guard)']},{'id':'T-PASS-12','category':'structural','rule':'Guard\x20count\x20≤\x20MAX_GUARD_COUNT_PASSPORT=20;\x20submission\x20serialized\x20size\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes','applies_to':['guard\x20array','submission\x20array']}];export const PASSPORT_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 explainPassport(a){const b=[];b['push']('Passport\x20'+a['object']),b['push']('\x20\x20Signer:\x20'+a['signer']),b['push']('\x20\x20Time:\x20'+new Date(a['time'])['toISOString']()),b['push']('\x20\x20Verified:\x20'+a['has_verified']);a['has_verified']&&b['push']('\x20\x20Result:\x20'+(a['result']?'PASS\x20✅':'FAIL\x20❌'));b['push']('\x20\x20Guards:\x20'+a['info']['length']+'/'+MAX_GUARD_COUNT_PASSPORT);if(a['info']['length']>0x0){b['push']('\x20\x20Guard\x20details:');for(const c of a['info']){const d=c['impack']?'IMPACK':'non-impack',e=c['result']?'PASS':'FAIL';b['push']('\x20\x20\x20\x20-\x20Guard\x20'+c['guard']+':\x20'+e+'\x20('+d+')');}}return a['impack_guard']&&a['impack_guard']['length']>0x0&&b['push']('\x20\x20impack_guard\x20list\x20(lazy-filled):\x20'+a['impack_guard']['join'](',\x20')),a['tx_hash']&&b['push']('\x20\x20tx_hash:\x20'+a['tx_hash']),b['join']('\x0a');}export function passportJsonToSemantic(a){const b=[];if(a['type']==='submission'||a['guard']&&a['guard']['length']>0x0){b['push']('Operation:\x20CREATE\x20Passport\x20via\x20SubmissionCall');if(a['guard']&&a['guard']['length']>0x0){const c=a['guard']['filter'](e=>e['impack'])['length'],d=a['guard']['length']-c;b['push']('-\x20Guards:\x20'+a['guard']['length']+'/'+MAX_GUARD_COUNT_PASSPORT+'\x20('+c+'\x20impack,\x20'+d+'\x20non-impack)'),c===0x0&&b['push']('\x20\x20⚠️\x20No\x20impack\x20Guard\x20—\x20verify\x20will\x20abort\x20E_IMPACK_GUARD_NOT_FOUND\x20(9)'),a['guard']['forEach']((e,f)=>{const h=e['impack']?'IMPACK\x20(affects\x20result)':'non-impack\x20(audit-only)';b['push']('\x20\x20['+f+']\x20'+e['object']+'\x20—\x20'+h);});}if(a['submission']&&a['submission']['length']>0x0){b['push']('-\x20Submissions:\x20'+a['submission']['length']+'\x20guard(s)\x20with\x20submission\x20data');for(const e of a['submission']){const f=e['submission']['reduce']((h,i)=>h+estimateSubmissionSize(i['value_type']),0x0),g=f>MAX_SUBMISSION_SIZE_PASSPORT?'\x20⚠️\x20'+f+'\x20>\x20'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20bytes\x20(E_SUBMISSION_SIZE_EXCEEDED)':'';b['push']('\x20\x20-\x20guard='+e['guard']+':\x20'+e['submission']['length']+'\x20item(s),\x20estimated\x20size='+f+'\x20bytes'+g);}}}else{if(a['operation']){b['push']('Operation:\x20'+a['operation']['toUpperCase']());switch(a['operation']){case'verify':b['push']('-\x20One-time\x20verification;\x20sets\x20has_verified=true,\x20computes\x20final\x20result'),b['push']('-\x20Aborts\x20E_HAS_VERIFIED\x20(4)\x20if\x20already\x20verified');break;case'freezen':b['push']('-\x20Permanent\x20freeze\x20(transfer::freeze_object)'),b['push']('-\x20Cannot\x20be\x20destroyed\x20after\x20freezing');break;case'destroy':b['push']('-\x20Permanent\x20deletion\x20(object::delete)'),b['push']('-\x20Must\x20be\x20called\x20BEFORE\x20freeze');break;case'guard_clear':b['push']('-\x20Removes\x20all\x20Guards\x20from\x20Passport'),b['push']('-\x20Only\x20allowed\x20before\x20verify\x20(E_HAS_VERIFIED\x20if\x20verified)');break;case'result_query':b['push']('-\x20Returns\x20final\x20verification\x20result\x20(bool)'),b['push']('-\x20Requires\x20has_verified=true\x20(E_NOT_VERIFIED)\x20and\x20tx_hash\x20match\x20(E_TX_NOT_MATCH)');break;case'result_for_guard':b['push']('-\x20Hard-verifies\x20Guard\x20'+a['guard_target']+'\x20is\x20impack\x20and\x20passed'),b['push']('-\x20Aborts\x20E_NOT_IMPACK_GUARD\x20(6)\x20if\x20not\x20impack;\x20E_VERIFY_FAILED\x20(7)\x20if\x20result=false');break;case'result_for_permission':b['push']('-\x20Returns\x20impack\x20Guard\x20address\x20list\x20(lazy-filled)'),b['push']('-\x20Aborts\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false');break;case'submission_get':b['push']('-\x20Reads\x20submission\x20value\x20for\x20(guard='+a['guard_target']+',\x20identifier='+a['identifier']+')'),b['push']('-\x20Read-only,\x20no\x20tx_hash\x20check'),b['push']('-\x20Aborts\x20E_SUBMISSION_NOT_FOUND\x20(10)\x20if\x20no\x20entry');break;}}else b['push']('⚠️\x20Cannot\x20determine\x20operation:\x20provide\x20\x27type:\x20submission\x27\x20with\x20guard[],\x20or\x20\x27operation\x27\x20field');}return b['join']('\x0a');}export function semanticToPassportJson(a){switch(a['action']){case'create':{if(!a['guards']||a['guards']['length']===0x0)throw new Error('Create\x20action\x20requires\x20at\x20least\x201\x20Guard\x20in\x20intent.guards');if(a['guards']['length']>MAX_GUARD_COUNT_PASSPORT)throw new Error('Guard\x20count\x20'+a['guards']['length']+'\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT);const b=a['guards']['some'](c=>c['impack']);if(!b)throw new Error('At\x20least\x201\x20Guard\x20must\x20have\x20impack=true\x20(else\x20verify\x20aborts\x20E_IMPACK_GUARD_NOT_FOUND=9)');return{'type':'submission','guard':a['guards']['map'](c=>({'object':c['object'],'impack':c['impack']})),'submission':a['guards']['filter'](c=>c['submission']&&c['submission']['length']>0x0)['map'](c=>({'guard':c['object'],'submission':c['submission']}))};}case'verify':return{'operation':'verify'};case'freeze':return{'operation':'freezen'};case'destroy':return{'operation':'destroy'};case'guard_clear':return{'operation':'guard_clear'};case'query_result':return{'operation':'result_query'};case'query_guard_result':if(!a['targetGuard'])throw new Error('query_guard_result\x20requires\x20intent.targetGuard');return{'operation':'result_for_guard','guard_target':a['targetGuard']};case'query_impack_list':return{'operation':'result_for_permission'};case'get_submission':if(!a['targetGuard'])throw new Error('get_submission\x20requires\x20intent.targetGuard');if(a['targetIdentifier']===undefined)throw new Error('get_submission\x20requires\x20intent.targetIdentifier');return{'operation':'submission_get','guard_target':a['targetGuard'],'identifier':a['targetIdentifier']};}}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 explainImpack(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='impack'&&b['type_name']==='impack='+a);}export function explainReliesLogic(a){const b=a?'AND\x20(relies_logic_and=true)':'OR\x20(relies_logic_and=false)';return SCHEMA_TO_SEMANTIC_RULES['find'](c=>c['element_type']==='relies_logic'&&c['type_name']===b);}export function getConstraintsByCategory(a){return PASSPORT_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainError(a){const b={[PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']]:'Guard\x20count\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT\x20(20)\x20—\x20remove\x20non-essential\x20Guards\x20or\x20merge\x20similar\x20ones',[PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']]:'Relied\x20Guard\x20not\x20yet\x20added\x20—\x20add\x20relied\x20Guards\x20in\x20topological\x20order\x20before\x20adding\x20the\x20dependent\x20Guard',[PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']]:'Submission\x20serialized\x20size\x20exceeds\x20MAX_SUBMISSION_SIZE_PASSPORT\x20(256\x20bytes)\x20—\x20use\x20Repository\x20reference\x20for\x20large\x20data',[PASSPORT_ERROR_CODES['E_HAS_VERIFIED']]:'Passport\x20already\x20verified\x20—\x20verify\x20is\x20one-time;\x20create\x20a\x20new\x20Passport\x20to\x20re-verify',[PASSPORT_ERROR_CODES['E_NOT_VERIFIED']]:'result()\x20called\x20before\x20verify()\x20—\x20call\x20verify()\x20first\x20in\x20the\x20same\x20transaction',[PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']]:'result_for_guard\x20called\x20on\x20non-impack\x20Guard\x20—\x20only\x20impack\x20Guards\x20can\x20be\x20hard-verified',[PASSPORT_ERROR_CODES['E_VERIFY_FAILED']]:'result_for_guard\x20/\x20result_for_permission\x20called\x20when\x20overall\x20result=false\x20—\x20fix\x20Guard\x20configuration\x20or\x20submission\x20data',[PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']]:'result()\x20called\x20from\x20a\x20different\x20transaction\x20—\x20Passport\x20is\x20tx_hash-bound,\x20must\x20query\x20in\x20the\x20same\x20tx\x20as\x20verify()',[PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']]:'verify()\x20found\x20no\x20impack\x20Guard\x20—\x20at\x20least\x201\x20Guard\x20must\x20have\x20impack=true',[PASSPORT_ERROR_CODES['E_SUBMISSION_NOT_FOUND']]:'submission_get\x20found\x20no\x20entry\x20for\x20(guard,\x20identifier)\x20—\x20check\x20Guard.table[identifier].b_submission=true',[PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']]:'guard_add\x20/\x20verify\x20/\x20guard_clear\x20called\x20from\x20a\x20different\x20transaction\x20—\x20Passport\x20is\x20tx_hash-bound'};return b[a]??'Unknown\x20Passport\x20error\x20code:\x20'+a;}function estimateSubmissionSize(a){switch(a){case'bool':return 0x1;case'u8':return 0x1;case'u64':return 0x8;case'address':return 0x20;case'string':return 0x20;case'vector<u8>':return 0x20;default:return 0x40;}}
|
|
1
|
+
import{PASSPORT_ERROR_CODES,MAX_GUARD_COUNT_PASSPORT,MAX_SUBMISSION_SIZE_PASSPORT}from'./passport-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-PASS-01','pattern_name':'Create\x20Passport','semantic_intent':'Create\x20a\x20new\x20verification\x20carrier\x20object\x20bound\x20to\x20the\x20current\x20transaction','match_keywords':['create','new','passport','instantiate'],'schema_fields':['(SubmissionCall)'],'example_json':{'type':'submission','guard':[],'submission':[]},'reverse_explanation':'Passport\x20created\x20via\x20passport::new_v2(clock,\x20object_linker_tx,\x20ctx).\x20tx_hash\x20bound\x20to\x20tx_context::digest(ctx).\x20Registers\x20the\x20creator\x20(tx\x20sender)\x20into\x20ObjectLinkerTx\x20so\x20the\x20passport\x20can\x20be\x20queried\x20by\x20the\x20creator\x20address.\x20No\x20Guard\x20added\x20yet.'},{'id':'P-PASS-02','pattern_name':'Add\x20impack\x20Guard','semantic_intent':'Add\x20a\x20Guard\x20that\x20affects\x20the\x20final\x20verification\x20result\x20(impack=true)','match_keywords':['impack','affect','decisive','critical\x20guard'],'schema_fields':['guard[].object','guard[].impack=true'],'example_json':{'guard':[{'object':'kyc_guard','impack':!![]}],'submission':[{'guard':'kyc_guard','submission':[{'identifier':0x0,'value':'0x1234...','value_type':'address'}]}]},'reverse_explanation':'guard[].impack=true\x20marks\x20this\x20Guard\x20as\x20affecting\x20final\x20result.\x20At\x20least\x201\x20impack\x20Guard\x20required\x20(else\x20E_IMPACK_GUARD_NOT_FOUND).\x20Failure\x20aborts\x20overall\x20result\x20to\x20false.'},{'id':'P-PASS-03','pattern_name':'Add\x20non-impack\x20Guard','semantic_intent':'Add\x20a\x20Guard\x20that\x20only\x20records\x20per-Guard\x20result\x20(impack=false)','match_keywords':['non-impack','record','audit','log'],'schema_fields':['guard[].object','guard[].impack=false'],'example_json':{'guard':[{'object':'audit_log_guard','impack':![]}],'submission':[]},'reverse_explanation':'guard[].impack=false\x20marks\x20this\x20Guard\x20as\x20audit-only.\x20Its\x20result\x20is\x20recorded\x20but\x20does\x20NOT\x20affect\x20final\x20result.\x20Useful\x20for\x20logging\x20/\x20secondary\x20checks.'},{'id':'P-PASS-04','pattern_name':'Add\x20Guard\x20with\x20relies\x20dependency','semantic_intent':'Add\x20a\x20Guard\x20that\x20depends\x20on\x20other\x20Guards\x20(AND/OR\x20logic)','match_keywords':['relies','depend','dependency','and','or'],'schema_fields':['guard[].object','guard[].impack','(relies\x20read\x20from\x20Guard\x20object)'],'example_json':{'guard':[{'object':'guard_a','impack':!![]},{'object':'guard_b','impack':!![]}],'submission':[]},'reverse_explanation':'relies\x20is\x20read\x20from\x20guard::relies(guard)\x20—\x20NOT\x20set\x20in\x20Passport\x20JSON.\x20Must\x20add\x20relied\x20Guards\x20first\x20(E_RELIES_GUARD_NOT_ADDED).\x20relies_logic_and=true=AND,\x20false=OR.\x20No\x20transitive\x20dependencies\x20allowed.'},{'id':'P-PASS-05','pattern_name':'Verify\x20Passport\x20(one-time)','semantic_intent':'Trigger\x20one-time\x20verification\x20of\x20all\x20Guards;\x20result\x20is\x20immutable\x20after\x20this\x20call','match_keywords':['verify','validation','submit'],'schema_fields':['(verify\x20operation)'],'example_json':{'operation':'verify'},'reverse_explanation':'passport::verify(self,\x20ctx).\x20One-time\x20—\x20has_verified\x20set\x20to\x20true.\x20Computes\x20per-Guard\x20result\x20via\x20relies\x20logic,\x20then\x20impack\x20Guards\x20decide\x20final\x20result.\x20Aborts\x20E_HAS_VERIFIED\x20if\x20called\x20twice.'},{'id':'P-PASS-06','pattern_name':'Freeze\x20Passport\x20(permanent)','semantic_intent':'Permanently\x20freeze\x20the\x20Passport\x20as\x20immutable\x20(cannot\x20be\x20destroyed\x20after)','match_keywords':['freeze','freezen','permanent'],'schema_fields':['(freezen\x20operation)'],'example_json':{'operation':'freezen'},'reverse_explanation':'passport::freezen(self)\x20calls\x20transfer::freeze_object(self).\x20Passport\x20becomes\x20immutable\x20and\x20publicly\x20readable.\x20Cannot\x20be\x20destroyed\x20after\x20freezing.\x20SDK\x20exports\x20as\x20`freeze`\x20(correct\x20spelling).'},{'id':'P-PASS-07','pattern_name':'Query\x20result','semantic_intent':'Get\x20the\x20final\x20verification\x20result\x20(requires\x20has_verified=true\x20+\x20tx_hash\x20match)','match_keywords':['result','query','outcome'],'schema_fields':['(result\x20query)'],'example_json':{'operation':'result_query'},'reverse_explanation':'passport::result(self,\x20ctx)\x20:\x20bool.\x20Aborts\x20E_NOT_VERIFIED\x20(5)\x20if\x20not\x20yet\x20verified;\x20E_TX_NOT_MATCH\x20(8)\x20if\x20called\x20from\x20a\x20different\x20transaction.\x20Must\x20be\x20called\x20in\x20the\x20same\x20tx\x20as\x20verify().'},{'id':'P-PASS-08','pattern_name':'Query\x20specific\x20Guard\x20result\x20(result_for_guard)','semantic_intent':'Hard-verify\x20that\x20a\x20specific\x20impack\x20Guard\x20passed\x20(aborts\x20E_VERIFY_FAILED\x20if\x20not)','match_keywords':['result_for_guard','hard-verify','specific\x20guard'],'schema_fields':['(result_for_guard\x20query)'],'example_json':{'operation':'result_for_guard','guard':'kyc_guard'},'reverse_explanation':'passport::result_for_guard(self,\x20guard,\x20ctx).\x20Aborts\x20E_NOT_IMPACK_GUARD\x20(6)\x20if\x20guard\x20is\x20not\x20impack;\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false.\x20Used\x20by\x20consumers\x20to\x20enforce\x20specific\x20Guard\x20checks.'},{'id':'P-PASS-09','pattern_name':'Query\x20impack\x20Guard\x20list\x20(result_for_permission)','semantic_intent':'Get\x20the\x20list\x20of\x20impack\x20Guard\x20addresses\x20(lazy-filled\x20on\x20first\x20call)','match_keywords':['result_for_permission','impack\x20list','impack\x20addresses'],'schema_fields':['(result_for_permission\x20query)'],'example_json':{'operation':'result_for_permission'},'reverse_explanation':'passport::result_for_permission(self,\x20ctx)\x20:\x20vector<address>.\x20Lazy-fills\x20self.impack\x20on\x20first\x20call.\x20Aborts\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false.\x20Used\x20by\x20Permission/Allocation\x20to\x20get\x20authorized\x20Guard\x20list.'},{'id':'P-PASS-10','pattern_name':'Get\x20submission\x20value','semantic_intent':'Read\x20the\x20submitted\x20value\x20for\x20a\x20(guard,\x20identifier)\x20pair','match_keywords':['submission_get','read','fetch\x20submission'],'schema_fields':['(submission_get\x20query)'],'example_json':{'operation':'submission_get','guard':'voting_guard','identifier':0x0},'reverse_explanation':'passport::submission_get(self,\x20guard,\x20identifier)\x20:\x20vector<u8>.\x20Read-only\x20—\x20no\x20tx_hash\x20check.\x20Returns\x20the\x20BCS-encoded\x20value.\x20Aborts\x20E_SUBMISSION_NOT_FOUND\x20(10)\x20if\x20no\x20entry\x20exists.'},{'id':'P-PASS-11','pattern_name':'Destroy\x20Passport','semantic_intent':'Permanently\x20delete\x20the\x20Passport\x20to\x20release\x20storage\x20(must\x20be\x20before\x20freeze)','match_keywords':['destroy','delete','remove'],'schema_fields':['(destroy\x20operation)'],'example_json':{'operation':'destroy'},'reverse_explanation':'passport::destroy(self)\x20calls\x20object::delete(id).\x20Must\x20be\x20called\x20BEFORE\x20freeze\x20(frozen\x20objects\x20are\x20immutable,\x20cannot\x20be\x20destroyed).\x20Move\x20ownership\x20protects:\x20only\x20signer\x20holding\x20the\x20object\x20can\x20call.'},{'id':'P-PASS-12','pattern_name':'Clear\x20all\x20Guards\x20(pre-verify\x20only)','semantic_intent':'Remove\x20all\x20Guards\x20from\x20Passport\x20(only\x20allowed\x20before\x20verify)','match_keywords':['guard_clear','clear','reset'],'schema_fields':['(guard_clear\x20operation)'],'example_json':{'operation':'guard_clear'},'reverse_explanation':'passport::guard_clear(self,\x20ctx).\x20Aborts\x20E_HAS_VERIFIED\x20(4)\x20if\x20already\x20verified;\x20E_DIGEST_NOT_MATCH\x20(11)\x20if\x20tx_hash\x20mismatch.\x20Useful\x20for\x20resetting\x20configuration\x20before\x20verify.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Passport\x20object\x20reference\x20(address).\x20For\x20create,\x20no\x20object\x20yet;\x20for\x20operate,\x20the\x20existing\x20Passport\x20address.'},{'element_type':'field','type_name':'guard','semantic_explanation':'Array\x20of\x20{object,\x20impack}.\x20Each\x20entry\x20references\x20a\x20Guard\x20object\x20and\x20marks\x20whether\x20it\x20affects\x20final\x20result.\x20Count\x20≤\x20MAX_GUARD_COUNT_PASSPORT=20.'},{'element_type':'field','type_name':'guard[].object','semantic_explanation':'Guard\x20object\x20address.\x20Must\x20be\x20unique\x20within\x20the\x20Passport\x20(duplicate\x20addresses\x20overwrite\x20existing\x20config).\x20Resolved\x20via\x20LocalMark\x20before\x20on-chain\x20call.'},{'element_type':'field','type_name':'guard[].impack','semantic_explanation':'Boolean.\x20true=affects\x20final\x20result\x20(at\x20least\x201\x20required);\x20false=audit-only.\x20impack\x20Guards\x20failing\x20→\x20overall\x20result=false\x20immediately.'},{'element_type':'field','type_name':'submission','semantic_explanation':'Array\x20of\x20{guard,\x20submission[]}.\x20Each\x20submission\x20is\x20{identifier,\x20value,\x20value_type}.\x20identifier\x20is\x20u8\x20(0-255)\x20matching\x20Guard.table[].identifier.'},{'element_type':'field','type_name':'submission[].identifier','semantic_explanation':'u8\x20(0-255).\x20References\x20Guard.table[identifier].\x20Must\x20be\x20marked\x20b_submission=true\x20in\x20the\x20Guard.'},{'element_type':'field','type_name':'submission[].value','semantic_explanation':'Value\x20matching\x20submission[].value_type.\x20BCS-serialized\x20on-chain;\x20total\x20serialized\x20size\x20per\x20submission\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes.'},{'element_type':'field','type_name':'submission[].value_type','semantic_explanation':'Type\x20string:\x20\x27address\x27\x20|\x20\x27u64\x27\x20|\x20\x27bool\x27\x20|\x20\x27string\x27\x20|\x20\x27vector<u8>\x27\x20etc.\x20Must\x20match\x20Guard.table[identifier].value_type.'},{'element_type':'op','type_name':'create\x20(new)','semantic_explanation':'passport::new_v2(clock,\x20object_linker_tx,\x20ctx)\x20→\x20Passport.\x20Binds\x20tx_hash\x20=\x20tx_context::digest(ctx).\x20signer\x20=\x20tx_context::sender(ctx).\x20time\x20=\x20clock::timestamp_ms(clock).\x20Registers\x20creator\x20(tx\x20sender)\x20into\x20ObjectLinkerTx\x20for\x20creator\x20reverse\x20lookup.'},{'element_type':'op','type_name':'guard_add','semantic_explanation':'passport::guard_add(self,\x20guard,\x20identifiers,\x20values,\x20impack,\x20ctx).\x20Pre-verify\x20only.\x20Reads\x20guard::relies(guard)\x20for\x20dependency\x20info.\x20Aborts\x20E_RELIES_GUARD_NOT_ADDED\x20if\x20relies\x20missing.'},{'element_type':'op','type_name':'verify','semantic_explanation':'passport::verify(self,\x20ctx)\x20:\x20bool.\x20One-time.\x20Computes\x20per-Guard\x20result\x20via\x20relies,\x20then\x20impack\x20Guards\x20decide\x20final\x20result.\x20Sets\x20has_verified=true.'},{'element_type':'op','type_name':'freezen','semantic_explanation':'passport::freezen(self).\x20Permanent\x20freeze\x20(transfer::freeze_object).\x20Cannot\x20destroy\x20after.\x20Historical\x20typo:\x20Move\x20function\x20name\x20is\x20\x27freezen\x27\x20(not\x20\x27freeze\x27),\x20retained\x20for\x20compatibility.\x20SDK\x20exports\x20as\x20`freeze`.'},{'element_type':'op','type_name':'destroy','semantic_explanation':'passport::destroy(self).\x20Releases\x20storage\x20(object::delete).\x20Must\x20be\x20before\x20freeze.\x20Move\x20ownership\x20protects:\x20only\x20object\x20holder\x20can\x20call.'},{'element_type':'impack','type_name':'impack=true','semantic_explanation':'Guard\x20affects\x20final\x20result.\x20At\x20least\x201\x20required\x20(E_IMPACK_GUARD_NOT_FOUND).\x20Failure\x20→\x20overall\x20result=false,\x20immediate\x20return.'},{'element_type':'impack','type_name':'impack=false','semantic_explanation':'Guard\x20is\x20audit-only.\x20Per-Guard\x20result\x20is\x20recorded\x20but\x20does\x20NOT\x20affect\x20final\x20result.\x20Useful\x20for\x20logging\x20/\x20secondary\x20checks.'},{'element_type':'relies_logic','type_name':'AND\x20(relies_logic_and=true)','semantic_explanation':'All\x20relied\x20Guards\x20must\x20pass.\x20Short-circuits\x20on\x20first\x20false.\x20Initial\x20value\x20=\x20true;\x20result\x20=\x20true\x20AND\x20rely1.result\x20AND\x20rely2.result\x20...'},{'element_type':'relies_logic','type_name':'OR\x20(relies_logic_and=false)','semantic_explanation':'Any\x20relied\x20Guard\x20may\x20pass.\x20Short-circuits\x20on\x20first\x20true.\x20Initial\x20value\x20=\x20false;\x20result\x20=\x20false\x20OR\x20rely1.result\x20OR\x20rely2.result\x20...'},{'element_type':'lifecycle','type_name':'new\x20→\x20guard_add\x20→\x20verify\x20→\x20use\x20→\x20freeze/destroy','semantic_explanation':'5-stage\x20lifecycle.\x20verify\x20is\x20one-time.\x20freeze\x20and\x20destroy\x20are\x20mutually\x20exclusive\x20terminal\x20states.\x20All\x20write\x20ops\x20(guard_add/verify)\x20require\x20tx_hash\x20match.'}];export const PASSPORT_CONSTRAINT_RULES=[{'id':'T-PASS-01','category':'structural','rule':'Passport\x20is\x20created\x20via\x20the\x20SubmissionCall\x20mechanism,\x20not\x20the\x20standard\x20Call\x20pattern\x20(schema/call/base.ts\x20SubmissionCallSchema)','applies_to':['SubmissionCall','passport::new_v2']},{'id':'T-PASS-02','category':'logic','rule':'Guards\x20with\x20guard[].impack=true\x20decide\x20the\x20final\x20result;\x20at\x20least\x201\x20impack\x20Guard\x20is\x20required\x20(E_IMPACK_GUARD_NOT_FOUND=9)','applies_to':['guard[].impack','verify\x20operation']},{'id':'T-PASS-03','category':'logic','rule':'Depended-on\x20Guards\x20must\x20be\x20added\x20first\x20(topological\x20order);\x20guard_add\x20checks\x20relies,\x20missing\x20relies\x20aborts\x20E_RELIES_GUARD_NOT_ADDED=2','applies_to':['guard_add\x20operation','guard::relies(guard)']},{'id':'T-PASS-04','category':'lifecycle','rule':'After\x20verify,\x20config\x20cannot\x20be\x20modified\x20(has_verified\x20is\x20one-time);\x20second\x20calls\x20to\x20guard_add/guard_clear/verify\x20abort\x20E_HAS_VERIFIED=4','applies_to':['verify\x20operation','has_verified\x20field']},{'id':'T-PASS-05','category':'lifecycle','rule':'tx_hash\x20binding\x20ensures\x20Passport\x20cannot\x20be\x20reused\x20across\x20transactions;\x20write\x20functions\x20and\x20result\x20queries\x20check\x20tx_hash\x20match','applies_to':['tx_hash\x20field','guard_add','verify','result']},{'id':'T-PASS-06','category':'structural','rule':'submission\x20data\x20must\x20match\x20Guard\x20identifier\x20type;\x20BCS\x20serialization\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes','applies_to':['submission[].value_type','submission[].identifier']},{'id':'T-PASS-07','category':'lifecycle','rule':'result\x20query\x20must\x20be\x20in\x20the\x20same\x20transaction\x20(tx_hash\x20matches\x20current\x20transaction);\x20otherwise\x20E_TX_NOT_MATCH=8','applies_to':['result\x20operation','result_for_guard','result_for_permission']},{'id':'T-PASS-08','category':'lifecycle','rule':'After\x20freeze,\x20Passport\x20is\x20permanently\x20retained\x20(cannot\x20be\x20destroyed);\x20freezen\x20calls\x20transfer::freeze_object','applies_to':['freezen\x20operation','destroy\x20operation']},{'id':'T-PASS-09','category':'lifecycle','rule':'destroy\x20must\x20happen\x20before\x20freeze\x20(destroyable\x20when\x20not\x20frozen);\x20after\x20freezing\x20the\x20object\x20becomes\x20immutable\x20and\x20cannot\x20be\x20received\x20by\x20value','applies_to':['destroy\x20operation','freezen\x20operation']},{'id':'T-PASS-10','category':'operational','rule':'explainPassport\x20must\x20translate\x20impack\x20and\x20result\x20status;\x20use\x20passport.object\x20(not\x20passport.id)\x20as\x20the\x20object\x20identifier','applies_to':['explainPassport\x20function','ObjectPassportSchema']},{'id':'T-PASS-11','category':'logic','rule':'relies\x20logic\x20(AND/OR)\x20must\x20be\x20reflected\x20in\x20explainPassport;\x20relies_logic_and=true=AND,\x20false=OR','applies_to':['explainPassport\x20function','guard::relies(guard)']},{'id':'T-PASS-12','category':'structural','rule':'Guard\x20count\x20≤\x20MAX_GUARD_COUNT_PASSPORT=20;\x20submission\x20serialized\x20size\x20≤\x20MAX_SUBMISSION_SIZE_PASSPORT=256\x20bytes','applies_to':['guard\x20array','submission\x20array']}];export const PASSPORT_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 explainPassport(a){const b=[];b['push']('Passport\x20'+a['object']),b['push']('\x20\x20Signer:\x20'+a['signer']),b['push']('\x20\x20Time:\x20'+new Date(a['time'])['toISOString']()),b['push']('\x20\x20Verified:\x20'+a['has_verified']);a['has_verified']&&b['push']('\x20\x20Result:\x20'+(a['result']?'PASS\x20✅':'FAIL\x20❌'));b['push']('\x20\x20Guards:\x20'+a['info']['length']+'/'+MAX_GUARD_COUNT_PASSPORT);if(a['info']['length']>0x0){b['push']('\x20\x20Guard\x20details:');for(const c of a['info']){const d=c['impack']?'IMPACK':'non-impack',e=c['result']?'PASS':'FAIL';b['push']('\x20\x20\x20\x20-\x20Guard\x20'+c['guard']+':\x20'+e+'\x20('+d+')');}}return a['impack_guard']&&a['impack_guard']['length']>0x0&&b['push']('\x20\x20impack_guard\x20list\x20(lazy-filled):\x20'+a['impack_guard']['join'](',\x20')),a['tx_hash']&&b['push']('\x20\x20tx_hash:\x20'+a['tx_hash']),b['join']('\x0a');}export function passportJsonToSemantic(a){const b=[];if(a['type']==='submission'||a['guard']&&a['guard']['length']>0x0){b['push']('Operation:\x20CREATE\x20Passport\x20via\x20SubmissionCall');if(a['guard']&&a['guard']['length']>0x0){const c=a['guard']['filter'](e=>e['impack'])['length'],d=a['guard']['length']-c;b['push']('-\x20Guards:\x20'+a['guard']['length']+'/'+MAX_GUARD_COUNT_PASSPORT+'\x20('+c+'\x20impack,\x20'+d+'\x20non-impack)'),c===0x0&&b['push']('\x20\x20⚠️\x20No\x20impack\x20Guard\x20—\x20verify\x20will\x20abort\x20E_IMPACK_GUARD_NOT_FOUND\x20(9)'),a['guard']['forEach']((e,f)=>{const h=e['impack']?'IMPACK\x20(affects\x20result)':'non-impack\x20(audit-only)';b['push']('\x20\x20['+f+']\x20'+e['object']+'\x20—\x20'+h);});}if(a['submission']&&a['submission']['length']>0x0){b['push']('-\x20Submissions:\x20'+a['submission']['length']+'\x20guard(s)\x20with\x20submission\x20data');for(const e of a['submission']){const f=e['submission']['reduce']((h,i)=>h+estimateSubmissionSize(i['value_type']),0x0),g=f>MAX_SUBMISSION_SIZE_PASSPORT?'\x20⚠️\x20'+f+'\x20>\x20'+MAX_SUBMISSION_SIZE_PASSPORT+'\x20bytes\x20(E_SUBMISSION_SIZE_EXCEEDED)':'';b['push']('\x20\x20-\x20guard='+e['guard']+':\x20'+e['submission']['length']+'\x20item(s),\x20estimated\x20size='+f+'\x20bytes'+g);}}}else{if(a['operation']){b['push']('Operation:\x20'+a['operation']['toUpperCase']());switch(a['operation']){case'verify':b['push']('-\x20One-time\x20verification;\x20sets\x20has_verified=true,\x20computes\x20final\x20result'),b['push']('-\x20Aborts\x20E_HAS_VERIFIED\x20(4)\x20if\x20already\x20verified');break;case'freezen':b['push']('-\x20Permanent\x20freeze\x20(transfer::freeze_object)'),b['push']('-\x20Cannot\x20be\x20destroyed\x20after\x20freezing');break;case'destroy':b['push']('-\x20Permanent\x20deletion\x20(object::delete)'),b['push']('-\x20Must\x20be\x20called\x20BEFORE\x20freeze');break;case'guard_clear':b['push']('-\x20Removes\x20all\x20Guards\x20from\x20Passport'),b['push']('-\x20Only\x20allowed\x20before\x20verify\x20(E_HAS_VERIFIED\x20if\x20verified)');break;case'result_query':b['push']('-\x20Returns\x20final\x20verification\x20result\x20(bool)'),b['push']('-\x20Requires\x20has_verified=true\x20(E_NOT_VERIFIED)\x20and\x20tx_hash\x20match\x20(E_TX_NOT_MATCH)');break;case'result_for_guard':b['push']('-\x20Hard-verifies\x20Guard\x20'+a['guard_target']+'\x20is\x20impack\x20and\x20passed'),b['push']('-\x20Aborts\x20E_NOT_IMPACK_GUARD\x20(6)\x20if\x20not\x20impack;\x20E_VERIFY_FAILED\x20(7)\x20if\x20result=false');break;case'result_for_permission':b['push']('-\x20Returns\x20impack\x20Guard\x20address\x20list\x20(lazy-filled)'),b['push']('-\x20Aborts\x20E_VERIFY_FAILED\x20(7)\x20if\x20overall\x20result=false');break;case'submission_get':b['push']('-\x20Reads\x20submission\x20value\x20for\x20(guard='+a['guard_target']+',\x20identifier='+a['identifier']+')'),b['push']('-\x20Read-only,\x20no\x20tx_hash\x20check'),b['push']('-\x20Aborts\x20E_SUBMISSION_NOT_FOUND\x20(10)\x20if\x20no\x20entry');break;}}else b['push']('⚠️\x20Cannot\x20determine\x20operation:\x20provide\x20\x27type:\x20submission\x27\x20with\x20guard[],\x20or\x20\x27operation\x27\x20field');}return b['join']('\x0a');}export function semanticToPassportJson(a){switch(a['action']){case'create':{if(!a['guards']||a['guards']['length']===0x0)throw new Error('Create\x20action\x20requires\x20at\x20least\x201\x20Guard\x20in\x20intent.guards');if(a['guards']['length']>MAX_GUARD_COUNT_PASSPORT)throw new Error('Guard\x20count\x20'+a['guards']['length']+'\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT='+MAX_GUARD_COUNT_PASSPORT);const b=a['guards']['some'](c=>c['impack']);if(!b)throw new Error('At\x20least\x201\x20Guard\x20must\x20have\x20impack=true\x20(else\x20verify\x20aborts\x20E_IMPACK_GUARD_NOT_FOUND=9)');return{'type':'submission','guard':a['guards']['map'](c=>({'object':c['object'],'impack':c['impack']})),'submission':a['guards']['filter'](c=>c['submission']&&c['submission']['length']>0x0)['map'](c=>({'guard':c['object'],'submission':c['submission']}))};}case'verify':return{'operation':'verify'};case'freeze':return{'operation':'freezen'};case'destroy':return{'operation':'destroy'};case'guard_clear':return{'operation':'guard_clear'};case'query_result':return{'operation':'result_query'};case'query_guard_result':if(!a['targetGuard'])throw new Error('query_guard_result\x20requires\x20intent.targetGuard');return{'operation':'result_for_guard','guard_target':a['targetGuard']};case'query_impack_list':return{'operation':'result_for_permission'};case'get_submission':if(!a['targetGuard'])throw new Error('get_submission\x20requires\x20intent.targetGuard');if(a['targetIdentifier']===undefined)throw new Error('get_submission\x20requires\x20intent.targetIdentifier');return{'operation':'submission_get','guard_target':a['targetGuard'],'identifier':a['targetIdentifier']};}}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 explainImpack(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='impack'&&b['type_name']==='impack='+a);}export function explainReliesLogic(a){const b=a?'AND\x20(relies_logic_and=true)':'OR\x20(relies_logic_and=false)';return SCHEMA_TO_SEMANTIC_RULES['find'](c=>c['element_type']==='relies_logic'&&c['type_name']===b);}export function getConstraintsByCategory(a){return PASSPORT_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainError(a){const b={[PASSPORT_ERROR_CODES['E_GUARD_COUNT_EXCEEDED']]:'Guard\x20count\x20exceeds\x20MAX_GUARD_COUNT_PASSPORT\x20(20)\x20—\x20remove\x20non-essential\x20Guards\x20or\x20merge\x20similar\x20ones',[PASSPORT_ERROR_CODES['E_RELIES_GUARD_NOT_ADDED']]:'Relied\x20Guard\x20not\x20yet\x20added\x20—\x20add\x20relied\x20Guards\x20in\x20topological\x20order\x20before\x20adding\x20the\x20dependent\x20Guard',[PASSPORT_ERROR_CODES['E_SUBMISSION_SIZE_EXCEEDED']]:'Submission\x20serialized\x20size\x20exceeds\x20MAX_SUBMISSION_SIZE_PASSPORT\x20(256\x20bytes)\x20—\x20use\x20Repository\x20reference\x20for\x20large\x20data',[PASSPORT_ERROR_CODES['E_HAS_VERIFIED']]:'Passport\x20already\x20verified\x20—\x20verify\x20is\x20one-time;\x20create\x20a\x20new\x20Passport\x20to\x20re-verify',[PASSPORT_ERROR_CODES['E_NOT_VERIFIED']]:'result()\x20called\x20before\x20verify()\x20—\x20call\x20verify()\x20first\x20in\x20the\x20same\x20transaction',[PASSPORT_ERROR_CODES['E_NOT_IMPACK_GUARD']]:'result_for_guard\x20called\x20on\x20non-impack\x20Guard\x20—\x20only\x20impack\x20Guards\x20can\x20be\x20hard-verified',[PASSPORT_ERROR_CODES['E_VERIFY_FAILED']]:'result_for_guard\x20/\x20result_for_permission\x20called\x20when\x20overall\x20result=false\x20—\x20fix\x20Guard\x20configuration\x20or\x20submission\x20data',[PASSPORT_ERROR_CODES['E_TX_NOT_MATCH']]:'result()\x20called\x20from\x20a\x20different\x20transaction\x20—\x20Passport\x20is\x20tx_hash-bound,\x20must\x20query\x20in\x20the\x20same\x20tx\x20as\x20verify()',[PASSPORT_ERROR_CODES['E_IMPACK_GUARD_NOT_FOUND']]:'verify()\x20found\x20no\x20impack\x20Guard\x20—\x20at\x20least\x201\x20Guard\x20must\x20have\x20impack=true',[PASSPORT_ERROR_CODES['E_SUBMISSION_NOT_FOUND']]:'submission_get\x20found\x20no\x20entry\x20for\x20(guard,\x20identifier)\x20—\x20check\x20Guard.table[identifier].b_submission=true',[PASSPORT_ERROR_CODES['E_DIGEST_NOT_MATCH']]:'guard_add\x20/\x20verify\x20/\x20guard_clear\x20called\x20from\x20a\x20different\x20transaction\x20—\x20Passport\x20is\x20tx_hash-bound'};return b[a]??'Unknown\x20Passport\x20error\x20code:\x20'+a;}function estimateSubmissionSize(a){switch(a){case'bool':return 0x1;case'u8':return 0x1;case'u64':return 0x8;case'address':return 0x20;case'string':return 0x20;case'vector<u8>':return 0x20;default:return 0x40;}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_PROOF_SIZE,MAX_SERVER_PUBKEY_SIZE,MAX_SERVER_SIGNATURE_SIZE,WOWOK_WTS_PROOF_TYPE}from'@wowok/wowok';const R_PR_1_01={'rule':{'id':'R-PROOF-01','level':'HIGH','category':'structural','title':'proof\x20content\x20exceeds\x20MAX_PROOF_SIZE\x20('+MAX_PROOF_SIZE+'\x20bytes)','description':'The\x20\x27proof\x27\x20string\x20field\x20is\x20bounded\x20by\x20MAX_PROOF_SIZE='+MAX_PROOF_SIZE+'\x20bytes\x20(Move\x20source:\x20proof.move:27).\x20'+'Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_PROOF_SIZE\x20(1).\x20The\x20proof\x20content\x20typically\x20holds\x20a\x20merkle\x20tree\x20root\x20'+'or\x20similar\x20compact\x20cryptographic\x20digest\x20—\x20large\x20data\x20should\x20be\x20stored\x20in\x20a\x20Repository\x20and\x20referenced\x20by\x20address,\x20'+'not\x20inlined\x20into\x20the\x20Proof\x20object.','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20a\x20proof\x20string\x20longer\x20than\x2010240\x20bytes','mitigation':'Keep\x20proof\x20content\x20compact\x20(merkle\x20root,\x20hash\x20digest).\x20For\x20larger\x20payloads,\x20store\x20data\x20in\x20a\x20Repository\x20'+'object\x20and\x20set\x20about_address\x20to\x20the\x20Repository\x20address,\x20or\x20use\x20item_count\x20to\x20indicate\x20the\x20off-chain\x20data\x20size.','related_move_error':'E_MAX_PROOF_SIZE\x20(1)','auto_fixable':![]},'check':a=>{if(!a['proof'])return null;if(a['proof']['length']<=MAX_PROOF_SIZE)return null;return{...R_PR_1_01['rule'],'evidence':'proof.length='+a['proof']['length']+',\x20limit='+MAX_PROOF_SIZE};}},R_PR_1_02={'rule':{'id':'R-PROOF-02','level':'MEDIUM','category':'structural','title':'server_pubkey\x20exceeds\x20MAX_SERVER_PUBKEY_SIZE\x20('+MAX_SERVER_PUBKEY_SIZE+'\x20bytes)','description':'The\x20\x27server_pubkey\x27\x20field\x20is\x20bounded\x20by\x20MAX_SERVER_PUBKEY_SIZE='+MAX_SERVER_PUBKEY_SIZE+'\x20bytes\x20(Move\x20source:\x20proof.move:28).\x20'+'Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_SERVER_PUBKEY_SIZE\x20(2).\x20Typical\x20public\x20keys\x20(Ed25519=32\x20bytes,\x20RSA-2048=256\x20bytes,\x20'+'BLS12-381\x20G1=48\x20bytes,\x20G2=96\x20bytes)\x20fit\x20comfortably\x20within\x20this\x20limit.','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20an\x20oversized\x20server\x20public\x20key\x20(e.g.\x20certificate\x20chain\x20instead\x20of\x20raw\x20key)','mitigation':'Submit\x20only\x20the\x20raw\x20public\x20key\x20bytes\x20(hex-encoded),\x20not\x20a\x20full\x20certificate\x20or\x20JWK\x20structure.','related_move_error':'E_MAX_SERVER_PUBKEY_SIZE\x20(2)','auto_fixable':![]},'check':a=>{if(!a['server_pubkey'])return null;if(a['server_pubkey']['length']<=MAX_SERVER_PUBKEY_SIZE)return null;return{...R_PR_1_02['rule'],'evidence':'server_pubkey.length='+a['server_pubkey']['length']+',\x20limit='+MAX_SERVER_PUBKEY_SIZE};}},R_PR_1_03={'rule':{'id':'R-PROOF-03','level':'MEDIUM','category':'structural','title':'server_signature\x20exceeds\x20MAX_SERVER_SIGNATURE_SIZE\x20('+MAX_SERVER_SIGNATURE_SIZE+'\x20bytes)','description':'The\x20\x27server_signature\x27\x20field\x20is\x20bounded\x20by\x20MAX_SERVER_SIGNATURE_SIZE='+MAX_SERVER_SIGNATURE_SIZE+'\x20bytes\x20'+'(Move\x20source:\x20proof.move:29).\x20Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_SERVER_SIGNATURE_SIZE\x20(3).\x20'+'Most\x20signature\x20schemes\x20produce\x20signatures\x20well\x20under\x20this\x20limit\x20(Ed25519=64\x20bytes,\x20ECDSA=64-72\x20bytes,\x20'+'BLS12-381=96\x20bytes,\x20RSA-2048=256\x20bytes).','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20an\x20oversized\x20signature\x20(e.g.\x20bundled\x20with\x20metadata)','mitigation':'Submit\x20only\x20the\x20raw\x20signature\x20bytes\x20(hex-encoded),\x20not\x20bundled\x20metadata\x20or\x20certificate\x20chains.','related_move_error':'E_MAX_SERVER_SIGNATURE_SIZE\x20(3)','auto_fixable':![]},'check':a=>{if(!a['server_signature'])return null;if(a['server_signature']['length']<=MAX_SERVER_SIGNATURE_SIZE)return null;return{...R_PR_1_03['rule'],'evidence':'server_signature.length='+a['server_signature']['length']+',\x20limit='+MAX_SERVER_SIGNATURE_SIZE};}},R_PR_2_01={'rule':{'id':'R-PROOF-04','level':'MEDIUM','category':'semantic','title':'proof_type\x20in\x20reserved\x20range\x20without\x20authority\x20(1-100\x20reserved\x20for\x20Wowok)','description':'proof_type='+WOWOK_WTS_PROOF_TYPE+'\x20is\x20WOWOK_WTS_PROOF_TYPE\x20(Will-To-Sign).\x20Values\x202-100\x20are\x20reserved\x20for\x20'+'future\x20Wowok-defined\x20proof\x20types.\x20User-defined\x20proof\x20types\x20must\x20use\x20values\x20>\x20100.\x20While\x20the\x20Move\x20contract\x20'+'does\x20not\x20currently\x20enforce\x20this\x20range\x20at\x20the\x20type\x20level\x20(it\x20accepts\x20any\x20u64),\x20using\x20a\x20reserved\x20value\x20without\x20'+'authority\x20creates\x20semantic\x20confusion:\x20consumers\x20may\x20misinterpret\x20the\x20proof\x27s\x20verification\x20rules.','affected_stakeholders':['creator','consumer','verifier'],'scenario':'User\x20creates\x20a\x20custom\x20proof\x20with\x20proof_type=5\x20(a\x20reserved\x20value)','mitigation':'Use\x20proof_type\x20>\x20100\x20for\x20user-defined\x20proof\x20types.\x20Use\x20proof_type=1\x20only\x20for\x20WTS\x20proofs\x20signed\x20by\x20an\x20'+'off-chain\x20server\x20(with\x20server_pubkey\x20+\x20server_signature).\x20Document\x20the\x20verification\x20rule\x20for\x20custom\x20types.','auto_fixable':![]},'check':a=>{if(a['proof_type']===undefined||a['proof_type']===null)return null;const b=typeof a['proof_type']==='string'?BigInt(a['proof_type']):BigInt(a['proof_type']);if(b===BigInt(WOWOK_WTS_PROOF_TYPE)||b>0x64n)return null;return{...R_PR_2_01['rule'],'evidence':'proof_type='+a['proof_type']+'\x20(reserved\x20range\x202-100)'};}},R_PR_2_02={'rule':{'id':'R-PROOF-05','level':'LOW','category':'semantic','title':'about_address\x20not\x20provided\x20—\x20consumers\x20cannot\x20locate\x20the\x20referenced\x20entity','description':'about_address\x20is\x20the\x20on-chain\x20address\x20of\x20the\x20entity\x20being\x20proved\x20(e.g.\x20a\x20user,\x20an\x20order,\x20a\x20Repository).\x20'+'When\x20null/undefined,\x20the\x20Proof\x20has\x20no\x20on-chain\x20binding\x20—\x20it\x20is\x20a\x20free-standing\x20cryptographic\x20statement.\x20'+'Consumers\x20(Repository,\x20Service,\x20etc.)\x20that\x20reference\x20this\x20Proof\x20cannot\x20automatically\x20resolve\x20which\x20entity\x20'+'it\x20applies\x20to.\x20This\x20is\x20acceptable\x20for\x20generic\x20proofs\x20but\x20problematic\x20for\x20entity-bound\x20attestations.','affected_stakeholders':['creator','consumer'],'scenario':'Caller\x20creates\x20a\x20Proof\x20without\x20about_address,\x20then\x20a\x20Repository\x20tries\x20to\x20bind\x20it\x20to\x20a\x20data\x20entry','mitigation':'Set\x20about_address\x20when\x20the\x20Proof\x20attests\x20to\x20a\x20specific\x20on-chain\x20entity.\x20Leave\x20it\x20null\x20only\x20for\x20'+'free-standing\x20cryptographic\x20statements\x20(e.g.\x20a\x20server\x27s\x20timestamp\x20attestation).','auto_fixable':!![]},'check':a=>{if(a['about_address'])return null;return{...R_PR_2_02['rule'],'evidence':'about_address=null/undefined'};}},R_PR_3_01={'rule':{'id':'R-PROOF-06','level':'LOW','category':'lifecycle','title':'description\x20missing\x20—\x20Proof\x20hard\x20to\x20identify\x20in\x20queries\x20and\x20audit\x20logs','description':'description\x20is\x20a\x20REQUIRED\x20field\x20(PF-D-2=A).\x20The\x20Move\x20contract\x20stores\x20it\x20as\x20a\x20String\x20field\x20and\x20SDK\x20'+'passes\x20it\x20to\x20create_wowok_proof.\x20An\x20empty\x20description\x20(\x22\x22)\x20is\x20technically\x20valid\x20but\x20makes\x20the\x20Proof\x20'+'hard\x20to\x20identify\x20in\x20query\x20results\x20and\x20audit\x20logs.\x20Non-empty\x20descriptions\x20are\x20strongly\x20recommended.','affected_stakeholders':['creator','verifier'],'scenario':'Caller\x20passes\x20description=\x22\x22\x20to\x20save\x20typing','mitigation':'Provide\x20a\x20one-line\x20description\x20like\x20\x22KYC\x20attestation\x20for\x20user\x200xabc\x22\x20or\x20\x22merkle\x20root\x20for\x20batch\x20#42\x22.','auto_fixable':![]},'check':a=>{if(a['description']===undefined)return null;if(a['description']['length']>0x0)return null;return{...R_PR_3_01['rule'],'evidence':'description=\x22\x22\x20(empty)'};}},R_PR_3_02={'rule':{'id':'R-PROOF-07','level':'HIGH','category':'lifecycle','title':'Proof\x20is\x20immutable\x20—\x20cannot\x20modify\x20after\x20creation\x20(freeze_object)','description':'Proof\x20is\x20created\x20via\x20transfer::freeze_object(obj)\x20in\x20Move\x20(proof.move:65).\x20Once\x20frozen,\x20the\x20object\x20'+'cannot\x20be\x20modified,\x20transferred,\x20or\x20deleted.\x20All\x20fields\x20(proof,\x20server_pubkey,\x20server_signature,\x20'+'about,\x20proof_type,\x20signer,\x20time,\x20description,\x20item_count)\x20are\x20permanently\x20fixed\x20at\x20the\x20value\x20set\x20'+'during\x20create_wowok_proof().\x20To\x20\x27update\x27\x20a\x20Proof,\x20create\x20a\x20new\x20one\x20and\x20update\x20references.','affected_stakeholders':['creator','consumer'],'scenario':'Caller\x20wants\x20to\x20update\x20server_signature\x20after\x20key\x20rotation\x20—\x20cannot,\x20must\x20create\x20new\x20Proof','mitigation':'Verify\x20all\x20fields\x20before\x20calling\x20create_wowok_proof.\x20For\x20scenarios\x20requiring\x20key\x20rotation,\x20'+'create\x20a\x20new\x20Proof\x20and\x20update\x20the\x20referencing\x20object\x20(Repository\x20data,\x20Service\x20config,\x20etc.)\x20to\x20'+'point\x20to\x20the\x20new\x20Proof\x20address.','auto_fixable':![]},'check':a=>null},R_PR_4_01={'rule':{'id':'R-PROOF-08','level':'INFO','category':'knowledge','title':'Knowledge\x20layer\x20&\x20constant\x20sync\x20—\x20RESOLVED','description':'All\x204\x20Proof\x20constants\x20(WOWOK_WTS_PROOF_TYPE,\x20MAX_PROOF_SIZE,\x20MAX_SERVER_PUBKEY_SIZE,\x20'+'MAX_SERVER_SIGNATURE_SIZE)\x20are\x20now\x20synced\x20to\x20onchain-constants.ts\x20(P-PROOF-P2-5).\x20The\x20MCP\x20Knowledge\x20'+'layer\x20now\x20includes\x20proof-risk.ts,\x20proof-confirm.ts,\x20proof-translation.ts\x20(P-PROOF-P2-6).\x20'+'This\x20risk\x20rule\x20is\x20retained\x20for\x20historical\x20audit\x20and\x20to\x20detect\x20future\x20regressions.','affected_stakeholders':['system'],'scenario':'Future\x20regression:\x20someone\x20removes\x20a\x20Proof\x20constant\x20from\x20onchain-constants.ts','mitigation':'Run\x20the\x20onchain-constants\x20sync\x20test\x20to\x20detect\x20drift.','auto_fixable':![]},'check':a=>{if(a['constants_synced'])return null;return{...R_PR_4_01['rule'],'evidence':'constants_synced=false'};}};export const PROOF_RISK_RULES=[R_PR_1_01,R_PR_1_02,R_PR_1_03,R_PR_2_01,R_PR_2_02,R_PR_3_01,R_PR_3_02,R_PR_4_01];export function checkProofRisks(a){const b=[];for(const c of PROOF_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-PROOF-07')&&b['push'](R_PR_3_02['rule']),b;}export function getProofRiskById(a){return PROOF_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
1
|
+
import{MAX_PROOF_SIZE,MAX_SERVER_PUBKEY_SIZE,MAX_SERVER_SIGNATURE_SIZE,WOWOK_WTS_PROOF_TYPE}from'@wowok/wowok';const R_PR_1_01={'rule':{'id':'R-PROOF-01','level':'HIGH','category':'structural','title':'proof\x20content\x20exceeds\x20MAX_PROOF_SIZE\x20('+MAX_PROOF_SIZE+'\x20bytes)','description':'The\x20\x27proof\x27\x20string\x20field\x20is\x20bounded\x20by\x20MAX_PROOF_SIZE='+MAX_PROOF_SIZE+'\x20bytes\x20(Move\x20source:\x20proof.move:27).\x20'+'Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_PROOF_SIZE\x20(1).\x20The\x20proof\x20content\x20typically\x20holds\x20a\x20merkle\x20tree\x20root\x20'+'or\x20similar\x20compact\x20cryptographic\x20digest\x20—\x20large\x20data\x20should\x20be\x20stored\x20in\x20a\x20Repository\x20and\x20referenced\x20by\x20address,\x20'+'not\x20inlined\x20into\x20the\x20Proof\x20object.','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20a\x20proof\x20string\x20longer\x20than\x2010240\x20bytes','mitigation':'Keep\x20proof\x20content\x20compact\x20(merkle\x20root,\x20hash\x20digest).\x20For\x20larger\x20payloads,\x20store\x20data\x20in\x20a\x20Repository\x20'+'object\x20and\x20set\x20about_address\x20to\x20the\x20Repository\x20address,\x20or\x20use\x20item_count\x20to\x20indicate\x20the\x20off-chain\x20data\x20size.','related_move_error':'E_MAX_PROOF_SIZE\x20(1)','auto_fixable':![]},'check':a=>{if(!a['proof'])return null;if(a['proof']['length']<=MAX_PROOF_SIZE)return null;return{...R_PR_1_01['rule'],'evidence':'proof.length='+a['proof']['length']+',\x20limit='+MAX_PROOF_SIZE};}},R_PR_1_02={'rule':{'id':'R-PROOF-02','level':'MEDIUM','category':'structural','title':'server_pubkey\x20exceeds\x20MAX_SERVER_PUBKEY_SIZE\x20('+MAX_SERVER_PUBKEY_SIZE+'\x20bytes)','description':'The\x20\x27server_pubkey\x27\x20field\x20is\x20bounded\x20by\x20MAX_SERVER_PUBKEY_SIZE='+MAX_SERVER_PUBKEY_SIZE+'\x20bytes\x20(Move\x20source:\x20proof.move:28).\x20'+'Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_SERVER_PUBKEY_SIZE\x20(2).\x20Typical\x20public\x20keys\x20(Ed25519=32\x20bytes,\x20RSA-2048=256\x20bytes,\x20'+'BLS12-381\x20G1=48\x20bytes,\x20G2=96\x20bytes)\x20fit\x20comfortably\x20within\x20this\x20limit.','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20an\x20oversized\x20server\x20public\x20key\x20(e.g.\x20certificate\x20chain\x20instead\x20of\x20raw\x20key)','mitigation':'Submit\x20only\x20the\x20raw\x20public\x20key\x20bytes\x20(hex-encoded),\x20not\x20a\x20full\x20certificate\x20or\x20JWK\x20structure.','related_move_error':'E_MAX_SERVER_PUBKEY_SIZE\x20(2)','auto_fixable':![]},'check':a=>{if(!a['server_pubkey'])return null;if(a['server_pubkey']['length']<=MAX_SERVER_PUBKEY_SIZE)return null;return{...R_PR_1_02['rule'],'evidence':'server_pubkey.length='+a['server_pubkey']['length']+',\x20limit='+MAX_SERVER_PUBKEY_SIZE};}},R_PR_1_03={'rule':{'id':'R-PROOF-03','level':'MEDIUM','category':'structural','title':'server_signature\x20exceeds\x20MAX_SERVER_SIGNATURE_SIZE\x20('+MAX_SERVER_SIGNATURE_SIZE+'\x20bytes)','description':'The\x20\x27server_signature\x27\x20field\x20is\x20bounded\x20by\x20MAX_SERVER_SIGNATURE_SIZE='+MAX_SERVER_SIGNATURE_SIZE+'\x20bytes\x20'+'(Move\x20source:\x20proof.move:29).\x20Exceeding\x20this\x20limit\x20aborts\x20with\x20E_MAX_SERVER_SIGNATURE_SIZE\x20(3).\x20'+'Most\x20signature\x20schemes\x20produce\x20signatures\x20well\x20under\x20this\x20limit\x20(Ed25519=64\x20bytes,\x20ECDSA=64-72\x20bytes,\x20'+'BLS12-381=96\x20bytes,\x20RSA-2048=256\x20bytes).','affected_stakeholders':['creator'],'scenario':'Caller\x20submits\x20an\x20oversized\x20signature\x20(e.g.\x20bundled\x20with\x20metadata)','mitigation':'Submit\x20only\x20the\x20raw\x20signature\x20bytes\x20(hex-encoded),\x20not\x20bundled\x20metadata\x20or\x20certificate\x20chains.','related_move_error':'E_MAX_SERVER_SIGNATURE_SIZE\x20(3)','auto_fixable':![]},'check':a=>{if(!a['server_signature'])return null;if(a['server_signature']['length']<=MAX_SERVER_SIGNATURE_SIZE)return null;return{...R_PR_1_03['rule'],'evidence':'server_signature.length='+a['server_signature']['length']+',\x20limit='+MAX_SERVER_SIGNATURE_SIZE};}},R_PR_2_01={'rule':{'id':'R-PROOF-04','level':'MEDIUM','category':'semantic','title':'proof_type\x20in\x20reserved\x20range\x20without\x20authority\x20(1-100\x20reserved\x20for\x20Wowok)','description':'proof_type='+WOWOK_WTS_PROOF_TYPE+'\x20is\x20WOWOK_WTS_PROOF_TYPE\x20(Will-To-Sign).\x20Values\x202-100\x20are\x20reserved\x20for\x20'+'future\x20Wowok-defined\x20proof\x20types.\x20User-defined\x20proof\x20types\x20must\x20use\x20values\x20>\x20100.\x20While\x20the\x20Move\x20contract\x20'+'does\x20not\x20currently\x20enforce\x20this\x20range\x20at\x20the\x20type\x20level\x20(it\x20accepts\x20any\x20u64),\x20using\x20a\x20reserved\x20value\x20without\x20'+'authority\x20creates\x20semantic\x20confusion:\x20consumers\x20may\x20misinterpret\x20the\x20proof\x27s\x20verification\x20rules.','affected_stakeholders':['creator','consumer','verifier'],'scenario':'User\x20creates\x20a\x20custom\x20proof\x20with\x20proof_type=5\x20(a\x20reserved\x20value)','mitigation':'Use\x20proof_type\x20>\x20100\x20for\x20user-defined\x20proof\x20types.\x20Use\x20proof_type=1\x20only\x20for\x20WTS\x20proofs\x20signed\x20by\x20an\x20'+'off-chain\x20server\x20(with\x20server_pubkey\x20+\x20server_signature).\x20Document\x20the\x20verification\x20rule\x20for\x20custom\x20types.','auto_fixable':![]},'check':a=>{if(a['proof_type']===undefined||a['proof_type']===null)return null;const b=typeof a['proof_type']==='string'?BigInt(a['proof_type']):BigInt(a['proof_type']);if(b===BigInt(WOWOK_WTS_PROOF_TYPE)||b>0x64n)return null;return{...R_PR_2_01['rule'],'evidence':'proof_type='+a['proof_type']+'\x20(reserved\x20range\x202-100)'};}},R_PR_2_02={'rule':{'id':'R-PROOF-05','level':'LOW','category':'semantic','title':'about_address\x20not\x20provided\x20—\x20consumers\x20cannot\x20locate\x20the\x20referenced\x20entity','description':'about_address\x20is\x20the\x20on-chain\x20address\x20of\x20the\x20entity\x20being\x20proved\x20(e.g.\x20a\x20user,\x20an\x20order,\x20a\x20Repository).\x20'+'When\x20null/undefined,\x20the\x20Proof\x20has\x20no\x20on-chain\x20binding\x20—\x20it\x20is\x20a\x20free-standing\x20cryptographic\x20statement.\x20'+'Consumers\x20(Repository,\x20Service,\x20etc.)\x20that\x20reference\x20this\x20Proof\x20cannot\x20automatically\x20resolve\x20which\x20entity\x20'+'it\x20applies\x20to.\x20This\x20is\x20acceptable\x20for\x20generic\x20proofs\x20but\x20problematic\x20for\x20entity-bound\x20attestations.','affected_stakeholders':['creator','consumer'],'scenario':'Caller\x20creates\x20a\x20Proof\x20without\x20about_address,\x20then\x20a\x20Repository\x20tries\x20to\x20bind\x20it\x20to\x20a\x20data\x20entry','mitigation':'Set\x20about_address\x20when\x20the\x20Proof\x20attests\x20to\x20a\x20specific\x20on-chain\x20entity.\x20Leave\x20it\x20null\x20only\x20for\x20'+'free-standing\x20cryptographic\x20statements\x20(e.g.\x20a\x20server\x27s\x20timestamp\x20attestation).','auto_fixable':!![]},'check':a=>{if(a['about_address'])return null;return{...R_PR_2_02['rule'],'evidence':'about_address=null/undefined'};}},R_PR_3_01={'rule':{'id':'R-PROOF-06','level':'LOW','category':'lifecycle','title':'description\x20missing\x20—\x20Proof\x20hard\x20to\x20identify\x20in\x20queries\x20and\x20audit\x20logs','description':'description\x20is\x20a\x20REQUIRED\x20field\x20(PF-D-2=A).\x20The\x20Move\x20contract\x20stores\x20it\x20as\x20a\x20String\x20field\x20and\x20SDK\x20'+'passes\x20it\x20to\x20create_wowok_proof_v2.\x20An\x20empty\x20description\x20(\x22\x22)\x20is\x20technically\x20valid\x20but\x20makes\x20the\x20Proof\x20'+'hard\x20to\x20identify\x20in\x20query\x20results\x20and\x20audit\x20logs.\x20Non-empty\x20descriptions\x20are\x20strongly\x20recommended.','affected_stakeholders':['creator','verifier'],'scenario':'Caller\x20passes\x20description=\x22\x22\x20to\x20save\x20typing','mitigation':'Provide\x20a\x20one-line\x20description\x20like\x20\x22KYC\x20attestation\x20for\x20user\x200xabc\x22\x20or\x20\x22merkle\x20root\x20for\x20batch\x20#42\x22.','auto_fixable':![]},'check':a=>{if(a['description']===undefined)return null;if(a['description']['length']>0x0)return null;return{...R_PR_3_01['rule'],'evidence':'description=\x22\x22\x20(empty)'};}},R_PR_3_02={'rule':{'id':'R-PROOF-07','level':'HIGH','category':'lifecycle','title':'Proof\x20is\x20immutable\x20—\x20cannot\x20modify\x20after\x20creation\x20(freeze_object)','description':'Proof\x20is\x20created\x20via\x20transfer::freeze_object(obj)\x20in\x20Move\x20(proof.move:65).\x20Once\x20frozen,\x20the\x20object\x20'+'cannot\x20be\x20modified,\x20transferred,\x20or\x20deleted.\x20All\x20fields\x20(proof,\x20server_pubkey,\x20server_signature,\x20'+'about,\x20proof_type,\x20signer,\x20time,\x20description,\x20item_count)\x20are\x20permanently\x20fixed\x20at\x20the\x20value\x20set\x20'+'during\x20create_wowok_proof_v2().\x20To\x20\x27update\x27\x20a\x20Proof,\x20create\x20a\x20new\x20one\x20and\x20update\x20references.','affected_stakeholders':['creator','consumer'],'scenario':'Caller\x20wants\x20to\x20update\x20server_signature\x20after\x20key\x20rotation\x20—\x20cannot,\x20must\x20create\x20new\x20Proof','mitigation':'Verify\x20all\x20fields\x20before\x20calling\x20create_wowok_proof_v2.\x20For\x20scenarios\x20requiring\x20key\x20rotation,\x20'+'create\x20a\x20new\x20Proof\x20and\x20update\x20the\x20referencing\x20object\x20(Repository\x20data,\x20Service\x20config,\x20etc.)\x20to\x20'+'point\x20to\x20the\x20new\x20Proof\x20address.','auto_fixable':![]},'check':a=>null},R_PR_4_01={'rule':{'id':'R-PROOF-08','level':'INFO','category':'knowledge','title':'Knowledge\x20layer\x20&\x20constant\x20sync\x20—\x20RESOLVED','description':'All\x204\x20Proof\x20constants\x20(WOWOK_WTS_PROOF_TYPE,\x20MAX_PROOF_SIZE,\x20MAX_SERVER_PUBKEY_SIZE,\x20'+'MAX_SERVER_SIGNATURE_SIZE)\x20are\x20now\x20synced\x20to\x20onchain-constants.ts\x20(P-PROOF-P2-5).\x20The\x20MCP\x20Knowledge\x20'+'layer\x20now\x20includes\x20proof-risk.ts,\x20proof-confirm.ts,\x20proof-translation.ts\x20(P-PROOF-P2-6).\x20'+'This\x20risk\x20rule\x20is\x20retained\x20for\x20historical\x20audit\x20and\x20to\x20detect\x20future\x20regressions.','affected_stakeholders':['system'],'scenario':'Future\x20regression:\x20someone\x20removes\x20a\x20Proof\x20constant\x20from\x20onchain-constants.ts','mitigation':'Run\x20the\x20onchain-constants\x20sync\x20test\x20to\x20detect\x20drift.','auto_fixable':![]},'check':a=>{if(a['constants_synced'])return null;return{...R_PR_4_01['rule'],'evidence':'constants_synced=false'};}};export const PROOF_RISK_RULES=[R_PR_1_01,R_PR_1_02,R_PR_1_03,R_PR_2_01,R_PR_2_02,R_PR_3_01,R_PR_3_02,R_PR_4_01];export function checkProofRisks(a){const b=[];for(const c of PROOF_RISK_RULES){const d=c['check'](a);if(d)b['push'](d);}return!b['find'](e=>e['id']==='R-PROOF-07')&&b['push'](R_PR_3_02['rule']),b;}export function getProofRiskById(a){return PROOF_RISK_RULES['find'](b=>b['rule']['id']===a)?.['rule'];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const DEFAULT_VALUE_WARNINGS={'defaultAccount':'Using\x20default\x20account\x20(env.account=\x22\x22)','mainnet':'Operating\x20on\x20mainnet\x20—\x20irreversible','replaceExistName':'replaceExistName=true\x20will\x20unbind\x20the\x20existing\x20name\x20(breaking\x20refs)','defaultToken':'Using\x20default\x20token\x200x2::wow::WOW'};export const DEFAULT_AMOUNT_THRESHOLD=BigInt(0x174876e800);export function getAmountThreshold(){const a=process['env']['WOWOK_AMOUNT_THRESHOLD'];if(!a)return DEFAULT_AMOUNT_THRESHOLD;try{return BigInt(a);}catch{return DEFAULT_AMOUNT_THRESHOLD;}}const WOW_PRECISION=0x3b9aca00n;export function formatAmount(a,b=WOW_PRECISION){const c=typeof a==='string'?BigInt(a):a,d=c/b,e=c%b;if(e===0x0n)return''+d['toString']();const f=e['toString']()['padStart'](Number(b['toString']()['length'])-0x1,'0');return d['toString']()+'.'+f;}export function collectDefaultWarnings(a,b){const c=[],d=a?.['account'];(d===undefined||d==='')&&c['push'](DEFAULT_VALUE_WARNINGS['defaultAccount']);const e=a?.['network'];e&&/mainnet/i['test'](String(e))&&c['push'](DEFAULT_VALUE_WARNINGS['mainnet']);const f=b?.['namedNew']??b?.['object'];return f&&typeof f==='object'&&f['replaceExistName']===!![]&&c['push'](DEFAULT_VALUE_WARNINGS['replaceExistName']),c;}export const CONFIRMATION_RULES=[{'id':'irreversible_fund_or_verdict','when':(a,b,c)=>{if(a==='payment')return!![];if(a==='arbitration'&&b?.['arbitration']!==undefined)return!![];if(a==='treasury'){if(b?.['withdraw']||b?.['owner_receive'])return!![];if(b?.['external_withdraw']||b?.['external_deposit'])return!![];return![];}return![];},'level':'irreversible','preview':(a,b,c)=>({'level':'irreversible','operation':a,'irreversible':!![],'network':c?.['network'],'account':c?.['account']??'','warnings':collectDefaultWarnings(c,b),'amount':a==='payment'&&b?.['amount']?{'value':String(b['amount']['amount']??b['amount']['balance']??''),'token':b?.['token_type']??'0x2::wow::WOW','human_readable':formatAmount(String(b['amount']['amount']??b['amount']['balance']??'0')),'recipient':b?.['to']??b?.['recipient']}:undefined}),'bypass_on_explicit_intent':[]},{'id':'publish_immutable','when':(a,b,c)=>{if(a==='service'&&(b?.['publish']===!![]||b?.['bPublished']===!![]))return!![];if(a==='machine'&&b?.['publish']===!![])return!![];return![];},'level':'publish','preview':(a,b,c)=>({'level':'publish','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','immutable_after':a==='service'?['machine','order_allocators']:['nodes','pairs','forwards'],'warnings':collectDefaultWarnings(c,b)}),'bypass_on_explicit_intent':['force\x20publish','publish\x20now']},{'id':'amount_sensitive','when':(a,b,c)=>{const d=extractAmount(b);if(d===null)return![];if(a==='reward'||a==='treasury')return!![];if(a==='service'&&b?.['compensation_fund_add'])return!![];return![];},'level':'amount','preview':(a,b,c)=>{const d=extractAmount(b);return{'level':'amount','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','amount':d?{'value':d,'token':b?.['token_type']??'0x2::wow::WOW','human_readable':formatAmount(d)}:undefined,'warnings':collectDefaultWarnings(c,b)};},'bypass_on_explicit_intent':[]},{'id':'default_values','when':(a,b,c)=>{return collectDefaultWarnings(c,b)['length']>0x0;},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','warnings':collectDefaultWarnings(c,b)}),'bypass_on_explicit_intent':['use\x20default\x20account','default\x20account\x20is\x20fine','use\x20the\x20default\x20account','default\x20account\x20works\x20fine']},{'id':'guard_create_immutable','when':(a,b,c)=>{if(a==='guard')return!![];return![];},'level':'irreversible','preview':(a,b,c)=>{const d=b?.['table']??[],e=b?.['root'],f=b?.['rely'],g=typeof e==='object'&&e!==null&&'type'in e?e['type']:typeof e==='object'&&e!==null&&'type'in e&&e['type']==='file'?'file':'unknown',h=['table','root'];if(f)h['push']('rely');return{'level':'irreversible','operation':a,'object':b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','immutable_after':h,'irreversible':!![],'warnings':[...collectDefaultWarnings(c,b),'Guard\x20is\x20CREATE-only\x20and\x20immutable\x20—\x20cannot\x20be\x20edited\x20or\x20deleted\x20after\x20creation','Table\x20entries:\x20'+d['length']+'\x20(max\x20256)','Root\x20node\x20type:\x20'+g+'\x20(must\x20return\x20Bool)',...f?['Rely\x20dependencies:\x20'+(f['guards']?.['length']??0x0)+'\x20(max\x204,\x20AND/OR\x20logic)']:[],'To\x20modify\x20later:\x20export\x20via\x20guard2file\x20→\x20edit\x20→\x20CREATE\x20new\x20→\x20rebind']};},'bypass_on_explicit_intent':[]},{'id':'guard_gen_passport_test','when':(a,b,c)=>{if(a==='gen_passport')return!![];return![];},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['guard'],'network':c?.['network'],'account':c?.['account']??'','warnings':[...collectDefaultWarnings(c,b),'gen_passport\x20will\x20consume\x20gas\x20for\x20static\x20testing']}),'bypass_on_explicit_intent':['test\x20guard','testing\x20guard','gen\x20passport','generate\x20passport']},{'id':'progress_advance','when':(a,b,c)=>{if(a!=='progress')return![];return b?.['operate']?.['op']==='next';},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['object'],'network':c?.['network'],'account':c?.['account']??'','warnings':[...collectDefaultWarnings(c,b),'Advancing\x20the\x20progress\x20node\x20may\x20release\x20funds\x20per\x20the\x20machine\x20allocation']}),'bypass_on_explicit_intent':[]}];export function resolveOverrideId(a,b){if(a==='publish_immutable'){if(b==='service')return'service.publish';if(b==='machine')return'machine.publish';return undefined;}if(a==='progress_advance')return'node.advance';return undefined;}export function extractAmount(a){if(!a)return null;const b=[a?.['amount']?.['amount'],a?.['amount']?.['balance'],a?.['balance'],a?.['amount'],a?.['compensation_fund_add'],a?.['deposit']?.['coin']?.['balance'],typeof a?.['deposit']?.['coin']?.['coin']==='string'?undefined:a?.['deposit']?.['coin']?.['coin']?.['balance']];for(const d of b){if(d!==undefined&&d!==null&&d!=='')return String(d);}return null;}export const OBJECT_REUSE_RULES=[{'rule_id':'REUSE-001','object_type':'permission','recommendation':'strongly_recommended','reason':'Centralized\x20permission\x20control\x20across\x20all\x20services','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Permission\x20to\x20reuse?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-002','object_type':'machine','recommendation':'recommended','reason':'Save\x20design\x20time\x20for\x20similar\x20processes','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Machine\x20whose\x20workflow\x20fits?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-003','object_type':'guard','recommendation':'recommended','reason':'Avoid\x20redundant\x20validation\x20rules','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Guard\x20with\x20matching\x20validation\x20logic?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-004','object_type':'contact','recommendation':'recommended','reason':'Single\x20point\x20of\x20customer-service\x20management','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Contact\x20for\x20customer\x20service?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-005','object_type':'arbitration','recommendation':'always_reuse','reason':'Customers\x20choose\x20from\x20established\x20arbiters;\x20creating\x20a\x20new\x20Arbitration\x20is\x20an\x20operator-level\x20decision','ask_user':'Which\x20existing\x20Arbitration\x20service\x20should\x20disputes\x20route\x20to?\x20Provide\x20the\x20name\x20or\x20ID.'}];export const CREATE_VS_MODIFY_PATTERN={'reuse_form':'string','create_form':'object','resolution_api':'GetObjectExisted','note':'String\x20reference\x20=\x20REUSE\x20(name\x20resolution\x20failure\x20is\x20a\x20hard\x20error);\x20object\x20shape\x20=\x20CREATE\x20(always).'};export const IMMUTABILITY_RULES=[{'rule_id':'IMMUT-001','object_type':'machine','trigger':'publish','immutable_fields':['nodes','pairs','forwards'],'message':'Machine\x20topology\x20is\x20immutable\x20after\x20publish\x20—\x20verify\x20all\x20nodes/forwards\x20via\x20machineNode2file\x20BEFORE\x20publishing'},{'rule_id':'IMMUT-002','object_type':'service','trigger':'publish','immutable_fields':['machine','order_allocators','arbitrations'],'mutable_after':['sales'],'message':'Service.machine,\x20order_allocators\x20and\x20arbitrations\x20are\x20frozen\x20after\x20publish;\x20sales\x20remains\x20fully\x20modifiable\x20(L3)\x20without\x20pause'},{'rule_id':'IMMUT-003','object_type':'guard','trigger':'create','immutable_fields':['table','root','rely'],'message':'Guard\x20is\x20CREATE-only\x20and\x20immutable\x20—\x20cannot\x20be\x20edited\x20or\x20deleted\x20after\x20creation.\x20To\x20change:\x20export\x20via\x20guard2file\x20→\x20edit\x20→\x20CREATE\x20new\x20→\x20rebind'}];export const OPERATION_TYPE_CLASSIFICATION={'LOCAL_ONLY':['account_operation','local_mark_operation','local_info_operation','project_operation','config_operation'],'ONCHAIN':['onchain_operations','wip_file','bridge_operation','messenger_operation'],'QUERY':['query_toolkit','onchain_table_data','onchain_events','guard2file','machineNode2file','schema_query','wowok_buildin_info','trust_score'],'ENCRYPTED':['messenger_operation']};export const OPERATION_CLASS_META={'LOCAL_ONLY':{'gas':![],'confirmation_required':![],'note':'Local\x20state\x20only\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'},'ONCHAIN':{'gas':!![],'confirmation_required':!![],'note':'On-chain\x20write\x20—\x20gas\x20consumed,\x20explicit\x20user\x20confirmation\x20REQUIRED\x20before\x20execution'},'QUERY':{'gas':![],'confirmation_required':![],'note':'Read-only\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'},'ENCRYPTED':{'gas':![],'confirmation_required':![],'note':'Local\x20encryption\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'}};export function classifyTool(a){if(OPERATION_TYPE_CLASSIFICATION['ENCRYPTED']['includes'](a))return'ENCRYPTED';for(const b of['LOCAL_ONLY','ONCHAIN','QUERY']){if(OPERATION_TYPE_CLASSIFICATION[b]['includes'](a))return b;}return undefined;}export const NAMING_CONVENTIONS={'scheme':'<projectPrefix>_<type>_<purpose>_<version>','parts':{'project_prefix':{'example':'shopFunny_','purpose':'Prevents\x20cross-project\x20collisions'},'type_prefix':{'example':'machine_\x20/\x20guard_\x20/\x20service_','purpose':'Clarifies\x20object\x20type'},'purpose_suffix':{'example':'serviceWithdraw','purpose':'Describes\x20function'},'version_suffix':{'example':'_v2','purpose':'Enables\x20iteration\x20without\x20replaceExistName'}},'entry_id':{'pattern':'^<object_type>:<name>$','example':'service:myshop_service'},'replace_exist_name':{'default':![],'false_effect':'Throws\x20error\x20if\x20name\x20is\x20in\x20use\x20—\x20safe\x20default','true_effect':'Existing\x20object/account\x20with\x20the\x20same\x20name\x20is\x20suspended/unbound\x20to\x20free\x20the\x20name','account_default_forbidden':'replaceExistName:true\x20on\x20the\x20default\x20account\x20(name=\x27\x27)\x20is\x20FORBIDDEN\x20—\x20use\x20suspend()\x20explicitly','recommendation':'DISCOURAGED\x20—\x20prefer\x20versioned\x20names\x20(_v1,\x20_v2)\x20for\x20production'},'recommendations':['Always\x20provide\x20tags\x20on\x20object\x20creation\x20for\x20filtering\x20and\x20management','Use\x20names\x20as\x20primary\x20identifiers;\x20use\x20short\x20address\x20form\x20(0x1234...def)\x20only\x20for\x20display','All\x20cross-object\x20references\x20(Guard\x20tables,\x20Service\x20bindings,\x20Machine\x20forwards)\x20use\x20NAMES\x20—\x20resolved\x20per-network\x20at\x20build\x20time']};export function checkObjectReuseRules(a){const b=[];for(const c of a){if(!c['is_new'])continue;const d=OBJECT_REUSE_RULES['find'](e=>e['object_type']===c['object_type']);if(!d)continue;(d['recommendation']==='always_reuse'||d['recommendation']==='strongly_recommended')&&b['push']({'rule_id':d['rule_id'],'severity':d['recommendation']==='always_reuse'?'warn':'info','message':'Creating\x20NEW\x20'+c['object_type']+(c['name']?'\x20\x22'+c['name']+'\x22':'')+'\x20—\x20reuse\x20is\x20'+d['recommendation']+':\x20'+d['reason']+'.\x20'+d['ask_user']});}return b;}export function checkImmutabilityRules(a){const b=[];for(const c of a){const d=IMMUTABILITY_RULES['find'](e=>e['object_type']===c['object_type']&&e['trigger']===c['trigger']);if(!d)continue;b['push']({'rule_id':d['rule_id'],'severity':'warn','message':''+c['object_type']+(c['name']?'\x20\x22'+c['name']+'\x22':'')+'\x20'+c['trigger']+':\x20'+d['message']+'.\x20Immutable:\x20['+d['immutable_fields']['join'](',\x20')+']'+(d['mutable_after']?'.\x20Still\x20mutable:\x20['+d['mutable_after']['join'](',\x20')+']':'')});}return b;}export const SAFETY_RULES_VERSION=0x2;
|
|
1
|
+
export const DEFAULT_VALUE_WARNINGS={'defaultAccount':'Using\x20default\x20account\x20(env.account=\x22\x22)','mainnet':'Operating\x20on\x20mainnet\x20—\x20irreversible','replaceExistName':'replaceExistName=true\x20will\x20unbind\x20the\x20existing\x20name\x20(breaking\x20refs)','defaultToken':'Using\x20default\x20token\x200x2::wow::WOW'};export const DEFAULT_AMOUNT_THRESHOLD=BigInt(0x174876e800);export function getAmountThreshold(){const a=process['env']['WOWOK_AMOUNT_THRESHOLD'];if(!a)return DEFAULT_AMOUNT_THRESHOLD;try{return BigInt(a);}catch{return DEFAULT_AMOUNT_THRESHOLD;}}const WOW_PRECISION=0x3b9aca00n;export function formatAmount(a,b=WOW_PRECISION){const c=typeof a==='string'?BigInt(a):a,d=c/b,e=c%b;if(e===0x0n)return''+d['toString']();const f=e['toString']()['padStart'](Number(b['toString']()['length'])-0x1,'0');return d['toString']()+'.'+f;}export function collectDefaultWarnings(a,b){const c=[],d=a?.['account'];(d===undefined||d==='')&&c['push'](DEFAULT_VALUE_WARNINGS['defaultAccount']);const e=a?.['network'];e&&/mainnet/i['test'](String(e))&&c['push'](DEFAULT_VALUE_WARNINGS['mainnet']);const f=b?.['namedNew']??b?.['object'];return f&&typeof f==='object'&&f['replaceExistName']===!![]&&c['push'](DEFAULT_VALUE_WARNINGS['replaceExistName']),c;}export const CONFIRMATION_RULES=[{'id':'irreversible_fund_or_verdict','when':(a,b,c)=>{if(a==='payment')return!![];if(a==='arbitration'&&b?.['arbitration']!==undefined)return!![];if(a==='treasury'){if(b?.['withdraw']||b?.['owner_receive'])return!![];if(b?.['external_withdraw']||b?.['external_deposit'])return!![];return![];}return![];},'level':'irreversible','preview':(a,b,c)=>({'level':'irreversible','operation':a,'irreversible':!![],'network':c?.['network'],'account':c?.['account']??'','warnings':collectDefaultWarnings(c,b),'amount':a==='payment'&&b?.['amount']?{'value':String(b['amount']['amount']??b['amount']['balance']??''),'token':b?.['token_type']??'0x2::wow::WOW','human_readable':formatAmount(String(b['amount']['amount']??b['amount']['balance']??'0')),'recipient':b?.['to']??b?.['recipient']}:undefined}),'bypass_on_explicit_intent':[]},{'id':'publish_immutable','when':(a,b,c)=>{if(a==='service'&&(b?.['publish']===!![]||b?.['bPublished']===!![]))return!![];if(a==='machine'&&b?.['publish']===!![])return!![];return![];},'level':'publish','preview':(a,b,c)=>({'level':'publish','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','immutable_after':a==='service'?['machine','order_allocators']:['nodes','pairs','forwards'],'warnings':collectDefaultWarnings(c,b)}),'bypass_on_explicit_intent':['force\x20publish','publish\x20now']},{'id':'amount_sensitive','when':(a,b,c)=>{const d=extractAmount(b);if(d===null)return![];if(a==='reward'||a==='treasury')return!![];if(a==='service'&&b?.['compensation_fund_add'])return!![];return![];},'level':'amount','preview':(a,b,c)=>{const d=extractAmount(b);return{'level':'amount','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','amount':d?{'value':d,'token':b?.['token_type']??'0x2::wow::WOW','human_readable':formatAmount(d)}:undefined,'warnings':collectDefaultWarnings(c,b)};},'bypass_on_explicit_intent':[]},{'id':'default_values','when':(a,b,c)=>{return collectDefaultWarnings(c,b)['length']>0x0;},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['object']??b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','warnings':collectDefaultWarnings(c,b)}),'bypass_on_explicit_intent':['use\x20default\x20account','default\x20account\x20is\x20fine','use\x20the\x20default\x20account','default\x20account\x20works\x20fine']},{'id':'guard_create_immutable','when':(a,b,c)=>{if(a==='guard')return!![];return![];},'level':'irreversible','preview':(a,b,c)=>{const d=b?.['table']??[],e=b?.['root'],f=b?.['rely'],g=typeof e==='object'&&e!==null&&'type'in e?e['type']:typeof e==='object'&&e!==null&&'type'in e&&e['type']==='file'?'file':'unknown',h=['table','root'];if(f)h['push']('rely');return{'level':'irreversible','operation':a,'object':b?.['namedNew']?.['name'],'network':c?.['network'],'account':c?.['account']??'','immutable_after':h,'irreversible':!![],'warnings':[...collectDefaultWarnings(c,b),'Guard\x20is\x20CREATE-only\x20and\x20immutable\x20—\x20cannot\x20be\x20edited\x20or\x20deleted\x20after\x20creation','Table\x20entries:\x20'+d['length']+'\x20(max\x20256)','Root\x20node\x20type:\x20'+g+'\x20(must\x20return\x20Bool)',...f?['Rely\x20dependencies:\x20'+(f['guards']?.['length']??0x0)+'\x20(max\x204,\x20AND/OR\x20logic)']:[],'To\x20modify\x20later:\x20export\x20via\x20guard2file\x20→\x20edit\x20→\x20CREATE\x20new\x20→\x20rebind']};},'bypass_on_explicit_intent':[]},{'id':'guard_gen_passport_test','when':(a,b,c)=>{if(a==='gen_passport')return!![];return![];},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['guard'],'network':c?.['network'],'account':c?.['account']??'','warnings':[...collectDefaultWarnings(c,b),'gen_passport\x20will\x20consume\x20gas\x20for\x20static\x20testing']}),'bypass_on_explicit_intent':['test\x20guard','testing\x20guard','gen\x20passport','generate\x20passport']},{'id':'progress_advance','when':(a,b,c)=>{if(a!=='progress')return![];return b?.['operate']?.['op']==='next';},'level':'standard','preview':(a,b,c)=>({'level':'standard','operation':a,'object':b?.['object'],'network':c?.['network'],'account':c?.['account']??'','warnings':[...collectDefaultWarnings(c,b),'Advancing\x20the\x20progress\x20node\x20may\x20release\x20funds\x20per\x20the\x20machine\x20allocation']}),'bypass_on_explicit_intent':[]}];export function resolveOverrideId(a,b){if(a==='publish_immutable'){if(b==='service')return'service.publish';if(b==='machine')return'machine.publish';return undefined;}if(a==='progress_advance')return'node.advance';return undefined;}export function extractAmount(a){if(!a)return null;const b=[a?.['amount']?.['amount'],a?.['amount']?.['balance'],a?.['balance'],a?.['amount'],a?.['compensation_fund_add'],a?.['deposit']?.['coin']?.['balance'],typeof a?.['deposit']?.['coin']?.['coin']==='string'?undefined:a?.['deposit']?.['coin']?.['coin']?.['balance']];for(const d of b){if(d!==undefined&&d!==null&&d!=='')return String(d);}return null;}export const OBJECT_REUSE_RULES=[{'rule_id':'REUSE-001','object_type':'permission','recommendation':'strongly_recommended','reason':'Centralized\x20permission\x20control\x20across\x20all\x20services','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Permission\x20to\x20reuse?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-002','object_type':'machine','recommendation':'recommended','reason':'Save\x20design\x20time\x20for\x20similar\x20processes','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Machine\x20whose\x20workflow\x20fits?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-003','object_type':'guard','recommendation':'recommended','reason':'Avoid\x20redundant\x20validation\x20rules','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Guard\x20with\x20matching\x20validation\x20logic?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-004','object_type':'contact','recommendation':'recommended','reason':'Single\x20point\x20of\x20customer-service\x20management','ask_user':'Do\x20you\x20have\x20an\x20existing\x20Contact\x20for\x20customer\x20service?\x20Provide\x20the\x20name\x20or\x20ID.'},{'rule_id':'REUSE-005','object_type':'arbitration','recommendation':'always_reuse','reason':'Customers\x20choose\x20from\x20established\x20arbiters;\x20creating\x20a\x20new\x20Arbitration\x20is\x20an\x20operator-level\x20decision','ask_user':'Which\x20existing\x20Arbitration\x20service\x20should\x20disputes\x20route\x20to?\x20Provide\x20the\x20name\x20or\x20ID.'}];export const CREATE_VS_MODIFY_PATTERN={'reuse_form':'string','create_form':'object','resolution_api':'GetObjectExisted','note':'String\x20reference\x20=\x20REUSE\x20(name\x20resolution\x20failure\x20is\x20a\x20hard\x20error);\x20object\x20shape\x20=\x20CREATE\x20(always).'};export const IMMUTABILITY_RULES=[{'rule_id':'IMMUT-001','object_type':'machine','trigger':'publish','immutable_fields':['nodes','pairs','forwards'],'message':'Machine\x20topology\x20is\x20immutable\x20after\x20publish\x20—\x20verify\x20all\x20nodes/forwards\x20via\x20machineNode2file\x20BEFORE\x20publishing'},{'rule_id':'IMMUT-002','object_type':'service','trigger':'publish','immutable_fields':['machine','order_allocators','arbitrations'],'mutable_after':['sales'],'message':'Service.machine,\x20order_allocators\x20and\x20arbitrations\x20are\x20frozen\x20after\x20publish;\x20sales\x20remains\x20fully\x20modifiable\x20(L3)\x20without\x20pause'},{'rule_id':'IMMUT-003','object_type':'guard','trigger':'create','immutable_fields':['table','root','rely'],'message':'Guard\x20is\x20CREATE-only\x20and\x20immutable\x20—\x20cannot\x20be\x20edited\x20or\x20deleted\x20after\x20creation.\x20To\x20change:\x20export\x20via\x20guard2file\x20→\x20edit\x20→\x20CREATE\x20new\x20→\x20rebind'}];export const OPERATION_TYPE_CLASSIFICATION={'LOCAL_ONLY':['account_operation','local_mark_operation','local_info_operation','config_operation'],'ONCHAIN':['onchain_operations','wip_file','bridge_operation','messenger_operation'],'QUERY':['query_toolkit','onchain_table_data','onchain_events','guard2file','machineNode2file','schema_query','wowok_buildin_info','trust_score'],'ENCRYPTED':['messenger_operation']};export const OPERATION_CLASS_META={'LOCAL_ONLY':{'gas':![],'confirmation_required':![],'note':'Local\x20state\x20only\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'},'ONCHAIN':{'gas':!![],'confirmation_required':!![],'note':'On-chain\x20write\x20—\x20gas\x20consumed,\x20explicit\x20user\x20confirmation\x20REQUIRED\x20before\x20execution'},'QUERY':{'gas':![],'confirmation_required':![],'note':'Read-only\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'},'ENCRYPTED':{'gas':![],'confirmation_required':![],'note':'Local\x20encryption\x20—\x20no\x20gas,\x20no\x20confirmation\x20needed'}};export function classifyTool(a){if(OPERATION_TYPE_CLASSIFICATION['ENCRYPTED']['includes'](a))return'ENCRYPTED';for(const b of['LOCAL_ONLY','ONCHAIN','QUERY']){if(OPERATION_TYPE_CLASSIFICATION[b]['includes'](a))return b;}return undefined;}export const NAMING_CONVENTIONS={'scheme':'<projectPrefix>_<type>_<purpose>_<version>','parts':{'project_prefix':{'example':'shopFunny_','purpose':'Prevents\x20cross-project\x20collisions'},'type_prefix':{'example':'machine_\x20/\x20guard_\x20/\x20service_','purpose':'Clarifies\x20object\x20type'},'purpose_suffix':{'example':'serviceWithdraw','purpose':'Describes\x20function'},'version_suffix':{'example':'_v2','purpose':'Enables\x20iteration\x20without\x20replaceExistName'}},'entry_id':{'pattern':'^<object_type>:<name>$','example':'service:myshop_service'},'replace_exist_name':{'default':![],'false_effect':'Throws\x20error\x20if\x20name\x20is\x20in\x20use\x20—\x20safe\x20default','true_effect':'Existing\x20object/account\x20with\x20the\x20same\x20name\x20is\x20suspended/unbound\x20to\x20free\x20the\x20name','account_default_forbidden':'replaceExistName:true\x20on\x20the\x20default\x20account\x20(name=\x27\x27)\x20is\x20FORBIDDEN\x20—\x20use\x20suspend()\x20explicitly','recommendation':'DISCOURAGED\x20—\x20prefer\x20versioned\x20names\x20(_v1,\x20_v2)\x20for\x20production'},'recommendations':['Always\x20provide\x20tags\x20on\x20object\x20creation\x20for\x20filtering\x20and\x20management','Use\x20names\x20as\x20primary\x20identifiers;\x20use\x20short\x20address\x20form\x20(0x1234...def)\x20only\x20for\x20display','All\x20cross-object\x20references\x20(Guard\x20tables,\x20Service\x20bindings,\x20Machine\x20forwards)\x20use\x20NAMES\x20—\x20resolved\x20per-network\x20at\x20build\x20time']};export function checkObjectReuseRules(a){const b=[];for(const c of a){if(!c['is_new'])continue;const d=OBJECT_REUSE_RULES['find'](e=>e['object_type']===c['object_type']);if(!d)continue;(d['recommendation']==='always_reuse'||d['recommendation']==='strongly_recommended')&&b['push']({'rule_id':d['rule_id'],'severity':d['recommendation']==='always_reuse'?'warn':'info','message':'Creating\x20NEW\x20'+c['object_type']+(c['name']?'\x20\x22'+c['name']+'\x22':'')+'\x20—\x20reuse\x20is\x20'+d['recommendation']+':\x20'+d['reason']+'.\x20'+d['ask_user']});}return b;}export function checkImmutabilityRules(a){const b=[];for(const c of a){const d=IMMUTABILITY_RULES['find'](e=>e['object_type']===c['object_type']&&e['trigger']===c['trigger']);if(!d)continue;b['push']({'rule_id':d['rule_id'],'severity':'warn','message':''+c['object_type']+(c['name']?'\x20\x22'+c['name']+'\x22':'')+'\x20'+c['trigger']+':\x20'+d['message']+'.\x20Immutable:\x20['+d['immutable_fields']['join'](',\x20')+']'+(d['mutable_after']?'.\x20Still\x20mutable:\x20['+d['mutable_after']['join'](',\x20')+']':'')});}return b;}export const SAFETY_RULES_VERSION=0x2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'service::new','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'service::description_set','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'service::location_set','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'service::repository_add/remove/clear','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items','governed_operation':'service::sales_add/set/remove/clear','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'service::machine_set/machine_none','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'service::buy_guard_set/buy_guard_none','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'service::arbitration_add/remove/clear','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'service::customer_required_set','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'service::pause','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'service::publish','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'service::discount','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'service::order_allocators_set','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_withdraw','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'service::compensation_fund_add','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(lock_duration)','governed_operation':'service::compensation_fund_receive','post_publish_mutability':'locked_by_duration'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'service::setting_lock_duration_add','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(locked)','governed_operation':'service::reward_add/remove/clear','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'service::owner_receive','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'service::um_set/um_none','post_publish_mutability':'mutable'}];export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_SERVICE_NOT_PUBLISHED)','Service.bPaused\x20==\x20false\x20(else\x20E_SERVICE_PAUSED)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_NOT_FOUND)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_INSUFFICIENT)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20unexpired'],'side_effects':['quote_imp()\x20computes\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','service::quote\x20or\x20service::quote_with_discount\x20MoveCall'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['service::buy\x20or\x20service::buy_with_passport\x20MoveCall','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['service::order_allocation\x20MoveCall','Allocation\x20object\x20created\x20(first-match-wins\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['service::order_progress\x20MoveCall','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['agent_set\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','owner_change\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':!![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set','customer_required_set'],'permission_index_operations':['service::publish\x20(311)','service::pause\x20(310)','service::sales_add/set/remove/clear\x20(305)','service::order_allocators_set\x20(313)','service::buy_guard_set\x20(307)','service::discount\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::machine_set\x20(306)\x20—\x20for\x20rental\x20workflow','service::arbitration_add\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::discount\x20(312)\x20—\x20promotional\x20rates','service::reward_add\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::machine_set\x20(306)\x20—\x20bind\x20workflow','service::publish\x20(311)','service::order_allocators_set\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)','service::compensation_fund_add\x20(315)','service::setting_lock_duration_add\x20(317)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','compensation_claim\x20triggered\x20by\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::compensation_fund_add\x20(315)\x20—\x20deposit','service::compensation_fund_withdraw\x20(314)\x20—\x20withdraw\x20(locked)','service::compensation_fund_receive\x20(316)\x20—\x20receive\x20(locked)','service::setting_lock_duration_add\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20locked\x20by\x20duration','Fund\x20consumer:\x20arbitration::compensation_claim\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::reward_add/remove/clear\x20(318)\x20—\x20locked\x20by\x20duration','service::discount\x20(312)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(still\x20allowed,\x20but\x20locked\x20by\x20duration)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20removal\x20also\x20locked\x20by\x20duration\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_remove\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_clear\x20(308)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::buy_guard_set\x20(307)\x20—\x20bind\x20guard','service::buy_guard_none\x20(307)\x20—\x20clear\x20guard','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::discount\x20(312)\x20—\x20issue\x20coupons','service::sales_add/set\x20(305)\x20—\x20adjust\x20base\x20prices','service::sales_remove\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'locked_by_duration','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20is\x20met\x20handles\x20the\x20order'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|
|
1
|
+
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'service::new','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'service::description_set','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'service::location_set','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'service::repository_add/remove/clear','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items','governed_operation':'service::sales_add/set/remove/clear','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'service::machine_set/machine_none','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'service::buy_guard_set/buy_guard_none','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'service::arbitration_add/remove/clear','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'service::customer_required_set','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'service::pause','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'service::publish','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'service::discount','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'service::order_allocators_set','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'service::compensation_fund_withdraw','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'service::compensation_fund_add','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'service::compensation_fund_receive','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'service::setting_lock_duration_add','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'service::reward_add/remove/clear','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'service::owner_receive','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'service::um_set/um_none','post_publish_mutability':'mutable'}];export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_SERVICE_NOT_PUBLISHED)','Service.bPaused\x20==\x20false\x20(else\x20E_SERVICE_PAUSED)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_NOT_FOUND)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_INSUFFICIENT)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20unexpired'],'side_effects':['quote_imp()\x20computes\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','service::quote\x20or\x20service::quote_with_discount\x20MoveCall'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['service::buy\x20or\x20service::buy_with_passport\x20MoveCall','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['service::order_allocation\x20MoveCall','Allocation\x20object\x20created\x20(first-match-wins\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['service::order_progress\x20MoveCall','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['agent_set\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','owner_change\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set','customer_required_set'],'permission_index_operations':['service::publish\x20(311)','service::pause\x20(310)','service::sales_add/set/remove/clear\x20(305)','service::order_allocators_set\x20(313)','service::buy_guard_set\x20(307)','service::discount\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::machine_set\x20(306)\x20—\x20for\x20rental\x20workflow','service::arbitration_add\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::publish\x20(311)','service::sales_add/set\x20(305)','service::discount\x20(312)\x20—\x20promotional\x20rates','service::reward_add\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set','location_set'],'permission_index_operations':['service::machine_set\x20(306)\x20—\x20bind\x20workflow','service::publish\x20(311)','service::order_allocators_set\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)','service::compensation_fund_add\x20(315)','service::setting_lock_duration_add\x20(317)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','compensation_claim\x20triggered\x20by\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::compensation_fund_add\x20(315)\x20—\x20deposit','service::compensation_fund_withdraw\x20(314)\x20—\x20withdraw\x20(time-locked\x20after\x20publish)','service::compensation_fund_receive\x20(316)\x20—\x20receive\x20arbitration\x20payout\x20(always\x20mutable)','service::setting_lock_duration_add\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration::compensation_claim\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::reward_add/remove/clear\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','service::discount\x20(312)','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::arbitration_add\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_remove\x20(308)\x20—\x20pre-publish\x20only','service::arbitration_clear\x20(308)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::buy_guard_set\x20(307)\x20—\x20bind\x20guard','service::buy_guard_none\x20(307)\x20—\x20clear\x20guard','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::discount\x20(312)\x20—\x20issue\x20coupons','service::sales_add/set\x20(305)\x20—\x20adjust\x20base\x20prices','service::sales_remove\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['um_set','builder\x20(transfer)'],'admin_operations':['description_set'],'permission_index_operations':['service::order_allocators_set\x20(313)\x20—\x20pre-publish\x20only','service::publish\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20is\x20met\x20handles\x20the\x20order'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|