@wowok/agent-mcp 3.2.3 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/communication/proof-reuse.d.ts +9 -0
- package/dist/communication/proof-reuse.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +1 -0
- package/dist/knowledge/template-loader.d.ts +1 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.d.ts +1 -0
- package/dist/playbooks/service-build/service-quote.spec.js +1 -0
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +4 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/query/bi.d.ts +26 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +1 -0
- package/dist/schemas/bridge_operation.output.json +1 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/local_cache_operation.output.json +1 -0
- package/dist/schemas/local_history_operation.output.json +1 -0
- package/dist/schemas/local_info_operation.output.json +1 -0
- package/dist/schemas/local_mark_operation.output.json +1 -0
- package/dist/schemas/onchain_operations.output.json +1 -0
- package/dist/schemas/onchain_operations.schema.json +3 -3
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_machine.schema.json +1 -1
- package/dist/schemas/onchain_operations_service.schema.json +1 -1
- package/dist/schemas/query_toolkit.output.json +91 -7
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findScene,inferSceneFromFlow}from'./machine-ledger.js';export const MACHINE_TEMPLATES=[{'id':'tpl_machine_ecommerce_standard','scene_id':'ecommerce_standard','name':'Standard\x20E-commerce\x20Flow','description':'Linear\x20e-commerce\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive\x20->\x20Complete.\x20'+'Payment\x20is\x20handled\x20by\x20the\x20Service\x20buy\x20flow\x20(direct\x20or\x20Passport-gated\x20purchase)\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Reaching\x20Complete\x20does\x20NOT\x20move\x20funds\x20—\x20allocation\x20is\x20a\x20separate\x20submitted\x20call\x20and\x20allocation.move\x20has\x20no\x20timer,\x20'+'so\x20a\x20keeper\x20(merchant\x20or\x20buyer-side\x20trigger)\x20must\x20fire\x20it\x20or\x20the\x20order\x20stays\x20settled-but-unpaid.\x20Recommended\x20baseline\x20for\x20new\x20merchants.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20address\x20or\x20name\x20(must\x20have\x20custom\x20indices\x20defined)','constraint':'Permission\x20must\x20already\x20be\x20created;\x20index\x202\x20(merchant)\x20and\x20index\x203\x20(admin)\x20recommended'},{'name':'ship_forward_name','type':'string','required':!![],'default':'Ship','description':'Forward\x20name\x20for\x20shipping\x20step','constraint':'Must\x20be\x20<64\x20BCS\x20bytes;\x20only\x20letters/digits/underscore'},{'name':'receive_forward_name','type':'string','required':!![],'default':'Receive','description':'Forward\x20name\x20for\x20customer\x20receipt\x20confirmation'},{'name':'complete_node_name','type':'string','required':!![],'default':'Complete','description':'Terminal\x20node\x20name\x20triggering\x20fund\x20allocation'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Goods\x20dispatched'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'${complete_node_name}','description':'Terminal:\x20triggers\x20allocation'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'${ship_forward_name}','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'${receive_forward_name}','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Received','next_node':'${complete_node_name}','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]}],'required_guards':[],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'${complete_node_name}','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address'}],'forkable_fields':['node_names','forward_names','thresholds','additional_branches'],'applicable_industries':['ecommerce','retail'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M2-01','R-M3-02','R-M4-01'],'creation_notes':['Build\x20order:\x20Permission\x20->\x20Machine\x20(unpublished)\x20->\x20Guards\x20->\x20Bind\x20guards\x20->\x20Publish\x20->\x20Bind\x20to\x20Service','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Entry\x20point:\x20prev_node=\x27\x27\x20(empty\x20string)\x20targets\x20\x27Paid\x27\x20—\x20at\x20least\x20one\x20Pair\x20must\x20exist\x20with\x20empty\x20prev_node','If\x20using\x20P16\x20circular\x20reference\x20for\x20Service,\x20use\x20name\x20not\x20address\x20(Service\x20not\x20yet\x20published)'],'example_use_case':'Small\x20e-commerce\x20shop\x20selling\x20camera\x20accessories.\x20Linear\x20flow\x20with\x20no\x20exceptions.\x20'+'Funds\x20allocated\x20to\x20merchant\x20personal\x20address\x20on\x20Complete.','publish_checklist':['All\x204\x20nodes\x20have\x20at\x20least\x20one\x20outgoing\x20Forward\x20(except\x20terminal)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','permissionIndex\x20values\x20match\x20Permission\x20object\x20indices','Test\x20Progress\x20run\x20on\x20testnet','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_ecommerce_exceptions','scene_id':'ecommerce_with_exceptions','name':'E-commerce\x20Flow\x20with\x20Exception\x20Branches','description':'Multi-path\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive/Lost/Return.\x20Lost\x20uses\x20dual-sig\x20(threshold=2).\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Return\x20path\x20opens\x20Refund\x20->\x20Complete.\x20Competing\x20pairs\x20first-wins.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'lost_threshold','type':'number','required':!![],'default':'2','description':'Threshold\x20for\x20dual-sig\x20on\x20Lost\x20node','constraint':'Must\x20be\x202\x20(customer\x20+\x20merchant)'},{'name':'arbitration_ref','type':'arbitration_ref','required':![],'description':'Arbitration\x20object\x20if\x20Lost\x20escalates\x20to\x20arbitration'},{'name':'time_guard_days','type':'number','required':!![],'default':'10','description':'Days\x20before\x20auto-complete\x20trigger\x20(time\x20guard)','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-30'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return/refund\x20node\x20in\x20the\x20exception\x20branch'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped'},{'name':'Received'},{'name':'Lost'},{'name':'Return'},{'name':'Refund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Lost','threshold':'${lost_threshold}','forwards':[{'name':'CustomerReport','weight':0x1,'named_operator':''},{'name':'MerchantConfirm','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Return','threshold':0x1,'forwards':[{'name':'RequestReturn','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Complete','threshold':0x1,'forwards':[{'name':'TimeGuard','weight':0x1,'permission_index':0x3,'guard':'time_guard_${time_guard_days}_days'},{'name':'MerchantFinish','weight':0x1,'permission_index':0x2}]},{'prev_node':'Return','next_node':'Refund','threshold':0x1,'forwards':[{'name':'IssueRefund','weight':0x1,'permission_index':0x2}]},{'prev_node':'Refund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CloseReturn','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantConfirm','purpose':'Dual-sig\x20on\x20Lost\x20node'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeGuard','purpose':'Time\x20lock\x20${time_guard_days}\x20days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role'},{'index':0x3,'name':'admin','description':'Admin\x20/\x20time-guard\x20trigger'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Full\x20allocation\x20to\x20merchant\x20on\x20normal\x20completion'},{'name':'RefundAllocation','trigger_node':'Refund','description':'Full\x20refund\x20to\x20customer\x20on\x20return'},{'name':'LostAllocation','trigger_node':'Lost','description':'Optional:\x20partial\x20refund\x20or\x20escrow\x20(depends\x20on\x20policy)'}],'forkable_fields':['node_names','branch_conditions','time_guard_days','lost_threshold'],'applicable_industries':['ecommerce','logistics'],'relevant_risks':['R-M1-01','R-M1-03','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M3-05','R-M4-01','R-M5-03'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Competing\x20Pairs\x20(Shipped\x20->\x20Received/Lost/Return)\x20are\x20mutually\x20exclusive\x20—\x20first\x20threshold\x20met\x20wins','Lost\x20node\x20threshold=2\x20means\x20BOTH\x20customer\x20and\x20merchant\x20Forwards\x20must\x20execute','TimeGuard\x20must\x20use\x20context(Clock)\x20>=\x20progress.current_time\x20+\x20duration\x20(progress.move\x20exposes\x20current_time,\x20refreshed\x20on\x20every\x20node\x20transition\x20—\x20there\x20is\x20no\x20entry_time\x20field)','If\x20Lost\x20escalates\x20to\x20arbitration,\x20bind\x20arbitration_usage_guard\x20on\x20Lost\x20forward','Refund\x20Allocation\x20must\x20use\x20sharing.who=OrderHolder\x20(refund\x20to\x20customer,\x20NOT\x20merchant)'],'example_use_case':'Mid-size\x20e-commerce\x20with\x207-day\x20return\x20policy\x20and\x20dispute\x20handling.\x20'+'Lost\x20claims\x20require\x20customer+merchant\x20dual\x20confirmation.','publish_checklist':['All\x20competing\x20Pairs\x20tested:\x20verify\x20first-wins\x20semantics\x20on\x20testnet','Lost\x20dual-sig\x20tested:\x20incomplete\x20signatures\x20do\x20not\x20advance','TimeGuard\x20Clock\x20query\x20verified\x20(testnet)','All\x20three\x20Allocators\x20tested\x20with\x20correct\x20sharing.who','Arbitration\x20binding\x20(if\x20any)\x20verified\x20via\x20gen_passport']},{'id':'tpl_machine_rental','scene_id':'rental_standard','name':'Equipment\x20Rental\x20Flow','description':'Rental\x20flow:\x20DepositPaid\x20(entry)\x20->\x20Pickup\x20->\x20In\x20Use\x20->\x20Return\x20->\x20Refund\x20Deposit.\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-deposit\x20state.\x20'+'Separates\x20deposit\x20from\x20rental\x20fee\x20(two\x20Allocators).\x20Damage\x20report\x20via\x20retained_submission.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'deposit_amount','type':'number','required':!![],'description':'Deposit\x20amount\x20in\x20smallest\x20WOW\x20unit','constraint':'Must\x20equal\x20order.amount\x20field;\x20verify\x20via\x20Guard\x20query'},{'name':'damage_inspection_node','type':'string','required':!![],'default':'DamageCheck','description':'Name\x20of\x20the\x20node\x20where\x20damage\x20inspection\x20occurs'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return\x20node\x20after\x20damage\x20check\x20fails'}],'example_nodes':[{'name':'DepositPaid','description':'Entry:\x20deposit\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'PickedUp'},{'name':'InUse'},{'name':'Return'},{'name':'DamageCheck'},{'name':'DepositRefund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'DepositPaid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'DepositPaid','next_node':'PickedUp','threshold':0x1,'forwards':[{'name':'Pickup','weight':0x1,'named_operator':'','permission_index':0x2}]},{'prev_node':'PickedUp','next_node':'InUse','threshold':0x1,'forwards':[{'name':'StartUse','weight':0x1,'named_operator':''}]},{'prev_node':'InUse','next_node':'Return','threshold':0x1,'forwards':[{'name':'ReturnItem','weight':0x1,'named_operator':''}]},{'prev_node':'Return','next_node':'DamageCheck','threshold':0x1,'forwards':[{'name':'Inspect','weight':0x1,'permission_index':0x2,'retained_submission':'damage_report'}]},{'prev_node':'Return','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CleanReturn','weight':0x1,'permission_index':0x2}]},{'prev_node':'DamageCheck','next_node':'DepositRefund','threshold':0x1,'forwards':[{'name':'DeductDamage','weight':0x1,'permission_index':0x2}]},{'prev_node':'DepositRefund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Close','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'Inspect','purpose':'Optional:\x20damage\x20evidence\x20proof\x20(photo,\x20video)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Rental\x20provider'}],'required_allocators':[{'name':'RentalFeeAllocation','trigger_node':'Complete','description':'Rental\x20fee\x20to\x20merchant'},{'name':'DepositRefundAllocation','trigger_node':'DepositRefund','description':'Remaining\x20deposit\x20to\x20customer\x20(OrderHolder\x20sharing.who)'},{'name':'DamageDeductionAllocation','trigger_node':'DamageCheck','description':'Damage\x20deduction\x20to\x20merchant'}],'forkable_fields':['deposit_amount','damage_node_logic','additional_inspection_steps'],'applicable_industries':['rental','equipment','vehicle'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M4-01','R-M5-02'],'creation_notes':['First\x20node\x20\x27DepositPaid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20deposit\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Reserve\x27\x20or\x20\x27PayDeposit\x27\x20nodes\x20needed\x20—\x20reservation\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Damage\x20report\x20uses\x20retained_submission\x20—\x20values\x20stored\x20uniquely\x20by\x20(current_node,\x20next_node,\x20forward_name)','Two\x20competing\x20Pairs\x20at\x20Return\x20node:\x20DamageCheck\x20vs\x20Complete\x20(clean\x20return)','DamageDeduction\x20Allocation\x20uses\x20sharing.who=Entity\x20(merchant),\x20not\x20OrderHolder'],'example_use_case':'Camera\x20equipment\x20rental:\x20customer\x20pays\x201000\x20WOW\x20deposit,\x20returns\x20equipment,\x20'+'merchant\x20inspects.\x20If\x20damaged,\x20200\x20WOW\x20deducted;\x20otherwise\x20full\x20refund.','publish_checklist':['Deposit\x20Guard\x20tested\x20(testnet)\x20with\x20valid/invalid\x20amounts','Damage\x20report\x20retained_submission\x20stored\x20correctly\x20(query\x20progress_history)','Both\x20Return\x20branches\x20tested\x20(DamageCheck\x20+\x20CleanReturn)','All\x20three\x20Allocators\x20verified\x20with\x20correct\x20sharing.who']},{'id':'tpl_machine_dual_signature','scene_id':'dual_signature','name':'Dual-Signature\x20Consensus\x20Flow','description':'Critical\x20node\x20requires\x20both\x20customer\x20+\x20merchant\x20confirmation.\x20threshold=2\x20with\x20two\x20Forwards\x20(weight=1\x20each).\x20'+'Customer\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder);\x20merchant\x20uses\x20permissionIndex=2.','recommended_patterns':['P-M-AND'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'critical_node_name','type':'string','required':!![],'default':'Approve','description':'Node\x20requiring\x20dual-sig'},{'name':'next_node_after_approval','type':'string','required':!![],'default':'Execute','description':'Name\x20of\x20the\x20node\x20that\x20follows\x20after\x20dual-signature\x20approval'}],'example_nodes':[{'name':'Initiated'},{'name':'${critical_node_name}','description':'Dual-sig\x20required\x20here'},{'name':'${next_node_after_approval}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Initiated','threshold':0x1,'forwards':[{'name':'Initiate','weight':0x1,'named_operator':''}]},{'prev_node':'Initiated','next_node':'${critical_node_name}','threshold':0x1,'forwards':[{'name':'Submit','weight':0x1,'named_operator':''}]},{'prev_node':'${critical_node_name}','next_node':'${next_node_after_approval}','threshold':0x2,'forwards':[{'name':'CustomerApprove','weight':0x1,'named_operator':'','guard':'customer_identity_guard'},{'name':'MerchantApprove','weight':0x1,'permission_index':0x2,'guard':'merchant_identity_guard'}]},{'prev_node':'${next_node_after_approval}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'CustomerApprove','purpose':'Verify\x20customer\x20identity\x20(order.owner)'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantApprove','purpose':'Verify\x20merchant\x20identity\x20(permission\x20holder)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20approval'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20on\x20dual-sig\x20completion'}],'forkable_fields':['critical_node_name','additional_approvers','guard_logic'],'applicable_industries':['ecommerce','service','logistics','escrow'],'relevant_risks':['R-M1-08','R-M2-01','R-M3-02','R-M3-04'],'creation_notes':['threshold=2\x20means\x20BOTH\x20Forwards\x20must\x20execute\x20to\x20advance\x20(AND\x20semantics)','Customer\x20Forward\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder)','Merchant\x20Forward\x20uses\x20permissionIndex=2','If\x20either\x20party\x20fails\x20to\x20sign,\x20workflow\x20stalls\x20—\x20consider\x20adding\x20timeout\x20Guard'],'example_use_case':'High-value\x20order\x20(e.g.\x20real\x20estate\x20transaction)\x20requiring\x20both\x20buyer\x20and\x20seller\x20confirmation.','publish_checklist':['Both\x20Forward\x20identities\x20tested\x20on\x20testnet','Verify\x20partial\x20signature\x20does\x20NOT\x20advance\x20(threshold=2)','Guards\x20correctly\x20distinguish\x20customer\x20vs\x20merchant\x20identity']},{'id':'tpl_machine_weighted_voting','scene_id':'weighted_voting','name':'Weighted\x20Voting\x20Flow','description':'Multi-party\x20voting\x20with\x20unequal\x20weights.\x20threshold=100,\x20chief\x20weight=60,\x20members\x20weight=40\x20total.\x20'+'Each\x20member\x27s\x20weight\x20extracted\x20via\x20Guard\x20query\x20from\x20Arbitration\x20object.','recommended_patterns':['P-M-VOTE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'arbitration_ref','type':'arbitration_ref','required':!![],'description':'Arbitration\x20object\x20storing\x20voter\x20weights'},{'name':'threshold_total','type':'number','required':!![],'default':'100','description':'Total\x20weight\x20threshold\x20for\x20decision'},{'name':'chief_weight','type':'number','required':!![],'default':'60','description':'Weight\x20assigned\x20to\x20the\x20chief\x20voter\x20(out\x20of\x20100)'},{'name':'member_count','type':'number','required':!![],'default':'5','description':'Number\x20of\x20voting\x20members\x20(excluding\x20chief)'}],'example_nodes':[{'name':'VoteOpened'},{'name':'Voting'},{'name':'Approved'},{'name':'Rejected'}],'example_pairs':[{'prev_node':'','next_node':'VoteOpened','threshold':0x1,'forwards':[{'name':'OpenVote','weight':0x1,'permission_index':0x3}]},{'prev_node':'VoteOpened','next_node':'Voting','threshold':0x1,'forwards':[{'name':'StartVoting','weight':0x1,'permission_index':0x3}]},{'prev_node':'Voting','next_node':'Approved','threshold':'${threshold_total}','forwards':[{'name':'ChiefVote','weight':'${chief_weight}','permission_index':0x2,'guard':'arb_voting_guard','retained_submission':'chief_vote_record'},{'name':'MemberVote','weight':0x8,'named_operator':'member','guard':'arb_voting_guard','retained_submission':'member_vote_record'}]},{'prev_node':'Voting','next_node':'Rejected','threshold':0x1,'forwards':[{'name':'TimeoutReject','weight':0x1,'permission_index':0x3,'guard':'voting_timeout_guard'}]}],'required_guards':[{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'ChiefVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20extract\x20weight\x20from\x20Arbitration'},{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'MemberVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20prevent\x20double-vote'}],'required_permissions':[{'index':0x2,'name':'chief','description':'Chief\x20voter\x20(high\x20weight)'},{'index':0x3,'name':'admin','description':'Vote\x20opener\x20/\x20timeout\x20trigger'}],'required_allocators':[{'name':'ApprovedAllocation','trigger_node':'Approved','description':'Allocation\x20on\x20approval'}],'forkable_fields':['weights','voter_count','timeout_days'],'applicable_industries':['governance','arbitration','dao'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-M5-04','R-X1-14'],'creation_notes':['Member\x20weight\x20must\x20be\x20extracted\x20dynamically\x20via\x20Guard\x20query\x20(not\x20hardcoded\x20in\x20Forward)','Guard\x20MUST\x20check\x20arb.voted\x20has\x20[Signer]\x20to\x20prevent\x20double-voting\x20(R-X1-14\x20CRITICAL)','Competing\x20Pair:\x20Approved\x20vs\x20Rejected\x20(timeout)\x20—\x20first-wins','Voting\x20weight\x20is\x20query-derived;\x20Forward\x20weight\x20field\x20is\x20just\x20session\x20counter'],'example_use_case':'Arbitration\x20panel:\x201\x20chief\x20(weight\x2060)\x20+\x205\x20members\x20(weight\x208\x20each\x20=\x2040).\x20'+'Need\x20total\x20>=\x20100\x20to\x20approve.\x20Reject\x20after\x2072h\x20timeout.','publish_checklist':['Arbitration\x20object\x20created\x20and\x20tested','Double-vote\x20prevention\x20verified\x20(try\x20voting\x20twice\x20—\x20should\x20fail)','Weight\x20extraction\x20tested\x20with\x20different\x20voter\x20configurations','Timeout\x20Guard\x20(Clock)\x20verified\x20on\x20testnet']},{'id':'tpl_machine_cross_machine','scene_id':'cross_machine_supply_chain','name':'Cross-Machine\x20Supply\x20Chain','description':'Decomposed\x20supply\x20chain\x20across\x20multiple\x20Machines.\x20Machine\x20B\x27s\x20Forward\x20Guard\x20queries\x20Machine\x20A\x27s\x20Progress\x20'+'via\x20convert_witness=100\x20to\x20verify\x20upstream\x20completion\x20before\x20advancing.','recommended_patterns':['P-M-CROSS-MACHINE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'machine_a_id','type':'machine_ref','required':!![],'description':'Upstream\x20Machine\x20(must\x20already\x20be\x20published)','constraint':'Machine\x20A\x20must\x20be\x20published\x20BEFORE\x20Machine\x20B\x27s\x20Guard\x20can\x20reference\x20its\x20Progress\x20'+'(Progress\x20creation\x20verifies\x20the\x20bound\x20Machine\x20is\x20published\x20—\x20see\x2006\x20§14.6)'},{'name':'machine_a_complete_node','type':'string','required':!![],'default':'Complete','description':'Target\x20node\x20name\x20in\x20Machine\x20A\x20to\x20verify'},{'name':'machine_b_permission','type':'permission_ref','required':!![],'description':'Machine\x20B\x27s\x20Permission\x20object'}],'example_nodes':[{'name':'UpstreamVerified'},{'name':'Production'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'UpstreamVerified','threshold':0x1,'forwards':[{'name':'VerifyUpstream','weight':0x1,'permission_index':0x2,'guard':'upstream_progress_guard','retained_submission':'upstream_progress_id'}]},{'prev_node':'UpstreamVerified','next_node':'Production','threshold':0x1,'forwards':[{'name':'StartProduction','weight':0x1,'permission_index':0x2}]},{'prev_node':'Production','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'VerifyUpstream','purpose':'Query\x20Machine\x20A\x27s\x20Progress:\x20verify\x20it\x20reached\x20${machine_a_complete_node}'}],'required_permissions':[{'index':0x2,'name':'manufacturer','description':'Machine\x20B\x20operator'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20Machine\x20B\x27s\x20merchant'}],'forkable_fields':['upstream_machine_ref','verification_node_name'],'applicable_industries':['manufacturing','logistics','retail','supply_chain'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-04','R-M5-04','R-M5-05','R-M5-06'],'creation_notes':['Machine\x20A\x20MUST\x20be\x20published\x20before\x20Machine\x20B\x20(dependency\x20order)','Guard\x20uses\x20convert_witness=100\x20to\x20convert\x20submitted\x20Order/Progress\x20ID\x20into\x20queryable\x20Progress\x20object','Cross-Machine\x20dependency\x20is\x20one-way\x20(no\x20cycles)','retained_submission\x20stores\x20upstream\x20Progress\x20ID\x20for\x20later\x20audit','Multi-party\x20chain:\x20extend\x20pattern\x20with\x20Machine\x20C,\x20D,\x20...\x20(each\x20independently\x20published)','Dependency\x20verification:\x20enforced\x20when\x20the\x20Progress\x20object\x20is\x20created\x20(creation\x20checks\x20the\x20bound\x20Machine\x20is\x20published\x20—\x20see\x2006\x20§14.6)'],'example_use_case':'Supplier\x20(Machine\x20A)\x20->\x20Manufacturer\x20(Machine\x20B)\x20->\x20Retailer\x20(Machine\x20C).\x20'+'Manufacturer\x20cannot\x20start\x20production\x20until\x20supplier\x27s\x20Progress\x20reaches\x20\x27Complete\x27.','publish_checklist':['Machine\x20A\x20already\x20published\x20on-chain\x20(verify\x20via\x20onchain_objects)','Cross-Machine\x20Guard\x20tested\x20with\x20valid/invalid\x20upstream\x20Progress\x20IDs','retained_submission\x20verified\x20(query\x20progress_history\x20for\x20upstream_progress_id)','Independent\x20testing:\x20run\x20Machine\x20A\x20to\x20Complete,\x20then\x20attempt\x20Machine\x20B\x27s\x20VerifyUpstream']},{'id':'tpl_machine_privacy_delivery','scene_id':'privacy_delivery','name':'Privacy-Preserving\x20Delivery\x20Flow','description':'Customer\x20submits\x20privacy\x20data\x20via\x20Messenger\x20(encrypted,\x20off-chain).\x20Chain\x20stores\x20only\x20Merkle\x20Root\x20Proof.\x20'+'Guard\x20verifies\x20Proof\x20signature\x20+\x20timestamp\x20+\x20service\x20binding.\x20Uses\x20tpl_forward_privacy_delivery_proof\x20(strict\x20mode).','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'proof_node_name','type':'string','required':!![],'default':'ProofSubmitted','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20proof\x20is\x20submitted'},{'name':'delivery_node_name','type':'string','required':!![],'default':'DeliveryConfirmed','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20confirmation\x20occurs'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'${proof_node_name}','description':'Customer\x20submits\x20Proof\x20via\x20Messenger'},{'name':'${delivery_node_name}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'${proof_node_name}','threshold':0x1,'forwards':[{'name':'SubmitProof','weight':0x1,'named_operator':'','guard':'tpl_forward_privacy_delivery_proof','retained_submission':'proof_address'}]},{'prev_node':'${proof_node_name}','next_node':'${delivery_node_name}','threshold':0x1,'forwards':[{'name':'ConfirmDelivery','weight':0x1,'permission_index':0x2}]},{'prev_node':'${delivery_node_name}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'SubmitProof','purpose':'Verify\x20Proof:\x20signer=proof.signer\x20∧\x20proof.time>order.time\x20∧\x20order.service=service'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20confirms\x20delivery'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20merchant\x20after\x20delivery\x20confirmation'}],'forkable_fields':['proof_node_name','delivery_node_name','additional_evidence_steps'],'applicable_industries':['ecommerce','logistics','privacy_service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M5-03'],'creation_notes':['Use\x20strict\x20mode\x20tpl_forward_privacy_delivery_proof\x20(3\x20conditions:\x20Signer\x20+\x20time\x20+\x20service\x20binding)','submitChainProof\x20about_address\x20=\x20peerAddress\x20(NOT\x20sessionId)','order_id\x20passed\x20via\x20description\x20string\x20field\x20(not\x20about_address)','Guard\x20table\x20item\x20name\x20MUST\x20be\x20<64\x20BCS\x20bytes\x20(MAX_NAME_LENGTH=64)','retained_submission\x20stores\x20Proof\x20address\x20for\x20arbitration\x20query','Proof\x20MUST\x20be\x20generated\x20by\x20messenger.submitChainProof\x20(not\x20manual)'],'example_use_case':'Customer\x20sends\x20delivery\x20address\x20via\x20Messenger\x20(encrypted).\x20Chain\x20stores\x20only\x20Proof.\x20'+'Merchant\x20verifies\x20Proof,\x20then\x20confirms\x20delivery.','publish_checklist':['Strict\x20mode\x20Guard\x20tested:\x203\x20conditions\x20verified\x20individually','Messenger\x20integration\x20tested\x20end-to-end\x20(submit\x20+\x20verify)','retained_submission\x20stored\x20Proof\x20address\x20queryable\x20from\x20progress_history','Guard\x20table\x20item\x20name\x20length\x20validated\x20(<64\x20BCS\x20bytes)']},{'id':'tpl_machine_reward','scene_id':'reward_incentive','name':'Reward\x20Incentive\x20Flow','description':'Customer\x20triggers\x20Reward\x20claim\x20at\x20specific\x20node.\x20Guard\x20prevents\x20double-claim\x20via\x20query_reward_record_count==0.\x20'+'Reward\x20object\x20independent\x20of\x20Allocator.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'reward_ref','type':'reward_ref','required':!![],'description':'Reward\x20object\x20address\x20(must\x20be\x20already\x20created)'},{'name':'claim_node_name','type':'string','required':!![],'default':'ClaimReward','description':'Name\x20of\x20the\x20node\x20where\x20reward\x20claims\x20are\x20triggered'}],'example_nodes':[{'name':'Eligible'},{'name':'${claim_node_name}'},{'name':'Rewarded'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Eligible','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Eligible','next_node':'${claim_node_name}','threshold':0x1,'forwards':[{'name':'TriggerClaim','weight':0x1,'named_operator':'','guard':'reward_anti_double_guard','retained_submission':'claim_record'}]},{'prev_node':'${claim_node_name}','next_node':'Rewarded','threshold':0x1,'forwards':[{'name':'IssueReward','weight':0x1,'permission_index':0x3}]},{'prev_node':'Rewarded','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_reward_one_time_claim','bound_to_forward':'TriggerClaim','purpose':'Verify\x20query_reward_record_count==0\x20to\x20prevent\x20double-claim'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Completes\x20flow'},{'index':0x3,'name':'reward_admin','description':'Issues\x20reward\x20tokens'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Standard\x20allocation\x20(separate\x20from\x20Reward)'}],'forkable_fields':['claim_node_name','additional_reward_conditions'],'applicable_industries':['ecommerce','subscription','education','loyalty'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-X1-14'],'creation_notes':['Reward\x20Guard\x20MUST\x20check\x20query_reward_record_count\x20==\x200\x20(R-X1-14\x20CRITICAL)','Reward\x20is\x20INDEPENDENT\x20of\x20Allocator\x20—\x20both\x20can\x20fire\x20on\x20different\x20nodes','Reward\x20object\x20must\x20be\x20created\x20BEFORE\x20publishing\x20this\x20Machine','retained_submission\x20stores\x20claim\x20record\x20for\x20audit'],'example_use_case':'Loyalty\x20program:\x20after\x20customer\x20completes\x205\x20orders,\x20eligible\x20to\x20claim\x20reward\x20token.\x20'+'Anti-double-claim\x20Guard\x20ensures\x20one\x20claim\x20per\x20customer.','publish_checklist':['Reward\x20object\x20already\x20created\x20and\x20tested','Anti-double-claim\x20Guard\x20tested:\x20claim\x20twice\x20should\x20fail\x20on\x20second\x20attempt','retained_submission\x20verified\x20(claim_record\x20queryable)']},{'id':'tpl_machine_wonder_feedback','scene_id':'wonder_feedback','name':'Wonder\x20Feedback\x20Flow\x20(Post-Completion\x20Rating)','description':'Post-completion\x20rating\x20flow:\x20Paid\x20(entry)\x20→\x20Shipped\x20→\x20Received\x20→\x20Completed\x20→\x20{Wonder\x20|\x20NoWonder}.\x20'+'After\x20the\x20order\x20reaches\x20\x27Completed\x27\x20(terminal\x20business\x20state,\x20funds\x20already\x20allocated\x20to\x20merchant),\x20'+'the\x20OrderHolder\x20(namedOperator=\x27\x27)\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20'+'(negative\x20review).\x20A\x20bound\x20Reward\x20object\x27s\x20claim_guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27\x20before\x20'+'paying\x20out\x20—\x20reward\x20claim\x20needs\x20NO\x20Permission.\x20Dispute\x20is\x20NEVER\x20modeled\x20here:\x20it\x20flows\x20through\x20'+'the\x20Order\x27s\x20dispute\x20flow\x20→\x20Arb\x20case\x20→\x20arbiter\x20ruling\x20→\x20fee\x20withdrawal,\x20fully\x20off-Machine.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20(index\x202\x20=\x20merchant,\x20index\x203\x20=\x20admin)'},{'name':'wonder_node_name','type':'string','required':!![],'default':'wonder','description':'Node\x20name\x20for\x20positive\x20feedback\x20(praise)\x20terminal','constraint':'Must\x20match\x20/^(wonder|praise|thumbs_up)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'no_wonder_node_name','type':'string','required':!![],'default':'no_wonder','description':'Node\x20name\x20for\x20negative\x20feedback\x20(complaint)\x20terminal','constraint':'Must\x20match\x20/^(no_wonder|complain|thumbs_down)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'reward_ref','type':'reward_ref','required':![],'description':'Reward\x20object\x20address\x20(optional).\x20If\x20bound,\x20its\x20claim_guard\x20should\x20verify\x20Progress.current\x20==\x20wonder_node_name\x20AND\x20order.holder\x20==\x20signer.\x20Use\x20wonder_praise\x20or\x20wonder_feedback\x20reward\x20template.'},{'name':'rating_time_limit_days','type':'number','required':![],'default':'30','description':'Days\x20after\x20completion\x20during\x20which\x20the\x20customer\x20can\x20rate\x20(enforced\x20by\x20Guard\x20on\x20Praise/Complain\x20forwards\x20via\x20context(Clock))','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-90'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Merchant\x20dispatched\x20goods/service'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'Completed','description':'Terminal\x20business\x20state\x20—\x20triggers\x20merchant\x20Allocation.\x20Funds\x20settled.'},{'name':'${wonder_node_name}','description':'Positive\x20feedback\x20terminal\x20(praise).\x20OrderHolder-only.\x20Reward-eligible.'},{'name':'${no_wonder_node_name}','description':'Negative\x20feedback\x20terminal\x20(complaint).\x20OrderHolder-only.\x20Optional\x20Repository\x20write\x20for\x20analytics.'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Completed','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Completed','next_node':'${wonder_node_name}','threshold':0x1,'forwards':[{'name':'Praise','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]},{'prev_node':'Completed','next_node':'${no_wonder_node_name}','threshold':0x1,'forwards':[{'name':'Complain','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Praise','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Complain','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish\x20(NOT\x20for\x20rating\x20—\x20rating\x20is\x20OrderHolder-only\x20via\x20named_operator=\x27\x27)'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'Completed','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address.\x20Fires\x20at\x20Completion\x20—\x20NOT\x20at\x20Wonder/NoWonder\x20(those\x20are\x20reputation-only\x20terminals\x20with\x20no\x20fund\x20flow).'}],'forkable_fields':['wonder_node_name','no_wonder_node_name','rating_time_limit_days','additional_rating_nodes'],'applicable_industries':['ecommerce','service','rental','subscription','education'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M1-11','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-03'],'creation_notes':['DISPUTE\x20INDEPENDENCE:\x20This\x20Machine\x20MUST\x20NOT\x20contain\x20\x27disputed\x27,\x20\x27refunded\x27,\x20\x27arb\x27,\x20\x27arbitration\x27\x20nodes\x20(R-M1-11\x20critical).\x20Disputes\x20are\x20filed\x20off-Machine\x20—\x20through\x20the\x20Arbitration\x20dispute\x20flow\x20on\x20the\x20order\x20and\x20arbitration\x20objects.','Build\x20order:\x20Permission\x20→\x20Machine\x20(unpublished)\x20→\x20Guards\x20→\x20Bind\x20guards\x20→\x20Publish\x20→\x20Bind\x20to\x20Service\x20→\x20Bind\x20Reward\x20(optional)','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Wonder/NoWonder\x20forwards\x20have\x20named_operator=\x27\x27\x20(empty)\x20—\x20this\x20delegates\x20to\x20the\x20OrderHolder\x20(customer).\x20No\x20Permission\x20index\x20needed\x20for\x20rating.','Completed\x20node\x20triggers\x20MerchantAllocation\x20—\x20funds\x20are\x20settled\x20BEFORE\x20the\x20rating\x20window\x20opens.\x20Rating\x20does\x20NOT\x20affect\x20fund\x20flow.','Competing\x20Pair:\x20Praise\x20vs\x20Complain\x20(first-wins)\x20—\x20one\x20rating\x20per\x20order,\x20enforced\x20by\x20Guard\x20+\x20retained_submission\x20audit\x20trail.','Reward\x20object\x20(if\x20bound)\x20is\x20INDEPENDENT\x20of\x20Allocator:\x20Reward.claim()\x20requires\x20Guard+passport,\x20not\x20Permission.\x20Guard\x20checks\x20Progress.current\x20==\x20\x27wonder\x27\x20AND\x20order.holder\x20==\x20signer.','rating_window_guard\x20enforces\x20time\x20limit:\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days.\x20After\x20window\x20closes,\x20no\x20rating\x20possible\x20(Completed\x20becomes\x20true\x20terminal).','Optional:\x20bind\x20a\x20Repository\x20to\x20record\x20feedback\x20node\x20for\x20analytics.\x20Repository\x20write\x20happens\x20via\x20Guard\x27s\x20data\x20extraction\x20(NOT\x20auto-passed\x20—\x20see\x2006\x20§14.4).'],'example_use_case':'Photography\x20service:\x20Paid\x20→\x20Shipped\x20(booking\x20confirmed)\x20→\x20Received\x20(session\x20delivered)\x20→\x20Completed\x20'+'(photos\x20delivered,\x20funds\x20released\x20to\x20photographer)\x20→\x20customer\x20advances\x20to\x20\x27wonder\x27\x20(loved\x20the\x20work)\x20'+'or\x20\x27no_wonder\x27\x20(didn\x27t\x20love\x20it).\x20Bound\x20Reward\x20pays\x201\x20WOW\x20to\x20customers\x20who\x20advance\x20to\x20\x27wonder\x27.\x20'+'Merchant\x27s\x20wonder/no_wonder\x20ratio\x20becomes\x20an\x20on-chain\x20reputation\x20signal.\x20Disputes\x20(if\x20any)\x20are\x20'+'filed\x20separately\x20via\x20Arbitration\x20object\x20—\x20never\x20enter\x20this\x20Machine.','publish_checklist':['All\x206\x20nodes\x20verified:\x20no\x20\x27disputed\x27/\x27refunded\x27/\x27arb\x27/\x27arbitration\x27\x20names\x20(R-M1-11\x20PASS)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','Competing\x20Pair\x20tested:\x20Praise\x20vs\x20Complain\x20—\x20first-wins\x20semantics\x20verified\x20on\x20testnet','rating_window_guard\x20tested:\x20rating\x20blocked\x20after\x20time\x20limit\x20expires','MerchantAllocation\x20fires\x20ONLY\x20at\x20Completed\x20(NOT\x20at\x20Wonder/NoWonder)','Reward\x20object\x20(if\x20bound):\x20claim_guard\x20tested\x20—\x20Progress.current\x20==\x20\x27wonder\x27\x20required,\x20claim\x20fails\x20at\x20\x27no_wonder\x27\x20or\x20\x27Completed\x27','named_operator=\x27\x27\x20on\x20Praise/Complain\x20forwards\x20verified\x20(OrderHolder-only\x20operation)','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_subscription','scene_id':'subscription','name':'Subscription\x20/\x20Membership\x20Flow','description':'Subscribe\x20->\x20Pay\x20->\x20Activate\x20->\x20[Renew\x20|\x20Expire]\x20->\x20Cancel/End.\x20Time-lock\x20on\x20Renew.\x20'+'Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20(first-wins).\x20Repository\x20stores\x20subscription\x20status.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Provider\x20Permission\x20object'},{'name':'subscription_duration_days','type':'number','required':!![],'default':'30','description':'Days\x20between\x20Renew\x20and\x20Expire\x20eligibility'},{'name':'repository_ref','type':'address','required':!![],'description':'Repository\x20object\x20storing\x20subscription\x20status\x20(note:\x20not\x20consensus_repositories,\x20which\x20is\x20declarative-only\x20—\x20see\x2006\x20§14.4)'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20subscription\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Active'},{'name':'RenewEligible'},{'name':'Renewed'},{'name':'Expired'},{'name':'Cancelled'},{'name':'Ended'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Active','threshold':0x1,'forwards':[{'name':'Activate','weight':0x1,'permission_index':0x2,'guard':'repository_write_guard'}]},{'prev_node':'Active','next_node':'RenewEligible','threshold':0x1,'forwards':[{'name':'TimeUnlock','weight':0x1,'permission_index':0x3,'guard':'time_lock_guard_${subscription_duration_days}_days'}]},{'prev_node':'RenewEligible','next_node':'Renewed','threshold':0x1,'forwards':[{'name':'Renew','weight':0x1,'named_operator':''}]},{'prev_node':'RenewEligible','next_node':'Expired','threshold':0x1,'forwards':[{'name':'AutoExpire','weight':0x1,'permission_index':0x3,'guard':'expire_time_guard'}]},{'prev_node':'RenewEligible','next_node':'Cancelled','threshold':0x1,'forwards':[{'name':'Cancel','weight':0x1,'named_operator':''}]},{'prev_node':'Renewed','next_node':'Active','threshold':0x1,'forwards':[{'name':'Reactivate','weight':0x1,'permission_index':0x2}]},{'prev_node':'Expired','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseExpired','weight':0x1,'permission_index':0x3}]},{'prev_node':'Cancelled','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseCancelled','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeUnlock','purpose':'Time\x20lock:\x20context(Clock)\x20>=\x20progress.current_time\x20+\x20${subscription_duration_days}\x20days'},{'guard_template_id':'tpl_write_guard_type_check','bound_to_forward':'Activate','purpose':'Write\x20subscription\x20status\x20to\x20Repository'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'AutoExpire','purpose':'Hard\x20expire:\x20context(Clock)\x20>=\x20progress.current_time\x20+\x202x\x20duration'}],'required_permissions':[{'index':0x2,'name':'provider','description':'Provider\x20activates/reactivates'},{'index':0x3,'name':'admin','description':'Time-lock\x20triggers'}],'required_allocators':[{'name':'RenewAllocation','trigger_node':'Renewed','description':'Charge\x20renewal\x20fee\x20on\x20Renew'}],'forkable_fields':['duration_days','grace_period','additional_tiers'],'applicable_industries':['subscription','saas','membership','service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-04'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20subscription\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Subscribe\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20subscription\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Time-lock\x20uses\x20context(Clock)\x20—\x20verify\x20Clock\x20address\x20in\x20Guard\x20table','Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20vs\x20Cancel\x20—\x20first-wins','Renewed\x20node\x20loops\x20back\x20to\x20Active\x20(recurring\x20subscription)','Repository\x20records\x20subscription\x20status\x20for\x20cross-Machine\x20verification','Renewal\x20Allocation\x20triggers\x20on\x20Renewed\x20node\x20(not\x20Active\x20—\x20avoids\x20double-charge)','Note:\x20consensus_repositories\x20is\x20declarative-only\x20(NOT\x20auto-passed\x20to\x20Progress);\x20use\x20repository_ref\x20parameter\x20for\x20actual\x20Repository\x20object\x20—\x20see\x2006\x20§14.4','VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20replace\x20time-lock\x20Renew/Expire\x20with\x20content-delivery\x20flow:','\x20\x206-node\x20variant:\x20Paid\x20(entry)\x20→\x20ContentPublished\x20→\x20Completed\x20(terminal-success)','\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Paid\x20→\x20Cancelled\x20(terminal-cancel)\x20|\x20Paid\x20→\x20Disputed\x20→\x20Refunded\x20(terminal-dispute)','\x20\x20Permission:\x20author=index\x201000\x20(publish\x20+\x20cancel),\x20arbitrator=index\x201500\x20(resolve\x20dispute),\x20reader=namedOperator=\x27\x27\x20(open\x20role,\x20no\x20specific\x20operator)','\x20\x20Guards:\x20deliver_guard\x20(verify\x20author\x20permission\x20+\x20content\x20hash),\x20cancel_guard\x20(verify\x20subscriber\x20request),\x20refund_guard\x20(verify\x20arbitration\x20outcome)','\x20\x20Allocators:\x20deliver=100%\x20to\x20author,\x20cancel=100%\x20refund\x20to\x20subscriber,\x20dispute=100%\x20refund\x20to\x20subscriber\x20(Guard-first-wins\x20pattern)','\x20\x20First-Forward-wins:\x20when\x20Paid\x20has\x20competing\x20forwards\x20(Deliver|Cancel|Dispute),\x20the\x20first\x20triggered\x20forward\x20wins;\x20subscribers\x20cannot\x20double-claim','CRITICAL\x20—\x20v1→v2\x20lesson:\x20arbitrations\x20MUST\x20be\x20added\x20BEFORE\x20Service.publish\x20(post-publish,\x20arbitrations\x20become\x20immutable\x20and\x20cannot\x20be\x20added\x20—\x20F-S-21)','\x20\x20If\x20you\x20accidentally\x20published\x20without\x20arbitrations,\x20you\x20MUST\x20create\x20a\x20new\x20Service\x20v2\x20with\x20arbitrations\x20bound\x20before\x20publishing\x20(the\x20v1\x20Service\x20must\x20be\x20paused/abandoned)','\x20\x20ConfirmGate\x20(C-S-19,\x20QS11)\x20will\x20warn\x20before\x20publish\x20without\x20arbitrations\x20—\x20do\x20not\x20bypass\x20this\x20warning\x20unless\x20explicitly\x20intending\x20no-arbitration\x20operation','Build\x20order\x20(content\x20variant):\x20Permission\x20→\x20Machine\x20(unpublished,\x20with\x20initial\x20forward)\x20→\x203\x20Guards\x20→\x203\x20Allocators\x20(template\x20on\x20Service)\x20→\x20Service\x20(unpublished,\x20bind\x20machine+buy_guard+order_allocators+arbitrations)\x20→\x20Publish\x20Service\x20→\x20Test\x20order\x20(3\x20paths:\x20normal/cancel/dispute)'],'example_use_case':'Monthly\x20SaaS\x20subscription:\x20$10/month.\x20Customer\x20can\x20renew\x20anytime\x20after\x20day\x2025.\x20'+'Auto-expire\x20on\x20day\x2035\x20if\x20not\x20renewed.\x20Cancel\x20anytime.\x0a\x0a'+'VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20$5/month\x20newsletter.\x20Author\x20publishes\x20content\x20→\x20'+'subscriber\x20reads.\x20Subscriber\x20can\x20cancel\x20anytime\x20for\x20full\x20refund.\x20Disputes\x20resolved\x20by\x20arbitrator\x20'+'(100%\x20refund\x20to\x20subscriber\x20if\x20dispute\x20upheld).\x206-node\x20Machine,\x203\x20Guards,\x203\x20Allocators.\x20'+'Tested\x20on\x20testnet\x20with\x203\x20order\x20paths:\x20normal\x20delivery,\x20cancel,\x20dispute.','publish_checklist':['Time-lock\x20Guards\x20tested\x20on\x20testnet\x20(both\x20TimeUnlock\x20+\x20AutoExpire)','Competing\x20Pair\x20semantics\x20verified\x20(Renew\x20vs\x20Expire\x20vs\x20Cancel)','Repository\x20write\x20tested\x20(subscription\x20status\x20queryable)','Renewal\x20loop\x20tested:\x20Paid\x20->\x20Active\x20->\x20RenewEligible\x20->\x20Renewed\x20->\x20Active','Content\x20variant:\x20initial\x20node\x20(prev_node=\x27\x27)\x20MUST\x20have\x20at\x20least\x20one\x20forward\x20(FIX-002)\x20—\x20empty\x20forwards=[]\x20causes\x20Progress\x20to\x20be\x20permanently\x20stuck','Content\x20variant:\x20arbitrations\x20added\x20BEFORE\x20publish\x20(cannot\x20add\x20post-publish\x20per\x20F-S-21)','Content\x20variant:\x203\x20order\x20paths\x20tested\x20on\x20testnet\x20—\x20normal\x20delivery,\x20cancel-within-grace,\x20dispute-resolution','Content\x20variant:\x20machineNode2file\x20export\x20as\x20backup\x20(covers\x20all\x206\x20nodes)']}];export const MACHINE_TEMPLATES_VERSION='1.0.0';export const MACHINE_TEMPLATES_COUNT=MACHINE_TEMPLATES['length'];export function getAllTemplates(){return MACHINE_TEMPLATES;}export function getTemplateById(a){return MACHINE_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return MACHINE_TEMPLATES['filter'](b=>b['scene_id']===a);}export function getTemplatesByIndustry(a){return MACHINE_TEMPLATES['filter'](b=>b['applicable_industries']['includes'](a));}export function getTemplatesByPattern(a){return MACHINE_TEMPLATES['filter'](b=>b['recommended_patterns']['includes'](a));}export function suggestTemplateForIntent(a){const b=inferSceneFromFlow(a);if(!b)return undefined;const c=getTemplatesByScene(b['id']);return c[0x0];}export function getTemplateParameters(a){const b=getTemplateById(a);return b?b['parameters']:[];}export function getRequiredParameters(a){return getTemplateParameters(a)['filter'](b=>b['required']);}export function getOptionalParameters(a){return getTemplateParameters(a)['filter'](b=>!b['required']);}function validateParamType(a,b){switch(b){case'address':case'string':case'permission_ref':case'guard_ref':case'machine_ref':case'service_ref':case'arbitration_ref':case'reward_ref':return typeof a==='string';case'number':return typeof a==='number'||typeof a==='string'&&/^\d+$/['test'](a);case'boolean':return typeof a==='boolean';case'vec_address':case'vec_string':case'node_name_list':return Array['isArray'](a)&&a['every'](c=>typeof c==='string');default:return![];}}function deepSubstitute(a,b){if(typeof a==='string')return a['replace'](/\$\{(\w+)\}/g,(c,d)=>d in b?String(b[d]):'${'+d+'}');if(Array['isArray'](a))return a['map'](c=>deepSubstitute(c,b));if(a&&typeof a==='object'){const c={};for(const [d,e]of Object['entries'](a)){c[d]=deepSubstitute(e,b);}return c;}return a;}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'success':![],'validation_errors':['Template\x20not\x20found:\x20'+a]};const d=c['parameters']['filter'](h=>h['required']&&!(h['name']in b))['map'](h=>h['name']);if(d['length']>0x0)return{'success':![],'missing_params':d,'validation_errors':['Missing\x20required\x20parameters:\x20'+d['join'](',\x20')]};const e=[];for(const h of c['parameters']){if(h['name']in b){const i=b[h['name']];!validateParamType(i,h['type'])&&e['push']('Parameter\x20\x22'+h['name']+'\x22\x20type\x20mismatch:\x20expected\x20'+h['type']+',\x20got\x20'+typeof i);}}if(e['length']>0x0)return{'success':![],'validation_errors':e};const f=deepSubstitute(c['example_nodes'],b),g=deepSubstitute(c['example_pairs'],b);return{'success':!![],'filled_nodes':f,'filled_pairs':g};}export function forkTemplate(a){const b=getTemplateById(a);if(!b)return undefined;const c={};for(const d of b['forkable_fields']){c[d]='see\x20example_nodes/example_pairs';}return{'template_id':a,'forkable_fields':b['forkable_fields'],'current_values':c,'instructions':['Modify\x20fields\x20below\x20to\x20customize\x20the\x20workflow','Keep\x20template\x20structure\x20intact\x20unless\x20explicitly\x20noted','Run\x20risk\x20assessment\x20after\x20modification\x20(machine-risk.ts)','User\x20MUST\x20confirm\x20final\x20JSON\x20before\x20publish\x20(ConfirmGate)']};}export const DECISION_TREE={'Q1':{'question':'Does\x20the\x20workflow\x20involve\x20multiple\x20independent\x20services/parties?','no_next':'Q3'},'Q2':{'question':'Are\x20these\x20services\x20already\x20published\x20as\x20separate\x20Machines?','yes_template':'tpl_machine_cross_machine','no_next':'DECOMPOSE'},'Q3':{'question':'Does\x20any\x20node\x20require\x20multiple\x20parties\x27\x20confirmation\x20to\x20advance?','no_next':'Q5'},'Q4':{'question':'Do\x20all\x20parties\x20have\x20EQUAL\x20weight?','yes_template':'tpl_machine_dual_signature','no_next':'tpl_machine_weighted_voting'},'Q5':{'question':'Does\x20the\x20workflow\x20need\x20exception\x20branches\x20(lost,\x20return,\x20dispute)?','yes_template':'tpl_machine_ecommerce_exceptions','no_next':'Q6'},'Q6':{'question':'Does\x20it\x20involve\x20recurring\x20payments\x20or\x20time-based\x20state\x20changes?','yes_template':'tpl_machine_subscription','no_next':'Q7'},'Q7':{'question':'Does\x20it\x20need\x20privacy-preserving\x20data\x20delivery\x20(Messenger)?','yes_template':'tpl_machine_privacy_delivery','no_next':'Q8'},'Q8':{'question':'Does\x20it\x20involve\x20deposit/refund\x20separation?','yes_template':'tpl_machine_rental','no_next':'Q9'},'Q9':{'question':'Does\x20it\x20need\x20reward/incentive\x20distribution\x20at\x20a\x20specific\x20node?','yes_template':'tpl_machine_reward','no_next':'tpl_machine_ecommerce_standard'}};export function walkDecisionTree(a){let b='Q1';while(b){const c=DECISION_TREE[b];if(!c)return'UNKNOWN';const d=a[b];if(d===undefined)return b;if(d){if(c['yes_template'])return c['yes_template'];if(b==='Q1'){b='Q2';continue;}if(b==='Q3'){b='Q4';continue;}return'UNKNOWN';}else{if(c['no_next']){if(c['no_next']==='DECOMPOSE')return'DECOMPOSE_INTO_MULTIPLE_MACHINES';if(c['no_next']['startsWith']('tpl_'))return c['no_next'];b=c['no_next'];continue;}return'UNKNOWN';}}return'UNKNOWN';}export function verifyTemplateSceneReferences(){const a=[];for(const b of MACHINE_TEMPLATES){!findScene(b['scene_id'])&&a['push']({'template_id':b['id'],'invalid_scene_id':b['scene_id']});}return a;}export function getReferencedGuardTemplateIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['required_guards']){a['add'](c['guard_template_id']);}}return a;}export function getReferencedRiskIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['relevant_risks']){a['add'](c);}}return a;}export function listTemplates(){return MACHINE_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'scene_id':a['scene_id'],'patterns':a['recommended_patterns'],'industries':a['applicable_industries']}));}
|
|
1
|
+
import{findScene,inferSceneFromFlow}from'./machine-ledger.js';export const MACHINE_TEMPLATES=[{'id':'tpl_machine_ecommerce_standard','scene_id':'ecommerce_standard','name':'Standard\x20E-commerce\x20Flow','description':'Linear\x20e-commerce\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive\x20->\x20Complete.\x20'+'Payment\x20is\x20handled\x20by\x20the\x20Service\x20buy\x20flow\x20(direct\x20or\x20Passport-gated\x20purchase)\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Reaching\x20Complete\x20does\x20NOT\x20move\x20funds\x20—\x20allocation\x20is\x20a\x20separate\x20submitted\x20call\x20and\x20allocation.move\x20has\x20no\x20timer,\x20'+'so\x20a\x20keeper\x20(merchant\x20or\x20buyer-side\x20trigger)\x20must\x20fire\x20it\x20or\x20the\x20order\x20stays\x20settled-but-unpaid.\x20Recommended\x20baseline\x20for\x20new\x20merchants.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20address\x20or\x20name\x20(must\x20have\x20custom\x20indices\x20defined)','constraint':'Permission\x20must\x20already\x20be\x20created;\x20index\x202\x20(merchant)\x20and\x20index\x203\x20(admin)\x20recommended'},{'name':'ship_forward_name','type':'string','required':!![],'default':'Ship','description':'Forward\x20name\x20for\x20shipping\x20step','constraint':'Must\x20be\x20<64\x20BCS\x20bytes;\x20only\x20letters/digits/underscore'},{'name':'receive_forward_name','type':'string','required':!![],'default':'Receive','description':'Forward\x20name\x20for\x20customer\x20receipt\x20confirmation'},{'name':'complete_node_name','type':'string','required':!![],'default':'Complete','description':'Terminal\x20node\x20name\x20triggering\x20fund\x20allocation'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Goods\x20dispatched'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'${complete_node_name}','description':'Terminal:\x20triggers\x20allocation'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'${ship_forward_name}','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'${receive_forward_name}','weight':0x1,'named_operator':'','permission_index':0x0}]},{'prev_node':'Received','next_node':'${complete_node_name}','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]}],'required_guards':[],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'${complete_node_name}','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address'}],'forkable_fields':['node_names','forward_names','thresholds','additional_branches'],'applicable_industries':['ecommerce','retail'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M2-01','R-M3-02','R-M4-01'],'creation_notes':['Build\x20order:\x20Permission\x20->\x20Machine\x20(unpublished)\x20->\x20Guards\x20->\x20Bind\x20guards\x20->\x20Publish\x20->\x20Bind\x20to\x20Service','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Entry\x20point:\x20prev_node=\x27\x27\x20(empty\x20string)\x20targets\x20\x27Paid\x27\x20—\x20at\x20least\x20one\x20Pair\x20must\x20exist\x20with\x20empty\x20prev_node','If\x20using\x20P16\x20circular\x20reference\x20for\x20Service,\x20use\x20name\x20not\x20address\x20(Service\x20not\x20yet\x20published)'],'example_use_case':'Small\x20e-commerce\x20shop\x20selling\x20camera\x20accessories.\x20Linear\x20flow\x20with\x20no\x20exceptions.\x20'+'Funds\x20allocated\x20to\x20merchant\x20personal\x20address\x20on\x20Complete.','publish_checklist':['All\x204\x20nodes\x20have\x20at\x20least\x20one\x20outgoing\x20Forward\x20(except\x20terminal)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','permissionIndex\x20values\x20match\x20Permission\x20object\x20indices','Test\x20Progress\x20run\x20on\x20testnet','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_ecommerce_exceptions','scene_id':'ecommerce_with_exceptions','name':'E-commerce\x20Flow\x20with\x20Exception\x20Branches','description':'Multi-path\x20workflow:\x20Paid\x20(entry)\x20->\x20Ship\x20->\x20Receive/Lost/Return.\x20Lost\x20uses\x20dual-sig\x20(threshold=2).\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-payment\x20state.\x20'+'Return\x20path\x20opens\x20Refund\x20->\x20Complete.\x20Competing\x20pairs\x20first-wins.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'lost_threshold','type':'number','required':!![],'default':'2','description':'Threshold\x20for\x20dual-sig\x20on\x20Lost\x20node','constraint':'Must\x20be\x202\x20(customer\x20+\x20merchant)'},{'name':'arbitration_ref','type':'arbitration_ref','required':![],'description':'Arbitration\x20object\x20if\x20Lost\x20escalates\x20to\x20arbitration'},{'name':'time_guard_days','type':'number','required':!![],'default':'10','description':'Days\x20before\x20auto-complete\x20trigger\x20(time\x20guard)','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-30'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return/refund\x20node\x20in\x20the\x20exception\x20branch'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped'},{'name':'Received'},{'name':'Lost'},{'name':'Return'},{'name':'Refund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Lost','threshold':'${lost_threshold}','forwards':[{'name':'CustomerReport','weight':0x1,'named_operator':''},{'name':'MerchantConfirm','weight':0x1,'permission_index':0x2}]},{'prev_node':'Shipped','next_node':'Return','threshold':0x1,'forwards':[{'name':'RequestReturn','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Complete','threshold':0x1,'forwards':[{'name':'TimeGuard','weight':0x1,'permission_index':0x3,'guard':'time_guard_${time_guard_days}_days'},{'name':'MerchantFinish','weight':0x1,'permission_index':0x2}]},{'prev_node':'Return','next_node':'Refund','threshold':0x1,'forwards':[{'name':'IssueRefund','weight':0x1,'permission_index':0x2}]},{'prev_node':'Refund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CloseReturn','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantConfirm','purpose':'Dual-sig\x20on\x20Lost\x20node'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeGuard','purpose':'Time\x20lock\x20${time_guard_days}\x20days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role'},{'index':0x3,'name':'admin','description':'Admin\x20/\x20time-guard\x20trigger'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Full\x20allocation\x20to\x20merchant\x20on\x20normal\x20completion'},{'name':'RefundAllocation','trigger_node':'Refund','description':'Full\x20refund\x20to\x20customer\x20on\x20return'},{'name':'LostAllocation','trigger_node':'Lost','description':'Optional:\x20partial\x20refund\x20or\x20escrow\x20(depends\x20on\x20policy)'}],'forkable_fields':['node_names','branch_conditions','time_guard_days','lost_threshold'],'applicable_industries':['ecommerce','logistics'],'relevant_risks':['R-M1-01','R-M1-03','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M3-05','R-M4-01','R-M5-03'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Competing\x20Pairs\x20(Shipped\x20->\x20Received/Lost/Return)\x20are\x20mutually\x20exclusive\x20—\x20first\x20threshold\x20met\x20wins','Lost\x20node\x20threshold=2\x20means\x20BOTH\x20customer\x20and\x20merchant\x20Forwards\x20must\x20execute','TimeGuard\x20must\x20use\x20context(Clock)\x20>=\x20progress.current_time\x20+\x20duration\x20(progress.move\x20exposes\x20current_time,\x20refreshed\x20on\x20every\x20node\x20transition\x20—\x20there\x20is\x20no\x20entry_time\x20field)','If\x20Lost\x20escalates\x20to\x20arbitration,\x20bind\x20arbitration_usage_guard\x20on\x20Lost\x20forward','Refund\x20Allocation\x20must\x20use\x20sharing.who=OrderHolder\x20(refund\x20to\x20customer,\x20NOT\x20merchant)'],'example_use_case':'Mid-size\x20e-commerce\x20with\x207-day\x20return\x20policy\x20and\x20dispute\x20handling.\x20'+'Lost\x20claims\x20require\x20customer+merchant\x20dual\x20confirmation.','publish_checklist':['All\x20competing\x20Pairs\x20tested:\x20verify\x20first-wins\x20semantics\x20on\x20testnet','Lost\x20dual-sig\x20tested:\x20incomplete\x20signatures\x20do\x20not\x20advance','TimeGuard\x20Clock\x20query\x20verified\x20(testnet)','All\x20three\x20Allocators\x20tested\x20with\x20correct\x20sharing.who','Arbitration\x20binding\x20(if\x20any)\x20verified\x20via\x20gen_passport']},{'id':'tpl_machine_rental','scene_id':'rental_standard','name':'Equipment\x20Rental\x20Flow','description':'Rental\x20flow:\x20DepositPaid\x20(entry)\x20->\x20Pickup\x20->\x20In\x20Use\x20->\x20Return\x20->\x20Refund\x20Deposit.\x20'+'Payment\x20is\x20handled\x20by\x20Service.buy()\x20atomically;\x20Machine\x20starts\x20at\x20post-deposit\x20state.\x20'+'Separates\x20deposit\x20from\x20rental\x20fee\x20(two\x20Allocators).\x20Damage\x20report\x20via\x20retained_submission.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'deposit_amount','type':'number','required':!![],'description':'Deposit\x20amount\x20in\x20smallest\x20WOW\x20unit','constraint':'Must\x20equal\x20order.amount\x20field;\x20verify\x20via\x20Guard\x20query'},{'name':'damage_inspection_node','type':'string','required':!![],'default':'DamageCheck','description':'Name\x20of\x20the\x20node\x20where\x20damage\x20inspection\x20occurs'},{'name':'return_node_name','type':'string','required':!![],'default':'Return','description':'Name\x20of\x20the\x20return\x20node\x20after\x20damage\x20check\x20fails'}],'example_nodes':[{'name':'DepositPaid','description':'Entry:\x20deposit\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'PickedUp'},{'name':'InUse'},{'name':'Return'},{'name':'DamageCheck'},{'name':'DepositRefund'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'DepositPaid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'DepositPaid','next_node':'PickedUp','threshold':0x1,'forwards':[{'name':'Pickup','weight':0x1,'named_operator':'','permission_index':0x2}]},{'prev_node':'PickedUp','next_node':'InUse','threshold':0x1,'forwards':[{'name':'StartUse','weight':0x1,'named_operator':''}]},{'prev_node':'InUse','next_node':'Return','threshold':0x1,'forwards':[{'name':'ReturnItem','weight':0x1,'named_operator':''}]},{'prev_node':'Return','next_node':'DamageCheck','threshold':0x1,'forwards':[{'name':'Inspect','weight':0x1,'permission_index':0x2,'retained_submission':'damage_report'}]},{'prev_node':'Return','next_node':'Complete','threshold':0x1,'forwards':[{'name':'CleanReturn','weight':0x1,'permission_index':0x2}]},{'prev_node':'DamageCheck','next_node':'DepositRefund','threshold':0x1,'forwards':[{'name':'DeductDamage','weight':0x1,'permission_index':0x2}]},{'prev_node':'DepositRefund','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Close','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'Inspect','purpose':'Optional:\x20damage\x20evidence\x20proof\x20(photo,\x20video)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Rental\x20provider'}],'required_allocators':[{'name':'RentalFeeAllocation','trigger_node':'Complete','description':'Rental\x20fee\x20to\x20merchant'},{'name':'DepositRefundAllocation','trigger_node':'DepositRefund','description':'Remaining\x20deposit\x20to\x20customer\x20(OrderHolder\x20sharing.who)'},{'name':'DamageDeductionAllocation','trigger_node':'DamageCheck','description':'Damage\x20deduction\x20to\x20merchant'}],'forkable_fields':['deposit_amount','damage_node_logic','additional_inspection_steps'],'applicable_industries':['rental','equipment','vehicle'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M4-01','R-M5-02'],'creation_notes':['First\x20node\x20\x27DepositPaid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20deposit\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Reserve\x27\x20or\x20\x27PayDeposit\x27\x20nodes\x20needed\x20—\x20reservation\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Damage\x20report\x20uses\x20retained_submission\x20—\x20values\x20stored\x20uniquely\x20by\x20(current_node,\x20next_node,\x20forward_name)','Two\x20competing\x20Pairs\x20at\x20Return\x20node:\x20DamageCheck\x20vs\x20Complete\x20(clean\x20return)','DamageDeduction\x20Allocation\x20uses\x20sharing.who=Entity\x20(merchant),\x20not\x20OrderHolder'],'example_use_case':'Camera\x20equipment\x20rental:\x20customer\x20pays\x201000\x20WOW\x20deposit,\x20returns\x20equipment,\x20'+'merchant\x20inspects.\x20If\x20damaged,\x20200\x20WOW\x20deducted;\x20otherwise\x20full\x20refund.','publish_checklist':['Deposit\x20Guard\x20tested\x20(testnet)\x20with\x20valid/invalid\x20amounts','Damage\x20report\x20retained_submission\x20stored\x20correctly\x20(query\x20progress_history)','Both\x20Return\x20branches\x20tested\x20(DamageCheck\x20+\x20CleanReturn)','All\x20three\x20Allocators\x20verified\x20with\x20correct\x20sharing.who']},{'id':'tpl_machine_dual_signature','scene_id':'dual_signature','name':'Dual-Signature\x20Consensus\x20Flow','description':'Critical\x20node\x20requires\x20both\x20customer\x20+\x20merchant\x20confirmation.\x20threshold=2\x20with\x20two\x20Forwards\x20(weight=1\x20each).\x20'+'Customer\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder);\x20merchant\x20uses\x20permissionIndex=2.','recommended_patterns':['P-M-AND'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'critical_node_name','type':'string','required':!![],'default':'Approve','description':'Node\x20requiring\x20dual-sig'},{'name':'next_node_after_approval','type':'string','required':!![],'default':'Execute','description':'Name\x20of\x20the\x20node\x20that\x20follows\x20after\x20dual-signature\x20approval'}],'example_nodes':[{'name':'Initiated'},{'name':'${critical_node_name}','description':'Dual-sig\x20required\x20here'},{'name':'${next_node_after_approval}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Initiated','threshold':0x1,'forwards':[{'name':'Initiate','weight':0x1,'named_operator':''}]},{'prev_node':'Initiated','next_node':'${critical_node_name}','threshold':0x1,'forwards':[{'name':'Submit','weight':0x1,'named_operator':''}]},{'prev_node':'${critical_node_name}','next_node':'${next_node_after_approval}','threshold':0x2,'forwards':[{'name':'CustomerApprove','weight':0x1,'named_operator':'','guard':'customer_identity_guard'},{'name':'MerchantApprove','weight':0x1,'permission_index':0x2,'guard':'merchant_identity_guard'}]},{'prev_node':'${next_node_after_approval}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'CustomerApprove','purpose':'Verify\x20customer\x20identity\x20(order.owner)'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'MerchantApprove','purpose':'Verify\x20merchant\x20identity\x20(permission\x20holder)'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20approval'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20on\x20dual-sig\x20completion'}],'forkable_fields':['critical_node_name','additional_approvers','guard_logic'],'applicable_industries':['ecommerce','service','logistics','escrow'],'relevant_risks':['R-M1-08','R-M2-01','R-M3-02','R-M3-04'],'creation_notes':['threshold=2\x20means\x20BOTH\x20Forwards\x20must\x20execute\x20to\x20advance\x20(AND\x20semantics)','Customer\x20Forward\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder)','Merchant\x20Forward\x20uses\x20permissionIndex=2','If\x20either\x20party\x20fails\x20to\x20sign,\x20workflow\x20stalls\x20—\x20consider\x20adding\x20timeout\x20Guard'],'example_use_case':'High-value\x20order\x20(e.g.\x20real\x20estate\x20transaction)\x20requiring\x20both\x20buyer\x20and\x20seller\x20confirmation.','publish_checklist':['Both\x20Forward\x20identities\x20tested\x20on\x20testnet','Verify\x20partial\x20signature\x20does\x20NOT\x20advance\x20(threshold=2)','Guards\x20correctly\x20distinguish\x20customer\x20vs\x20merchant\x20identity']},{'id':'tpl_machine_weighted_voting','scene_id':'weighted_voting','name':'Weighted\x20Voting\x20Flow','description':'Multi-party\x20voting\x20with\x20unequal\x20weights.\x20threshold=100,\x20chief\x20weight=60,\x20members\x20weight=40\x20total.\x20'+'Each\x20member\x27s\x20weight\x20extracted\x20via\x20Guard\x20query\x20from\x20Arbitration\x20object.','recommended_patterns':['P-M-VOTE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'arbitration_ref','type':'arbitration_ref','required':!![],'description':'Arbitration\x20object\x20storing\x20voter\x20weights'},{'name':'threshold_total','type':'number','required':!![],'default':'100','description':'Total\x20weight\x20threshold\x20for\x20decision'},{'name':'chief_weight','type':'number','required':!![],'default':'60','description':'Weight\x20assigned\x20to\x20the\x20chief\x20voter\x20(out\x20of\x20100)'},{'name':'member_count','type':'number','required':!![],'default':'5','description':'Number\x20of\x20voting\x20members\x20(excluding\x20chief)'}],'example_nodes':[{'name':'VoteOpened'},{'name':'Voting'},{'name':'Approved'},{'name':'Rejected'}],'example_pairs':[{'prev_node':'','next_node':'VoteOpened','threshold':0x1,'forwards':[{'name':'OpenVote','weight':0x1,'permission_index':0x3}]},{'prev_node':'VoteOpened','next_node':'Voting','threshold':0x1,'forwards':[{'name':'StartVoting','weight':0x1,'permission_index':0x3}]},{'prev_node':'Voting','next_node':'Approved','threshold':'${threshold_total}','forwards':[{'name':'ChiefVote','weight':'${chief_weight}','permission_index':0x2,'guard':'arb_voting_guard','retained_submission':'chief_vote_record'},{'name':'MemberVote','weight':0x8,'named_operator':'member','guard':'arb_voting_guard','retained_submission':'member_vote_record'}]},{'prev_node':'Voting','next_node':'Rejected','threshold':0x1,'forwards':[{'name':'TimeoutReject','weight':0x1,'permission_index':0x3,'guard':'voting_timeout_guard'}]}],'required_guards':[{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'ChiefVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20extract\x20weight\x20from\x20Arbitration'},{'guard_template_id':'tpl_voting_guard_numeric_weight','bound_to_forward':'MemberVote','purpose':'Verify\x20voting\x20eligibility\x20+\x20prevent\x20double-vote'}],'required_permissions':[{'index':0x2,'name':'chief','description':'Chief\x20voter\x20(high\x20weight)'},{'index':0x3,'name':'admin','description':'Vote\x20opener\x20/\x20timeout\x20trigger'}],'required_allocators':[{'name':'ApprovedAllocation','trigger_node':'Approved','description':'Allocation\x20on\x20approval'}],'forkable_fields':['weights','voter_count','timeout_days'],'applicable_industries':['governance','arbitration','dao'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-M5-04','R-X1-14'],'creation_notes':['Member\x20weight\x20must\x20be\x20extracted\x20dynamically\x20via\x20Guard\x20query\x20(not\x20hardcoded\x20in\x20Forward)','Guard\x20MUST\x20check\x20arb.voted\x20has\x20[Signer]\x20to\x20prevent\x20double-voting\x20(R-X1-14\x20CRITICAL)','Competing\x20Pair:\x20Approved\x20vs\x20Rejected\x20(timeout)\x20—\x20first-wins','Voting\x20weight\x20is\x20query-derived;\x20Forward\x20weight\x20field\x20is\x20just\x20session\x20counter'],'example_use_case':'Arbitration\x20panel:\x201\x20chief\x20(weight\x2060)\x20+\x205\x20members\x20(weight\x208\x20each\x20=\x2040).\x20'+'Need\x20total\x20>=\x20100\x20to\x20approve.\x20Reject\x20after\x2072h\x20timeout.','publish_checklist':['Arbitration\x20object\x20created\x20and\x20tested','Double-vote\x20prevention\x20verified\x20(try\x20voting\x20twice\x20—\x20should\x20fail)','Weight\x20extraction\x20tested\x20with\x20different\x20voter\x20configurations','Timeout\x20Guard\x20(Clock)\x20verified\x20on\x20testnet']},{'id':'tpl_machine_cross_machine','scene_id':'cross_machine_supply_chain','name':'Cross-Machine\x20Supply\x20Chain','description':'Decomposed\x20supply\x20chain\x20across\x20multiple\x20Machines.\x20Machine\x20B\x27s\x20Forward\x20Guard\x20queries\x20Machine\x20A\x27s\x20Progress\x20'+'via\x20convert_witness=100\x20to\x20verify\x20upstream\x20completion\x20before\x20advancing.','recommended_patterns':['P-M-CROSS-MACHINE'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'machine_a_id','type':'machine_ref','required':!![],'description':'Upstream\x20Machine\x20(must\x20already\x20be\x20published)','constraint':'Machine\x20A\x20must\x20be\x20published\x20BEFORE\x20Machine\x20B\x27s\x20Guard\x20can\x20reference\x20its\x20Progress\x20'+'(Progress\x20creation\x20verifies\x20the\x20bound\x20Machine\x20is\x20published\x20—\x20see\x2006\x20§14.6)'},{'name':'machine_a_complete_node','type':'string','required':!![],'default':'Complete','description':'Target\x20node\x20name\x20in\x20Machine\x20A\x20to\x20verify'},{'name':'machine_b_permission','type':'permission_ref','required':!![],'description':'Machine\x20B\x27s\x20Permission\x20object'}],'example_nodes':[{'name':'UpstreamVerified'},{'name':'Production'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'UpstreamVerified','threshold':0x1,'forwards':[{'name':'VerifyUpstream','weight':0x1,'permission_index':0x2,'guard':'upstream_progress_guard','retained_submission':'upstream_progress_id'}]},{'prev_node':'UpstreamVerified','next_node':'Production','threshold':0x1,'forwards':[{'name':'StartProduction','weight':0x1,'permission_index':0x2}]},{'prev_node':'Production','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'VerifyUpstream','purpose':'Query\x20Machine\x20A\x27s\x20Progress:\x20verify\x20it\x20reached\x20${machine_a_complete_node}'}],'required_permissions':[{'index':0x2,'name':'manufacturer','description':'Machine\x20B\x20operator'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20Machine\x20B\x27s\x20merchant'}],'forkable_fields':['upstream_machine_ref','verification_node_name'],'applicable_industries':['manufacturing','logistics','retail','supply_chain'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-04','R-M5-04','R-M5-05','R-M5-06'],'creation_notes':['Machine\x20A\x20MUST\x20be\x20published\x20before\x20Machine\x20B\x20(dependency\x20order)','Guard\x20uses\x20convert_witness=100\x20to\x20convert\x20submitted\x20Order/Progress\x20ID\x20into\x20queryable\x20Progress\x20object','Cross-Machine\x20dependency\x20is\x20one-way\x20(no\x20cycles)','retained_submission\x20stores\x20upstream\x20Progress\x20ID\x20for\x20later\x20audit','Multi-party\x20chain:\x20extend\x20pattern\x20with\x20Machine\x20C,\x20D,\x20...\x20(each\x20independently\x20published)','Dependency\x20verification:\x20enforced\x20when\x20the\x20Progress\x20object\x20is\x20created\x20(creation\x20checks\x20the\x20bound\x20Machine\x20is\x20published\x20—\x20see\x2006\x20§14.6)'],'example_use_case':'Supplier\x20(Machine\x20A)\x20->\x20Manufacturer\x20(Machine\x20B)\x20->\x20Retailer\x20(Machine\x20C).\x20'+'Manufacturer\x20cannot\x20start\x20production\x20until\x20supplier\x27s\x20Progress\x20reaches\x20\x27Complete\x27.','publish_checklist':['Machine\x20A\x20already\x20published\x20on-chain\x20(verify\x20via\x20onchain_objects)','Cross-Machine\x20Guard\x20tested\x20with\x20valid/invalid\x20upstream\x20Progress\x20IDs','retained_submission\x20verified\x20(query\x20progress_history\x20for\x20upstream_progress_id)','Independent\x20testing:\x20run\x20Machine\x20A\x20to\x20Complete,\x20then\x20attempt\x20Machine\x20B\x27s\x20VerifyUpstream']},{'id':'tpl_machine_privacy_delivery','scene_id':'privacy_delivery','name':'Privacy-Preserving\x20Delivery\x20Flow','description':'Customer\x20submits\x20privacy\x20data\x20via\x20Messenger\x20(encrypted,\x20off-chain).\x20Chain\x20stores\x20only\x20Merkle\x20Root\x20Proof.\x20'+'Guard\x20verifies\x20Proof\x20signature\x20+\x20timestamp\x20+\x20service\x20binding.\x20Uses\x20tpl_forward_privacy_delivery_proof\x20(strict\x20mode).','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object'},{'name':'proof_node_name','type':'string','required':!![],'default':'ProofSubmitted','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20proof\x20is\x20submitted'},{'name':'delivery_node_name','type':'string','required':!![],'default':'DeliveryConfirmed','description':'Name\x20of\x20the\x20node\x20where\x20delivery\x20confirmation\x20occurs'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'${proof_node_name}','description':'Customer\x20submits\x20Proof\x20via\x20Messenger'},{'name':'${delivery_node_name}'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'${proof_node_name}','threshold':0x1,'forwards':[{'name':'SubmitProof','weight':0x1,'named_operator':'','guard':'tpl_forward_privacy_delivery_proof','retained_submission':'proof_address'}]},{'prev_node':'${proof_node_name}','next_node':'${delivery_node_name}','threshold':0x1,'forwards':[{'name':'ConfirmDelivery','weight':0x1,'permission_index':0x2}]},{'prev_node':'${delivery_node_name}','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_privacy_delivery_proof','bound_to_forward':'SubmitProof','purpose':'Verify\x20Proof:\x20signer=proof.signer\x20∧\x20proof.time>order.time\x20∧\x20order.service=service'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20confirms\x20delivery'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Allocation\x20to\x20merchant\x20after\x20delivery\x20confirmation'}],'forkable_fields':['proof_node_name','delivery_node_name','additional_evidence_steps'],'applicable_industries':['ecommerce','logistics','privacy_service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-04','R-M3-02','R-M5-03'],'creation_notes':['Use\x20strict\x20mode\x20tpl_forward_privacy_delivery_proof\x20(3\x20conditions:\x20Signer\x20+\x20time\x20+\x20service\x20binding)','submitChainProof\x20about_address\x20=\x20peerAddress\x20(NOT\x20sessionId)\x20—\x20about\x20records\x20ONLY\x20the\x20contact;\x20it\x20has\x20no\x20on-chain\x20meaning\x20and\x20must\x20NEVER\x20be\x20a\x20guard\x20decision\x20condition','PRIVACY:\x20never\x20pass\x20order_id\x20or\x20any\x20order\x20reference\x20via\x20the\x20description\x20field\x20(that\x20would\x20publicly\x20link\x20Proof\x20to\x20Order\x20on\x20chain)\x20—\x20all\x20order/business\x20linkage\x20stays\x20inside\x20the\x20Messenger\x20conversation;\x20acceptance\x20of\x20delivered\x20info\x20is\x20the\x20merchant\x27s\x20confirming\x20forward,\x20not\x20the\x20proof\x27s\x20recorded\x20address','Guard\x20table\x20item\x20name\x20MUST\x20be\x20<64\x20BCS\x20bytes\x20(MAX_NAME_LENGTH=64)','retained_submission\x20stores\x20Proof\x20address\x20for\x20arbitration\x20query','Proof\x20MUST\x20be\x20generated\x20by\x20messenger.submitChainProof\x20(not\x20manual)'],'example_use_case':'Customer\x20sends\x20delivery\x20address\x20via\x20Messenger\x20(encrypted).\x20Chain\x20stores\x20only\x20Proof.\x20'+'Merchant\x20verifies\x20Proof,\x20then\x20confirms\x20delivery.','publish_checklist':['Strict\x20mode\x20Guard\x20tested:\x203\x20conditions\x20verified\x20individually','Messenger\x20integration\x20tested\x20end-to-end\x20(submit\x20+\x20verify)','retained_submission\x20stored\x20Proof\x20address\x20queryable\x20from\x20progress_history','Guard\x20table\x20item\x20name\x20length\x20validated\x20(<64\x20BCS\x20bytes)']},{'id':'tpl_machine_reward','scene_id':'reward_incentive','name':'Reward\x20Incentive\x20Flow','description':'Customer\x20triggers\x20Reward\x20claim\x20at\x20specific\x20node.\x20Guard\x20prevents\x20double-claim\x20via\x20query_reward_record_count==0.\x20'+'Reward\x20object\x20independent\x20of\x20Allocator.','recommended_patterns':['P-M-SEQ'],'recommended_topology':['P-M-LINEAR'],'parameters':[{'name':'reward_ref','type':'reward_ref','required':!![],'description':'Reward\x20object\x20address\x20(must\x20be\x20already\x20created)'},{'name':'claim_node_name','type':'string','required':!![],'default':'ClaimReward','description':'Name\x20of\x20the\x20node\x20where\x20reward\x20claims\x20are\x20triggered'}],'example_nodes':[{'name':'Eligible'},{'name':'${claim_node_name}'},{'name':'Rewarded'},{'name':'Complete'}],'example_pairs':[{'prev_node':'','next_node':'Eligible','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Eligible','next_node':'${claim_node_name}','threshold':0x1,'forwards':[{'name':'TriggerClaim','weight':0x1,'named_operator':'','guard':'reward_anti_double_guard','retained_submission':'claim_record'}]},{'prev_node':'${claim_node_name}','next_node':'Rewarded','threshold':0x1,'forwards':[{'name':'IssueReward','weight':0x1,'permission_index':0x3}]},{'prev_node':'Rewarded','next_node':'Complete','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_reward_one_time_claim','bound_to_forward':'TriggerClaim','purpose':'Verify\x20query_reward_record_count==0\x20to\x20prevent\x20double-claim'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Completes\x20flow'},{'index':0x3,'name':'reward_admin','description':'Issues\x20reward\x20tokens'}],'required_allocators':[{'name':'CompleteAllocation','trigger_node':'Complete','description':'Standard\x20allocation\x20(separate\x20from\x20Reward)'}],'forkable_fields':['claim_node_name','additional_reward_conditions'],'applicable_industries':['ecommerce','subscription','education','loyalty'],'relevant_risks':['R-M1-08','R-M2-05','R-M3-04','R-X1-14'],'creation_notes':['Reward\x20Guard\x20MUST\x20check\x20query_reward_record_count\x20==\x200\x20(R-X1-14\x20CRITICAL)','Reward\x20is\x20INDEPENDENT\x20of\x20Allocator\x20—\x20both\x20can\x20fire\x20on\x20different\x20nodes','Reward\x20object\x20must\x20be\x20created\x20BEFORE\x20publishing\x20this\x20Machine','retained_submission\x20stores\x20claim\x20record\x20for\x20audit'],'example_use_case':'Loyalty\x20program:\x20after\x20customer\x20completes\x205\x20orders,\x20eligible\x20to\x20claim\x20reward\x20token.\x20'+'Anti-double-claim\x20Guard\x20ensures\x20one\x20claim\x20per\x20customer.','publish_checklist':['Reward\x20object\x20already\x20created\x20and\x20tested','Anti-double-claim\x20Guard\x20tested:\x20claim\x20twice\x20should\x20fail\x20on\x20second\x20attempt','retained_submission\x20verified\x20(claim_record\x20queryable)']},{'id':'tpl_machine_wonder_feedback','scene_id':'wonder_feedback','name':'Wonder\x20Feedback\x20Flow\x20(Post-Completion\x20Rating)','description':'Post-completion\x20rating\x20flow:\x20Paid\x20(entry)\x20→\x20Shipped\x20→\x20Received\x20→\x20Completed\x20→\x20{Wonder\x20|\x20NoWonder}.\x20'+'After\x20the\x20order\x20reaches\x20\x27Completed\x27\x20(terminal\x20business\x20state,\x20funds\x20already\x20allocated\x20to\x20merchant),\x20'+'the\x20OrderHolder\x20(namedOperator=\x27\x27)\x20can\x20advance\x20Progress\x20to\x20\x27wonder\x27\x20(positive\x20review)\x20or\x20\x27no_wonder\x27\x20'+'(negative\x20review).\x20A\x20bound\x20Reward\x20object\x27s\x20claim_guard\x20verifies\x20Progress.current\x20==\x20\x27wonder\x27\x20before\x20'+'paying\x20out\x20—\x20reward\x20claim\x20needs\x20NO\x20Permission.\x20Dispute\x20is\x20NEVER\x20modeled\x20here:\x20it\x20flows\x20through\x20'+'the\x20Order\x27s\x20dispute\x20flow\x20→\x20Arb\x20case\x20→\x20arbiter\x20ruling\x20→\x20fee\x20withdrawal,\x20fully\x20off-Machine.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Merchant\x20Permission\x20object\x20(index\x202\x20=\x20merchant,\x20index\x203\x20=\x20admin)'},{'name':'wonder_node_name','type':'string','required':!![],'default':'wonder','description':'Node\x20name\x20for\x20positive\x20feedback\x20(praise)\x20terminal','constraint':'Must\x20match\x20/^(wonder|praise|thumbs_up)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'no_wonder_node_name','type':'string','required':!![],'default':'no_wonder','description':'Node\x20name\x20for\x20negative\x20feedback\x20(complaint)\x20terminal','constraint':'Must\x20match\x20/^(no_wonder|complain|thumbs_down)$/i\x20OR\x20be\x20a\x20custom\x20name;\x20must\x20NOT\x20match\x20dispute\x20anti-pattern\x20regex'},{'name':'reward_ref','type':'reward_ref','required':![],'description':'Reward\x20object\x20address\x20(optional).\x20If\x20bound,\x20its\x20claim_guard\x20should\x20verify\x20Progress.current\x20==\x20wonder_node_name\x20AND\x20order.holder\x20==\x20signer.\x20Use\x20wonder_praise\x20or\x20wonder_feedback\x20reward\x20template.'},{'name':'rating_time_limit_days','type':'number','required':![],'default':'30','description':'Days\x20after\x20completion\x20during\x20which\x20the\x20customer\x20can\x20rate\x20(enforced\x20by\x20Guard\x20on\x20Praise/Complain\x20forwards\x20via\x20context(Clock))','constraint':'Must\x20be\x20>\x200;\x20reasonable\x20range\x207-90'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20order\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Shipped','description':'Merchant\x20dispatched\x20goods/service'},{'name':'Received','description':'Customer\x20confirmed\x20receipt'},{'name':'Completed','description':'Terminal\x20business\x20state\x20—\x20triggers\x20merchant\x20Allocation.\x20Funds\x20settled.'},{'name':'${wonder_node_name}','description':'Positive\x20feedback\x20terminal\x20(praise).\x20OrderHolder-only.\x20Reward-eligible.'},{'name':'${no_wonder_node_name}','description':'Negative\x20feedback\x20terminal\x20(complaint).\x20OrderHolder-only.\x20Optional\x20Repository\x20write\x20for\x20analytics.'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Shipped','threshold':0x1,'forwards':[{'name':'Ship','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Shipped','next_node':'Received','threshold':0x1,'forwards':[{'name':'ConfirmReceive','weight':0x1,'named_operator':''}]},{'prev_node':'Received','next_node':'Completed','threshold':0x1,'forwards':[{'name':'Finish','weight':0x1,'permission_index':0x2,'named_operator':''}]},{'prev_node':'Completed','next_node':'${wonder_node_name}','threshold':0x1,'forwards':[{'name':'Praise','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]},{'prev_node':'Completed','next_node':'${no_wonder_node_name}','threshold':0x1,'forwards':[{'name':'Complain','weight':0x1,'named_operator':'','guard':'rating_window_guard','retained_submission':'rating_record'}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Praise','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'Complain','purpose':'Verify\x20Progress.current\x20==\x20\x27Completed\x27\x20(rating\x20only\x20allowed\x20after\x20completion)\x20AND\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days'}],'required_permissions':[{'index':0x2,'name':'merchant','description':'Merchant\x20role\x20for\x20Ship\x20+\x20Finish\x20(NOT\x20for\x20rating\x20—\x20rating\x20is\x20OrderHolder-only\x20via\x20named_operator=\x27\x27)'},{'index':0x3,'name':'admin','description':'Admin\x20override\x20(optional)'}],'required_allocators':[{'name':'MerchantAllocation','trigger_node':'Completed','description':'100%\x20to\x20merchant\x20Treasury\x20or\x20personal\x20address.\x20Fires\x20at\x20Completion\x20—\x20NOT\x20at\x20Wonder/NoWonder\x20(those\x20are\x20reputation-only\x20terminals\x20with\x20no\x20fund\x20flow).'}],'forkable_fields':['wonder_node_name','no_wonder_node_name','rating_time_limit_days','additional_rating_nodes'],'applicable_industries':['ecommerce','service','rental','subscription','education'],'relevant_risks':['R-M1-01','R-M1-02','R-M1-08','R-M1-11','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-03'],'creation_notes':['DISPUTE\x20INDEPENDENCE:\x20This\x20Machine\x20MUST\x20NOT\x20contain\x20\x27disputed\x27,\x20\x27refunded\x27,\x20\x27arb\x27,\x20\x27arbitration\x27\x20nodes\x20(R-M1-11\x20critical).\x20Disputes\x20are\x20filed\x20off-Machine\x20—\x20through\x20the\x20Arbitration\x20dispute\x20flow\x20on\x20the\x20order\x20and\x20arbitration\x20objects.','Build\x20order:\x20Permission\x20→\x20Machine\x20(unpublished)\x20→\x20Guards\x20→\x20Bind\x20guards\x20→\x20Publish\x20→\x20Bind\x20to\x20Service\x20→\x20Bind\x20Reward\x20(optional)','First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Order\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20payment\x20is\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Wonder/NoWonder\x20forwards\x20have\x20named_operator=\x27\x27\x20(empty)\x20—\x20this\x20delegates\x20to\x20the\x20OrderHolder\x20(customer).\x20No\x20Permission\x20index\x20needed\x20for\x20rating.','Completed\x20node\x20triggers\x20MerchantAllocation\x20—\x20funds\x20are\x20settled\x20BEFORE\x20the\x20rating\x20window\x20opens.\x20Rating\x20does\x20NOT\x20affect\x20fund\x20flow.','Competing\x20Pair:\x20Praise\x20vs\x20Complain\x20(first-wins)\x20—\x20one\x20rating\x20per\x20order,\x20enforced\x20by\x20Guard\x20+\x20retained_submission\x20audit\x20trail.','Reward\x20object\x20(if\x20bound)\x20is\x20INDEPENDENT\x20of\x20Allocator:\x20Reward.claim()\x20requires\x20Guard+passport,\x20not\x20Permission.\x20Guard\x20checks\x20Progress.current\x20==\x20\x27wonder\x27\x20AND\x20order.holder\x20==\x20signer.','rating_window_guard\x20enforces\x20time\x20limit:\x20context(Clock)\x20<=\x20progress.current_time\x20+\x20rating_time_limit_days.\x20After\x20window\x20closes,\x20no\x20rating\x20possible\x20(Completed\x20becomes\x20true\x20terminal).','Optional:\x20bind\x20a\x20Repository\x20to\x20record\x20feedback\x20node\x20for\x20analytics.\x20Repository\x20write\x20happens\x20via\x20Guard\x27s\x20data\x20extraction\x20(NOT\x20auto-passed\x20—\x20see\x2006\x20§14.4).'],'example_use_case':'Photography\x20service:\x20Paid\x20→\x20Shipped\x20(booking\x20confirmed)\x20→\x20Received\x20(session\x20delivered)\x20→\x20Completed\x20'+'(photos\x20delivered,\x20funds\x20released\x20to\x20photographer)\x20→\x20customer\x20advances\x20to\x20\x27wonder\x27\x20(loved\x20the\x20work)\x20'+'or\x20\x27no_wonder\x27\x20(didn\x27t\x20love\x20it).\x20Bound\x20Reward\x20pays\x201\x20WOW\x20to\x20customers\x20who\x20advance\x20to\x20\x27wonder\x27.\x20'+'Merchant\x27s\x20wonder/no_wonder\x20ratio\x20becomes\x20an\x20on-chain\x20reputation\x20signal.\x20Disputes\x20(if\x20any)\x20are\x20'+'filed\x20separately\x20via\x20Arbitration\x20object\x20—\x20never\x20enter\x20this\x20Machine.','publish_checklist':['All\x206\x20nodes\x20verified:\x20no\x20\x27disputed\x27/\x27refunded\x27/\x27arb\x27/\x27arbitration\x27\x20names\x20(R-M1-11\x20PASS)','Entry\x20Pair\x20exists\x20(prev_node=\x27\x27\x20targets\x20\x27Paid\x27)','Competing\x20Pair\x20tested:\x20Praise\x20vs\x20Complain\x20—\x20first-wins\x20semantics\x20verified\x20on\x20testnet','rating_window_guard\x20tested:\x20rating\x20blocked\x20after\x20time\x20limit\x20expires','MerchantAllocation\x20fires\x20ONLY\x20at\x20Completed\x20(NOT\x20at\x20Wonder/NoWonder)','Reward\x20object\x20(if\x20bound):\x20claim_guard\x20tested\x20—\x20Progress.current\x20==\x20\x27wonder\x27\x20required,\x20claim\x20fails\x20at\x20\x27no_wonder\x27\x20or\x20\x27Completed\x27','named_operator=\x27\x27\x20on\x20Praise/Complain\x20forwards\x20verified\x20(OrderHolder-only\x20operation)','machineNode2file\x20export\x20as\x20backup']},{'id':'tpl_machine_subscription','scene_id':'subscription','name':'Subscription\x20/\x20Membership\x20Flow','description':'Subscribe\x20->\x20Pay\x20->\x20Activate\x20->\x20[Renew\x20|\x20Expire]\x20->\x20Cancel/End.\x20Time-lock\x20on\x20Renew.\x20'+'Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20(first-wins).\x20Repository\x20stores\x20subscription\x20status.','recommended_patterns':['P-M-SEQ','P-M-COMPETING'],'recommended_topology':['P-M-LINEAR','P-M-COMPETING'],'parameters':[{'name':'merchant_permission','type':'permission_ref','required':!![],'description':'Provider\x20Permission\x20object'},{'name':'subscription_duration_days','type':'number','required':!![],'default':'30','description':'Days\x20between\x20Renew\x20and\x20Expire\x20eligibility'},{'name':'repository_ref','type':'address','required':!![],'description':'Repository\x20object\x20storing\x20subscription\x20status\x20(note:\x20not\x20consensus_repositories,\x20which\x20is\x20declarative-only\x20—\x20see\x2006\x20§14.4)'}],'example_nodes':[{'name':'Paid','description':'Entry:\x20subscription\x20created\x20and\x20paid\x20via\x20Service.buy();\x20Machine\x20starts\x20here'},{'name':'Active'},{'name':'RenewEligible'},{'name':'Renewed'},{'name':'Expired'},{'name':'Cancelled'},{'name':'Ended'}],'example_pairs':[{'prev_node':'','next_node':'Paid','threshold':0x1,'forwards':[{'name':'Enter','weight':0x1,'named_operator':''}]},{'prev_node':'Paid','next_node':'Active','threshold':0x1,'forwards':[{'name':'Activate','weight':0x1,'permission_index':0x2,'guard':'repository_write_guard'}]},{'prev_node':'Active','next_node':'RenewEligible','threshold':0x1,'forwards':[{'name':'TimeUnlock','weight':0x1,'permission_index':0x3,'guard':'time_lock_guard_${subscription_duration_days}_days'}]},{'prev_node':'RenewEligible','next_node':'Renewed','threshold':0x1,'forwards':[{'name':'Renew','weight':0x1,'named_operator':''}]},{'prev_node':'RenewEligible','next_node':'Expired','threshold':0x1,'forwards':[{'name':'AutoExpire','weight':0x1,'permission_index':0x3,'guard':'expire_time_guard'}]},{'prev_node':'RenewEligible','next_node':'Cancelled','threshold':0x1,'forwards':[{'name':'Cancel','weight':0x1,'named_operator':''}]},{'prev_node':'Renewed','next_node':'Active','threshold':0x1,'forwards':[{'name':'Reactivate','weight':0x1,'permission_index':0x2}]},{'prev_node':'Expired','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseExpired','weight':0x1,'permission_index':0x3}]},{'prev_node':'Cancelled','next_node':'Ended','threshold':0x1,'forwards':[{'name':'CloseCancelled','weight':0x1,'permission_index':0x2}]}],'required_guards':[{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'TimeUnlock','purpose':'Time\x20lock:\x20context(Clock)\x20>=\x20progress.current_time\x20+\x20${subscription_duration_days}\x20days'},{'guard_template_id':'tpl_write_guard_type_check','bound_to_forward':'Activate','purpose':'Write\x20subscription\x20status\x20to\x20Repository'},{'guard_template_id':'tpl_forward_node_check','bound_to_forward':'AutoExpire','purpose':'Hard\x20expire:\x20context(Clock)\x20>=\x20progress.current_time\x20+\x202x\x20duration'}],'required_permissions':[{'index':0x2,'name':'provider','description':'Provider\x20activates/reactivates'},{'index':0x3,'name':'admin','description':'Time-lock\x20triggers'}],'required_allocators':[{'name':'RenewAllocation','trigger_node':'Renewed','description':'Charge\x20renewal\x20fee\x20on\x20Renew'}],'forkable_fields':['duration_days','grace_period','additional_tiers'],'applicable_industries':['subscription','saas','membership','service'],'relevant_risks':['R-M1-01','R-M1-08','R-M2-01','R-M2-05','R-M3-02','R-M3-04','R-M4-01','R-M5-04'],'creation_notes':['First\x20node\x20\x27Paid\x27\x20represents\x20post-payment\x20state\x20—\x20Service.buy()\x20completes\x20subscription\x20payment\x20atomically\x20before\x20Progress\x20is\x20created','No\x20separate\x20\x27Subscribe\x27\x20or\x20\x27Pay\x27\x20nodes\x20needed\x20—\x20subscription\x20and\x20payment\x20are\x20handled\x20by\x20Service.buy(),\x20not\x20Machine','Time-lock\x20uses\x20context(Clock)\x20—\x20verify\x20Clock\x20address\x20in\x20Guard\x20table','Competing\x20Pair:\x20Renew\x20vs\x20Expire\x20vs\x20Cancel\x20—\x20first-wins','Renewed\x20node\x20loops\x20back\x20to\x20Active\x20(recurring\x20subscription)','Repository\x20records\x20subscription\x20status\x20for\x20cross-Machine\x20verification','Renewal\x20Allocation\x20triggers\x20on\x20Renewed\x20node\x20(not\x20Active\x20—\x20avoids\x20double-charge)','Note:\x20consensus_repositories\x20is\x20declarative-only\x20(NOT\x20auto-passed\x20to\x20Progress);\x20use\x20repository_ref\x20parameter\x20for\x20actual\x20Repository\x20object\x20—\x20see\x2006\x20§14.4','VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20replace\x20time-lock\x20Renew/Expire\x20with\x20content-delivery\x20flow:','\x20\x206-node\x20variant:\x20Paid\x20(entry)\x20→\x20ContentPublished\x20→\x20Completed\x20(terminal-success)','\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Paid\x20→\x20Cancelled\x20(terminal-cancel)\x20|\x20Paid\x20→\x20Disputed\x20→\x20Refunded\x20(terminal-dispute)','\x20\x20Permission:\x20author=index\x201000\x20(publish\x20+\x20cancel),\x20arbitrator=index\x201500\x20(resolve\x20dispute),\x20reader=namedOperator=\x27\x27\x20(open\x20role,\x20no\x20specific\x20operator)','\x20\x20Guards:\x20deliver_guard\x20(verify\x20author\x20permission\x20+\x20content\x20hash),\x20cancel_guard\x20(verify\x20subscriber\x20request),\x20refund_guard\x20(verify\x20arbitration\x20outcome)','\x20\x20Allocators:\x20deliver=100%\x20to\x20author,\x20cancel=100%\x20refund\x20to\x20subscriber,\x20dispute=100%\x20refund\x20to\x20subscriber\x20(Guard-first-wins\x20pattern)','\x20\x20First-Forward-wins:\x20when\x20Paid\x20has\x20competing\x20forwards\x20(Deliver|Cancel|Dispute),\x20the\x20first\x20triggered\x20forward\x20wins;\x20subscribers\x20cannot\x20double-claim','CRITICAL\x20—\x20v1→v2\x20lesson:\x20arbitrations\x20MUST\x20be\x20added\x20BEFORE\x20Service.publish\x20(post-publish,\x20arbitrations\x20become\x20immutable\x20and\x20cannot\x20be\x20added\x20—\x20F-S-21)','\x20\x20If\x20you\x20accidentally\x20published\x20without\x20arbitrations,\x20you\x20MUST\x20create\x20a\x20new\x20Service\x20v2\x20with\x20arbitrations\x20bound\x20before\x20publishing\x20(the\x20v1\x20Service\x20must\x20be\x20paused/abandoned)','\x20\x20ConfirmGate\x20(C-S-19,\x20QS11)\x20will\x20warn\x20before\x20publish\x20without\x20arbitrations\x20—\x20do\x20not\x20bypass\x20this\x20warning\x20unless\x20explicitly\x20intending\x20no-arbitration\x20operation','Build\x20order\x20(content\x20variant):\x20Permission\x20→\x20Machine\x20(unpublished,\x20with\x20initial\x20forward)\x20→\x203\x20Guards\x20→\x203\x20Allocators\x20(template\x20on\x20Service)\x20→\x20Service\x20(unpublished,\x20bind\x20machine+buy_guard+order_allocators+arbitrations)\x20→\x20Publish\x20Service\x20→\x20Test\x20order\x20(3\x20paths:\x20normal/cancel/dispute)'],'example_use_case':'Monthly\x20SaaS\x20subscription:\x20$10/month.\x20Customer\x20can\x20renew\x20anytime\x20after\x20day\x2025.\x20'+'Auto-expire\x20on\x20day\x2035\x20if\x20not\x20renewed.\x20Cancel\x20anytime.\x0a\x0a'+'VARIANT\x20—\x20Content\x20subscription\x20(Substack-style):\x20$5/month\x20newsletter.\x20Author\x20publishes\x20content\x20→\x20'+'subscriber\x20reads.\x20Subscriber\x20can\x20cancel\x20anytime\x20for\x20full\x20refund.\x20Disputes\x20resolved\x20by\x20arbitrator\x20'+'(100%\x20refund\x20to\x20subscriber\x20if\x20dispute\x20upheld).\x206-node\x20Machine,\x203\x20Guards,\x203\x20Allocators.\x20'+'Tested\x20on\x20testnet\x20with\x203\x20order\x20paths:\x20normal\x20delivery,\x20cancel,\x20dispute.','publish_checklist':['Time-lock\x20Guards\x20tested\x20on\x20testnet\x20(both\x20TimeUnlock\x20+\x20AutoExpire)','Competing\x20Pair\x20semantics\x20verified\x20(Renew\x20vs\x20Expire\x20vs\x20Cancel)','Repository\x20write\x20tested\x20(subscription\x20status\x20queryable)','Renewal\x20loop\x20tested:\x20Paid\x20->\x20Active\x20->\x20RenewEligible\x20->\x20Renewed\x20->\x20Active','Content\x20variant:\x20initial\x20node\x20(prev_node=\x27\x27)\x20MUST\x20have\x20at\x20least\x20one\x20forward\x20(FIX-002)\x20—\x20empty\x20forwards=[]\x20causes\x20Progress\x20to\x20be\x20permanently\x20stuck','Content\x20variant:\x20arbitrations\x20added\x20BEFORE\x20publish\x20(cannot\x20add\x20post-publish\x20per\x20F-S-21)','Content\x20variant:\x203\x20order\x20paths\x20tested\x20on\x20testnet\x20—\x20normal\x20delivery,\x20cancel-within-grace,\x20dispute-resolution','Content\x20variant:\x20machineNode2file\x20export\x20as\x20backup\x20(covers\x20all\x206\x20nodes)']}];export const MACHINE_TEMPLATES_VERSION='1.0.0';export const MACHINE_TEMPLATES_COUNT=MACHINE_TEMPLATES['length'];export function getAllTemplates(){return MACHINE_TEMPLATES;}export function getTemplateById(a){return MACHINE_TEMPLATES['find'](b=>b['id']===a);}export function getTemplatesByScene(a){return MACHINE_TEMPLATES['filter'](b=>b['scene_id']===a);}export function getTemplatesByIndustry(a){return MACHINE_TEMPLATES['filter'](b=>b['applicable_industries']['includes'](a));}export function getTemplatesByPattern(a){return MACHINE_TEMPLATES['filter'](b=>b['recommended_patterns']['includes'](a));}export function suggestTemplateForIntent(a){const b=inferSceneFromFlow(a);if(!b)return undefined;const c=getTemplatesByScene(b['id']);return c[0x0];}export function getTemplateParameters(a){const b=getTemplateById(a);return b?b['parameters']:[];}export function getRequiredParameters(a){return getTemplateParameters(a)['filter'](b=>b['required']);}export function getOptionalParameters(a){return getTemplateParameters(a)['filter'](b=>!b['required']);}function validateParamType(a,b){switch(b){case'address':case'string':case'permission_ref':case'guard_ref':case'machine_ref':case'service_ref':case'arbitration_ref':case'reward_ref':return typeof a==='string';case'number':return typeof a==='number'||typeof a==='string'&&/^\d+$/['test'](a);case'boolean':return typeof a==='boolean';case'vec_address':case'vec_string':case'node_name_list':return Array['isArray'](a)&&a['every'](c=>typeof c==='string');default:return![];}}function deepSubstitute(a,b){if(typeof a==='string')return a['replace'](/\$\{(\w+)\}/g,(c,d)=>d in b?String(b[d]):'${'+d+'}');if(Array['isArray'](a))return a['map'](c=>deepSubstitute(c,b));if(a&&typeof a==='object'){const c={};for(const [d,e]of Object['entries'](a)){c[d]=deepSubstitute(e,b);}return c;}return a;}export function fillTemplate(a,b){const c=getTemplateById(a);if(!c)return{'success':![],'validation_errors':['Template\x20not\x20found:\x20'+a]};const d=c['parameters']['filter'](h=>h['required']&&!(h['name']in b))['map'](h=>h['name']);if(d['length']>0x0)return{'success':![],'missing_params':d,'validation_errors':['Missing\x20required\x20parameters:\x20'+d['join'](',\x20')]};const e=[];for(const h of c['parameters']){if(h['name']in b){const i=b[h['name']];!validateParamType(i,h['type'])&&e['push']('Parameter\x20\x22'+h['name']+'\x22\x20type\x20mismatch:\x20expected\x20'+h['type']+',\x20got\x20'+typeof i);}}if(e['length']>0x0)return{'success':![],'validation_errors':e};const f=deepSubstitute(c['example_nodes'],b),g=deepSubstitute(c['example_pairs'],b);return{'success':!![],'filled_nodes':f,'filled_pairs':g};}export function forkTemplate(a){const b=getTemplateById(a);if(!b)return undefined;const c={};for(const d of b['forkable_fields']){c[d]='see\x20example_nodes/example_pairs';}return{'template_id':a,'forkable_fields':b['forkable_fields'],'current_values':c,'instructions':['Modify\x20fields\x20below\x20to\x20customize\x20the\x20workflow','Keep\x20template\x20structure\x20intact\x20unless\x20explicitly\x20noted','Run\x20risk\x20assessment\x20after\x20modification\x20(machine-risk.ts)','User\x20MUST\x20confirm\x20final\x20JSON\x20before\x20publish\x20(ConfirmGate)']};}export const DECISION_TREE={'Q1':{'question':'Does\x20the\x20workflow\x20involve\x20multiple\x20independent\x20services/parties?','no_next':'Q3'},'Q2':{'question':'Are\x20these\x20services\x20already\x20published\x20as\x20separate\x20Machines?','yes_template':'tpl_machine_cross_machine','no_next':'DECOMPOSE'},'Q3':{'question':'Does\x20any\x20node\x20require\x20multiple\x20parties\x27\x20confirmation\x20to\x20advance?','no_next':'Q5'},'Q4':{'question':'Do\x20all\x20parties\x20have\x20EQUAL\x20weight?','yes_template':'tpl_machine_dual_signature','no_next':'tpl_machine_weighted_voting'},'Q5':{'question':'Does\x20the\x20workflow\x20need\x20exception\x20branches\x20(lost,\x20return,\x20dispute)?','yes_template':'tpl_machine_ecommerce_exceptions','no_next':'Q6'},'Q6':{'question':'Does\x20it\x20involve\x20recurring\x20payments\x20or\x20time-based\x20state\x20changes?','yes_template':'tpl_machine_subscription','no_next':'Q7'},'Q7':{'question':'Does\x20it\x20need\x20privacy-preserving\x20data\x20delivery\x20(Messenger)?','yes_template':'tpl_machine_privacy_delivery','no_next':'Q8'},'Q8':{'question':'Does\x20it\x20involve\x20deposit/refund\x20separation?','yes_template':'tpl_machine_rental','no_next':'Q9'},'Q9':{'question':'Does\x20it\x20need\x20reward/incentive\x20distribution\x20at\x20a\x20specific\x20node?','yes_template':'tpl_machine_reward','no_next':'tpl_machine_ecommerce_standard'}};export function walkDecisionTree(a){let b='Q1';while(b){const c=DECISION_TREE[b];if(!c)return'UNKNOWN';const d=a[b];if(d===undefined)return b;if(d){if(c['yes_template'])return c['yes_template'];if(b==='Q1'){b='Q2';continue;}if(b==='Q3'){b='Q4';continue;}return'UNKNOWN';}else{if(c['no_next']){if(c['no_next']==='DECOMPOSE')return'DECOMPOSE_INTO_MULTIPLE_MACHINES';if(c['no_next']['startsWith']('tpl_'))return c['no_next'];b=c['no_next'];continue;}return'UNKNOWN';}}return'UNKNOWN';}export function verifyTemplateSceneReferences(){const a=[];for(const b of MACHINE_TEMPLATES){!findScene(b['scene_id'])&&a['push']({'template_id':b['id'],'invalid_scene_id':b['scene_id']});}return a;}export function getReferencedGuardTemplateIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['required_guards']){a['add'](c['guard_template_id']);}}return a;}export function getReferencedRiskIds(){const a=new Set();for(const b of MACHINE_TEMPLATES){for(const c of b['relevant_risks']){a['add'](c);}}return a;}export function listTemplates(){return MACHINE_TEMPLATES['map'](a=>({'id':a['id'],'name':a['name'],'scene_id':a['scene_id'],'patterns':a['recommended_patterns'],'industries':a['applicable_industries']}));}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT}from'@wowok/wowok';export{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT};export const PROGRESS_NEW={'index':0xdc,'name':'PROGRESS_NEW','description':'Create\x20new\x20Progress\x20(asserted\x20on\x20direct\x20Progress\x20creation)','governed_operations':['direct\x20Progress\x20creation','passport-guarded\x20Progress\x20creation'],'sdk_exposed':![]};export const PROGRESS_NAMED_OPERATOR={'index':0xdd,'name':'PROGRESS_NAMED_OPERATOR','description':'Manage\x20named\x20operators\x20(add/set/remove)\x20for\x20the\x20namedOperator\x20namespace','governed_operations':['progress::namedOperator_add','progress::namedOperator_set','progress::namedOperator_remove','progress::namedOperator_add_with_passport','progress::namedOperator_set_with_passport','progress::namedOperator_remove_with_passport'],'sdk_exposed':!![]};export const PROGRESS_TASK={'index':0xde,'name':'PROGRESS_TASK','description':'Submit\x20task\x20(one-time,\x20immutable\x20once\x20set\x20—\x20E_TASK_ALREADY_SET)','governed_operations':['submit\x20the\x20task\x20(one-time)','submit\x20the\x20task\x20with\x20a\x20passport'],'sdk_exposed':!![]};export const PROGRESS_CONTEXT_REPOSITORY={'index':0xdf,'name':'PROGRESS_CONTEXT_REPOSITORY','description':'Bind/unbind\x20context\x20Repository\x20(≤\x20MAX_CONTEXT_REPOSITORY_COUNT=30)','governed_operations':['bind\x20a\x20context\x20repository','unbind\x20a\x20context\x20repository','clear\x20all\x20context\x20repositories','bind\x20a\x20context\x20repository\x20(passport-guarded)','unbind\x20a\x20context\x20repository\x20(passport-guarded)','clear\x20all\x20context\x20repositories\x20(passport-guarded)'],'sdk_exposed':!![]};export const PROGRESS_UNHOLD={'index':0xe0,'name':'PROGRESS_UNHOLD','description':'Force\x20unhold\x20(adminUnhold)\x20—\x20bypasses\x20holder\x20check,\x20releases\x20blocked\x20forward','governed_operations':['force\x20unhold\x20(adminUnhold)','force\x20unhold\x20via\x20passport'],'sdk_exposed':!![]};export const PROGRESS_OWNER_RECEIVE={'index':0xe1,'name':'PROGRESS_OWNER_RECEIVE','description':'Owner\x20receives\x20objects/coins\x20(unwrap\x20Receiving<K>\x20→\x20owner)','governed_operations':['owner\x20receives\x20coins','owner\x20receives\x20a\x20generic\x20object','owner\x20receives\x20coins\x20via\x20passport','owner\x20receives\x20a\x20generic\x20object\x20via\x20passport'],'sdk_exposed':![]};export const PROGRESS_PERMISSIONS=[PROGRESS_NEW,PROGRESS_NAMED_OPERATOR,PROGRESS_TASK,PROGRESS_CONTEXT_REPOSITORY,PROGRESS_UNHOLD,PROGRESS_OWNER_RECEIVE];export const PROGRESS_SCENES=[{'id':'progress_task_submit','name':'Task\x20submission\x20&\x20binding\x20workflow','industry':['universal','ecommerce','logistics','education'],'scenario':'Submit\x20a\x20task\x20(Order/Reward/etc.)\x20to\x20Progress\x20via\x20task\x20submission.\x20'+'Task\x20is\x20one-time,\x20immutable\x20—\x20once\x20set,\x20E_TASK_ALREADY_SET\x20blocks\x20any\x20re-assignment.\x20'+'Binds\x20Progress\x201:1\x20to\x20the\x20task\x20object\x20for\x20the\x20rest\x20of\x20its\x20lifecycle.','phases':['task_binding','forward_advance'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_TASK],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Task\x20submission\x20is\x20one-time:\x20verify\x20task\x20address\x20before\x20submission\x20(E_TASK_ALREADY_SET\x20blocks\x20reset)','task\x20is\x20usually\x20an\x20Order\x20created\x20by\x20the\x20buy\x20flow\x20→\x20Progress.task\x20=\x20Order\x20address','Without\x20task,\x20Forward\x20advancement\x20falls\x20back\x20to\x20non-order\x20next()/hold()\x20paths'],'recommended_templates':['T-PR-01']},{'id':'progress_named_operator','name':'Named\x20operator\x20namespace\x20management','industry':['universal','logistics','arbitration','freelance'],'scenario':'Manage\x20named_operator\x20namespace\x20for\x20a\x20Progress.\x20Each\x20named\x20operator\x20is\x20a\x20(name\x20→\x20address\x20list)\x20'+'binding\x20used\x20by\x20Machine.forward.namedOperator\x20to\x20gate\x20next()/hold()\x20advancement.\x20'+'Up\x20to\x2060\x20named\x20operators\x20per\x20Progress,\x20up\x20to\x2080\x20addresses\x20per\x20operator.','phases':['named_operator_mgmt'],'requires_published_machine':!![],'requires_order_bound':![],'named_operator_roles':[{'role':'seller','typical_count':0x1},{'role':'logistics','typical_count':0x1},{'role':'reviewer','typical_count':0x3},{'role':'arbitrator','typical_count':0x5}],'builtin_indexes_consumed':[PROGRESS_NAMED_OPERATOR],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['namedOperator\x20name=\x27\x27:\x20special\x20case\x20—\x20means\x20OrderHolder\x20(order.owner/agent),\x20NOT\x20a\x20real\x20named\x20operator','add/set/remove\x20are\x20idempotent\x20on\x20duplicate\x20addresses\x20(vector::contains\x20check\x20before\x20push)','Use\x20\x27set\x27\x20to\x20REPLACE\x20an\x20operator\x27s\x20address\x20list;\x20use\x20\x27add\x27\x20to\x20extend;\x20\x27remove\x27\x20to\x20subtract','Names\x20must\x20satisfy\x20common::NAME\x20(isValidName)\x20—\x20non-empty,\x20length-bounded'],'recommended_templates':['T-PR-01','T-PR-02']},{'id':'progress_unhold','name':'Hold\x20release\x20(unhold\x20/\x20adminUnhold)\x20workflow','industry':['content','rental','arbitration','subscription'],'scenario':'Release\x20a\x20forward\x20that\x20was\x20previously\x20held.\x20Two\x20paths:\x20'+'(a)\x20unhold\x20by\x20original\x20holder\x20(named_operator\x20match);\x20'+'(b)\x20adminUnhold\x20(224)\x20by\x20permission-table\x20holder\x20—\x20bypasses\x20holder\x20check.\x20'+'adminUnhold\x20is\x20the\x20deadlock-resolution\x20escape\x20hatch\x20when\x20a\x20holder\x20is\x20unresponsive.','phases':['hold_state','unhold_state'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[{'role':'holder','typical_count':0x1},{'role':'admin','typical_count':0x1}],'builtin_indexes_consumed':[PROGRESS_UNHOLD],'typical_context_repository_count':0x0,'uses_hold_mechanism':!![],'uses_admin_unhold':!![],'common_patterns':['unhold\x20checks\x20whether\x20the\x20sender\x20holds\x20permission\x20index\x20224:\x20if\x20yes,\x20force\x20release;\x20if\x20no,\x20require\x20holder\x20match','adminUnhold\x20has\x20wider\x20blast\x20radius\x20—\x20only\x20grant\x20224\x20to\x20trusted\x20recovery\x20operators','If\x20forward\x20already\x20accomplished,\x20E_FORWARD_ALREADY_ACCOMPLISHED\x20blocks\x20re-hold','Repeated\x20hold/unhold\x20cycles\x20indicate\x20a\x20stuck\x20workflow\x20—\x20surface\x20to\x20order-monitor'],'recommended_templates':['T-PR-05']},{'id':'progress_context_repository','name':'Context\x20Repository\x20binding\x20workflow','industry':['education','content','rental','cross_chain'],'scenario':'Bind/unbind\x20Repository\x20objects\x20as\x20Progress\x20context_repositories.\x20'+'Used\x20to\x20provide\x20query-time\x20context\x20(learning\x20progress,\x20inspection\x20records,\x20bridge\x20state).\x20'+'Up\x20to\x20MAX_CONTEXT_REPOSITORY_COUNT=30\x20repositories\x20per\x20Progress.','phases':['context_binding'],'requires_published_machine':!![],'requires_order_bound':![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_CONTEXT_REPOSITORY],'typical_context_repository_count':0x3,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Binding\x20a\x20context\x20repository\x20registers\x20the\x20link\x20through\x20an\x20affiliation\x20transaction\x20(enables\x20cross-object\x20queries)','Unbinding\x20disaffiliates\x20the\x20link\x20—\x20Repository\x20may\x20be\x20garbage-collected\x20if\x20no\x20other\x20refs','Clearing\x20empties\x20the\x20entire\x20list\x20in\x20one\x20transaction','add\x20is\x20idempotent:\x20if\x20Repository\x20already\x20in\x20list,\x20no-op\x20(vector::contains\x20check)','Bind\x20before\x20forward\x20advance\x20so\x20on-chain\x20guards\x20can\x20read\x20context\x20data'],'recommended_templates':['T-PR-03']},{'id':'progress_owner_receive','name':'Owner\x20receive\x20(unwrap)\x20workflow','industry':['finance','treasury','rental','freelance'],'scenario':'Owner\x20receives\x20Receiving<K>\x20objects\x20or\x20CoinWrapper<T>\x20coins\x20sent\x20to\x20the\x20Progress\x20object.\x20'+'unwrap\x20→\x20forwarded\x20to\x20the\x20Permission\x20owner\x20through\x20the\x20permission\x20owner-receive\x20path.\x20'+'Used\x20at\x20terminal\x20nodes\x20(return_approved,\x20completed,\x20enforced)\x20to\x20disburse\x20funds.','phases':['owner_receive'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_OWNER_RECEIVE],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['owner_receive\x20unwraps\x20CoinWrapper<T>\x20via\x20the\x20payment\x27s\x20type-checked\x20unwrap\x20(amount\x20validation)','Receiving\x20a\x20generic\x20K:key+store\x20object\x20forwards\x20it\x20to\x20the\x20Permission\x20owner','Triggered\x20at\x20terminal\x20nodes\x20(e.g.\x20\x27return_approved\x27\x20in\x20rental,\x20\x27enforced\x27\x20in\x20arbitration)','Permission\x20owner\x20≠\x20Progress\x20creator:\x20receives\x20flow\x20to\x20whoever\x20owns\x20the\x20bound\x20Machine\x27s\x20Permission'],'recommended_templates':['T-PR-06']},{'id':'progress_completed','name':'Forward\x20advancement\x20&\x20session\x20completion','industry':['universal'],'scenario':'Advance\x20Progress\x20via\x20next()\x20/\x20the\x20order-holder\x20advancement\x20path\x20—\x20accumulates\x20weights\x20in\x20session.forwards,\x20'+'and\x20when\x20weights\x20≥\x20threshold,\x20moves\x20session\x20into\x20history\x20and\x20updates\x20Progress.current.\x20'+'This\x20is\x20the\x20canonical\x20Forward\x20advancement\x20path\x20for\x20ALL\x20non-hold\x20operations.','phases':['forward_advance','completed'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[{'role':'OrderHolder','typical_count':0x1},{'role':'next_node_operator','typical_count':0x1}],'builtin_indexes_consumed':[],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Forward\x20guard\x20(Some):\x20requires\x20Passport;\x20the\x20passport\x20verification\x20against\x20the\x20guard\x20must\x20pass','Forward\x20guard\x20(None):\x20requires\x20permissionIndex\x20(Some)\x20or\x20namedOperator\x20match\x20(ASSERT_PERMISSION)','session.weights\x20+=\x20forward.weight;\x20when\x20≥\x20threshold,\x20push\x20session\x20into\x20ParentTableVec<History>','Progress.current\x20=\x20next_node\x20only\x20after\x20session\x20completes\x20(atomic\x20update)','E_NOT_THE_HOLDER:\x20if\x20forward\x20was\x20held\x20by\x20another\x20address,\x20next()\x20aborts','E_FORWARD_ALREADY_ACCOMPLISHED:\x20re-hold\x20on\x20completed\x20forward\x20is\x20blocked','⚠\x20ROUTING\x20RULE:\x20Forward.namedOperator=\x22\x22\x20(empty)\x20→\x20MUST\x20use\x20the\x20order-holder\x20path\x20(order.progress);\x20'+'non-empty\x20namedOperator\x20or\x20permissionIndex-only\x20→\x20MUST\x20call\x20progress.operate\x20(next).\x20'+'Wrong\x20path\x20→\x20Permission\x20denied\x20(abort\x20code\x205).\x20See\x20file\x20header\x20CRITICAL\x20ROUTING\x20RULE.'],'recommended_templates':['T-PR-04']}];export const PROGRESS_LEDGER_VERSION='1.0.0';export function getScenesByPhase(a){return PROGRESS_SCENES['filter'](b=>b['phases']['includes'](a));}export function findSceneById(a){return PROGRESS_SCENES['find'](b=>b['id']===a);}export function getScenesByIndustry(a){return PROGRESS_SCENES['filter'](b=>b['industry']['includes'](a)||b['industry']['includes']('universal'));}export function getBuiltinPermissionByIndex(a){return PROGRESS_PERMISSIONS['find'](b=>b['index']===a);}export function isProgressBuiltinPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['adminunhold','progress_unhold'],['admin\x20unhold','progress_unhold'],['force\x20unhold','progress_unhold'],['unhold','progress_unhold'],['release\x20hold','progress_unhold'],['owner_receive','progress_owner_receive'],['owner\x20receive','progress_owner_receive'],['unwrap','progress_owner_receive'],['context_repository','progress_context_repository'],['context\x20repository','progress_context_repository'],['repository\x20binding','progress_context_repository'],['named_operator','progress_named_operator'],['named\x20operator','progress_named_operator'],['namedoperator','progress_named_operator'],['task\x20set','progress_task_submit'],['submit\x20task','progress_task_submit'],['next','progress_completed'],['advance','progress_completed'],['complete','progress_completed']];for(const [d,e]of c){if(b['includes'](d)){const f=findSceneById(e);if(f)return f;}}return undefined;}export function getAllBuiltinPermissions(){return[...PROGRESS_PERMISSIONS];}export function getProgressScenesCount(){return PROGRESS_SCENES['length'];}export function validateNamedOperatorAddressList(b){const c=[];b['length']>MAX_NAMED_OPERATOR_ADDRESS_COUNT&&c['push']('Named\x20operator\x20address\x20count\x20'+b['length']+'\x20exceeds\x20MAX_NAMED_OPERATOR_ADDRESS_COUNT\x20'+MAX_NAMED_OPERATOR_ADDRESS_COUNT);const d=new Set();for(const e of b){if(d['has'](e)){c['push']('Duplicate\x20address\x20in\x20list:\x20'+e+'\x20(Move\x20will\x20dedupe\x20silently)');break;}d['add'](e);}return{'ok':c['length']===0x0,'violations':c};}export function validateNamedOperatorCount(a){if(a>=MAX_NAMED_OPERATOR_COUNT)return{'ok':![],'violation':'Named\x20operator\x20count\x20'+a+'\x20would\x20exceed\x20MAX_NAMED_OPERATOR_COUNT\x20'+MAX_NAMED_OPERATOR_COUNT};return{'ok':!![]};}export function validateContextRepositoryCount(a,b){const c=a+b;if(c>MAX_CONTEXT_REPOSITORY_COUNT)return{'ok':![],'violation':'Context\x20repository\x20count\x20'+c+'\x20would\x20exceed\x20MAX_CONTEXT_REPOSITORY_COUNT\x20'+MAX_CONTEXT_REPOSITORY_COUNT};return{'ok':!![]};}export const PROGRESS_CROSS_OBJECT_REFS=[{'object':'Machine','phase':'universal','relationship':'Progress.machine\x20(immutable\x20bind,\x20E_MACHINE_NOT_MATCH\x20on\x20every\x20op)'},{'object':'Order','phase':'forward_advance','relationship':'Progress.task\x20=\x20Order.address\x20(1:1,\x20set\x20via\x20task\x20submission\x20or\x20the\x20buy\x20flow)'},{'object':'Order','phase':'forward_advance','relationship':'order-holder\x20paths\x20(advance\x20/\x20hold):\x20the\x20order\x20owner-or-agent\x20permission\x20check\x20gates\x20Forward\x20advance'},{'object':'Permission','phase':'universal','relationship':'Machine.permission\x20is\x20borrowed\x20for\x20ALL\x20220-225\x20assertions'},{'object':'Repository','phase':'context_binding','relationship':'context_repositories:\x20vector<address>\x20(≤\x2030),\x20bound\x20via\x20an\x20affiliation\x20transaction'},{'object':'Service','phase':'creation','relationship':'the\x20buy\x20flow\x20creates\x20the\x20Progress\x20internally\x20(bypasses\x20220\x20assertion\x20—\x20package-internal\x20entry)'},{'object':'Passport','phase':'forward_advance','relationship':'Forward.guard\x20(Some)\x20requires\x20Passport\x20+\x20passing\x20the\x20passport\x20verification'},{'object':'Passport','phase':'unhold_state','relationship':'passport-based\x20unhold:\x20224\x20check\x20via\x20passport\x20(fallback\x20when\x20the\x20sender\x27s\x20direct\x20224\x20permission\x20check\x20fails)'},{'object':'Payment','phase':'owner_receive','relationship':'owner_receive\x20unwraps\x20CoinWrapper<T>\x20via\x20the\x20payment\x27s\x20type-checked\x20unwrap'},{'object':'Allocation','phase':'completed','relationship':'Terminal\x20node\x20triggers\x20Allocation\x20alloc\x20(e.g.\x20\x27completed\x27,\x20\x27enforced\x27,\x20\x27return_approved\x27)'}];
|
|
1
|
+
import{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT}from'@wowok/wowok';export{MAX_NAMED_OPERATOR_COUNT,MAX_NAMED_OPERATOR_ADDRESS_COUNT,MAX_CONTEXT_REPOSITORY_COUNT};export const PROGRESS_NEW={'index':0xdc,'name':'PROGRESS_NEW','description':'Create\x20new\x20Progress\x20(asserted\x20on\x20direct\x20Progress\x20creation)','governed_operations':['direct\x20Progress\x20creation','passport-guarded\x20Progress\x20creation'],'sdk_exposed':![]};export const PROGRESS_NAMED_OPERATOR={'index':0xdd,'name':'PROGRESS_NAMED_OPERATOR','description':'Manage\x20named\x20operators\x20(add/set/remove)\x20for\x20the\x20namedOperator\x20namespace','governed_operations':['progress::namedOperator_add','progress::namedOperator_set','progress::namedOperator_remove','progress::namedOperator_add_with_passport','progress::namedOperator_set_with_passport','progress::namedOperator_remove_with_passport'],'sdk_exposed':!![]};export const PROGRESS_TASK={'index':0xde,'name':'PROGRESS_TASK','description':'Submit\x20task\x20(one-time,\x20immutable\x20once\x20set\x20—\x20E_TASK_ALREADY_SET)','governed_operations':['submit\x20the\x20task\x20(one-time)','submit\x20the\x20task\x20with\x20a\x20passport'],'sdk_exposed':!![]};export const PROGRESS_CONTEXT_REPOSITORY={'index':0xdf,'name':'PROGRESS_CONTEXT_REPOSITORY','description':'Bind/unbind\x20context\x20Repository\x20(≤\x20MAX_CONTEXT_REPOSITORY_COUNT=30)','governed_operations':['bind\x20a\x20context\x20repository','unbind\x20a\x20context\x20repository','clear\x20all\x20context\x20repositories','bind\x20a\x20context\x20repository\x20(passport-guarded)','unbind\x20a\x20context\x20repository\x20(passport-guarded)','clear\x20all\x20context\x20repositories\x20(passport-guarded)'],'sdk_exposed':!![]};export const PROGRESS_UNHOLD={'index':0xe0,'name':'PROGRESS_UNHOLD','description':'Force\x20unhold\x20(adminUnhold)\x20—\x20bypasses\x20holder\x20check,\x20releases\x20blocked\x20forward','governed_operations':['force\x20unhold\x20(adminUnhold)','force\x20unhold\x20via\x20passport'],'sdk_exposed':!![]};export const PROGRESS_OWNER_RECEIVE={'index':0xe1,'name':'PROGRESS_OWNER_RECEIVE','description':'Owner\x20receives\x20objects/coins\x20(unwrap\x20Receiving<K>\x20→\x20owner)','governed_operations':['owner\x20receives\x20coins','owner\x20receives\x20a\x20generic\x20object','owner\x20receives\x20coins\x20via\x20passport','owner\x20receives\x20a\x20generic\x20object\x20via\x20passport'],'sdk_exposed':![]};export const PROGRESS_PERMISSIONS=[PROGRESS_NEW,PROGRESS_NAMED_OPERATOR,PROGRESS_TASK,PROGRESS_CONTEXT_REPOSITORY,PROGRESS_UNHOLD,PROGRESS_OWNER_RECEIVE];export const PROGRESS_SCENES=[{'id':'progress_task_submit','name':'Task\x20submission\x20&\x20binding\x20workflow','industry':['universal','ecommerce','logistics','education'],'scenario':'Submit\x20a\x20task\x20(Order/Reward/etc.)\x20to\x20Progress\x20via\x20task\x20submission.\x20'+'Task\x20is\x20one-time,\x20immutable\x20—\x20once\x20set,\x20E_TASK_ALREADY_SET\x20blocks\x20any\x20re-assignment.\x20'+'Binds\x20Progress\x201:1\x20to\x20the\x20task\x20object\x20for\x20the\x20rest\x20of\x20its\x20lifecycle.','phases':['task_binding','forward_advance'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_TASK],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Task\x20submission\x20is\x20one-time:\x20verify\x20task\x20address\x20before\x20submission\x20(E_TASK_ALREADY_SET\x20blocks\x20reset)','task\x20is\x20usually\x20an\x20Order\x20created\x20by\x20the\x20buy\x20flow\x20→\x20Progress.task\x20=\x20Order\x20address','Without\x20task,\x20Forward\x20advancement\x20falls\x20back\x20to\x20non-order\x20next()/hold()\x20paths'],'recommended_templates':['T-PR-01']},{'id':'progress_named_operator','name':'Named\x20operator\x20namespace\x20management','industry':['universal','logistics','arbitration','freelance'],'scenario':'Manage\x20named_operator\x20namespace\x20for\x20a\x20Progress.\x20Each\x20named\x20operator\x20is\x20a\x20(name\x20→\x20address\x20list)\x20'+'binding\x20used\x20by\x20Machine.forward.namedOperator\x20to\x20gate\x20next()/hold()\x20advancement.\x20'+'Up\x20to\x2060\x20named\x20operators\x20per\x20Progress,\x20up\x20to\x2080\x20addresses\x20per\x20operator.','phases':['named_operator_mgmt'],'requires_published_machine':!![],'requires_order_bound':![],'named_operator_roles':[{'role':'seller','typical_count':0x1},{'role':'logistics','typical_count':0x1},{'role':'reviewer','typical_count':0x3},{'role':'arbitrator','typical_count':0x5}],'builtin_indexes_consumed':[PROGRESS_NAMED_OPERATOR],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['namedOperator\x20name=\x27\x27:\x20special\x20case\x20—\x20means\x20OrderHolder\x20(order.owner/agent),\x20NOT\x20a\x20real\x20named\x20operator','add/set/remove\x20are\x20idempotent\x20on\x20duplicate\x20addresses\x20(vector::contains\x20check\x20before\x20push)','Use\x20\x27set\x27\x20to\x20REPLACE\x20an\x20operator\x27s\x20address\x20list;\x20use\x20\x27add\x27\x20to\x20extend;\x20\x27remove\x27\x20to\x20subtract','Names\x20must\x20satisfy\x20common::NAME\x20(isValidName)\x20—\x20non-empty,\x20length-bounded'],'recommended_templates':['T-PR-01','T-PR-02']},{'id':'progress_unhold','name':'Hold\x20release\x20(unhold\x20/\x20adminUnhold)\x20workflow','industry':['content','rental','arbitration','subscription'],'scenario':'Release\x20a\x20forward\x20that\x20was\x20previously\x20held.\x20Two\x20paths:\x20'+'(a)\x20unhold\x20by\x20original\x20holder\x20(named_operator\x20match);\x20'+'(b)\x20adminUnhold\x20(224)\x20by\x20permission-table\x20holder\x20—\x20bypasses\x20holder\x20check.\x20'+'adminUnhold\x20is\x20the\x20deadlock-resolution\x20escape\x20hatch\x20when\x20a\x20holder\x20is\x20unresponsive.','phases':['hold_state','unhold_state'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[{'role':'holder','typical_count':0x1},{'role':'admin','typical_count':0x1}],'builtin_indexes_consumed':[PROGRESS_UNHOLD],'typical_context_repository_count':0x0,'uses_hold_mechanism':!![],'uses_admin_unhold':!![],'common_patterns':['unhold\x20checks\x20whether\x20the\x20sender\x20holds\x20permission\x20index\x20224:\x20if\x20yes,\x20force\x20release;\x20if\x20no,\x20require\x20holder\x20match','adminUnhold\x20has\x20wider\x20blast\x20radius\x20—\x20only\x20grant\x20224\x20to\x20trusted\x20recovery\x20operators','If\x20forward\x20already\x20accomplished,\x20E_FORWARD_ALREADY_ACCOMPLISHED\x20blocks\x20re-hold','Repeated\x20hold/unhold\x20cycles\x20indicate\x20a\x20stuck\x20workflow\x20—\x20surface\x20to\x20order-monitor'],'recommended_templates':['T-PR-05']},{'id':'progress_context_repository','name':'Context\x20Repository\x20binding\x20workflow','industry':['education','content','rental','cross_chain'],'scenario':'Bind/unbind\x20Repository\x20objects\x20as\x20Progress\x20context_repositories.\x20'+'Used\x20to\x20provide\x20query-time\x20context\x20(learning\x20progress,\x20inspection\x20records,\x20bridge\x20state).\x20'+'Up\x20to\x20MAX_CONTEXT_REPOSITORY_COUNT=30\x20repositories\x20per\x20Progress.','phases':['context_binding'],'requires_published_machine':!![],'requires_order_bound':![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_CONTEXT_REPOSITORY],'typical_context_repository_count':0x3,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Binding\x20a\x20context\x20repository\x20registers\x20the\x20link\x20through\x20an\x20affiliation\x20transaction\x20(enables\x20cross-object\x20queries)','Unbinding\x20disaffiliates\x20the\x20link\x20—\x20Repository\x20may\x20be\x20garbage-collected\x20if\x20no\x20other\x20refs','Clearing\x20empties\x20the\x20entire\x20list\x20in\x20one\x20transaction','add\x20is\x20idempotent:\x20if\x20Repository\x20already\x20in\x20list,\x20no-op\x20(vector::contains\x20check)','Bind\x20before\x20forward\x20advance\x20so\x20on-chain\x20guards\x20can\x20read\x20context\x20data'],'recommended_templates':['T-PR-03']},{'id':'progress_owner_receive','name':'Owner\x20receive\x20(unwrap)\x20workflow','industry':['finance','treasury','rental','freelance'],'scenario':'Owner\x20receives\x20Receiving<K>\x20objects\x20or\x20CoinWrapper<T>\x20coins\x20sent\x20to\x20the\x20Progress\x20object.\x20'+'unwrap\x20→\x20forwarded\x20to\x20the\x20Permission\x20owner\x20through\x20the\x20permission\x20owner-receive\x20path.\x20'+'Used\x20at\x20terminal\x20nodes\x20(return_approved,\x20completed,\x20enforced)\x20to\x20disburse\x20funds.','phases':['owner_receive'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[],'builtin_indexes_consumed':[PROGRESS_OWNER_RECEIVE],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['owner_receive\x20unwraps\x20CoinWrapper<T>\x20via\x20the\x20payment\x27s\x20type-checked\x20unwrap\x20(amount\x20validation)','Receiving\x20a\x20generic\x20K:key+store\x20object\x20forwards\x20it\x20to\x20the\x20Permission\x20owner','Triggered\x20at\x20terminal\x20nodes\x20(e.g.\x20\x27return_approved\x27\x20in\x20rental,\x20\x27enforced\x27\x20in\x20arbitration)','Permission\x20owner\x20≠\x20Progress\x20creator:\x20receives\x20flow\x20to\x20whoever\x20owns\x20the\x20bound\x20Machine\x27s\x20Permission'],'recommended_templates':['T-PR-06']},{'id':'progress_completed','name':'Forward\x20advancement\x20&\x20session\x20completion','industry':['universal'],'scenario':'Advance\x20Progress\x20via\x20next()\x20/\x20the\x20order-holder\x20advancement\x20path\x20—\x20accumulates\x20weights\x20in\x20session.forwards,\x20'+'and\x20when\x20weights\x20≥\x20threshold,\x20moves\x20session\x20into\x20history\x20and\x20updates\x20Progress.current.\x20'+'This\x20is\x20the\x20canonical\x20Forward\x20advancement\x20path\x20for\x20ALL\x20non-hold\x20operations.','phases':['forward_advance','completed'],'requires_published_machine':!![],'requires_order_bound':!![],'named_operator_roles':[{'role':'OrderHolder','typical_count':0x1},{'role':'next_node_operator','typical_count':0x1}],'builtin_indexes_consumed':[],'typical_context_repository_count':0x0,'uses_hold_mechanism':![],'uses_admin_unhold':![],'common_patterns':['Forward\x20guard\x20(Some):\x20requires\x20Passport;\x20the\x20passport\x20verification\x20against\x20the\x20guard\x20must\x20pass','Forward\x20guard\x20(None):\x20requires\x20permissionIndex\x20(Some)\x20or\x20namedOperator\x20match\x20(ASSERT_PERMISSION)','session.weights\x20+=\x20forward.weight;\x20when\x20≥\x20threshold,\x20push\x20session\x20into\x20ParentTableVec<History>','Progress.current\x20=\x20next_node\x20only\x20after\x20session\x20completes\x20(atomic\x20update)','E_NOT_THE_HOLDER:\x20if\x20forward\x20was\x20held\x20by\x20another\x20address,\x20next()\x20aborts','E_FORWARD_ALREADY_ACCOMPLISHED:\x20re-hold\x20on\x20completed\x20forward\x20is\x20blocked','⚠\x20ROUTING\x20FACT:\x20Forward.namedOperator=\x22\x22\x20(empty)\x20→\x20order-bound\x20entry\x20only\x20(order.progress,\x20or\x20'+'progress.operate\x20which\x20auto-routes\x20when\x20the\x20Progress\x20task\x20is\x20an\x20Order).\x20Non-empty\x20namedOperator\x20or\x20'+'permissionIndex-only\x20→\x20either\x20entry\x20(identical\x20checks).\x20A\x20standalone\x20Progress\x20cannot\x20advance\x20\x22\x22\x20'+'forwards\x20at\x20all\x20(abort\x208\x20—\x20no\x20order\x20payer\x20exists).\x20See\x20file\x20header\x20ROUTING\x20FACTS.'],'recommended_templates':['T-PR-04']}];export const PROGRESS_LEDGER_VERSION='1.0.0';export function getScenesByPhase(a){return PROGRESS_SCENES['filter'](b=>b['phases']['includes'](a));}export function findSceneById(a){return PROGRESS_SCENES['find'](b=>b['id']===a);}export function getScenesByIndustry(a){return PROGRESS_SCENES['filter'](b=>b['industry']['includes'](a)||b['industry']['includes']('universal'));}export function getBuiltinPermissionByIndex(a){return PROGRESS_PERMISSIONS['find'](b=>b['index']===a);}export function isProgressBuiltinPermission(a){return getBuiltinPermissionByIndex(a)!==undefined;}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['adminunhold','progress_unhold'],['admin\x20unhold','progress_unhold'],['force\x20unhold','progress_unhold'],['unhold','progress_unhold'],['release\x20hold','progress_unhold'],['owner_receive','progress_owner_receive'],['owner\x20receive','progress_owner_receive'],['unwrap','progress_owner_receive'],['context_repository','progress_context_repository'],['context\x20repository','progress_context_repository'],['repository\x20binding','progress_context_repository'],['named_operator','progress_named_operator'],['named\x20operator','progress_named_operator'],['namedoperator','progress_named_operator'],['task\x20set','progress_task_submit'],['submit\x20task','progress_task_submit'],['next','progress_completed'],['advance','progress_completed'],['complete','progress_completed']];for(const [d,e]of c){if(b['includes'](d)){const f=findSceneById(e);if(f)return f;}}return undefined;}export function getAllBuiltinPermissions(){return[...PROGRESS_PERMISSIONS];}export function getProgressScenesCount(){return PROGRESS_SCENES['length'];}export function validateNamedOperatorAddressList(b){const c=[];b['length']>MAX_NAMED_OPERATOR_ADDRESS_COUNT&&c['push']('Named\x20operator\x20address\x20count\x20'+b['length']+'\x20exceeds\x20MAX_NAMED_OPERATOR_ADDRESS_COUNT\x20'+MAX_NAMED_OPERATOR_ADDRESS_COUNT);const d=new Set();for(const e of b){if(d['has'](e)){c['push']('Duplicate\x20address\x20in\x20list:\x20'+e+'\x20(Move\x20will\x20dedupe\x20silently)');break;}d['add'](e);}return{'ok':c['length']===0x0,'violations':c};}export function validateNamedOperatorCount(a){if(a>=MAX_NAMED_OPERATOR_COUNT)return{'ok':![],'violation':'Named\x20operator\x20count\x20'+a+'\x20would\x20exceed\x20MAX_NAMED_OPERATOR_COUNT\x20'+MAX_NAMED_OPERATOR_COUNT};return{'ok':!![]};}export function validateContextRepositoryCount(a,b){const c=a+b;if(c>MAX_CONTEXT_REPOSITORY_COUNT)return{'ok':![],'violation':'Context\x20repository\x20count\x20'+c+'\x20would\x20exceed\x20MAX_CONTEXT_REPOSITORY_COUNT\x20'+MAX_CONTEXT_REPOSITORY_COUNT};return{'ok':!![]};}export const PROGRESS_CROSS_OBJECT_REFS=[{'object':'Machine','phase':'universal','relationship':'Progress.machine\x20(immutable\x20bind,\x20E_MACHINE_NOT_MATCH\x20on\x20every\x20op)'},{'object':'Order','phase':'forward_advance','relationship':'Progress.task\x20=\x20Order.address\x20(1:1,\x20set\x20via\x20task\x20submission\x20or\x20the\x20buy\x20flow)'},{'object':'Order','phase':'forward_advance','relationship':'order-holder\x20paths\x20(advance\x20/\x20hold):\x20the\x20order\x20owner-or-agent\x20permission\x20check\x20gates\x20Forward\x20advance'},{'object':'Permission','phase':'universal','relationship':'Machine.permission\x20is\x20borrowed\x20for\x20ALL\x20220-225\x20assertions'},{'object':'Repository','phase':'context_binding','relationship':'context_repositories:\x20vector<address>\x20(≤\x2030),\x20bound\x20via\x20an\x20affiliation\x20transaction'},{'object':'Service','phase':'creation','relationship':'the\x20buy\x20flow\x20creates\x20the\x20Progress\x20internally\x20(bypasses\x20220\x20assertion\x20—\x20package-internal\x20entry)'},{'object':'Passport','phase':'forward_advance','relationship':'Forward.guard\x20(Some)\x20requires\x20Passport\x20+\x20passing\x20the\x20passport\x20verification'},{'object':'Passport','phase':'unhold_state','relationship':'passport-based\x20unhold:\x20224\x20check\x20via\x20passport\x20(fallback\x20when\x20the\x20sender\x27s\x20direct\x20224\x20permission\x20check\x20fails)'},{'object':'Payment','phase':'owner_receive','relationship':'owner_receive\x20unwraps\x20CoinWrapper<T>\x20via\x20the\x20payment\x27s\x20type-checked\x20unwrap'},{'object':'Allocation','phase':'completed','relationship':'Terminal\x20node\x20triggers\x20Allocation\x20alloc\x20(e.g.\x20\x27completed\x27,\x20\x27enforced\x27,\x20\x27return_approved\x27)'}];
|
|
@@ -40,6 +40,7 @@ export interface ModeMachineNode {
|
|
|
40
40
|
role: string;
|
|
41
41
|
operator?: "merchant" | "order_payer";
|
|
42
42
|
semantic_role?: "draft" | "active" | "delivered" | "final" | "cancelled";
|
|
43
|
+
optional?: boolean;
|
|
43
44
|
from?: (string | ModeMachineEdge)[];
|
|
44
45
|
}
|
|
45
46
|
export interface ModeMachineEdge {
|
|
@@ -27,6 +27,7 @@ export declare const TemplateFrontmatterSchema: z.ZodObject<{
|
|
|
27
27
|
final: "final";
|
|
28
28
|
cancelled: "cancelled";
|
|
29
29
|
}>>;
|
|
30
|
+
optional: z.ZodOptional<z.ZodBoolean>;
|
|
30
31
|
from: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
31
32
|
prev: z.ZodString;
|
|
32
33
|
forward: z.ZodOptional<z.ZodString>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{copyFileSync,existsSync,mkdirSync,readdirSync,readFileSync,renameSync,rmdirSync,statSync,writeFileSync}from'node:fs';import{join}from'node:path';import{z}from'zod';import{getWowokDataDir,getWowokIndustryDir}from'@wowok/wowok';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{isRegisteredIndustry}from'./industry-registry.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'./builtin-templates.js';import{classifyRelease,releaseBodyHash,releaseSentinelLine,stripReleaseSentinel}from'./release-sentinel.js';export const TEMPLATES_SUBDIR='templates';export function resolveTemplatesDir(){return process['env']['WOWOK_TEMPLATES_DIR']||getWowokIndustryDir();}function resolveLegacyTemplatesDir(){return process['env']['WOWOK_LEGACY_TEMPLATES_DIR']||join(getWowokDataDir(),'templates');}const MachineEdgeSchema=z['object']({'prev':z['string'](),'forward':z['string']()['min'](0x1)['optional'](),'operator':z['enum'](['merchant','order_payer'])['optional'](),'permission_index':z['number']()['int']()['min'](0x3e8)['optional'](),'guard_key':z['string']()['min'](0x1)['optional']()}),MachineNodeSchema=z['object']({'name':z['string']()['min'](0x1),'role':z['string']()['min'](0x1),'operator':z['enum'](['merchant','order_payer'])['optional'](),'semantic_role':z['enum'](['draft','active','delivered','final','cancelled'])['optional'](),'from':z['array'](z['union']([z['string'](),MachineEdgeSchema]))['optional']()}),GuardRefSchema=z['object']({'template_id':z['string']()['regex'](/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/,'guard\x20template_id\x20must\x20be\x20a\x20\x27pattern.*\x27\x20design\x20pattern\x20or\x20\x27tpl_*\x27\x20guard\x20template'),'host':z['enum'](['service','machine','reward','repository','arbitration']),'purpose':z['string']()['min'](0x1),'key':z['string']()['min'](0x1)['optional']()}),AllocatorRowSchema=z['object']({'track':z['enum'](['settlement','refund']),'recipient':z['enum'](['entity','guard_identifier','signer']),'recipient_key':z['string']()['min'](0x1)['optional'](),'mode':z['enum'](['amount','rate','surplus']),'value':z['union']([z['string'](),z['number']()])['optional'](),'value_from':z['string']()['optional'](),'fix':z['union']([z['string'](),z['number']()])['optional'](),'fix_from':z['string']()['optional'](),'guard_key':z['string']()['min'](0x1)['optional'](),'note':z['string']()['optional']()})['strict'](),AllocatorSchema=z['object']({'recipient':z['enum'](['signer','entity','fixed']),'recipient_key':z['string']()['min'](0x1)['optional'](),'refund_track':z['enum'](['order_anchored'])['optional'](),'count':z['number']()['int']()['positive'](),'mode':z['enum'](['amount','rate','surplus']),'once_per_order':z['boolean']()['optional'](),'rows':z['array'](AllocatorRowSchema)['optional'](),'description':z['string']()['min'](0x1)})['strict'](),IndustryNameSchema=z['string']()['regex'](/^[a-z][a-z0-9_]*$/,'industry\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)')['refine'](a=>isRegisteredIndustry(a),{'message':'unknown\x20industry\x20—\x20register\x20it\x20first\x20via\x20an\x20industry\x20pack\x20'+'(industry_pack_operation\x20action=\x27scaffold\x27)\x20or\x20the\x20industry\x20generalizer;\x20'+('builtin\x20industries:\x20'+SUPPORTED_INDUSTRIES['join'](',\x20'))});export const TemplateFrontmatterSchema=z['object']({'id':z['string']()['regex'](/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/,'id\x20must\x20be\x20\x27<industry>/<variant>\x27'),'industry':IndustryNameSchema,'variant':z['string']()['regex'](/^[a-z][a-z0-9_-]*$/),'product_ref':z['string']()['regex'](/^[a-z][a-z0-9._-]*$/,'product_ref\x20must\x20be\x20a\x20lowercase\x20product\x20slug')['optional'](),'archetype':z['enum'](['leader','challenger']),'phase':z['number']()['int']()['min'](0x1)['max'](0x3),'machine_shape':z['array'](MachineNodeSchema)['min'](0x1),'guards':z['array'](GuardRefSchema),'allocator':AllocatorSchema,'fee_params':z['record'](z['string'](),z['union']([z['number'](),z['string']()])),'trust_mechanisms':z['array'](z['string']()),'keeper_dependencies':z['array'](z['string']()),'recommended_role':z['enum'](['merchant','supplier','both']),'role_rationale':z['string']()['min'](0x1),'differences':z['array'](z['string']()),'user_inputs':z['array'](z['string']()),'key_risk':z['string']()['min'](0x1)['max'](0x12c,'key_risk\x20must\x20be\x20a\x20one-line\x20risk\x20statement\x20(<=\x20300\x20chars)\x20—\x20rules\x20and\x20doctrine\x20do\x20not\x20belong\x20in\x20this\x20field')['refine'](a=>!/STANDING RULE|TECHNOLOGY PROVIDER|NOT A PARTY TO THE DEAL|Full text:/i['test'](a),{'message':'key_risk\x20carries\x20an\x20instruction-block\x20fragment\x20(STANDING\x20RULE\x20/\x20provider\x20doctrine\x20/\x20\x27Full\x20text:\x27\x20reference)\x20—\x20keep\x20doctrine\x20in\x20body\x20prose\x20or\x20playbooks,\x20not\x20in\x20this\x20field'}),'build_notes':z['array'](z['string']()),'time_anchors':z['record'](z['string'](),z['string']())['optional'](),'payment_model':z['enum'](['milestone','subscription','escrow'])['optional'](),'arbitration_mode':z['enum'](['none','merchant_pick','mutual_pick','third_party'])['optional']()})['strict']();export function parseTemplateFile(a){const b=a['replace'](/^\uFEFF/,'')['replace'](/^<!-- builtin:[a-z0-9-]+:v\d+:[0-9a-f]+ -->\r?\n/,''),c=b['split'](/\r?\n/);if(c[0x0]?.['trim']()!=='---')throw new Error('template\x20must\x20start\x20with\x20a\x20\x27---\x27\x20frontmatter\x20block');let d=-0x1;for(let f=0x1;f<c['length'];f++){if(c[f]['trim']()==='---'){d=f;break;}}if(d===-0x1)throw new Error('unterminated\x20frontmatter\x20block\x20(missing\x20closing\x20\x27---\x27)');const e={};for(let g=0x1;g<d;g++){const h=c[g];if(!h['trim']()||h['trim']()['startsWith']('#'))continue;const j=h['indexOf'](':');if(j===-0x1)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20\x27'+h['trim']()+'\x27\x20(expected\x20\x27key:\x20value\x27)');const k=h['slice'](0x0,j)['trim'](),l=h['slice'](j+0x1)['trim']();if(!k)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20empty\x20key');if(l['startsWith']('[')||l['startsWith']('{'))try{e[k]=JSON['parse'](l);}catch(m){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+m['message']);}else/^-?\d+(\.\d+)?$/['test'](l)?e[k]=Number(l):e[k]=l;}return{'frontmatter':e,'body':c['slice'](d+0x1)['join']('\x0a')['trim']()};}function frontmatterLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export const TEMPLATE_SENTINEL_KIND='industry-template';function canonicalTemplateContent(a){const b=[['id',a['id']],['industry',a['industry']],['variant',a['variant']],['product_ref',a['product_ref']],['archetype',a['archetype']],['phase',a['phase']],['recommended_role',a['recommended_role']],['role_rationale',a['role_rationale']],['key_risk',a['key_risk']],['machine_shape',a['machine_shape']],['guards',a['guards']],['allocator',a['allocator']],['fee_params',a['fee_params']],['trust_mechanisms',a['trust_mechanisms']],['keeper_dependencies',a['keeper_dependencies']],['differences',a['differences']],['user_inputs',a['user_inputs']],['build_notes',a['build_notes']],...a['time_anchors']?[['time_anchors',a['time_anchors']]]:[],...a['payment_model']?[['payment_model',a['payment_model']]]:[],...a['arbitration_mode']?[['arbitration_mode',a['arbitration_mode']]]:[]],c=['---',...b['map'](([e,f])=>frontmatterLine(e,f)),'---'],d=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')','','>\x20Industry\x20archetype\x20template.\x20Editable\x20and\x20migratable:\x20the\x20frontmatter\x20is','>\x20zod-validated\x20on\x20every\x20load;\x20the\x20body\x20is\x20free-form\x20guidance\x20for\x20the\x20AI.','','##\x20Key\x20risk','',a['key_risk'],'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['map'](e=>'-\x20'+e),'','##\x20User\x20inputs\x20(inject\x20at\x20build\x20time)','',...a['user_inputs']['map'](e=>'-\x20'+e),'','##\x20Risk-avoidance\x20checklist\x20(R1-R10)','',...a['trust_mechanisms']['map'](e=>'-\x20'+e),'','##\x20Build\x20notes','',...a['build_notes']['map'](e=>'-\x20'+e),''];return[...c,...d]['join']('\x0a');}export function renderTemplateFile(a){const b=canonicalTemplateContent(a);return releaseSentinelLine(TEMPLATE_SENTINEL_KIND,BUILTIN_TEMPLATES_VERSION,releaseBodyHash(b))+'\x0a'+b;}let seeded=![];function migrateLegacyTemplates(a){const b=resolveLegacyTemplatesDir();if(b===a)return;if(!existsSync(b))return;try{for(const c of readdirSync(b,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(b,c['name']),e=join(a,c['name'],TEMPLATES_SUBDIR);for(const g of readdirSync(d,{'withFileTypes':!![]})){if(!g['isFile']()||!g['name']['endsWith']('.md'))continue;const h=join(e,g['name']);if(existsSync(h))continue;mkdirSync(e,{'recursive':!![]}),renameSync(join(d,g['name']),h);}try{rmdirSync(d);}catch{}}try{rmdirSync(b);}catch{}}catch{}}export function seedBuiltinTemplates(){const a=[],b=resolveTemplatesDir();migrateLegacyTemplates(b);for(const c of BUILTIN_TEMPLATES){const d=join(b,c['industry'],TEMPLATES_SUBDIR),e=join(d,c['variant']+'.md'),f={'template':c['id'],'status':'written','path':e};try{if(!existsSync(e))mkdirSync(d,{'recursive':!![]}),writeFileSync(e,renderTemplateFile(c),'utf-8');else{const {sentinel:g,content:h}=stripReleaseSentinel(readFileSync(e,'utf-8'),TEMPLATE_SENTINEL_KIND);if(!g)f['status']='skipped_user_file',f['detail']='template\x20file\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched';else{const i=classifyRelease(g,h,BUILTIN_TEMPLATES_VERSION);if(i==='current')f['status']='current';else i==='user_modified'?(f['status']='skipped_user_modified',f['detail']='template\x20file\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'):(writeFileSync(e,renderTemplateFile(c),'utf-8'),f['status']='updated');}}}catch(j){f['status']='error',f['detail']=j['message'];}a['push'](f);}return a;}export function repairBuiltinTemplates(a){const b=[],c=resolveTemplatesDir(),d=a?.['backup']!==![],e=a?.['dryRun']===!![];for(const f of BUILTIN_TEMPLATES){const g=join(c,f['industry'],TEMPLATES_SUBDIR),h=join(g,f['variant']+'.md'),i={'template':f['id'],'status':'skipped_user_file','path':h};if(!existsSync(h))continue;let j=null;try{j=stripReleaseSentinel(readFileSync(h,'utf-8'),TEMPLATE_SENTINEL_KIND)['sentinel'];}catch(l){i['status']='error',i['detail']=l['message'],b['push'](i);continue;}if(j)continue;let k;try{k=String(parseTemplateFile(readFileSync(h,'utf-8'))['frontmatter']['id']??'');}catch{continue;}if(k!==f['id'])continue;if(e){i['status']='would_update',i['detail']='legacy\x20sentinel-less\x20builtin\x20file\x20would\x20be\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+f['id']+')'+(d?';\x20previous\x20content\x20would\x20be\x20saved\x20as\x20<file>.bak':'')+'\x20—\x20execute\x20with\x20authorize=true\x20after\x20the\x20user\x20explicitly\x20confirms',b['push'](i);continue;}try{if(d)copyFileSync(h,h+'.bak');writeFileSync(h,renderTemplateFile(f),'utf-8'),cache['delete'](h),i['status']='updated',i['detail']='legacy\x20sentinel-less\x20builtin\x20file\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+f['id']+')'+(d?';\x20previous\x20content\x20saved\x20as\x20<file>.bak':'');}catch(m){i['status']='error',i['detail']=m['message'];}b['push'](i);}return b;}export function builtinTemplateDrift(){const a=[],b=resolveTemplatesDir();for(const c of BUILTIN_TEMPLATES){const d=join(b,c['industry'],TEMPLATES_SUBDIR,c['variant']+'.md');if(!existsSync(d)){a['push']({'template':c['id'],'path':d,'state':'missing','detail':'no\x20file\x20on\x20disk;\x20seeding\x20will\x20create\x20it'});continue;}let e=null,f='';try{const h=stripReleaseSentinel(readFileSync(d,'utf-8'),TEMPLATE_SENTINEL_KIND);e=h['sentinel'],f=h['content'];}catch(i){a['push']({'template':c['id'],'path':d,'state':'missing','detail':'unreadable:\x20'+i['message']});continue;}if(!e){let j;try{j=String(parseTemplateFile(readFileSync(d,'utf-8'))['frontmatter']['id']??'');}catch{j=undefined;}a['push']({'template':c['id'],'path':d,'state':'no_sentinel_legacy','detail':j===c['id']?'builtin\x20id\x20but\x20NO\x20release\x20sentinel\x20—\x20seeding\x20classifies\x20this\x20as\x20a\x20user\x20file\x20and\x20will\x20NEVER\x20upgrade\x20it;\x20every\x20code-side\x20fix\x20to\x20this\x20template\x20is\x20invisible\x20at\x20runtime':'no\x20release\x20sentinel\x20and\x20id\x20\x27'+(j??'<unparseable>')+'\x27\x20does\x20not\x20match\x20a\x20builtin\x20id\x20—\x20treated\x20as\x20a\x20user\x20template,\x20never\x20touched'});continue;}const g=classifyRelease(e,f,BUILTIN_TEMPLATES_VERSION);if(g==='current')continue;a['push']({'template':c['id'],'path':d,'state':g==='user_modified'?'user_modified':'stale_release','detail':g==='user_modified'?'sentinel\x20present,\x20body\x20edited\x20locally\x20—\x20kept\x20by\x20design':'sentinel\x20present,\x20older\x20release\x20—\x20seeding\x20upgrades\x20it\x20on\x20next\x20access'});}return a;}const cache=new Map();export function reloadTemplates(){cache['clear'](),seeded=![];}export function loadAndValidate(a){const b=readFileSync(a,'utf-8');let c;try{c=parseTemplateFile(b);}catch(e){throw new Error('template\x20\x27'+a+'\x27\x20failed\x20to\x20parse:\x20'+e['message']);}const d=TemplateFrontmatterSchema['safeParse'](c['frontmatter']);if(!d['success']){const f=d['error']['issues']['map'](g=>(g['path']['join']('.')||'<root>')+':\x20'+g['message'])['join'](';\x20');throw new Error('template\x20\x27'+a+'\x27\x20failed\x20validation:\x20'+f);}return{...d['data'],'body':c['body'],'source_path':a};}function templateFilesOnDisk(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name'],TEMPLATES_SUBDIR);if(!existsSync(d))continue;for(const e of readdirSync(d,{'withFileTypes':!![]})){if(e['isFile']()&&e['name']['endsWith']('.md'))b['push'](join(d,e['name']));}}return b['sort']();}export function listTemplates(){!seeded&&(seedBuiltinTemplates(),seeded=!![]);const a=resolveTemplatesDir(),b=[],c=[],d=new Set();for(const e of templateFilesOnDisk(a)){d['add'](e);try{const f=statSync(e)['mtimeMs'],g=cache['get'](e);if(g&&g['mtimeMs']===f){b['push'](g['template']);continue;}const h=loadAndValidate(e);cache['set'](e,{'mtimeMs':f,'template':h}),b['push'](h);}catch(i){cache['delete'](e),c['push'](i['message']);}}for(const j of[...cache['keys']()]){if(!d['has'](j))cache['delete'](j);}return b['sort']((k,l)=>k['id']['localeCompare'](l['id'])),{'templates':b,'errors':c};}export function getTemplate(a){return listTemplates()['templates']['find'](b=>b['id']===a);}export function getTemplatesByIndustry(a){return listTemplates()['templates']['filter'](b=>b['industry']===a);}
|
|
1
|
+
import{copyFileSync,existsSync,mkdirSync,readdirSync,readFileSync,renameSync,rmdirSync,statSync,writeFileSync}from'node:fs';import{join}from'node:path';import{z}from'zod';import{getWowokDataDir,getWowokIndustryDir}from'@wowok/wowok';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{isRegisteredIndustry}from'./industry-registry.js';import{BUILTIN_TEMPLATES,BUILTIN_TEMPLATES_VERSION}from'./builtin-templates.js';import{classifyRelease,releaseBodyHash,releaseSentinelLine,stripReleaseSentinel}from'./release-sentinel.js';export const TEMPLATES_SUBDIR='templates';export function resolveTemplatesDir(){return process['env']['WOWOK_TEMPLATES_DIR']||getWowokIndustryDir();}function resolveLegacyTemplatesDir(){return process['env']['WOWOK_LEGACY_TEMPLATES_DIR']||join(getWowokDataDir(),'templates');}const MachineEdgeSchema=z['object']({'prev':z['string'](),'forward':z['string']()['min'](0x1)['optional'](),'operator':z['enum'](['merchant','order_payer'])['optional'](),'permission_index':z['number']()['int']()['min'](0x3e8)['optional'](),'guard_key':z['string']()['min'](0x1)['optional']()}),MachineNodeSchema=z['object']({'name':z['string']()['min'](0x1),'role':z['string']()['min'](0x1),'operator':z['enum'](['merchant','order_payer'])['optional'](),'semantic_role':z['enum'](['draft','active','delivered','final','cancelled'])['optional'](),'optional':z['boolean']()['optional'](),'from':z['array'](z['union']([z['string'](),MachineEdgeSchema]))['optional']()}),GuardRefSchema=z['object']({'template_id':z['string']()['regex'](/^(pattern\.[a-z0-9_]+|tpl_[a-z0-9_]+)$/,'guard\x20template_id\x20must\x20be\x20a\x20\x27pattern.*\x27\x20design\x20pattern\x20or\x20\x27tpl_*\x27\x20guard\x20template'),'host':z['enum'](['service','machine','reward','repository','arbitration']),'purpose':z['string']()['min'](0x1),'key':z['string']()['min'](0x1)['optional']()}),AllocatorRowSchema=z['object']({'track':z['enum'](['settlement','refund']),'recipient':z['enum'](['entity','guard_identifier','signer']),'recipient_key':z['string']()['min'](0x1)['optional'](),'mode':z['enum'](['amount','rate','surplus']),'value':z['union']([z['string'](),z['number']()])['optional'](),'value_from':z['string']()['optional'](),'fix':z['union']([z['string'](),z['number']()])['optional'](),'fix_from':z['string']()['optional'](),'guard_key':z['string']()['min'](0x1)['optional'](),'note':z['string']()['optional']()})['strict'](),AllocatorSchema=z['object']({'recipient':z['enum'](['signer','entity','fixed']),'recipient_key':z['string']()['min'](0x1)['optional'](),'refund_track':z['enum'](['order_anchored'])['optional'](),'count':z['number']()['int']()['positive'](),'mode':z['enum'](['amount','rate','surplus']),'once_per_order':z['boolean']()['optional'](),'rows':z['array'](AllocatorRowSchema)['optional'](),'description':z['string']()['min'](0x1)})['strict'](),IndustryNameSchema=z['string']()['regex'](/^[a-z][a-z0-9_]*$/,'industry\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)')['refine'](a=>isRegisteredIndustry(a),{'message':'unknown\x20industry\x20—\x20register\x20it\x20first\x20via\x20an\x20industry\x20pack\x20'+'(industry_pack_operation\x20action=\x27scaffold\x27)\x20or\x20the\x20industry\x20generalizer;\x20'+('builtin\x20industries:\x20'+SUPPORTED_INDUSTRIES['join'](',\x20'))});export const TemplateFrontmatterSchema=z['object']({'id':z['string']()['regex'](/^[a-z][a-z0-9_-]*\/[a-z][a-z0-9_-]*$/,'id\x20must\x20be\x20\x27<industry>/<variant>\x27'),'industry':IndustryNameSchema,'variant':z['string']()['regex'](/^[a-z][a-z0-9_-]*$/),'product_ref':z['string']()['regex'](/^[a-z][a-z0-9._-]*$/,'product_ref\x20must\x20be\x20a\x20lowercase\x20product\x20slug')['optional'](),'archetype':z['enum'](['leader','challenger']),'phase':z['number']()['int']()['min'](0x1)['max'](0x3),'machine_shape':z['array'](MachineNodeSchema)['min'](0x1),'guards':z['array'](GuardRefSchema),'allocator':AllocatorSchema,'fee_params':z['record'](z['string'](),z['union']([z['number'](),z['string']()])),'trust_mechanisms':z['array'](z['string']()),'keeper_dependencies':z['array'](z['string']()),'recommended_role':z['enum'](['merchant','supplier','both']),'role_rationale':z['string']()['min'](0x1),'differences':z['array'](z['string']()),'user_inputs':z['array'](z['string']()),'key_risk':z['string']()['min'](0x1)['max'](0x12c,'key_risk\x20must\x20be\x20a\x20one-line\x20risk\x20statement\x20(<=\x20300\x20chars)\x20—\x20rules\x20and\x20doctrine\x20do\x20not\x20belong\x20in\x20this\x20field')['refine'](a=>!/STANDING RULE|TECHNOLOGY PROVIDER|NOT A PARTY TO THE DEAL|Full text:/i['test'](a),{'message':'key_risk\x20carries\x20an\x20instruction-block\x20fragment\x20(STANDING\x20RULE\x20/\x20provider\x20doctrine\x20/\x20\x27Full\x20text:\x27\x20reference)\x20—\x20keep\x20doctrine\x20in\x20body\x20prose\x20or\x20playbooks,\x20not\x20in\x20this\x20field'}),'build_notes':z['array'](z['string']()),'time_anchors':z['record'](z['string'](),z['string']())['optional'](),'payment_model':z['enum'](['milestone','subscription','escrow'])['optional'](),'arbitration_mode':z['enum'](['none','merchant_pick','mutual_pick','third_party'])['optional']()})['strict']();export function parseTemplateFile(a){const b=a['replace'](/^\uFEFF/,'')['replace'](/^<!-- builtin:[a-z0-9-]+:v\d+:[0-9a-f]+ -->\r?\n/,''),c=b['split'](/\r?\n/);if(c[0x0]?.['trim']()!=='---')throw new Error('template\x20must\x20start\x20with\x20a\x20\x27---\x27\x20frontmatter\x20block');let d=-0x1;for(let f=0x1;f<c['length'];f++){if(c[f]['trim']()==='---'){d=f;break;}}if(d===-0x1)throw new Error('unterminated\x20frontmatter\x20block\x20(missing\x20closing\x20\x27---\x27)');const e={};for(let g=0x1;g<d;g++){const h=c[g];if(!h['trim']()||h['trim']()['startsWith']('#'))continue;const j=h['indexOf'](':');if(j===-0x1)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20\x27'+h['trim']()+'\x27\x20(expected\x20\x27key:\x20value\x27)');const k=h['slice'](0x0,j)['trim'](),l=h['slice'](j+0x1)['trim']();if(!k)throw new Error('invalid\x20frontmatter\x20line\x20'+(g+0x1)+':\x20empty\x20key');if(l['startsWith']('[')||l['startsWith']('{'))try{e[k]=JSON['parse'](l);}catch(m){throw new Error('frontmatter\x20key\x20\x27'+k+'\x27\x20is\x20not\x20valid\x20JSON:\x20'+m['message']);}else/^-?\d+(\.\d+)?$/['test'](l)?e[k]=Number(l):e[k]=l;}return{'frontmatter':e,'body':c['slice'](d+0x1)['join']('\x0a')['trim']()};}function frontmatterLine(a,b){if(typeof b==='number')return a+':\x20'+b;if(typeof b==='string')return a+':\x20'+b;return a+':\x20'+JSON['stringify'](b);}export const TEMPLATE_SENTINEL_KIND='industry-template';function canonicalTemplateContent(a){const b=[['id',a['id']],['industry',a['industry']],['variant',a['variant']],['product_ref',a['product_ref']],['archetype',a['archetype']],['phase',a['phase']],['recommended_role',a['recommended_role']],['role_rationale',a['role_rationale']],['key_risk',a['key_risk']],['machine_shape',a['machine_shape']],['guards',a['guards']],['allocator',a['allocator']],['fee_params',a['fee_params']],['trust_mechanisms',a['trust_mechanisms']],['keeper_dependencies',a['keeper_dependencies']],['differences',a['differences']],['user_inputs',a['user_inputs']],['build_notes',a['build_notes']],...a['time_anchors']?[['time_anchors',a['time_anchors']]]:[],...a['payment_model']?[['payment_model',a['payment_model']]]:[],...a['arbitration_mode']?[['arbitration_mode',a['arbitration_mode']]]:[]],c=['---',...b['map'](([e,f])=>frontmatterLine(e,f)),'---'],d=['','#\x20'+a['industry']+'\x20/\x20'+a['variant']+'\x20('+a['archetype']+')','','>\x20Industry\x20archetype\x20template.\x20Editable\x20and\x20migratable:\x20the\x20frontmatter\x20is','>\x20zod-validated\x20on\x20every\x20load;\x20the\x20body\x20is\x20free-form\x20guidance\x20for\x20the\x20AI.','','##\x20Key\x20risk','',a['key_risk'],'','##\x20Differences\x20vs\x20the\x20sibling\x20variant','',...a['differences']['map'](e=>'-\x20'+e),'','##\x20User\x20inputs\x20(inject\x20at\x20build\x20time)','',...a['user_inputs']['map'](e=>'-\x20'+e),'','##\x20Risk-avoidance\x20checklist\x20(R1-R10)','',...a['trust_mechanisms']['map'](e=>'-\x20'+e),'','##\x20Build\x20notes','',...a['build_notes']['map'](e=>'-\x20'+e),''];return[...c,...d]['join']('\x0a');}export function renderTemplateFile(a){const b=canonicalTemplateContent(a);return releaseSentinelLine(TEMPLATE_SENTINEL_KIND,BUILTIN_TEMPLATES_VERSION,releaseBodyHash(b))+'\x0a'+b;}let seeded=![];function migrateLegacyTemplates(a){const b=resolveLegacyTemplatesDir();if(b===a)return;if(!existsSync(b))return;try{for(const c of readdirSync(b,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(b,c['name']),e=join(a,c['name'],TEMPLATES_SUBDIR);for(const g of readdirSync(d,{'withFileTypes':!![]})){if(!g['isFile']()||!g['name']['endsWith']('.md'))continue;const h=join(e,g['name']);if(existsSync(h))continue;mkdirSync(e,{'recursive':!![]}),renameSync(join(d,g['name']),h);}try{rmdirSync(d);}catch{}}try{rmdirSync(b);}catch{}}catch{}}export function seedBuiltinTemplates(){const a=[],b=resolveTemplatesDir();migrateLegacyTemplates(b);for(const c of BUILTIN_TEMPLATES){const d=join(b,c['industry'],TEMPLATES_SUBDIR),e=join(d,c['variant']+'.md'),f={'template':c['id'],'status':'written','path':e};try{if(!existsSync(e))mkdirSync(d,{'recursive':!![]}),writeFileSync(e,renderTemplateFile(c),'utf-8');else{const {sentinel:g,content:h}=stripReleaseSentinel(readFileSync(e,'utf-8'),TEMPLATE_SENTINEL_KIND);if(!g)f['status']='skipped_user_file',f['detail']='template\x20file\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched';else{const i=classifyRelease(g,h,BUILTIN_TEMPLATES_VERSION);if(i==='current')f['status']='current';else i==='user_modified'?(f['status']='skipped_user_modified',f['detail']='template\x20file\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'):(writeFileSync(e,renderTemplateFile(c),'utf-8'),f['status']='updated');}}}catch(j){f['status']='error',f['detail']=j['message'];}a['push'](f);}return a;}export function repairBuiltinTemplates(a){const b=[],c=resolveTemplatesDir(),d=a?.['backup']!==![],e=a?.['dryRun']===!![];for(const f of BUILTIN_TEMPLATES){const g=join(c,f['industry'],TEMPLATES_SUBDIR),h=join(g,f['variant']+'.md'),i={'template':f['id'],'status':'skipped_user_file','path':h};if(!existsSync(h))continue;let j=null;try{j=stripReleaseSentinel(readFileSync(h,'utf-8'),TEMPLATE_SENTINEL_KIND)['sentinel'];}catch(l){i['status']='error',i['detail']=l['message'],b['push'](i);continue;}if(j)continue;let k;try{k=String(parseTemplateFile(readFileSync(h,'utf-8'))['frontmatter']['id']??'');}catch{continue;}if(k!==f['id'])continue;if(e){i['status']='would_update',i['detail']='legacy\x20sentinel-less\x20builtin\x20file\x20would\x20be\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+f['id']+')'+(d?';\x20previous\x20content\x20would\x20be\x20saved\x20as\x20<file>.bak':'')+'\x20—\x20execute\x20with\x20authorize=true\x20after\x20the\x20user\x20explicitly\x20confirms',b['push'](i);continue;}try{if(d)copyFileSync(h,h+'.bak');writeFileSync(h,renderTemplateFile(f),'utf-8'),cache['delete'](h),i['status']='updated',i['detail']='legacy\x20sentinel-less\x20builtin\x20file\x20reseeded\x20from\x20BUILTIN_TEMPLATES\x20('+f['id']+')'+(d?';\x20previous\x20content\x20saved\x20as\x20<file>.bak':'');}catch(m){i['status']='error',i['detail']=m['message'];}b['push'](i);}return b;}export function builtinTemplateDrift(){const a=[],b=resolveTemplatesDir();for(const c of BUILTIN_TEMPLATES){const d=join(b,c['industry'],TEMPLATES_SUBDIR,c['variant']+'.md');if(!existsSync(d)){a['push']({'template':c['id'],'path':d,'state':'missing','detail':'no\x20file\x20on\x20disk;\x20seeding\x20will\x20create\x20it'});continue;}let e=null,f='';try{const h=stripReleaseSentinel(readFileSync(d,'utf-8'),TEMPLATE_SENTINEL_KIND);e=h['sentinel'],f=h['content'];}catch(i){a['push']({'template':c['id'],'path':d,'state':'missing','detail':'unreadable:\x20'+i['message']});continue;}if(!e){let j;try{j=String(parseTemplateFile(readFileSync(d,'utf-8'))['frontmatter']['id']??'');}catch{j=undefined;}a['push']({'template':c['id'],'path':d,'state':'no_sentinel_legacy','detail':j===c['id']?'builtin\x20id\x20but\x20NO\x20release\x20sentinel\x20—\x20seeding\x20classifies\x20this\x20as\x20a\x20user\x20file\x20and\x20will\x20NEVER\x20upgrade\x20it;\x20every\x20code-side\x20fix\x20to\x20this\x20template\x20is\x20invisible\x20at\x20runtime':'no\x20release\x20sentinel\x20and\x20id\x20\x27'+(j??'<unparseable>')+'\x27\x20does\x20not\x20match\x20a\x20builtin\x20id\x20—\x20treated\x20as\x20a\x20user\x20template,\x20never\x20touched'});continue;}const g=classifyRelease(e,f,BUILTIN_TEMPLATES_VERSION);if(g==='current')continue;a['push']({'template':c['id'],'path':d,'state':g==='user_modified'?'user_modified':'stale_release','detail':g==='user_modified'?'sentinel\x20present,\x20body\x20edited\x20locally\x20—\x20kept\x20by\x20design':'sentinel\x20present,\x20older\x20release\x20—\x20seeding\x20upgrades\x20it\x20on\x20next\x20access'});}return a;}const cache=new Map();export function reloadTemplates(){cache['clear'](),seeded=![];}export function loadAndValidate(a){const b=readFileSync(a,'utf-8');let c;try{c=parseTemplateFile(b);}catch(e){throw new Error('template\x20\x27'+a+'\x27\x20failed\x20to\x20parse:\x20'+e['message']);}const d=TemplateFrontmatterSchema['safeParse'](c['frontmatter']);if(!d['success']){const f=d['error']['issues']['map'](g=>(g['path']['join']('.')||'<root>')+':\x20'+g['message'])['join'](';\x20');throw new Error('template\x20\x27'+a+'\x27\x20failed\x20validation:\x20'+f);}return{...d['data'],'body':c['body'],'source_path':a};}function templateFilesOnDisk(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name'],TEMPLATES_SUBDIR);if(!existsSync(d))continue;for(const e of readdirSync(d,{'withFileTypes':!![]})){if(e['isFile']()&&e['name']['endsWith']('.md'))b['push'](join(d,e['name']));}}return b['sort']();}export function listTemplates(){!seeded&&(seedBuiltinTemplates(),seeded=!![]);const a=resolveTemplatesDir(),b=[],c=[],d=new Set();for(const e of templateFilesOnDisk(a)){d['add'](e);try{const f=statSync(e)['mtimeMs'],g=cache['get'](e);if(g&&g['mtimeMs']===f){b['push'](g['template']);continue;}const h=loadAndValidate(e);cache['set'](e,{'mtimeMs':f,'template':h}),b['push'](h);}catch(i){cache['delete'](e),c['push'](i['message']);}}for(const j of[...cache['keys']()]){if(!d['has'](j))cache['delete'](j);}return b['sort']((k,l)=>k['id']['localeCompare'](l['id'])),{'templates':b,'errors':c};}export function getTemplate(a){return listTemplates()['templates']['find'](b=>b['id']===a);}export function getTemplatesByIndustry(a){return listTemplates()['templates']['filter'](b=>b['industry']===a);}
|