@wowok/agent-mcp 2.7.8 → 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/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/types.d.ts +0 -35
- package/dist/index.js +1 -1
- package/dist/knowledge/account-marks.d.ts +35 -0
- package/dist/knowledge/account-marks.js +1 -0
- package/dist/knowledge/audit-rules.d.ts +3 -1
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/examples-scanner-cli.js +1 -1
- package/dist/knowledge/examples-scanner.js +1 -1
- package/dist/knowledge/goal-completion.d.ts +19 -0
- package/dist/knowledge/goal-completion.js +1 -0
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.d.ts +3 -2
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/mcp-schema-audit-cli.js +1 -1
- package/dist/knowledge/mcp-schema-audit.js +1 -1
- package/dist/knowledge/operation-dictionary.js +1 -1
- 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-translation.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.d.ts +1 -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 +32 -12
- package/dist/monitor/EventStore.js +1 -1
- 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/persona/address-format.d.ts +1 -1
- package/dist/persona/address-format.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 +2 -0
- package/dist/persona/index.js +1 -1
- package/dist/persona/model.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/{project → playbooks/service-build}/machine-panorama.d.ts +5 -3
- 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/{project → playbooks/service-build}/object-panorama.d.ts +2 -3
- package/dist/playbooks/service-build/object-panorama.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/{project → playbooks/service-build}/service-panorama.d.ts +3 -19
- 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/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 +1 -1
- package/dist/schema/call/arbitration.d.ts +1 -1
- package/dist/schema/call/base.d.ts +1 -1
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +4 -4
- package/dist/schema/call/contact.d.ts +1 -1
- package/dist/schema/call/contact.js +1 -1
- package/dist/schema/call/demand.d.ts +1 -1
- package/dist/schema/call/demand.js +1 -1
- package/dist/schema/call/guard.d.ts +3 -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 +2 -2
- package/dist/schema/call/order.d.ts +1 -1
- package/dist/schema/call/payment.d.ts +1 -1
- package/dist/schema/call/permission.d.ts +1 -1
- package/dist/schema/call/personal.d.ts +1 -1
- package/dist/schema/call/progress.d.ts +1 -1
- package/dist/schema/call/proof.d.ts +2 -2
- package/dist/schema/call/repository.d.ts +1 -1
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +1 -1
- package/dist/schema/common/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 +1 -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/local/index.js +1 -1
- package/dist/schema/operations.d.ts +216 -19
- package/dist/schema/operations.js +1 -1
- package/dist/schema/permission/index.d.ts +1 -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 +661 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.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-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +3 -3
- package/dist/schemas/account_operation.schema.json +2 -2
- package/dist/schemas/bridge_operation.output.json +2 -2
- package/dist/schemas/bridge_operation.schema.json +12 -12
- package/dist/schemas/config_operation.output.json +1 -1
- package/dist/schemas/config_operation.schema.json +1 -1
- package/dist/schemas/goal_operation.schema.json +1016 -0
- package/dist/schemas/guard2file.schema.json +3 -3
- package/dist/schemas/index.json +12 -13
- package/dist/schemas/industry_pack_operation.output.json +898 -0
- package/dist/schemas/industry_pack_operation.schema.json +217 -2
- package/dist/schemas/local_info_operation.output.json +2 -2
- package/dist/schemas/local_mark_operation.output.json +2 -2
- package/dist/schemas/machineNode2file.schema.json +3 -3
- package/dist/schemas/messenger_operation.output.json +2 -2
- package/dist/schemas/monitor_events.output.json +78 -3
- package/dist/schemas/monitor_events.schema.json +24 -1
- 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 +4 -4
- package/dist/schemas/onchain_operations.output.json +2 -2
- package/dist/schemas/onchain_operations.schema.json +59 -59
- package/dist/schemas/onchain_operations_allocation.schema.json +3 -3
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +4 -4
- package/dist/schemas/onchain_operations_demand.schema.json +4 -4
- package/dist/schemas/onchain_operations_gen_passport.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_guard.schema.json +3 -3
- package/dist/schemas/onchain_operations_machine.schema.json +3 -3
- package/dist/schemas/onchain_operations_order.schema.json +3 -3
- package/dist/schemas/onchain_operations_payment.schema.json +3 -3
- package/dist/schemas/onchain_operations_permission.schema.json +3 -3
- package/dist/schemas/onchain_operations_personal.schema.json +3 -3
- package/dist/schemas/onchain_operations_progress.schema.json +3 -3
- package/dist/schemas/onchain_operations_proof.schema.json +3 -3
- package/dist/schemas/onchain_operations_repository.schema.json +5 -5
- package/dist/schemas/onchain_operations_reward.schema.json +3 -3
- package/dist/schemas/onchain_operations_service.schema.json +4 -4
- package/dist/schemas/onchain_operations_treasury.schema.json +3 -3
- package/dist/schemas/onchain_table_data.output.json +346 -2
- package/dist/schemas/onchain_table_data.schema.json +22 -22
- 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 +1274 -15
- package/dist/schemas/query_toolkit.schema.json +412 -11
- package/dist/schemas/workflow_operation.schema.json +4 -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/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/monitor.d.ts +24 -0
- package/dist/tools/handlers/monitor.js +1 -1
- 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/watch.js +1 -1
- package/dist/tools/index.d.ts +2 -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/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 -524
- 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-panorama.js +0 -1
- package/dist/project/merchant-guide.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/object-panorama.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/semantic-assembler.d.ts +0 -93
- package/dist/project/semantic-assembler.js +0 -1
- package/dist/project/service-panorama.js +0 -1
- package/dist/project/stage-gate.d.ts +0 -52
- package/dist/project/stage-gate.js +0 -1
- package/dist/project/task-tracker.d.ts +0 -30
- package/dist/project/task-tracker.js +0 -1
- package/dist/schema/project/index.d.ts +0 -2021
- 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 -1139
- 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}/machine-nodes.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/machine-nodes.js +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.d.ts +0 -0
- /package/dist/{project → playbooks/service-build}/object-type.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
|
-
import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{isServicePermission,getServicePermissionByIndex}from'./service-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-S-01','pattern_name':'Create\x20new\x20Service','semantic_intent':'Create\x20a\x20new\x20Service<T>\x20with\x20owner,\x20permission,\x20description,\x20coin\x20type','match_keywords':['create','new','open'],'schema_fields':['object(null)','description','permission','owner','coin_type'],'example_json':{'object':null,'description':'My\x20retail\x20shop','permission':'0xPERMISSION_ADDRESS'},'reverse_explanation':'object=null\x20indicates\x20creation;\x20permission\x20must\x20be\x20a\x20valid\x20Permission\x20object\x20owned\x20by\x20signer'},{'id':'P-S-02','pattern_name':'Modify\x20description\x20/\x20location\x20/\x20customer_required','semantic_intent':'Update\x20Service\x20metadata\x20fields\x20(mutable\x20pre\x20and\x20post\x20publish)','match_keywords':['describe','locate','customer_required','update','modify'],'schema_fields':['object','description','location','customer_required'],'example_json':{'object':'0xSERVICE_ADDRESS','description':'Updated\x20description','location':'Shanghai','customer_required':['name','phone']},'reverse_explanation':'These\x20fields\x20are\x20always\x20mutable.\x20customer_required\x20is\x20a\x20string[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time.'},{'id':'P-S-03','pattern_name':'Manage\x20sales\x20items\x20(add/set/remove/clear)','semantic_intent':'Add\x20product\x20SKUs,\x20update\x20prices/stock,\x20remove\x20deprecated\x20items,\x20or\x20clear\x20all','match_keywords':['sales','product','sku','inventory','price'],'schema_fields':['object','sales'],'example_json':{'object':'0xSERVICE_ADDRESS','sales':{'op':'add','sales':[{'name':'standard','price':'1000000000','stock':0x64,'wip':'https://ipfs/wip','wip_hash':'abcd...64'}]}},'reverse_explanation':'sales.op=add\x20appends;\x20set\x20replaces\x20matching\x20name;\x20remove\x20deletes\x20by\x20name;\x20clear\x20empties\x20all.\x20wip_hash\x20is\x20REQUIRED\x20for\x20tamper\x20protection.'},{'id':'P-S-04','pattern_name':'Bind/unbind\x20Machine\x20workflow','semantic_intent':'Bind\x20a\x20Machine\x20workflow\x20template\x20to\x20Service\x20(post-publish\x20immutable)','match_keywords':['machine','workflow','bind\x20machine'],'schema_fields':['object','machine'],'example_json':{'object':'0xSERVICE_ADDRESS','machine':'0xMACHINE_ADDRESS'},'reverse_explanation':'machine=<address>\x20binds;\x20machine=null\x20unbinds\x20(pre-publish\x20only).\x20Once\x20published,\x20machine\x20is\x20immutable\x20(F-S-20).\x20Progress\x20inherits\x20this\x20binding.'},{'id':'P-S-05','pattern_name':'Set/clear\x20buy\x20Guard','semantic_intent':'Set\x20buyer\x20eligibility\x20Guard\x20(KYC/whitelist)\x20or\x20clear\x20it','match_keywords':['buy_guard','kyc','whitelist'],'schema_fields':['object','buy_guard'],'example_json':{'object':'0xSERVICE_ADDRESS','buy_guard':'0xGUARD_ADDRESS'},'reverse_explanation':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Pre-sale:\x20set\x20to\x20whitelist;\x20public\x20sale:\x20set\x20to\x20null.'},{'id':'P-S-06','pattern_name':'Manage\x20arbitrations\x20(add/remove/clear)','semantic_intent':'Bind\x20Arbitration\x20objects\x20for\x20dispute\x20handling\x20(post-publish\x20immutable)','match_keywords':['arbitration','arbitrator','dispute'],'schema_fields':['object','arbitrations'],'example_json':{'object':'0xSERVICE_ADDRESS','arbitrations':{'op':'add','objects':['0xARB_ADDRESS']}},'reverse_explanation':'Required\x20when\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).\x20Use\x201-3\x20Arbitration\x20objects\x20covering\x20different\x20scopes.'},{'id':'P-S-07','pattern_name':'Manage\x20repositories\x20(add/remove/clear)','semantic_intent':'Bind\x20Repository\x20objects\x20(data\x20stores)\x20—\x20mutable\x20post-publish','match_keywords':['repository','data\x20store','storage','data\x20source'],'schema_fields':['object','repositories'],'example_json':{'object':'0xSERVICE_ADDRESS','repositories':{'op':'add','objects':['0xREPO_ADDRESS']}},'reverse_explanation':'Mutable\x20post-publish.\x20SDK\x20validates\x20ObjectType.Repository\x20via\x20queryObjectsWithType.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).'},{'id':'P-S-08','pattern_name':'Manage\x20rewards\x20(add\x20/\x20remove\x20/\x20clear)','semantic_intent':'Bind\x20or\x20unbind\x20Reward\x20objects\x20for\x20marketing\x20incentives','match_keywords':['reward','incentive','marketing'],'schema_fields':['object','rewards'],'example_json':{'object':'0xSERVICE_ADDRESS','rewards':{'op':'add','objects':['0xREWARD_ADDRESS']}},'reverse_explanation':'add\x20is\x20always\x20allowed\x20(max\x2020,\x20MAX_REWARD_COUNT).\x20remove/clear\x20are\x20time-locked\x20after\x20publish:\x20require\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20assert_not_published).'},{'id':'P-S-09','pattern_name':'Set\x20order_allocators','semantic_intent':'Configure\x20fund\x20distribution\x20strategy\x20(publish\x20prerequisite,\x20post-publish\x20immutable)','match_keywords':['allocator','order_allocators'],'schema_fields':['object','order_allocators'],'example_json':{'object':'0xSERVICE_ADDRESS','order_allocators':[{'threshold':'0','sharing':[{'who':{'Object':'0xOWNER'},'weight':0x50},{'who':{'Object':'0xPLATFORM'},'weight':0x14}]}]},'reverse_explanation':'MANDATORY\x20before\x20publish\x20(F-S-18,\x20E_NO_ALLOCATOR).\x20First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20<=\x20order\x20value\x20handles\x20distribution.\x20Post-publish\x20immutable\x20(F-S-22).'},{'id':'P-S-10','pattern_name':'Pause/resume\x20Service','semantic_intent':'Block\x20new\x20orders\x20(pause)\x20or\x20resume\x20accepting\x20orders','match_keywords':['pause','resume'],'schema_fields':['object','pause'],'example_json':{'object':'0xSERVICE_ADDRESS','pause':!![]},'reverse_explanation':'pause=true\x20blocks\x20new\x20orders\x20(E_SERVICE_PAUSED);\x20pause=false\x20resumes.\x20Existing\x20Progress\x20continues\x20normally.\x20compensation_fund_withdraw\x20requires\x20paused=true.'},{'id':'P-S-11','pattern_name':'Publish\x20Service\x20(IRREVERSIBLE)','semantic_intent':'Publish\x20Service\x20—\x20makes\x20it\x20buyable.\x20One-shot,\x20cannot\x20revert.','match_keywords':['publish','go\x20live','release'],'schema_fields':['object','publish'],'example_json':{'object':'0xSERVICE_ADDRESS','publish':!![]},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Requires\x20SERVICE_PUBLISH\x20(311)\x20permission.\x20Prerequisites:\x20order_allocators\x20set;\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty.\x20Locks\x20machine/arbitrations/order_allocators\x20forever.'},{'id':'P-S-12','pattern_name':'Issue/destroy\x20discount\x20coupons','semantic_intent':'Issue\x20promotional\x20discount\x20coupons\x20or\x20destroy\x20(redeem)\x20them','match_keywords':['discount','coupon'],'schema_fields':['object','discount'],'example_json':{'object':'0xSERVICE_ADDRESS','discount':{'name':'SUMMER10','discount_type':0x0,'data':0x3e8,'count':0x64,'receivers':['0xUSER1','0xUSER2'],'expire_at':0x1941f297c00}},'reverse_explanation':'discount_type=0\x20rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction).\x20Max\x201000\x20per\x20call\x20(MAX_DISCOUNT_COUNT_ONCE),\x2020000\x20total\x20(MAX_DISCOUNT_TOTAL_COUNT).\x20discount_destroy\x20is\x20holder-only.'},{'id':'P-S-13','pattern_name':'Compensation\x20fund\x20operations\x20(add\x20/\x20withdraw\x20/\x20receive)','semantic_intent':'Deposit\x20to\x20compensation_fund,\x20withdraw\x20(time-locked),\x20or\x20receive\x20arbitration\x20payouts','match_keywords':['compensation_fund','compensation','deposit','withdraw'],'schema_fields':['object','compensation_fund_add','compensation_fund_withdraw','compensation_fund_receive'],'example_json':{'object':'0xSERVICE_ADDRESS','compensation_fund_add':{'balance':'1000000000'}},'reverse_explanation':'add\x20and\x20receive\x20are\x20always\x20mutable\x20(permission\x20315/316).\x20withdraw\x20is\x20time-locked\x20after\x20publish:\x20requires\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20compensation_fund_withdraw_imp).\x20Internal\x20Balance<T>,\x20distinct\x20from\x20Treasury.'},{'id':'P-S-14','pattern_name':'Extend\x20setting_lock_duration','semantic_intent':'Add\x20milliseconds\x20to\x20setting_lock_duration\x20(only-increase\x20mechanism)','match_keywords':['setting_lock_duration','lock_duration','lock\x20period','extend\x20lock'],'schema_fields':['object','setting_lock_duration_add'],'example_json':{'object':'0xSERVICE_ADDRESS','setting_lock_duration_add':0x9a7ec800},'reverse_explanation':'Only-increase\x20(safe_add).\x20Default\x202592000000ms\x20(30\x20days).\x20Affects\x20rewards/compensation_fund_withdraw/compensation_fund_receive\x20mutability\x20windows.'},{'id':'P-S-15','pattern_name':'Buy\x20(8-stage\x20composite\x20order\x20flow)','semantic_intent':'Customer\x20places\x20order\x20—\x20atomic\x20creation\x20of\x20Order\x20+\x20Allocation\x20+\x20Progress','match_keywords':['buy','order','purchase'],'schema_fields':['object','order_new'],'example_json':{'object':'0xSERVICE_ADDRESS','order_new':{'buy':{'items':[{'name':'standard','wip_hash':'abcd...64','count':0x1}],'discount':'0xDISCOUNT_ADDRESS','total_pay':'1000000000','passport':null},'order_required_info':{'name':'Alice','phone':'+86...'},'agents':['0xAGENT1'],'transfer':null}},'reverse_explanation':'8\x20stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order\x20→\x20create_allocation\x20→\x20create_progress\x20→\x20post_actions\x20→\x20return_result.\x20Stock\x20deduction\x20is\x20NOT\x20rolled\x20back\x20on\x20later\x20failure.'},{'id':'P-S-16','pattern_name':'Transfer\x20ownership\x20(IRREVERSIBLE)','semantic_intent':'Transfer\x20Service\x20ownership\x20to\x20a\x20new\x20address','match_keywords':['transfer','handover'],'schema_fields':['object','builder'],'example_json':{'object':'0xSERVICE_ADDRESS','builder':'0xNEW_OWNER'},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20permission,\x20compensation_fund,\x20all\x20bindings.\x20Export\x20JSON\x20before\x20transfer.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Service\x20object\x20address.\x20STRING=operate\x20existing;\x20null/omitted=create\x20new'},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20Service\x20description.\x20Mutable\x20pre/post\x20publish.\x20Max\x204000\x20chars.'},{'element_type':'field','type_name':'location','semantic_explanation':'Geographic\x20location\x20of\x20the\x20service\x20(city/region).\x20Mutable.\x20Index\x20303\x20(SERVICE_LOCATION).'},{'element_type':'field','type_name':'customer_required','semantic_explanation':'String[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time\x20(e.g.\x20[\x27name\x27,\x27phone\x27]).\x20Mutable.\x20Index\x20309.'},{'element_type':'field','type_name':'sales','semantic_explanation':'Product\x20SKU\x20list.\x20op=add/set/remove/clear.\x20Each\x20sale\x20has\x20name/price/stock/wip/wip_hash.\x20Index\x20305\x20(SERVICE_SALES).'},{'element_type':'field','type_name':'machine','semantic_explanation':'Machine\x20workflow\x20template\x20binding.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-20).\x20Index\x20306\x20(SERVICE_MACHINE).'},{'element_type':'field','type_name':'buy_guard','semantic_explanation':'Buyer\x20eligibility\x20Guard.\x20⚠️\x20UNUSUAL:\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Index\x20307\x20(SERVICE_BUY_GUARD).'},{'element_type':'field','type_name':'arbitrations','semantic_explanation':'Arbitration\x20object\x20list.\x20Required\x20if\x20compensation_fund\x20>\x200.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-21).\x20Index\x20308.'},{'element_type':'field','type_name':'repositories','semantic_explanation':'Repository\x20object\x20list.\x20Mutable.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).\x20Index\x20304\x20(SERVICE_REPOSITORY).'},{'element_type':'field','type_name':'rewards','semantic_explanation':'Reward\x20object\x20list.\x20Mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24).\x20Max\x2020\x20(MAX_REWARD_COUNT).\x20Index\x20318.'},{'element_type':'field','type_name':'order_allocators','semantic_explanation':'Fund\x20distribution\x20strategy.\x20⚠️\x20MANDATORY\x20for\x20publish\x20(F-S-18).\x20IMMUTABLE\x20post-publish\x20(F-S-22).\x20Index\x20313.'},{'element_type':'field','type_name':'discount','semantic_explanation':'Discount\x20coupon\x20issuance.\x20discount_type=0\x20rates,\x201=minus.\x20Index\x20312\x20(SERVICE_DISCOUNT).'},{'element_type':'field','type_name':'pause','semantic_explanation':'true=pause\x20(block\x20new\x20orders);\x20false=resume.\x20Existing\x20Progress\x20unaffected.\x20Index\x20310\x20(SERVICE_PAUSE).'},{'element_type':'field','type_name':'publish','semantic_explanation':'⚠️\x20IRREVERSIBLE\x20one-shot.\x20Requires\x20prerequisites.\x20Locks\x203\x20fields\x20forever.\x20Index\x20311\x20(SERVICE_PUBLISH).'},{'element_type':'field','type_name':'compensation_fund_add','semantic_explanation':'Deposit\x20to\x20internal\x20Balance<T>.\x20Always\x20mutable.\x20Index\x20315.\x20Distinct\x20from\x20Treasury.'},{'element_type':'field','type_name':'compensation_fund_withdraw','semantic_explanation':'Withdraw\x20from\x20internal\x20Balance<T>.\x20Requires\x20bPaused=true\x20+\x20lock_duration\x20expired.\x20Index\x20314.\x20Locked\x20by\x20duration\x20(F-S-25).'},{'element_type':'field','type_name':'compensation_fund_receive','semantic_explanation':'Receive\x20compensation_fund\x20(for\x20arbitration\x20payouts).\x20Locked\x20by\x20setting_lock_duration.\x20Index\x20316.'},{'element_type':'field','type_name':'setting_lock_duration_add','semantic_explanation':'Extend\x20setting_lock_duration\x20(only-increase,\x20safe_add).\x20Index\x20317\x20(SERVICE_COMPENSATION_LOCK_DURATION_ADD).'},{'element_type':'field','type_name':'order_new','semantic_explanation':'Composite\x20buy\x20operation.\x20Triggers\x208-stage\x20flow:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20→\x20create_order/allocation/progress\x20→\x20post_actions\x20→\x20return_result.'},{'element_type':'field','type_name':'builder','semantic_explanation':'Transfer\x20ownership.\x20⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.'},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object).\x20Mutable.\x20Index\x20320\x20(SERVICE_UM).'},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Receive\x20Payment/objects\x20to\x20owner.\x20Index\x20319\x20(SERVICE_OWNER_RECEIVE).'},{'element_type':'op','type_name':'add','semantic_explanation':'Append\x20new\x20items\x20(sales/arbitrations/repositories/rewards).\x20Additive,\x20does\x20not\x20replace.'},{'element_type':'op','type_name':'set','semantic_explanation':'Replace\x20existing\x20item\x20by\x20name\x20(sales)\x20or\x20replace\x20entire\x20list\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'remove','semantic_explanation':'Remove\x20specific\x20items\x20by\x20name\x20(sales)\x20or\x20address\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'clear','semantic_explanation':'Remove\x20all\x20items\x20from\x20the\x20list.'}];export const SERVICE_CONSTRAINT_RULES=[{'id':'MC-S-01','category':'structural','rule':'Service\x20builtin\x20permission\x20indexes\x20must\x20be\x20in\x20range\x20300-320\x20(302\x20reserved/commented)','applies_to':['permission\x20table.index\x20(when\x20applied\x20to\x20Service)']},{'id':'MC-S-02','category':'structural','rule':'sales\x20count\x20<=\x20MAX_SALE_COUNT\x20('+MAX_SALE_COUNT+')','applies_to':['sales.sales']},{'id':'MC-S-03','category':'structural','rule':'repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20('+MAX_REPOSITORY_COUNT+')','applies_to':['repositories.objects']},{'id':'MC-S-04','category':'structural','rule':'arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20('+MAX_ARBITRATION_COUNT+')','applies_to':['arbitrations.objects']},{'id':'MC-S-05','category':'structural','rule':'rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','applies_to':['rewards.objects']},{'id':'MC-S-06','category':'structural','rule':'customer_required\x20count\x20<=\x2010,\x20each\x20item\x20length\x20<=\x2020','applies_to':['customer_required']},{'id':'MC-S-07','category':'structural','rule':'wip\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20('+MAX_WIP_LENGTH+')','applies_to':['sales.sales[].wip']},{'id':'MC-S-08','category':'structural','rule':'wip_hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20('+MAX_WIP_HASH_LENGTH+')\x20—\x20sha256\x20hex\x20(64\x20chars,\x20no\x20prefix)','applies_to':['sales.sales[].wip_hash','order_new.buy.items[].wip_hash']},{'id':'MC-S-09','category':'semantic','rule':'wip_hash\x20must\x20NOT\x20be\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','applies_to':['sales.sales[]']},{'id':'MC-S-10','category':'authority','rule':'publish\x20requires\x20order_allocators\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','applies_to':['publish','order_allocators']},{'id':'MC-S-11','category':'authority','rule':'publish\x20with\x20compensation_fund\x20>\x200\x20requires\x20arbitrations\x20non-empty\x20(F-S-19,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','applies_to':['publish','arbitrations','compensation_fund_add']},{'id':'MC-S-12','category':'lifecycle','rule':'machine\x20IMMUTABLE\x20post-publish\x20(F-S-20)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['machine']},{'id':'MC-S-13','category':'lifecycle','rule':'arbitrations\x20IMMUTABLE\x20post-publish\x20(F-S-21)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['arbitrations']},{'id':'MC-S-14','category':'lifecycle','rule':'order_allocators\x20IMMUTABLE\x20post-publish\x20(F-S-22)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['order_allocators']},{'id':'MC-S-15','category':'lifecycle','rule':'bPublished\x20is\x20IRREVERSIBLE\x20(one-shot,\x20cannot\x20revert\x20to\x20false)\x20—\x20to\x20\x27reset\x27,\x20create\x20new\x20Service','applies_to':['publish']},{'id':'MC-S-16','category':'lifecycle','rule':'setting_lock_duration\x20only-increase\x20(safe_add)\x20—\x20cannot\x20be\x20decreased;\x20protects\x20customers','applies_to':['setting_lock_duration_add']},{'id':'MC-S-17','category':'lifecycle','rule':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20AND\x20setting_lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','applies_to':['compensation_fund_withdraw','pause']},{'id':'MC-S-18','category':'semantic','rule':'discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20('+MAX_DISCOUNT_TOTAL_COUNT+');\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20('+MAX_DISCOUNT_COUNT_ONCE+')','applies_to':['discount.count']},{'id':'MC-S-19','category':'semantic','rule':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception)\x20—\x20all\x20other\x20guarded\x20fields\x20are\x20immutable','applies_to':['buy_guard']},{'id':'MC-S-20','category':'authority','rule':'Ownership\x20transfer\x20(builder)\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20inherits\x20permission\x20+\x20compensation_fund\x20+\x20all\x20bindings','applies_to':['builder']}];export const SERVICE_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainServiceCallData(b){const c=[];b['object']===null||b['object']===undefined?c['push']('Operation:\x20CREATE\x20new\x20Service'):c['push']('Operation:\x20MODIFY\x20existing\x20Service\x20at\x20'+b['object']);if(b['description'])c['push']('-\x20Set\x20description:\x20\x22'+b['description']+'\x22');if(b['location'])c['push']('-\x20Set\x20location:\x20'+b['location']);if(b['customer_required'])c['push']('-\x20Customer\x20required\x20fields:\x20['+b['customer_required']['join'](',\x20')+']');if(b['sales']){const e=b['sales'];if(e['op']==='clear')c['push']('-\x20Sales:\x20CLEAR\x20all\x20items');else{if(e['op']==='remove')c['push']('-\x20Sales\x20REMOVE:\x20['+e['sales_name']['join'](',\x20')+']');else{c['push']('-\x20Sales\x20'+e['op']['toUpperCase']()+':\x20'+e['sales']['length']+'\x20item(s)');for(const f of e['sales']){const g=f['wip_hash']?'\x20hash='+f['wip_hash']['slice'](0x0,0x8)+'...':'\x20⚠️NO_HASH';c['push']('\x20\x20\x20\x20•\x20'+f['name']+'\x20price='+(f['price']??'?')+'\x20stock='+(f['stock']??'?')+g);}}}}b['machine']!==undefined&&c['push'](b['machine']===null?'-\x20Machine:\x20unbind\x20(pre-publish\x20only)':'-\x20Machine:\x20bind\x20'+b['machine']);b['buy_guard']!==undefined&&c['push'](b['buy_guard']===null?'-\x20Buy\x20Guard:\x20clear':'-\x20Buy\x20Guard:\x20set\x20'+b['buy_guard']+'\x20[mutable\x20post-publish]');if(b['arbitrations']){const h=b['arbitrations'];h['op']==='clear'?c['push']('-\x20Arbitrations:\x20CLEAR\x20(pre-publish\x20only)'):c['push']('-\x20Arbitrations\x20'+h['op']['toUpperCase']()+':\x20'+h['objects']['length']+'\x20object(s)');}if(b['repositories']){const i=b['repositories'];i['op']==='clear'?c['push']('-\x20Repositories:\x20CLEAR'):c['push']('-\x20Repositories\x20'+i['op']['toUpperCase']()+':\x20'+i['objects']['length']+'\x20object(s)');}if(b['rewards']){const j=b['rewards'];j['op']==='clear'?c['push']('-\x20Rewards:\x20CLEAR\x20(locked\x20by\x20duration)'):c['push']('-\x20Rewards\x20'+j['op']['toUpperCase']()+':\x20'+j['objects']['length']+'\x20object(s)\x20[locked\x20by\x20duration]');}b['order_allocators']!==undefined&&c['push']('-\x20Order\x20Allocators:\x20'+(b['order_allocators']?'configured':'(clear)')+'\x20[immutable\x20post-publish]');if(b['discount']){const k=b['discount'],l=k['discount_type']===0x0?'rates\x20(basis\x20points,\x20per\x2010000)':'minus\x20(direct\x20deduction)';c['push']('-\x20Discount:\x20'+k['name']+'\x20type='+l+'\x20data='+k['data']+'\x20count='+k['count']);}b['pause']!==undefined&&c['push']('-\x20Pause:\x20'+(b['pause']?'PAUSE\x20(block\x20new\x20orders)':'RESUME'));b['publish']&&c['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE\x20—\x20locks\x20machine/arbitrations/order_allocators\x20forever)');b['compensation_fund_add']&&c['push']('-\x20Compensation\x20fund\x20deposit:\x20'+b['compensation_fund_add']['balance']+'\x20(internal\x20Balance<T>)');b['compensation_fund_withdraw']&&c['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20bPaused=true\x20+\x20lock_duration\x20expired)');b['compensation_fund_receive']&&c['push']('-\x20Compensation\x20fund\x20receive\x20(locked\x20by\x20duration)');b['setting_lock_duration_add']!==undefined&&c['push']('-\x20Setting\x20lock\x20duration\x20+'+b['setting_lock_duration_add']+'ms\x20(only-increase)');if(b['order_new']){const m=b['order_new'];c['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20composite\x20flow):'),c['push']('\x20\x20\x20\x20Items:\x20'+m['buy']['items']['length']),c['push']('\x20\x20\x20\x20Total\x20pay:\x20'+m['buy']['total_pay']);if(m['buy']['discount'])c['push']('\x20\x20\x20\x20Discount:\x20'+m['buy']['discount']);c['push']('\x20\x20\x20\x20Stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order/allocation/progress\x20→\x20return');}return b['builder']&&c['push']('-\x20⚠️\x20TRANSFER\x20ownership\x20to\x20'+b['builder']+'\x20(IRREVERSIBLE)'),b['um']!==undefined&&c['push'](b['um']===null?'-\x20UM:\x20revoke':'-\x20UM:\x20set\x20to\x20'+b['um']),b['owner_receive']&&c['push']('-\x20Owner\x20receive:\x20receive\x20Payment/objects\x20to\x20owner'),c['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function getConstraintsByCategory(a){return SERVICE_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainServicePermissionIndex(a){if(isServicePermission(a)){const b=getServicePermissionByIndex(a);if(!b)return'Unknown\x20Service\x20permission\x20('+a+')';const c=b['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE\x20post-publish]':b['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT,\x20irreversible]':b['post_publish_mutability']==='locked_by_duration'?'\x20[locked\x20by\x20setting_lock_duration]':'';return b['name']+'\x20('+a+')\x20—\x20'+b['description']+c;}return'Non-Service\x20permission\x20('+a+')\x20—\x20verify\x20against\x20host\x20object\x27s\x20index\x20range';}
|
|
1
|
+
import{MAX_SALE_COUNT,MAX_REPOSITORY_COUNT,MAX_ARBITRATION_COUNT,MAX_DISCOUNT_COUNT_ONCE,MAX_DISCOUNT_TOTAL_COUNT,MAX_WIP_LENGTH,MAX_WIP_HASH_LENGTH}from'@wowok/wowok';import{isServicePermission,getServicePermissionByIndex}from'./service-ledger.js';export const SEMANTIC_TO_SCHEMA_RULES=[{'id':'P-S-01','pattern_name':'Create\x20new\x20Service','semantic_intent':'Create\x20a\x20new\x20Service<T>\x20with\x20owner,\x20permission,\x20description,\x20coin\x20type','match_keywords':['create','new','open'],'schema_fields':['object(null)','description','permission','owner','coin_type'],'example_json':{'object':null,'description':'My\x20retail\x20shop','permission':'0xPERMISSION_ADDRESS'},'reverse_explanation':'object=null\x20indicates\x20creation;\x20permission\x20must\x20be\x20a\x20valid\x20Permission\x20object\x20owned\x20by\x20signer'},{'id':'P-S-02','pattern_name':'Modify\x20description\x20/\x20location\x20/\x20customer_required','semantic_intent':'Update\x20Service\x20metadata\x20fields\x20(mutable\x20pre\x20and\x20post\x20publish)','match_keywords':['describe','locate','customer_required','update','modify'],'schema_fields':['object','description','location','customer_required'],'example_json':{'object':'0xSERVICE_ADDRESS','description':'Updated\x20description','location':'Shanghai','customer_required':['name','phone']},'reverse_explanation':'These\x20fields\x20are\x20always\x20mutable.\x20customer_required\x20is\x20a\x20string[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time.'},{'id':'P-S-03','pattern_name':'Manage\x20sales\x20items\x20(add/set/remove/clear)','semantic_intent':'Add\x20product\x20SKUs,\x20update\x20prices/stock,\x20remove\x20deprecated\x20items,\x20or\x20clear\x20all','match_keywords':['sales','product','sku','inventory','price'],'schema_fields':['object','sales'],'example_json':{'object':'0xSERVICE_ADDRESS','sales':{'op':'add','sales':[{'name':'standard','price':'1000000000','stock':0x64,'wip':'https://ipfs/wip','wip_hash':'abcd...64'}]}},'reverse_explanation':'sales.op=add\x20appends;\x20set\x20replaces\x20matching\x20name;\x20remove\x20deletes\x20by\x20name;\x20clear\x20empties\x20all.\x20wip_hash\x20is\x20REQUIRED\x20for\x20tamper\x20protection.'},{'id':'P-S-04','pattern_name':'Bind/unbind\x20Machine\x20workflow','semantic_intent':'Bind\x20a\x20Machine\x20workflow\x20template\x20to\x20Service\x20(post-publish\x20immutable)','match_keywords':['machine','workflow','bind\x20machine'],'schema_fields':['object','machine'],'example_json':{'object':'0xSERVICE_ADDRESS','machine':'0xMACHINE_ADDRESS'},'reverse_explanation':'machine=<address>\x20binds;\x20machine=null\x20unbinds\x20(pre-publish\x20only).\x20Once\x20published,\x20machine\x20is\x20immutable\x20(F-S-20).\x20Progress\x20inherits\x20this\x20binding.'},{'id':'P-S-05','pattern_name':'Set/clear\x20buy\x20Guard','semantic_intent':'Set\x20buyer\x20eligibility\x20Guard\x20(KYC/whitelist)\x20or\x20clear\x20it','match_keywords':['buy_guard','kyc','whitelist'],'schema_fields':['object','buy_guard'],'example_json':{'object':'0xSERVICE_ADDRESS','buy_guard':'0xGUARD_ADDRESS'},'reverse_explanation':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Pre-sale:\x20set\x20to\x20whitelist;\x20public\x20sale:\x20set\x20to\x20null.'},{'id':'P-S-06','pattern_name':'Manage\x20arbitrations\x20(add/remove/clear)','semantic_intent':'Bind\x20Arbitration\x20objects\x20for\x20dispute\x20handling\x20(post-publish\x20immutable)','match_keywords':['arbitration','arbitrator','dispute'],'schema_fields':['object','arbitrations'],'example_json':{'object':'0xSERVICE_ADDRESS','arbitrations':{'op':'add','objects':['0xARB_ADDRESS']}},'reverse_explanation':'Required\x20when\x20compensation_fund\x20>\x200\x20(F-S-19).\x20Post-publish\x20immutable\x20(F-S-21).\x20Use\x201-3\x20Arbitration\x20objects\x20covering\x20different\x20scopes.'},{'id':'P-S-07','pattern_name':'Manage\x20repositories\x20(add/remove/clear)','semantic_intent':'Bind\x20Repository\x20objects\x20(data\x20stores)\x20—\x20mutable\x20post-publish','match_keywords':['repository','data\x20store','storage','data\x20source'],'schema_fields':['object','repositories'],'example_json':{'object':'0xSERVICE_ADDRESS','repositories':{'op':'add','objects':['0xREPO_ADDRESS']}},'reverse_explanation':'Mutable\x20post-publish.\x20SDK\x20validates\x20ObjectType.Repository\x20via\x20queryObjectsWithType.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).'},{'id':'P-S-08','pattern_name':'Manage\x20rewards\x20(add\x20/\x20remove\x20/\x20clear)','semantic_intent':'Bind\x20or\x20unbind\x20Reward\x20objects\x20for\x20marketing\x20incentives','match_keywords':['reward','incentive','marketing'],'schema_fields':['object','rewards'],'example_json':{'object':'0xSERVICE_ADDRESS','rewards':{'op':'add','objects':['0xREWARD_ADDRESS']}},'reverse_explanation':'add\x20is\x20always\x20allowed\x20(max\x2020,\x20MAX_REWARD_COUNT).\x20remove/clear\x20are\x20time-locked\x20after\x20publish:\x20require\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20assert_not_published).'},{'id':'P-S-09','pattern_name':'Set\x20order_allocators','semantic_intent':'Configure\x20fund\x20distribution\x20strategy\x20(publish\x20prerequisite,\x20post-publish\x20immutable)','match_keywords':['allocator','order_allocators'],'schema_fields':['object','order_allocators'],'example_json':{'object':'0xSERVICE_ADDRESS','order_allocators':[{'threshold':'0','sharing':[{'who':{'Object':'0xOWNER'},'weight':0x50},{'who':{'Object':'0xPLATFORM'},'weight':0x14}]}]},'reverse_explanation':'MANDATORY\x20before\x20publish\x20(F-S-18,\x20E_NO_ALLOCATOR).\x20First-match-wins:\x20first\x20allocator\x20whose\x20threshold\x20<=\x20order\x20value\x20handles\x20distribution.\x20Post-publish\x20immutable\x20(F-S-22).'},{'id':'P-S-10','pattern_name':'Pause/resume\x20Service','semantic_intent':'Block\x20new\x20orders\x20(pause)\x20or\x20resume\x20accepting\x20orders','match_keywords':['pause','resume'],'schema_fields':['object','pause'],'example_json':{'object':'0xSERVICE_ADDRESS','pause':!![]},'reverse_explanation':'pause=true\x20blocks\x20new\x20orders\x20(E_SERVICE_PAUSED);\x20pause=false\x20resumes.\x20Existing\x20Progress\x20continues\x20normally.\x20compensation_fund_withdraw\x20requires\x20paused=true.'},{'id':'P-S-11','pattern_name':'Publish\x20Service\x20(IRREVERSIBLE)','semantic_intent':'Publish\x20Service\x20—\x20makes\x20it\x20buyable.\x20One-shot,\x20cannot\x20revert.','match_keywords':['publish','go\x20live','release'],'schema_fields':['object','publish'],'example_json':{'object':'0xSERVICE_ADDRESS','publish':!![]},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Requires\x20SERVICE_PUBLISH\x20(311)\x20permission.\x20Prerequisites:\x20order_allocators\x20set;\x20if\x20compensation_fund\x20>\x200,\x20arbitrations\x20non-empty.\x20Locks\x20machine/arbitrations/order_allocators\x20forever.'},{'id':'P-S-12','pattern_name':'Issue/destroy\x20discount\x20coupons','semantic_intent':'Issue\x20promotional\x20discount\x20coupons\x20or\x20destroy\x20(redeem)\x20them','match_keywords':['discount','coupon'],'schema_fields':['object','discount'],'example_json':{'object':'0xSERVICE_ADDRESS','discount':{'name':'SUMMER10','discount_type':0x0,'data':0x3e8,'count':0x64,'receivers':['0xUSER1','0xUSER2'],'expire_at':0x1941f297c00}},'reverse_explanation':'discount_type=0\x20rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction).\x20Max\x201000\x20per\x20call\x20(MAX_DISCOUNT_COUNT_ONCE),\x2020000\x20total\x20(MAX_DISCOUNT_TOTAL_COUNT).\x20discount_destroy\x20is\x20holder-only.'},{'id':'P-S-13','pattern_name':'Compensation\x20fund\x20operations\x20(add\x20/\x20withdraw\x20/\x20receive)','semantic_intent':'Deposit\x20to\x20compensation_fund,\x20withdraw\x20(time-locked),\x20or\x20receive\x20arbitration\x20payouts','match_keywords':['compensation_fund','compensation','deposit','withdraw'],'schema_fields':['object','compensation_fund_add','compensation_fund_withdraw','compensation_fund_receive'],'example_json':{'object':'0xSERVICE_ADDRESS','compensation_fund_add':{'balance':'1000000000'}},'reverse_explanation':'add\x20and\x20receive\x20are\x20always\x20mutable\x20(permission\x20315/316).\x20withdraw\x20is\x20time-locked\x20after\x20publish:\x20requires\x20Service\x20paused\x20AND\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20clock\x20(service.move\x20compensation_fund_withdraw_imp).\x20Internal\x20Balance<T>,\x20distinct\x20from\x20Treasury.'},{'id':'P-S-14','pattern_name':'Extend\x20setting_lock_duration','semantic_intent':'Add\x20milliseconds\x20to\x20setting_lock_duration\x20(only-increase\x20mechanism)','match_keywords':['setting_lock_duration','lock_duration','lock\x20period','extend\x20lock'],'schema_fields':['object','setting_lock_duration_add'],'example_json':{'object':'0xSERVICE_ADDRESS','setting_lock_duration_add':0x9a7ec800},'reverse_explanation':'Only-increase\x20(safe_add).\x20Default\x202592000000ms\x20(30\x20days).\x20Affects\x20rewards/compensation_fund_withdraw/compensation_fund_receive\x20mutability\x20windows.'},{'id':'P-S-15','pattern_name':'Buy\x20(8-stage\x20composite\x20order\x20flow)','semantic_intent':'Customer\x20places\x20order\x20—\x20atomic\x20creation\x20of\x20Order\x20+\x20Allocation\x20+\x20Progress','match_keywords':['buy','order','purchase'],'schema_fields':['object','order_new'],'example_json':{'object':'0xSERVICE_ADDRESS','order_new':{'buy':{'items':[{'name':'standard','wip_hash':'abcd...64','count':0x1}],'discount':'0xDISCOUNT_ADDRESS','total_pay':'1000000000','passport':null},'order_required_info':{'name':'Alice','phone':'+86...'},'agents':['0xAGENT1'],'transfer':null}},'reverse_explanation':'8\x20stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order\x20→\x20create_allocation\x20→\x20create_progress\x20→\x20post_actions\x20→\x20return_result.\x20Stock\x20deduction\x20is\x20NOT\x20rolled\x20back\x20on\x20later\x20failure.'},{'id':'P-S-16','pattern_name':'Transfer\x20ownership\x20(IRREVERSIBLE)','semantic_intent':'Transfer\x20Service\x20ownership\x20to\x20a\x20new\x20address','match_keywords':['transfer','handover'],'schema_fields':['object','builder'],'example_json':{'object':'0xSERVICE_ADDRESS','builder':'0xNEW_OWNER'},'reverse_explanation':'⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.\x20New\x20owner\x20inherits\x20permission,\x20compensation_fund,\x20all\x20bindings.\x20Export\x20JSON\x20before\x20transfer.'}];export const SCHEMA_TO_SEMANTIC_RULES=[{'element_type':'field','type_name':'object','semantic_explanation':'Service\x20object\x20address.\x20STRING=operate\x20existing;\x20null/omitted=create\x20new'},{'element_type':'field','type_name':'description','semantic_explanation':'Human-readable\x20Service\x20description.\x20Mutable\x20pre/post\x20publish.\x20Max\x204000\x20chars.'},{'element_type':'field','type_name':'location','semantic_explanation':'The\x20service\x20area\x20and\x20scope\x20as\x20stated\x20by\x20the\x20merchant.\x20Mutable.\x20Index\x20303\x20(SERVICE_LOCATION).'},{'element_type':'field','type_name':'customer_required','semantic_explanation':'String[]\x20of\x20field\x20names\x20buyers\x20must\x20provide\x20at\x20order\x20time\x20(e.g.\x20[\x27name\x27,\x27phone\x27]).\x20Mutable.\x20Index\x20309.'},{'element_type':'field','type_name':'sales','semantic_explanation':'Product\x20SKU\x20list.\x20op=add/set/remove/clear.\x20Each\x20sale\x20has\x20name/price/stock/wip/wip_hash.\x20Index\x20305\x20(SERVICE_SALES).'},{'element_type':'field','type_name':'machine','semantic_explanation':'Machine\x20workflow\x20template\x20binding.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-20).\x20Index\x20306\x20(SERVICE_MACHINE).'},{'element_type':'field','type_name':'buy_guard','semantic_explanation':'Buyer\x20eligibility\x20Guard.\x20⚠️\x20UNUSUAL:\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception).\x20Index\x20307\x20(SERVICE_BUY_GUARD).'},{'element_type':'field','type_name':'arbitrations','semantic_explanation':'Arbitration\x20object\x20list.\x20Required\x20if\x20compensation_fund\x20>\x200.\x20⚠️\x20IMMUTABLE\x20post-publish\x20(F-S-21).\x20Index\x20308.'},{'element_type':'field','type_name':'repositories','semantic_explanation':'Repository\x20object\x20list.\x20Mutable.\x20Max\x20100\x20(MAX_REPOSITORY_COUNT).\x20Index\x20304\x20(SERVICE_REPOSITORY).'},{'element_type':'field','type_name':'rewards','semantic_explanation':'Reward\x20object\x20list.\x20Mutable\x20but\x20locked\x20by\x20setting_lock_duration\x20(F-S-24).\x20Max\x2020\x20(MAX_REWARD_COUNT).\x20Index\x20318.'},{'element_type':'field','type_name':'order_allocators','semantic_explanation':'Fund\x20distribution\x20strategy.\x20⚠️\x20MANDATORY\x20for\x20publish\x20(F-S-18).\x20IMMUTABLE\x20post-publish\x20(F-S-22).\x20Index\x20313.'},{'element_type':'field','type_name':'discount','semantic_explanation':'Discount\x20coupon\x20issuance.\x20discount_type=0\x20rates,\x201=minus.\x20Index\x20312\x20(SERVICE_DISCOUNT).'},{'element_type':'field','type_name':'pause','semantic_explanation':'true=pause\x20(block\x20new\x20orders);\x20false=resume.\x20Existing\x20Progress\x20unaffected.\x20Index\x20310\x20(SERVICE_PAUSE).'},{'element_type':'field','type_name':'publish','semantic_explanation':'⚠️\x20IRREVERSIBLE\x20one-shot.\x20Requires\x20prerequisites.\x20Locks\x203\x20fields\x20forever.\x20Index\x20311\x20(SERVICE_PUBLISH).'},{'element_type':'field','type_name':'compensation_fund_add','semantic_explanation':'Deposit\x20to\x20internal\x20Balance<T>.\x20Always\x20mutable.\x20Index\x20315.\x20Distinct\x20from\x20Treasury.'},{'element_type':'field','type_name':'compensation_fund_withdraw','semantic_explanation':'Withdraw\x20from\x20internal\x20Balance<T>.\x20Requires\x20bPaused=true\x20+\x20lock_duration\x20expired.\x20Index\x20314.\x20Locked\x20by\x20duration\x20(F-S-25).'},{'element_type':'field','type_name':'compensation_fund_receive','semantic_explanation':'Receive\x20compensation_fund\x20(for\x20arbitration\x20payouts).\x20Locked\x20by\x20setting_lock_duration.\x20Index\x20316.'},{'element_type':'field','type_name':'setting_lock_duration_add','semantic_explanation':'Extend\x20setting_lock_duration\x20(only-increase,\x20safe_add).\x20Index\x20317\x20(SERVICE_COMPENSATION_LOCK_DURATION_ADD).'},{'element_type':'field','type_name':'order_new','semantic_explanation':'Composite\x20buy\x20operation.\x20Triggers\x208-stage\x20flow:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20→\x20create_order/allocation/progress\x20→\x20post_actions\x20→\x20return_result.'},{'element_type':'field','type_name':'builder','semantic_explanation':'Transfer\x20ownership.\x20⚠️\x20IRREVERSIBLE.\x20Original\x20owner\x20loses\x20ALL\x20control.'},{'element_type':'field','type_name':'um','semantic_explanation':'User\x20Manager\x20(Contact\x20object).\x20Mutable.\x20Index\x20320\x20(SERVICE_UM).'},{'element_type':'field','type_name':'owner_receive','semantic_explanation':'Receive\x20Payment/objects\x20to\x20owner.\x20Index\x20319\x20(SERVICE_OWNER_RECEIVE).'},{'element_type':'op','type_name':'add','semantic_explanation':'Append\x20new\x20items\x20(sales/arbitrations/repositories/rewards).\x20Additive,\x20does\x20not\x20replace.'},{'element_type':'op','type_name':'set','semantic_explanation':'Replace\x20existing\x20item\x20by\x20name\x20(sales)\x20or\x20replace\x20entire\x20list\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'remove','semantic_explanation':'Remove\x20specific\x20items\x20by\x20name\x20(sales)\x20or\x20address\x20(repositories/rewards/arbitrations).'},{'element_type':'op','type_name':'clear','semantic_explanation':'Remove\x20all\x20items\x20from\x20the\x20list.'}];export const SERVICE_CONSTRAINT_RULES=[{'id':'MC-S-01','category':'structural','rule':'Service\x20builtin\x20permission\x20indexes\x20must\x20be\x20in\x20range\x20300-320\x20(302\x20reserved/commented)','applies_to':['permission\x20table.index\x20(when\x20applied\x20to\x20Service)']},{'id':'MC-S-02','category':'structural','rule':'sales\x20count\x20<=\x20MAX_SALE_COUNT\x20('+MAX_SALE_COUNT+')','applies_to':['sales.sales']},{'id':'MC-S-03','category':'structural','rule':'repositories\x20count\x20<=\x20MAX_REPOSITORY_COUNT\x20('+MAX_REPOSITORY_COUNT+')','applies_to':['repositories.objects']},{'id':'MC-S-04','category':'structural','rule':'arbitrations\x20count\x20<=\x20MAX_ARBITRATION_COUNT\x20('+MAX_ARBITRATION_COUNT+')','applies_to':['arbitrations.objects']},{'id':'MC-S-05','category':'structural','rule':'rewards\x20count\x20<=\x20MAX_REWARD_COUNT\x20(20)','applies_to':['rewards.objects']},{'id':'MC-S-06','category':'structural','rule':'customer_required\x20count\x20<=\x2010,\x20each\x20item\x20length\x20<=\x2020','applies_to':['customer_required']},{'id':'MC-S-07','category':'structural','rule':'wip\x20URL\x20length\x20<=\x20MAX_WIP_LENGTH\x20('+MAX_WIP_LENGTH+')','applies_to':['sales.sales[].wip']},{'id':'MC-S-08','category':'structural','rule':'wip_hash\x20length\x20<=\x20MAX_WIP_HASH_LENGTH\x20('+MAX_WIP_HASH_LENGTH+')\x20—\x20sha256\x20hex\x20(64\x20chars,\x20no\x20prefix)','applies_to':['sales.sales[].wip_hash','order_new.buy.items[].wip_hash']},{'id':'MC-S-09','category':'semantic','rule':'wip_hash\x20must\x20NOT\x20be\x20empty\x20when\x20wip\x20URL\x20is\x20set\x20(tamper\x20protection)','applies_to':['sales.sales[]']},{'id':'MC-S-10','category':'authority','rule':'publish\x20requires\x20order_allocators\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','applies_to':['publish','order_allocators']},{'id':'MC-S-11','category':'authority','rule':'publish\x20with\x20compensation_fund\x20>\x200\x20requires\x20arbitrations\x20non-empty\x20(F-S-19,\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','applies_to':['publish','arbitrations','compensation_fund_add']},{'id':'MC-S-12','category':'lifecycle','rule':'machine\x20IMMUTABLE\x20post-publish\x20(F-S-20)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['machine']},{'id':'MC-S-13','category':'lifecycle','rule':'arbitrations\x20IMMUTABLE\x20post-publish\x20(F-S-21)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['arbitrations']},{'id':'MC-S-14','category':'lifecycle','rule':'order_allocators\x20IMMUTABLE\x20post-publish\x20(F-S-22)\x20—\x20SDK\x20checkNotPublished()\x20blocks','applies_to':['order_allocators']},{'id':'MC-S-15','category':'lifecycle','rule':'bPublished\x20is\x20IRREVERSIBLE\x20(one-shot,\x20cannot\x20revert\x20to\x20false)\x20—\x20to\x20\x27reset\x27,\x20create\x20new\x20Service','applies_to':['publish']},{'id':'MC-S-16','category':'lifecycle','rule':'setting_lock_duration\x20only-increase\x20(safe_add)\x20—\x20cannot\x20be\x20decreased;\x20protects\x20customers','applies_to':['setting_lock_duration_add']},{'id':'MC-S-17','category':'lifecycle','rule':'compensation_fund_withdraw\x20requires\x20bPaused=true\x20AND\x20setting_lock_duration\x20expired\x20(F-S-25,\x20F-S-26)','applies_to':['compensation_fund_withdraw','pause']},{'id':'MC-S-18','category':'semantic','rule':'discount\x20count\x20<=\x20MAX_DISCOUNT_TOTAL_COUNT\x20('+MAX_DISCOUNT_TOTAL_COUNT+');\x20per-call\x20<=\x20MAX_DISCOUNT_COUNT_ONCE\x20('+MAX_DISCOUNT_COUNT_ONCE+')','applies_to':['discount.count']},{'id':'MC-S-19','category':'semantic','rule':'buy_guard\x20is\x20the\x20ONLY\x20field\x20still\x20mutable\x20post-publish\x20(F-S-26\x20exception)\x20—\x20all\x20other\x20guarded\x20fields\x20are\x20immutable','applies_to':['buy_guard']},{'id':'MC-S-20','category':'authority','rule':'Ownership\x20transfer\x20(builder)\x20is\x20IRREVERSIBLE\x20—\x20new\x20owner\x20inherits\x20permission\x20+\x20compensation_fund\x20+\x20all\x20bindings','applies_to':['builder']}];export const SERVICE_TRANSLATION_VERSION='1.0.0';export function matchSemanticPattern(a){const b=a['toLowerCase']();return SEMANTIC_TO_SCHEMA_RULES['filter'](c=>c['match_keywords']['some'](d=>b['includes'](d['toLowerCase']())));}export function explainServiceCallData(b){const c=[];b['object']===null||b['object']===undefined?c['push']('Operation:\x20CREATE\x20new\x20Service'):c['push']('Operation:\x20MODIFY\x20existing\x20Service\x20at\x20'+b['object']);if(b['description'])c['push']('-\x20Set\x20description:\x20\x22'+b['description']+'\x22');if(b['location'])c['push']('-\x20Set\x20location:\x20'+b['location']);if(b['customer_required'])c['push']('-\x20Customer\x20required\x20fields:\x20['+b['customer_required']['join'](',\x20')+']');if(b['sales']){const e=b['sales'];if(e['op']==='clear')c['push']('-\x20Sales:\x20CLEAR\x20all\x20items');else{if(e['op']==='remove')c['push']('-\x20Sales\x20REMOVE:\x20['+e['sales_name']['join'](',\x20')+']');else{c['push']('-\x20Sales\x20'+e['op']['toUpperCase']()+':\x20'+e['sales']['length']+'\x20item(s)');for(const f of e['sales']){const g=f['wip_hash']?'\x20hash='+f['wip_hash']['slice'](0x0,0x8)+'...':'\x20⚠️NO_HASH';c['push']('\x20\x20\x20\x20•\x20'+f['name']+'\x20price='+(f['price']??'?')+'\x20stock='+(f['stock']??'?')+g);}}}}b['machine']!==undefined&&c['push'](b['machine']===null?'-\x20Machine:\x20unbind\x20(pre-publish\x20only)':'-\x20Machine:\x20bind\x20'+b['machine']);b['buy_guard']!==undefined&&c['push'](b['buy_guard']===null?'-\x20Buy\x20Guard:\x20clear':'-\x20Buy\x20Guard:\x20set\x20'+b['buy_guard']+'\x20[mutable\x20post-publish]');if(b['arbitrations']){const h=b['arbitrations'];h['op']==='clear'?c['push']('-\x20Arbitrations:\x20CLEAR\x20(pre-publish\x20only)'):c['push']('-\x20Arbitrations\x20'+h['op']['toUpperCase']()+':\x20'+h['objects']['length']+'\x20object(s)');}if(b['repositories']){const i=b['repositories'];i['op']==='clear'?c['push']('-\x20Repositories:\x20CLEAR'):c['push']('-\x20Repositories\x20'+i['op']['toUpperCase']()+':\x20'+i['objects']['length']+'\x20object(s)');}if(b['rewards']){const j=b['rewards'];j['op']==='clear'?c['push']('-\x20Rewards:\x20CLEAR\x20(locked\x20by\x20duration)'):c['push']('-\x20Rewards\x20'+j['op']['toUpperCase']()+':\x20'+j['objects']['length']+'\x20object(s)\x20[locked\x20by\x20duration]');}b['order_allocators']!==undefined&&c['push']('-\x20Order\x20Allocators:\x20'+(b['order_allocators']?'configured':'(clear)')+'\x20[immutable\x20post-publish]');if(b['discount']){const k=b['discount'],l=k['discount_type']===0x0?'rates\x20(basis\x20points,\x20per\x2010000)':'minus\x20(direct\x20deduction)';c['push']('-\x20Discount:\x20'+k['name']+'\x20type='+l+'\x20data='+k['data']+'\x20count='+k['count']);}b['pause']!==undefined&&c['push']('-\x20Pause:\x20'+(b['pause']?'PAUSE\x20(block\x20new\x20orders)':'RESUME'));b['publish']&&c['push']('-\x20⚠️\x20PUBLISH\x20(IRREVERSIBLE\x20—\x20locks\x20machine/arbitrations/order_allocators\x20forever)');b['compensation_fund_add']&&c['push']('-\x20Compensation\x20fund\x20deposit:\x20'+b['compensation_fund_add']['balance']+'\x20(internal\x20Balance<T>)');b['compensation_fund_withdraw']&&c['push']('-\x20⚠️\x20Compensation\x20fund\x20withdraw\x20(requires\x20bPaused=true\x20+\x20lock_duration\x20expired)');b['compensation_fund_receive']&&c['push']('-\x20Compensation\x20fund\x20receive\x20(locked\x20by\x20duration)');b['setting_lock_duration_add']!==undefined&&c['push']('-\x20Setting\x20lock\x20duration\x20+'+b['setting_lock_duration_add']+'ms\x20(only-increase)');if(b['order_new']){const m=b['order_new'];c['push']('-\x20⚠️\x20ORDER\x20NEW\x20(8-stage\x20composite\x20flow):'),c['push']('\x20\x20\x20\x20Items:\x20'+m['buy']['items']['length']),c['push']('\x20\x20\x20\x20Total\x20pay:\x20'+m['buy']['total_pay']);if(m['buy']['discount'])c['push']('\x20\x20\x20\x20Discount:\x20'+m['buy']['discount']);c['push']('\x20\x20\x20\x20Stages:\x20pre_check\x20→\x20wip_verify\x20→\x20quote\x20(deducts\x20stock!)\x20→\x20create_order/allocation/progress\x20→\x20return');}return b['builder']&&c['push']('-\x20⚠️\x20TRANSFER\x20ownership\x20to\x20'+b['builder']+'\x20(IRREVERSIBLE)'),b['um']!==undefined&&c['push'](b['um']===null?'-\x20UM:\x20revoke':'-\x20UM:\x20set\x20to\x20'+b['um']),b['owner_receive']&&c['push']('-\x20Owner\x20receive:\x20receive\x20Payment/objects\x20to\x20owner'),c['join']('\x0a');}export function explainField(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='field'&&b['type_name']===a);}export function explainOp(a){return SCHEMA_TO_SEMANTIC_RULES['find'](b=>b['element_type']==='op'&&b['type_name']===a);}export function getConstraintsByCategory(a){return SERVICE_CONSTRAINT_RULES['filter'](b=>b['category']===a);}export function explainServicePermissionIndex(a){if(isServicePermission(a)){const b=getServicePermissionByIndex(a);if(!b)return'Unknown\x20Service\x20permission\x20('+a+')';const c=b['post_publish_mutability']==='immutable'?'\x20[IMMUTABLE\x20post-publish]':b['post_publish_mutability']==='one_shot'?'\x20[ONE-SHOT,\x20irreversible]':b['post_publish_mutability']==='locked_by_duration'?'\x20[locked\x20by\x20setting_lock_duration]':'';return b['name']+'\x20('+a+')\x20—\x20'+b['description']+c;}return'Non-Service\x20permission\x20('+a+')\x20—\x20verify\x20against\x20host\x20object\x27s\x20index\x20range';}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GUARD_TEMPLATES,fillGuardTemplate}from'./guard-templates.js';import{MACHINE_TEMPLATES,fillTemplate as
|
|
1
|
+
import{GUARD_TEMPLATES,fillGuardTemplate}from'./guard-templates.js';import{MACHINE_TEMPLATES,fillTemplate as a226a}from'./machine-templates.js';import{SERVICE_TEMPLATES,fillServiceTemplate}from'./service-templates.js';import{ORDER_TEMPLATES,fillTemplate as a226b}from'./order-templates.js';import{PROGRESS_TEMPLATES,fillProgressTemplate}from'./progress-templates.js';import{ARBITRATION_TEMPLATES,fillTemplate as a226c}from'./arbitration-templates.js';import{TREASURY_TEMPLATES,fillTemplate as a226d}from'./treasury-templates.js';import{PERMISSION_TEMPLATES,fillTemplate as a226e}from'./permission-templates.js';import{PASSPORT_TEMPLATES,fillTemplate as a226f}from'./passport-templates.js';import{ALLOCATION_TEMPLATES,fillTemplate as a226g}from'./allocation-templates.js';import{CONTACT_TEMPLATES,fillTemplate as a226h}from'./contact-templates.js';import{REWARD_TEMPLATES}from'./reward-templates.js';export const TEMPLATE_REGISTRY_VERSION=0x1;export const TEMPLATE_OBJECT_TYPES=['guard','machine','service','order','progress','arbitration','treasury','permission','passport','allocation','reward','contact'];function normalizeParam(a){return{'name':a['name'],'type':a['type'],'description':a['description']??'','required':a['required'],...a['default']!==undefined?{'default':a['default']}:{},...a['constraint']!==undefined?{'constraint':a['constraint']}:{}};}function guardMeta(a){return{'id':a['id'],'object_type':'guard','name':a['name'],'description':a['description'],'scenes':[a['scene_id']],'industries':a['applicable_industries'],'instantiable':!![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}function machineMeta(a){return{'id':a['id'],'object_type':'machine','name':a['name'],'description':a['description'],'scenes':[a['scene_id']],'industries':a['applicable_industries'],'instantiable':!![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}function bodyMeta(a,b,c,d){return{'id':a['id'],'object_type':b,'name':a['name'],'description':a['description'],'scenes':c,'industries':d,'instantiable':!![],'parameters':a['params']['map'](e=>normalizeParam(e))};}function rewardMeta(a){return{'id':a['type'],'object_type':'reward','name':a['name'],'description':a['description'],'scenes':[],'industries':[],'instantiable':![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}let REGISTRY=null,ID_COLLISIONS=[];function buildRegistry(){const a=new Map(),b=[],c=d=>{if(a['has'](d['meta']['id'])){b['push'](d['meta']['id']);return;}a['set'](d['meta']['id'],d);};for(const d of GUARD_TEMPLATES){c({'meta':guardMeta(d),'raw':d,'notes':d['creation_notes']});}for(const e of MACHINE_TEMPLATES){c({'meta':machineMeta(e),'raw':e,'notes':e['creation_notes']});}for(const f of SERVICE_TEMPLATES){c({'meta':bodyMeta(f,'service',f['applicable_scenes'],f['industry_tags']),'raw':f,'notes':f['notes']});}for(const g of ORDER_TEMPLATES){c({'meta':bodyMeta(g,'order',g['applicable_scenes'],g['industry_tags']),'raw':g,'notes':g['notes']});}for(const h of PROGRESS_TEMPLATES){c({'meta':bodyMeta(h,'progress',h['applicable_scenes'],h['industry_tags']),'raw':h,'notes':h['notes']});}for(const i of ARBITRATION_TEMPLATES){c({'meta':bodyMeta(i,'arbitration',i['applicable_scenes'],i['industry_tags']),'raw':i,'notes':i['notes']});}for(const j of TREASURY_TEMPLATES){c({'meta':bodyMeta(j,'treasury',j['applicable_scenes'],j['industry_tags']),'raw':j,'notes':j['notes']});}for(const k of PERMISSION_TEMPLATES){c({'meta':bodyMeta(k,'permission',k['applicable_scenes'],k['industry_tags']),'raw':k,'notes':k['notes']});}for(const l of PASSPORT_TEMPLATES){c({'meta':bodyMeta(l,'passport',l['applicable_scenarios'],l['industry_tags']),'raw':l,'notes':l['notes']});}for(const m of ALLOCATION_TEMPLATES){c({'meta':bodyMeta(m,'allocation',m['applicable_scenes'],m['industry_tags']),'raw':m,'notes':m['notes']});}for(const n of REWARD_TEMPLATES){c({'meta':rewardMeta(n),'raw':n,'guidance':{'guardCondition':n['guardCondition'],'amountRange':n['amountRange'],'allocationStrategy':n['allocationStrategy'],'example':n['example'],'relevantGuardOps':n['relevantGuardOps']}});}for(const o of CONTACT_TEMPLATES){c({'meta':bodyMeta(o,'contact',o['applicable_scenes'],o['industry_tags']),'raw':o,'notes':o['notes']});}return ID_COLLISIONS=b,a;}function registry(){return!REGISTRY&&(REGISTRY=buildRegistry()),REGISTRY;}export function getTemplateIdCollisions(){return registry(),ID_COLLISIONS;}export function getTemplateCounts(){const a=Object['fromEntries'](TEMPLATE_OBJECT_TYPES['map'](b=>[b,0x0]));for(const b of registry()['values']()){a[b['meta']['object_type']]+=0x1;}return a;}export function listTemplates(a){const b=[...registry()['values']()]['map'](c=>c['meta']);return a?b['filter'](c=>c['object_type']===a):b;}export function getTemplateDetail(a){const b=registry()['get'](a);if(!b)return null;return{...b['meta'],'raw':b['raw'],...b['notes']?{'notes':b['notes']}:{},...b['guidance']?{'guidance':b['guidance']}:{}};}export function findTemplateObjectType(a){return registry()['get'](a)?.['meta']['object_type']??null;}export function instantiateTemplate(a,b){const c=registry()['get'](a);if(!c)return{'ok':![],'object_type':null,'template_id':a,'error':'Template\x20not\x20found:\x20'+a+'.\x20Use\x20get_templates\x20without\x20\x27template\x27\x20to\x20list\x20all\x20template\x20ids.'};const d=c['meta']['object_type'];if(!c['meta']['instantiable'])return{'ok':![],'object_type':d,'template_id':a,'error':'Reward\x20templates\x20are\x20guidance-only\x20(prose\x20guard\x20conditions)\x20and\x20cannot\x20be\x20'+'instantiated\x20into\x20executable\x20JSON.\x20Use\x20the\x20guidance\x20payload\x20to\x20design\x20the\x20'+'Reward\x20+\x20Guard\x20manually.','guidance':c['guidance']};switch(d){case'guard':{const e=fillGuardTemplate(a,b);if(!e['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':e['error'],...e['missing']?{'missing_params':e['missing']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':{'table':e['table'],'root':e['root']},...c['notes']?{'notes':c['notes']}:{}};}case'machine':{const f=a226a(a,b);if(!f['success'])return{'ok':![],'object_type':d,'template_id':a,'error':f['validation_errors']?.['join'](';\x20')??'Machine\x20template\x20fill\x20failed',...f['missing_params']?{'missing_params':f['missing_params']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':{'nodes':f['filled_nodes'],'pairs':f['filled_pairs']},...c['notes']?{'notes':c['notes']}:{}};}case'service':{const g=fillServiceTemplate(a,b);if(!g['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':g['error']??'Service\x20template\x20fill\x20failed',...g['missing_required']?{'missing_params':g['missing_required']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':g['body'],...c['notes']?{'notes':c['notes']}:{}};}case'order':case'arbitration':case'treasury':case'permission':case'passport':case'allocation':case'progress':case'contact':{const h=fillBodyTemplate(d,a,b);if(!h['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':h['error']};return{'ok':!![],'object_type':d,'template_id':a,'body':h['body'],...c['notes']?{'notes':c['notes']}:{}};}default:return{'ok':![],'object_type':d,'template_id':a,'error':'Instantiation\x20not\x20supported\x20for\x20object_type\x20\x27'+d+'\x27'};}}function fillBodyTemplate(a,b,c){switch(a){case'order':return a226b(b,c);case'arbitration':return a226c(b,c);case'treasury':return a226d(b,c);case'permission':return a226e(b,c);case'passport':return a226f(b,c);case'allocation':return a226g(b,c);case'progress':return fillProgressTemplate(b,c);case'contact':return a226h(b,c);default:return{'ok':![],'error':'No\x20body-template\x20fill\x20for\x20\x27'+a+'\x27'};}}
|