@wowok/agent-mcp 3.3.5 → 3.3.6
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/eval-order.d.ts +17 -0
- package/dist/chain-semantics/eval-order.js +1 -0
- package/dist/chain-semantics/freeze-map.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/index.d.ts +1 -0
- package/dist/chain-semantics/index.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +1 -1
- package/dist/composition/compile.js +1 -1
- package/dist/data/api/api.spec.d.ts +1 -0
- package/dist/data/api/api.spec.js +1 -0
- package/dist/data/api/cli.d.ts +1 -0
- package/dist/data/api/cli.js +1 -0
- package/dist/data/api/head.d.ts +16 -0
- package/dist/data/api/head.js +1 -0
- package/dist/data/api/head.spec.d.ts +1 -0
- package/dist/data/api/head.spec.js +1 -0
- package/dist/data/api/index.d.ts +2 -0
- package/dist/data/api/index.js +1 -0
- package/dist/data/api/match.d.ts +69 -0
- package/dist/data/api/match.js +1 -0
- package/dist/data/api/match.spec.d.ts +1 -0
- package/dist/data/api/match.spec.js +1 -0
- package/dist/data/api/server.d.ts +12 -0
- package/dist/data/api/server.js +1 -0
- package/dist/data/projection/cli.d.ts +1 -0
- package/dist/data/projection/cli.js +1 -0
- package/dist/data/projection/edges.d.ts +8 -0
- package/dist/data/projection/edges.js +1 -0
- package/dist/data/projection/edges.spec.d.ts +1 -0
- package/dist/data/projection/edges.spec.js +1 -0
- package/dist/data/projection/facets.d.ts +18 -0
- package/dist/data/projection/facets.js +1 -0
- package/dist/data/projection/facets.spec.d.ts +1 -0
- package/dist/data/projection/facets.spec.js +1 -0
- package/dist/data/projection/facts.d.ts +40 -0
- package/dist/data/projection/facts.js +1 -0
- package/dist/data/projection/index.d.ts +6 -0
- package/dist/data/projection/index.js +1 -0
- package/dist/data/projection/project.d.ts +10 -0
- package/dist/data/projection/project.js +1 -0
- package/dist/data/projection/projection.spec.d.ts +1 -0
- package/dist/data/projection/projection.spec.js +1 -0
- package/dist/data/projection/schema.d.ts +1 -0
- package/dist/data/projection/schema.js +1 -0
- package/dist/data/projection/store.d.ts +49 -0
- package/dist/data/projection/store.js +1 -0
- package/dist/data/projection/types.d.ts +137 -0
- package/dist/data/projection/types.js +1 -0
- package/dist/data/sync/cdc.d.ts +34 -0
- package/dist/data/sync/cdc.js +1 -0
- package/dist/data/sync/cdc.spec.d.ts +1 -0
- package/dist/data/sync/cdc.spec.js +1 -0
- package/dist/data/sync/graphql-source.d.ts +16 -0
- package/dist/data/sync/graphql-source.js +1 -0
- package/dist/data/sync/index.d.ts +5 -0
- package/dist/data/sync/index.js +1 -0
- package/dist/data/sync/reconciler.d.ts +14 -0
- package/dist/data/sync/reconciler.js +1 -0
- package/dist/data/sync/reconciler.spec.d.ts +1 -0
- package/dist/data/sync/reconciler.spec.js +1 -0
- package/dist/data/sync/schema.d.ts +1 -0
- package/dist/data/sync/schema.js +1 -0
- package/dist/data/sync/store.d.ts +19 -0
- package/dist/data/sync/store.js +1 -0
- package/dist/data/sync/sync.spec.d.ts +1 -0
- package/dist/data/sync/sync.spec.js +1 -0
- package/dist/data/sync/synchronizer.d.ts +10 -0
- package/dist/data/sync/synchronizer.js +1 -0
- package/dist/data/sync/types.d.ts +162 -0
- package/dist/data/sync/types.js +1 -0
- package/dist/evaluation/builtins/demand-match.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/capability.d.ts +1 -0
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/extract.d.ts +7 -1
- package/dist/evaluation/extract.js +1 -1
- package/dist/evaluation/match-policy.d.ts +118 -0
- package/dist/evaluation/match-policy.js +1 -0
- package/dist/evaluation/match-policy.spec.d.ts +1 -0
- package/dist/evaluation/match-policy.spec.js +1 -0
- 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/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +16 -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-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-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.d.ts +26 -10
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/projection.d.ts +54 -0
- package/dist/knowledge/projection.js +1 -0
- package/dist/knowledge/projection.spec.d.ts +1 -0
- package/dist/knowledge/projection.spec.js +1 -0
- package/dist/knowledge/recipient-constraint.d.ts +1 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/service-ledger.d.ts +1 -1
- package/dist/knowledge/service-ledger.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/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.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/role/profiles.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/proof.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/evaluation/index.d.ts +189 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/query/bi.d.ts +4 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/evaluation_operation.output.json +384 -2
- package/dist/schemas/evaluation_operation.schema.json +202 -4
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/onchain_operations.schema.json +666 -100
- package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
- package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +660 -94
- package/dist/schemas/onchain_operations_service.schema.json +4 -4
- package/dist/schemas/query_toolkit.output.json +299 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +4 -2
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +7 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ValueType}from'@wowok/wowok';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';function asNode(a){if(typeof a!=='object'||a===null)return null;const b=a['type'];return typeof b==='string'?a:null;}function queryMeta(a){if(typeof a!=='number'&&typeof a!=='string')return null;const b=getGuardQueryByIdOrName(a);return b?{'id':b['id'],'name':b['name']}:null;}function childNodes(a){const b=[];if(Array['isArray'](a['nodes']))a['nodes']['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);});if(asNode(a['node']))b['push'](asNode(a['node']));return[a['nodeLeft'],a['nodeRight']]['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);}),b;}export function classifyRecipient(a){if(typeof a!=='object'||a===null)return null;const b=a;if(typeof b['Entity']==='string')return{'kind':'entity','address':b['Entity']};const c=b['Entity'];if(c&&typeof c==='object'&&typeof c['name_or_address']==='string')return{'kind':'entity','address':c['name_or_address']};if(b['Signer']==='signer'||b['Signer']===!![])return{'kind':'signer'};if(typeof b['GuardIdentifier']==='number')return{'kind':'submission','identifier':b['GuardIdentifier']};return null;}export function classifyDualPayoutTrack(a){let b=[];if(Array['isArray'](a))b=a;else{if(a&&typeof a==='object'){const e=a['allocators'];if(Array['isArray'](e))b=e;}}const c=[];for(const f of b){const h=f?.['sharing'];if(Array['isArray'](h))c['push'](...h);}if(c['length']===0x0)return{'track':'unknown'};const d=[];for(const i of c){const j=i?.['who'],k=classifyRecipient(typeof j==='string'?j==='Signer'?{'Signer':!![]}:{'Entity':j}:j);if(!k||k['kind']==='signer')return{'track':'unknown'};if(k['kind']==='submission')return{'track':'order-directed'};d['push'](k['address']);}return{'track':'entity-directed','recipients':d};}function leafInfo(a,b){if(a['type']==='context'&&typeof a['context']==='string'){if(a['context']==='Signer')return{'kind':'signer'};if(a['context']==='Clock')return{'kind':'clock'};}if(a['type']==='query'){const c=queryMeta(a['query']),d=a['object'];if(c&&d&&typeof d['identifier']==='number')return{'kind':'query','query_name':c['name'],'query_id':c['id'],'object_identifier':d['identifier'],'convert_witness':d['convert_witness']};}if(a['type']==='identifier'){const e=typeof a['identifier']==='number'?a['identifier']:-0x1,f=b['find'](g=>g['identifier']===e);if(f){const g=typeof f['value']==='string'?f['value']:undefined,h=normalizeValueType(f['value_type']);if(h===ValueType['Address'])return{'kind':'static_address','value':g};if(h===ValueType['String'])return{'kind':'static_string','value':g};}}return{'kind':'other'};}function comparisonLeaves(a,b){if(a['type']==='logic_equal'){const c=childNodes(a)['map'](d=>flattenLeaf(d,b));return c;}return[];}function flattenLeaf(a,b){if(a['type']==='logic_not'){const d=childNodes(a)[0x0];return d?flattenLeaf(d,b):{'kind':'other'};}return leafInfo(a,b);}function isOrderProgressWitness(a){if(a===0x64)return!![];return typeof a==='string'&&a['toLowerCase']()['includes']('orderprogress');}function describe(a){switch(a){case'service_binding':return'Submitted\x20object\x20must\x20belong\x20to\x20the\x20expected\x20service';case'progress_node_state':return'Submitted\x20order\x20must\x20be\x20at\x20a\x20qualifying\x20workflow\x20node';case'signer_is_submitted_object_owner':return'Caller\x20must\x20be\x20the\x20owner\x20of\x20the\x20submitted\x20object';case'signer_authorized_entity':return'Caller\x20must\x20equal\x20a\x20fixed\x20authorized\x20address';case'signer_permission_member':return'Caller\x20must\x20satisfy\x20a\x20Permission\x20membership\x20rule';case'time_lock':return'Current\x20time\x20must\x20satisfy\x20the\x20time-lock';case'repository_crosscheck':return'Repository\x20data\x20must\x20satisfy\x20the\x20cross-check';default:return'Other\x20guard\x20constraint';}}function extractConstraints(a,b){const c=[],d=new Set(),e=h=>{const i=h['code']+':'+(h['slot']??'-');!d['has'](i)&&(d['add'](i),c['push'](h));},f=(h,i)=>({'path':h,'queries':i}),g=(h,i)=>{const j=comparisonLeaves(h,b);if(j['length']>=0x2){const k=j['find'](r=>r['kind']==='signer'),l=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.owner'),m=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.service'),n=j['find'](r=>r['kind']==='query'&&r['query_name']==='progress.current'),o=j['find'](r=>r['kind']==='static_address'),p=j['find'](r=>r['kind']==='static_string');k&&l&&e({'code':'signer_is_submitted_object_owner','slot':l['object_identifier'],'description':describe('signer_is_submitted_object_owner'),'caller_constraint':!![],'evidence':f(i,['Signer','order.owner'])});k&&o&&e({'code':'signer_authorized_entity','description':describe('signer_authorized_entity'),'caller_constraint':!![],'evidence':f(i,['Signer'])});m&&o&&e({'code':'service_binding','slot':m['object_identifier'],'description':describe('service_binding'),'caller_constraint':![],'evidence':f(i,['order.service'])});if(n&&p){const r=n['object_identifier'];isOrderProgressWitness(n['convert_witness'])&&e({'code':'progress_node_state','slot':r,'description':describe('progress_node_state'),'caller_constraint':![],'evidence':f(i,['progress.current'])});}}if(h['type']['startsWith']('logic_as_u256')||h['type']==='calc_number_add'){const s=[h,...childNodes(h)]['map'](t=>flattenLeaf(t,b));if(s['some'](t=>t['kind']==='clock')&&s['some'](t=>t['kind']==='query'&&(t['query_name']==='progress.current_time'||t['query_name']==='progress.session.forward.time'))){const t=s['find'](u=>u['kind']==='query');e({'code':'time_lock','slot':t['object_identifier'],'description':describe('time_lock'),'caller_constraint':![],'evidence':f(i,['Clock',t['query_name']])});}}if(h['type']==='query'){const u=queryMeta(h['query']);if(u&&u['name']['startsWith']('repository.')){const v=h['object'];e({'code':'repository_crosscheck','slot':v?.['identifier'],'description':describe('repository_crosscheck'),'caller_constraint':![],'evidence':f(i,[u['name']])});}}childNodes(h)['forEach']((w,x)=>g(w,i+'/'+x));};return g(a,'/root'),c;}function findSessionQueries(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']);if(f&&(f['id']===0x4f6||f['id']===0x4f7))b['push'](e);}childNodes(d)['forEach']((g,h)=>c(g,e+'/'+h));};return c(a,'/root'),b;}function collectSlotUsages(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']),g=d['object'];f&&g&&typeof g['identifier']==='number'&&b['push']({'slot':g['identifier'],'path':e,'query_id':f['id'],'query_name':f['name'],...g['convert_witness']!==undefined?{'convert_witness':g['convert_witness']}:{}});}childNodes(d)['forEach']((h,j)=>c(h,e+'/'+j));};return c(a,'/root'),b;}function deriveReceiptRight(a,b){const c=b['find'](e=>e['code']==='progress_node_state'&&e['slot']===a),d=b['find'](e=>e['code']==='signer_is_submitted_object_owner'&&e['slot']===a);if(c||d)return{'object_type':'order','receive_entry':'owner-side\x20extraction\x20on\x20the\x20order','guarantee':'Delivered\x20funds\x20are\x20owned\x20by\x20the\x20submitted\x20Order;\x20only\x20its\x20current\x20owner\x20can\x20'+'extract\x20them\x20(&mut\x20Order\x20input),\x20and\x20coins\x20transfer\x20to\x20that\x20owner.'};return undefined;}function deriveBeneficialOwner(a,b){switch(a['kind']){case'entity':return'Fixed\x20entity\x20'+a['address'];case'signer':return'Transaction\x20caller\x20(Signer)\x20—\x20direct\x20wallet';case'submission':return b?'Owner\x20of\x20the\x20submitted\x20object\x20at\x20table['+a['identifier']+']\x20(object\x20receipt\x20=\x20owner\x20receipt)':'Address\x20submitted\x20at\x20table['+a['identifier']+']\x20(caller-provided)';}}function buildSlotModels(a,b,c,d){const e=[...new Set(c['map'](f=>f['spec'])['filter'](f=>f['kind']==='submission')['map'](f=>f['identifier']))];return e['map'](f=>{const g=a['find'](p=>p['identifier']===f),h=g?normalizeValueType(g['value_type']):undefined,i=h===ValueType['Address'],j=b['filter'](p=>p['slot']===f),k=c['filter'](p=>p['spec']['kind']==='submission'&&p['spec']['identifier']===f)['map'](p=>p['mode']??'Unknown'),l=d['filter'](p=>p['slot']===undefined||p['slot']===f),m=deriveReceiptRight(f,d),n=l['some'](p=>p['code']==='service_binding'||p['code']==='repository_crosscheck'||p['code']==='signer_permission_member'),o=[];if(h!==undefined&&!i)o['push']('RC-FIND-07');if(!n)o['push']('RC-FIND-02');if(m?.['object_type']==='order')o['push']('RC-FIND-03');return{'identifier':f,'externally_submitted':g?.['b_submission']??!![],...h!==undefined?{'declared_value_type':h}:{},'is_address':i,'usages':j,'recipient_modes':k,'constraints':l,...m?{'receipt':m}:{},'beneficial_owner':deriveBeneficialOwner({'kind':'submission','identifier':f},m),'assessment':{'address_typed':i,'scope_bound':n,'object_receipt':m?.['object_type']==='order'},'findings':o};});}function buildSlotFinding(a,b,c){const d=a['identifier'];switch(b){case'RC-FIND-07':return{'code':b,'severity':'medium','title':'Submission\x20slot\x20'+d+'\x20is\x20not\x20address-typed','explanation':'GuardIdentifier\x20recipients\x20require\x20an\x20address-typed\x20table\x20entry\x20'+'(enforced\x20at\x20allocator\x20registration\x20/\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','evidence_paths':c,'mitigation':'Set\x20the\x20slot\x20value_type\x20to\x20Address,\x20or\x20use\x20an\x20Entity\x20recipient.','unavoidable':![]};case'RC-FIND-02':return{'code':b,'severity':'high','title':'Submission\x20slot\x20'+d+'\x20has\x20no\x20scope\x20binding','explanation':'Nothing\x20constrains\x20which\x20submitted\x20objects/addresses\x20qualify:\x20no\x20'+'service\x20binding,\x20repository\x20cross-check\x20or\x20permission\x20membership.\x20A\x20caller\x20'+'can\x20submit\x20arbitrary\x20qualifying-by-other-conditions\x20inputs.','evidence_paths':c,'mitigation':'Add\x20a\x20constraint\x20binding\x20the\x20slot\x20(e.g.\x20order.service\x20==\x20host\x20service).','unavoidable':![]};case'RC-FIND-03':return{'code':b,'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','explanation':'The\x20submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20Allocation\x20being\x20settled\x20'+'(alloc\x20is\x20permissionless\x20and\x20allocation\x20context\x20is\x20not\x20a\x20Guard\x20input).\x20A\x20'+'caller\x20owning\x20ANY\x20qualifying\x20order\x20can\x20settle\x20OTHER\x20allocations;\x20funds\x20land\x20'+'at\x20the\x20submitted\x20order\x20and\x20are\x20receivable\x20by\x20its\x20owner.\x20Destination\x20is\x20safe\x20'+'(an\x20order\x20owner),\x20allocation\x20choice\x20is\x20the\x20residual.','evidence_paths':c,'mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20—\x20declare\x20that\x20any\x20qualifying\x20order\x20may\x20settle\x20'+'this\x20allocation\x20and\x20cap\x20the\x20exposure\x20(sharing\x20threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20—\x20use\x20a\x20fixed\x20Entity\x20(treasury)\x20recipient,\x20the\x20only\x20'+'exclusive\x20choice\x20on\x20the\x20automatic\x20order_allocators\x20route\x20(trust\x20shifts\x20to\x20'+'the\x20entity\x20operator);\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20—\x20abandon\x20automatic\x20order_allocators\x20and\x20attach\x20'+'a\x20per-order\x20Guard\x20pinning\x20the\x20order\x20id\x20(order.owner\x20==\x20constant),\x20the\x20'+'trustless\x20exclusive\x20route.','unavoidable':!![],'resolution_required':!![]};default:return{'code':b,'severity':'low','title':'Slot\x20'+d+'\x20finding\x20'+b,'explanation':'','evidence_paths':c,'mitigation':'','unavoidable':![]};}}function buildFindings(a,b){const c=[];let d=![],e=![];for(const f of b){const g=f['recipients']['flatMap'](h=>h['constraints'])['filter'](h=>h['caller_constraint']);if(g['length']>0x0)d=!![];if(f['slots']['some'](h=>h['assessment']['scope_bound']))e=!![];for(const h of f['recipients']){const i=h['constraints']['map'](j=>j['evidence']['path']);h['spec']['kind']==='signer'&&g['length']===0x0&&c['push']({'code':'RC-FIND-01','severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','explanation':'Funds\x20are\x20delivered\x20directly\x20to\x20the\x20transaction\x20caller,\x20but\x20the\x20Guard\x20'+'does\x20not\x20bind\x20the\x20Signer\x20to\x20an\x20authorized\x20identity.\x20Anyone\x20who\x20satisfies\x20the\x20'+'other\x20conditions\x20steals\x20the\x20funds.','evidence_paths':i,'mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.','unavoidable':![]});}for(const j of f['slots']){const k=j['constraints']['map'](l=>l['evidence']['path']);for(const l of j['findings']){c['push'](buildSlotFinding(j,l,k));}}a['trigger_source']==='service_order_allocators'&&f['recipients']['length']>0x0&&!f['recipients']['some'](m=>m['spec']['kind']==='submission')&&c['push']({'code':'RC-FIND-09','severity':'low','title':'Allocator\x20Guard\x20'+f['guard']+'\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','explanation':'Every\x20sharing\x20row\x20is\x20a\x20fixed\x20recipient\x20(Entity/Signer),\x20which\x20resolves\x20no\x20'+'submission.\x20The\x20Guard\x20therefore\x20cannot\x20read\x20the\x20paying\x20order\x20(order.*\x20queries\x20have\x20'+'no\x20binding\x20target),\x20and\x20the\x20allocation\x20pays\x20the\x20same\x20fixed\x20destinations\x20for\x20EVERY\x20order.\x20'+'This\x20is\x20often\x20intended\x20—\x20confirm\x20it\x20is.','evidence_paths':[],'mitigation':'If\x20the\x20Guard\x20should\x20distinguish\x20orders,\x20add\x20a\x20zero-share\x20{GuardIdentifier:\x200}\x20'+'anchor\x20row\x20(Rate\x200)\x20so\x20the\x20Identifier\x20slot\x20resolves\x20to\x20the\x20paying\x20order\x20'+'(pattern.allocator_order_anchor).\x20If\x20fixed-pay\x20is\x20intended,\x20no\x20action.','unavoidable':![]});}a['trigger_source']==='standalone'&&!d&&c['push']({'code':'RC-FIND-04','severity':'high','title':'Standalone\x20allocation\x20without\x20issuer\x20identity\x20constraint','explanation':'Standalone\x20allocations\x20have\x20no\x20Service/Arbitration\x20access-control\x20layer.\x20'+'Without\x20a\x20Signer/permission\x20binding\x20in\x20the\x20Guard,\x20anyone\x20can\x20trigger\x20distribution.','evidence_paths':[],'mitigation':'Bind\x20the\x20issuer\x20(Signer==owner/admin)\x20or\x20move\x20the\x20allocation\x20into\x20a\x20Service.','unavoidable':![]});c['push']({'code':'RC-FIND-06','severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','explanation':'Once\x20the\x20Guard\x27s\x20conditions\x20are\x20satisfiable,\x20anyone\x20can\x20trigger\x20settlement\x20of\x20an\x20'+'order\x27s\x20allocation.\x20With\x20Entity/object\x20recipients\x20this\x20affects\x20timing\x20only,\x20not\x20destination.','evidence_paths':[],'mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.','unavoidable':!![]});for(const [m,n]of Object['entries'](a['guards']??{})){const o=asNode(n['root']);if(!o)continue;for(const q of findSessionQueries(o)){c['push']({'code':'RC-FIND-05','severity':'medium','title':'Guard\x20'+m+'\x20uses\x20session-only\x20query\x20at\x20'+q,'explanation':'Queries\x201270/1271\x20read\x20the\x20active\x20session;\x20after\x20the\x20session\x20migrates\x20to\x20'+'history\x20the\x20query\x20aborts\x20(W_FIELD_NOT_FOUND)\x20and\x20the\x20Guard\x20permanently\x20fails.','evidence_paths':[q],'mitigation':'Use\x20progress.current_time\x20(1272)\x20or\x20history\x20queries\x20(1274-1280).','unavoidable':![]});}}for(const [s,t]of Object['entries'](a['guards']??{})){const u=(t['relies']??[])['filter'](v=>typeof v==='string'&&v);if(u['length']===0x0)continue;c['push']({'code':'RC-FIND-08','severity':'low','title':'Guard\x20'+s+'\x20relies\x20on\x20'+u['length']+'\x20sub-guard(s)\x20—\x20not\x20credited\x20by\x20this\x20audit','explanation':'Guard\x20composition\x20(relies,\x20one\x20level,\x20≤4,\x20'+((t['relies_logic_and']===![]?'OR':'AND')+'-logic)\x20may\x20carry\x20the\x20scope/signer\x20')+'constraints\x20in\x20the\x20relied\x20sub-guards.\x20This\x20audit\x20evaluates\x20only\x20the\x20guard\x27s\x20own\x20root:\x20'+'sub-guard\x20constraints\x20are\x20NOT\x20credited,\x20so\x20scope-binding\x20gaps\x20(RC-FIND-02)\x20may\x20be\x20'+'over-reported\x20and\x20sub-guard-only\x20conditions\x20stay\x20unverified.','evidence_paths':u,'mitigation':'Resolve\x20the\x20relied\x20sub-guards\x20and\x20verify\x20their\x20constraints\x20manually,\x20or\x20re-run\x20'+'with\x20the\x20sub-guard\x20defs\x20included\x20(read-side\x20resolvers\x20attach\x20them\x20automatically).','unavoidable':![]});}if(!e&&a['trigger_source']==='service_order_allocators'){}return c;}function buildPayoff(a,b){const c=a['recipients']['some'](h=>h['constraints']['some'](i=>i['caller_constraint'])),d=c?'Caller\x20must\x20satisfy\x20the\x20Guard\x27s\x20Signer/identity\x20binding':b==='standalone'?'Any\x20caller\x20(no\x20identity\x20binding)':'Any\x20caller\x20who\x20satisfies\x20the\x20Guard\x27s\x20object/state\x20conditions',e=a['recipients']['map'](h=>h['beneficial_owner'])['join'](';\x20')||'(none)',f={},g=a['recipients']['some'](h=>h['spec']['kind']==='signer'&&!c);return f['caller']=g?'gains':c?'conditional':'neutral',f['provider']=a['recipients']['some'](h=>h['spec']['kind']==='entity')?'gains':'conditional',f['customer']=a['recipients']['some'](h=>h['receipt']?.['object_type']==='order')?'conditional':'neutral',f['system']='neutral',{'caller_eligibility':d,'beneficial_recipient':e,'positions':f};}export const RECIPIENT_CONSTRAINT_VERSION='1.2.0';export function analyzeRecipientConstraints(a){const b=a['allocators']['map'](h=>{const i=a['guards']?.[h['guard']],j=asNode(i?.['root']),k=i?.['table']??[],l=j?extractConstraints(j,k):[],m=j?collectSlotUsages(j):[],n=h['sharing']['map'](q=>{const r=classifyRecipient(q['who']);if(!r)return{'spec':{'kind':'entity','address':'(unclassifiable)'},'constraints':l,'beneficial_owner':'Unclassifiable\x20recipient\x20—\x20check\x20allocator\x20config'};const t=r['kind']==='submission'?r['identifier']:undefined,u=t!==undefined?k['find'](w=>w['identifier']===t):undefined,v=t!==undefined?deriveReceiptRight(t,l):undefined;return{'spec':r,'slot_value_type':u?normalizeValueType(u['value_type']):undefined,'constraints':t!==undefined?l['filter'](w=>w['slot']===undefined||w['slot']===t):l,'receipt':v,'beneficial_owner':deriveBeneficialOwner(r,v)};}),o=buildSlotModels(k,m,h['sharing']['map'](q=>({'spec':classifyRecipient(q['who'])??{'kind':'entity','address':'(unclassifiable)'},'mode':q['mode']})),l),p={'guard':h['guard'],'recipients':n,'slots':o,'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return p['payoff']=buildPayoff(p,a['trigger_source']),p;}),c=buildFindings(a,b),d=c['some'](h=>h['severity']==='critical')?'critical':c['some'](h=>h['severity']==='high')?'high':c['some'](h=>h['severity']==='medium')?'medium':'low',e=!c['some'](h=>h['code']==='RC-FIND-01'),f=c['some'](h=>h['resolution_required']),g=[{'code':'RC-FIND-03','title':'Cross-allocation\x20settlement','detail':'Submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20settled\x20allocation;\x20destination\x20stays\x20at\x20an\x20order\x20owner.'},{'code':'RC-FIND-06','title':'Forced\x20settlement\x20timing','detail':'alloc\x20is\x20permissionless;\x20settlement\x20can\x20be\x20triggered\x20by\x20anyone\x20once\x20conditions\x20hold.'},{'code':'RC-RES-01','title':'Published\x20immutability','detail':'order_allocators,\x20Machine\x20and\x20Guards\x20are\x20immutable\x20after\x20publish.'},{'code':'RC-RES-03','title':'Off-chain\x20arbitration\x20backstop','detail':'No\x20on-chain\x20clawback;\x20post-incident\x20recovery\x20relies\x20on\x20arbitration.'}];return{'version':RECIPIENT_CONSTRAINT_VERSION,'scope':{'trigger_source':a['trigger_source'],'host_service':a['host_service'],'allocation':a['allocation']},'allocators':b,'findings':c,'unavoidable':g,'safe_destination':e,'resolution_required':f,'overall':d,'summary':'Analyzed\x20'+b['length']+'\x20allocator(s):\x20'+c['filter'](h=>!h['unavoidable'])['length']+'\x20actionable,\x20'+(c['filter'](h=>h['unavoidable'])['length']+'\x20structural\x20finding(s).\x20Safe\x20destination:\x20'+e+'.')+(''+(f?'\x20Resolution\x20REQUIRED:\x20at\x20least\x20one\x20residual\x20demands\x20an\x20explicit\x20design\x20decision\x20before\x20publish.':''))};}export function derivePayoffFromSharing(a,b,c){const d=asNode(c?.['root']),e=c?.['table']??[],f=d?extractConstraints(d,e):[],g=a['map'](i=>{const j=classifyRecipient(i['who'])??{'kind':'entity','address':'(unclassifiable)'},k=j['kind']==='submission'?j['identifier']:undefined,l=k!==undefined?e['find'](n=>n['identifier']===k):undefined,m=k!==undefined?deriveReceiptRight(k,f):undefined;return{'spec':j,'slot_value_type':l?normalizeValueType(l['value_type']):undefined,'constraints':k!==undefined?f['filter'](n=>n['slot']===undefined||n['slot']===k):f,'receipt':m,'beneficial_owner':deriveBeneficialOwner(j,m)};}),h={'guard':'','recipients':g,'slots':[],'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return buildPayoff(h,b);}function normalizeValueType(a){if(typeof a==='number')return a;const b={'bool':ValueType['Bool'],'address':ValueType['Address'],'string':ValueType['String'],'u64':ValueType['U64'],'u256':ValueType['U256']};return b[a['toLowerCase']()];}export function isUnboundSignerTheft(a){return a['recipient_is_signer']&&!a['caller_identity_constrained'];}export function canonicalDoctrine(a){switch(a){case'RC-FIND-01':return{'severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.'};case'RC-FIND-03':return{'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20with\x20capped\x20exposure\x20(threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20(treasury)\x20—\x20the\x20only\x20exclusive\x20choice\x20on\x20the\x20automatic\x20'+'order_allocators\x20route;\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20(order.owner\x20==\x20constant)\x20—\x20the\x20trustless\x20'+'exclusive\x20route.','resolution_required':!![]};case'RC-FIND-06':return{'severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.'};}}export const RECIPIENT_DESIGN_OPTIONS=[{'id':'entity','move_recipient':'Recipient::Entity(address)','semantics':'Funds\x20flow\x20to\x20a\x20fixed\x20address\x20(a\x20constrained\x20user\x20account\x20/\x20treasury).\x20'+'Destination\x20never\x20depends\x20on\x20the\x20caller.','required_constraints':['The\x20address\x20is\x20chosen\x20at\x20design\x20time\x20and\x20recorded\x20in\x20the\x20allocator\x20table.']},{'id':'submitted_object','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20the\x20object\x20submitted\x20under\x20protocol\x20context\x20(e.g.\x20the\x20order\x20being\x20settled).\x20'+'Receivable\x20only\x20by\x20that\x20object\x27s\x20owner\x20—\x20object\x20receipt\x20=\x20owner\x20receipt.','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(which\x20query/object\x20type\x20the\x20slot\x20carries).','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-02\x20/\x20RC-FIND-07'},{'id':'signer','move_recipient':'Recipient::Signer','semantics':'Funds\x20flow\x20to\x20the\x20caller\x20who\x20executes\x20the\x20permissionless\x20alloc.\x20'+'Safe\x20only\x20when\x20the\x20Guard\x20proves\x20exactly\x20who\x20the\x20caller\x20may\x20be.','required_constraints':['The\x20Guard\x20constrains\x20the\x20Signer\x20identity\x20(signer\x20==\x20a\x20fixed\x20address\x20or\x20a\x20derived\x20legitimate\x20owner).'],'finding_if_unmet':'RC-FIND-01'},{'id':'constrained_submission','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20an\x20object\x20address\x20supplied\x20by\x20the\x20signer,\x20but\x20the\x20Guard\x20constrains\x20'+'both\x20the\x20submission\x20scope\x20and\x20the\x20signer\x27s\x20relation\x20to\x20it\x20(e.g.\x20the\x20signer\x20owns\x20the\x20submitted\x20order).','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(object/query\x20type).','The\x20Guard\x20binds\x20the\x20signer\x20to\x20the\x20submitted\x20object.','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-01\x20/\x20RC-FIND-02\x20/\x20RC-FIND-07'}];export function recipientDesignGuidance(){return RECIPIENT_DESIGN_OPTIONS;}export const OBJECT_DRIVEABILITY=[{'object_type':'order','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20order','owner-side\x20object\x20extraction\x20from\x20the\x20order'],'anyone_drivable':!![],'funds_settle_to':'order.owner','rationale':'Order\x20is\x20a\x20shared\x20object\x20and\x20extraction\x20has\x20no\x20signer\x20gate;\x20'+'Receiving\x20is\x20restricted\x20to\x20objects\x20actually\x20delivered\x20to\x20that\x20order,\x20and\x20coins\x20settle\x20to\x20its\x20owner.'},{'object_type':'permission','receive_entries':['owner-side\x20coin\x20extraction\x20via\x20the\x20permission\x20object','owner-side\x20object\x20extraction\x20via\x20the\x20permission\x20object'],'anyone_drivable':!![],'funds_settle_to':'permission.owner','rationale':'Permission\x20is\x20the\x20final\x20authority;\x20anyone\x20can\x20drive\x20extraction\x20of\x20funds\x20sent\x20to\x20its\x20address,\x20but\x20the\x20destination\x20is\x20its\x20owner.'},{'object_type':'service','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20service','owner-side\x20object\x20extraction\x20from\x20the\x20service'],'anyone_drivable':![],'permission_index':0x13f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20319);\x20members\x20drive,\x20value\x20settles\x20to\x20the\x20organization\x20owner.'},{'object_type':'treasury','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20treasury','owner-side\x20object\x20extraction\x20from\x20the\x20treasury'],'anyone_drivable':![],'permission_index':0x101,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20257).'},{'object_type':'arbitration','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20arbitration','owner-side\x20object\x20extraction\x20from\x20the\x20arbitration'],'anyone_drivable':![],'permission_index':0x16f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20367).'},{'object_type':'machine','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20machine','owner-side\x20object\x20extraction\x20from\x20the\x20machine'],'anyone_drivable':![],'permission_index':0xcf,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20207).'},{'object_type':'progress','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20progress','owner-side\x20object\x20extraction\x20from\x20the\x20progress'],'anyone_drivable':![],'permission_index':0xe1,'funds_settle_to':'machine\x27s\x20permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20225),\x20scoped\x20to\x20the\x20Machine\x20permission.'},{'object_type':'demand','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20demand','owner-side\x20object\x20extraction\x20from\x20the\x20demand'],'anyone_drivable':![],'permission_index':0x197,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20407).'},{'object_type':'contact','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20contact','owner-side\x20object\x20extraction\x20from\x20the\x20contact'],'anyone_drivable':![],'permission_index':0x1c6,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20454).'}];export function driveabilityOf(a){return OBJECT_DRIVEABILITY['find'](b=>b['object_type']===a);}function rewardRecipientKind(a){if(typeof a==='string'){const e=a['toLowerCase']();if(e==='signer')return{'kind':'signer'};return{'kind':'entity'};}if(typeof a!=='object'||a===null)return{'kind':'entity'};const b=a,c=f=>typeof b[f]==='number'?b[f]:undefined,d=c('GuardIdentifier')??c('guard_identifier')??c('identifier');if(d!==undefined)return{'kind':'submission','slot':d};if(b['Signer']!==undefined||b['signer']!==undefined)return{'kind':'signer'};return{'kind':'entity'};}const SLOT_BINDING_CODES=new Set(['service_binding','progress_node_state','signer_is_submitted_object_owner','repository_crosscheck','signer_permission_member']);export function analyzeRewardClaimGuard(a){const {kind:b,slot:c}=rewardRecipientKind(a['recipient']),d={'entry_index':a['entry_index'],'guard':a['guard'],'recipient_kind':b,...c!==undefined?{'recipient_slot':c}:{},'guard_resolved':![],'constraint_codes':[],'recipient_slot_usages':0x0,'caller_identity_constrained':![],'viability':'unverifiable','reason':'Guard\x20table/root\x20not\x20fetched\x20with\x20the\x20topology\x20—\x20the\x20deciding\x20predicate\x20is\x20outside\x20the\x20evidence;\x20the\x20owner\x20must\x20disclose\x20the\x20full\x20guard\x20definitions.'},e=asNode(a['guard_def']?.['root']);if(!e)return d;const f=a['guard_def']?.['table']??[],g=extractConstraints(e,f);d['guard_resolved']=!![],d['constraint_codes']=g['map'](k=>k['code']),d['caller_identity_constrained']=g['some'](k=>k['caller_constraint']);if(b==='entity')return d['viability']='blocked',d['reason']='Payout\x20address\x20is\x20fixed\x20at\x20guard\x20registration\x20(Entity\x20recipient);\x20the\x20claim\x20path\x20cannot\x20redirect\x20it.',d;if(b==='signer')return d['caller_identity_constrained']?(d['viability']='blocked',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20but\x20the\x20guard\x20binds\x20the\x20caller\x20identity\x20—\x20only\x20the\x20authorized\x20party\x20can\x20claim.'):(d['viability']='viable',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20with\x20no\x20identity\x20binding\x20—\x20anyone\x20satisfying\x20the\x20remaining\x20conditions\x20claims\x20to\x20their\x20own\x20address.'),d;const h=c??-0x1,i=collectSlotUsages(e)['filter'](k=>k['slot']===h);d['recipient_slot_usages']=i['length'];const j=g['filter'](k=>k['slot']===h&&SLOT_BINDING_CODES['has'](k['code']));if(j['length']>0x0)d['viability']='blocked',d['reason']='Submitted\x20address\x20is\x20constrained\x20inside\x20the\x20guard\x20('+j['map'](k=>k['code'])['join'](',\x20')+')\x20—\x20a\x20passerby\x20cannot\x20fill\x20the\x20slot\x20with\x20an\x20arbitrary\x20address.';else i['length']>0x0?(d['viability']='conditional',d['reason']='The\x20guard\x20reads\x20the\x20submitted\x20slot\x20('+i['length']+'\x20query\x20usage(s))\x20but\x20no\x20recognized\x20scope/equality\x20constraint\x20was\x20matched\x20—\x20manual\x20predicate\x20review\x20required.'):(d['viability']='viable',d['reason']='No\x20guard\x20query\x20consumes\x20the\x20submitted\x20slot\x20—\x20the\x20predicate\x20cannot\x20constrain\x20the\x20payout\x20address;\x20any\x20passing\x20party\x20claims\x20to\x20their\x20own\x20address.');return d;}
|
|
1
|
+
import{ValueType}from'@wowok/wowok';import{getGuardQueryByIdOrName}from'../schema/utils/guard-query-utils.js';function asNode(a){if(typeof a!=='object'||a===null)return null;const b=a['type'];return typeof b==='string'?a:null;}function queryMeta(a){if(typeof a!=='number'&&typeof a!=='string')return null;const b=getGuardQueryByIdOrName(a);return b?{'id':b['id'],'name':b['name']}:null;}function childNodes(a){const b=[];if(Array['isArray'](a['nodes']))a['nodes']['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);});if(asNode(a['node']))b['push'](asNode(a['node']));return[a['nodeLeft'],a['nodeRight']]['forEach'](d=>{const e=asNode(d);if(e)b['push'](e);}),b;}export function classifyRecipient(a){if(typeof a!=='object'||a===null)return null;const b=a;if(typeof b['Entity']==='string')return{'kind':'entity','address':b['Entity']};const c=b['Entity'];if(c&&typeof c==='object'&&typeof c['name_or_address']==='string')return{'kind':'entity','address':c['name_or_address']};if(b['Signer']==='signer'||b['Signer']===!![])return{'kind':'signer'};if(typeof b['GuardIdentifier']==='number')return{'kind':'submission','identifier':b['GuardIdentifier']};return null;}export function classifyDualPayoutTrack(a,b){let c=[];if(Array['isArray'](a))c=a;else{if(a&&typeof a==='object'){const f=a['allocators'];if(Array['isArray'](f))c=f;}}const d=[];for(const h of c){if(b){const j=h?.['guard'];if(typeof j!=='string'||j['toLowerCase']()!==b['toLowerCase']())continue;}const i=h?.['sharing'];if(Array['isArray'](i))d['push'](...i);}if(d['length']===0x0)return{'track':'unknown'};const e=[];for(const k of d){const l=k?.['who'],m=classifyRecipient(typeof l==='string'?l==='Signer'?{'Signer':!![]}:{'Entity':l}:l);if(!m||m['kind']==='signer')return{'track':'unknown'};if(m['kind']==='submission')return{'track':'order-directed'};e['push'](m['address']);}return{'track':'entity-directed','recipients':e};}function leafInfo(a,b){if(a['type']==='context'&&typeof a['context']==='string'){if(a['context']==='Signer')return{'kind':'signer'};if(a['context']==='Clock')return{'kind':'clock'};}if(a['type']==='query'){const c=queryMeta(a['query']),d=a['object'];if(c&&d&&typeof d['identifier']==='number')return{'kind':'query','query_name':c['name'],'query_id':c['id'],'object_identifier':d['identifier'],'convert_witness':d['convert_witness']};}if(a['type']==='identifier'){const e=typeof a['identifier']==='number'?a['identifier']:-0x1,f=b['find'](g=>g['identifier']===e);if(f){const g=typeof f['value']==='string'?f['value']:undefined,h=normalizeValueType(f['value_type']);if(h===ValueType['Address'])return{'kind':'static_address','value':g};if(h===ValueType['String'])return{'kind':'static_string','value':g};}}return{'kind':'other'};}function comparisonLeaves(a,b){if(a['type']==='logic_equal'){const c=childNodes(a)['map'](d=>flattenLeaf(d,b));return c;}return[];}function flattenLeaf(a,b){if(a['type']==='logic_not'){const d=childNodes(a)[0x0];return d?flattenLeaf(d,b):{'kind':'other'};}return leafInfo(a,b);}function isOrderProgressWitness(a){if(a===0x64)return!![];return typeof a==='string'&&a['toLowerCase']()['includes']('orderprogress');}function describe(a){switch(a){case'service_binding':return'Submitted\x20object\x20must\x20belong\x20to\x20the\x20expected\x20service';case'progress_node_state':return'Submitted\x20order\x20must\x20be\x20at\x20a\x20qualifying\x20workflow\x20node';case'signer_is_submitted_object_owner':return'Caller\x20must\x20be\x20the\x20owner\x20of\x20the\x20submitted\x20object';case'signer_authorized_entity':return'Caller\x20must\x20equal\x20a\x20fixed\x20authorized\x20address';case'signer_permission_member':return'Caller\x20must\x20satisfy\x20a\x20Permission\x20membership\x20rule';case'time_lock':return'Current\x20time\x20must\x20satisfy\x20the\x20time-lock';case'repository_crosscheck':return'Repository\x20data\x20must\x20satisfy\x20the\x20cross-check';default:return'Other\x20guard\x20constraint';}}function extractConstraints(a,b){const c=[],d=new Set(),e=h=>{const i=h['code']+':'+(h['slot']??'-');!d['has'](i)&&(d['add'](i),c['push'](h));},f=(h,i)=>({'path':h,'queries':i}),g=(h,i)=>{const j=comparisonLeaves(h,b);if(j['length']>=0x2){const k=j['find'](r=>r['kind']==='signer'),l=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.owner'),m=j['find'](r=>r['kind']==='query'&&r['query_name']==='order.service'),n=j['find'](r=>r['kind']==='query'&&r['query_name']==='progress.current'),o=j['find'](r=>r['kind']==='static_address'),p=j['find'](r=>r['kind']==='static_string');k&&l&&e({'code':'signer_is_submitted_object_owner','slot':l['object_identifier'],'description':describe('signer_is_submitted_object_owner'),'caller_constraint':!![],'evidence':f(i,['Signer','order.owner'])});k&&o&&e({'code':'signer_authorized_entity','description':describe('signer_authorized_entity'),'caller_constraint':!![],'evidence':f(i,['Signer'])});m&&o&&e({'code':'service_binding','slot':m['object_identifier'],'description':describe('service_binding'),'caller_constraint':![],'evidence':f(i,['order.service'])});if(n&&p){const r=n['object_identifier'];isOrderProgressWitness(n['convert_witness'])&&e({'code':'progress_node_state','slot':r,'description':describe('progress_node_state'),'caller_constraint':![],'evidence':f(i,['progress.current'])});}}if(h['type']['startsWith']('logic_as_u256')||h['type']==='calc_number_add'){const s=[h,...childNodes(h)]['map'](t=>flattenLeaf(t,b));if(s['some'](t=>t['kind']==='clock')&&s['some'](t=>t['kind']==='query'&&(t['query_name']==='progress.current_time'||t['query_name']==='progress.session.forward.time'))){const t=s['find'](u=>u['kind']==='query');e({'code':'time_lock','slot':t['object_identifier'],'description':describe('time_lock'),'caller_constraint':![],'evidence':f(i,['Clock',t['query_name']])});}}if(h['type']==='query'){const u=queryMeta(h['query']);if(u&&u['name']['startsWith']('repository.')){const v=h['object'];e({'code':'repository_crosscheck','slot':v?.['identifier'],'description':describe('repository_crosscheck'),'caller_constraint':![],'evidence':f(i,[u['name']])});}}childNodes(h)['forEach']((w,x)=>g(w,i+'/'+x));};return g(a,'/root'),c;}function findSessionQueries(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']);if(f&&(f['id']===0x4f6||f['id']===0x4f7))b['push'](e);}childNodes(d)['forEach']((g,h)=>c(g,e+'/'+h));};return c(a,'/root'),b;}function collectSlotUsages(a){const b=[],c=(d,e)=>{if(d['type']==='query'){const f=queryMeta(d['query']),g=d['object'];f&&g&&typeof g['identifier']==='number'&&b['push']({'slot':g['identifier'],'path':e,'query_id':f['id'],'query_name':f['name'],...g['convert_witness']!==undefined?{'convert_witness':g['convert_witness']}:{}});}childNodes(d)['forEach']((h,j)=>c(h,e+'/'+j));};return c(a,'/root'),b;}function deriveReceiptRight(a,b){const c=b['find'](e=>e['code']==='progress_node_state'&&e['slot']===a),d=b['find'](e=>e['code']==='signer_is_submitted_object_owner'&&e['slot']===a);if(c||d)return{'object_type':'order','receive_entry':'owner-side\x20extraction\x20on\x20the\x20order','guarantee':'Delivered\x20funds\x20are\x20owned\x20by\x20the\x20submitted\x20Order;\x20only\x20its\x20current\x20owner\x20can\x20'+'extract\x20them\x20(&mut\x20Order\x20input),\x20and\x20coins\x20transfer\x20to\x20that\x20owner.'};return undefined;}function deriveBeneficialOwner(a,b){switch(a['kind']){case'entity':return'Fixed\x20entity\x20'+a['address'];case'signer':return'Transaction\x20caller\x20(Signer)\x20—\x20direct\x20wallet';case'submission':return b?'Owner\x20of\x20the\x20submitted\x20object\x20at\x20table['+a['identifier']+']\x20(object\x20receipt\x20=\x20owner\x20receipt)':'Address\x20submitted\x20at\x20table['+a['identifier']+']\x20(caller-provided)';}}function buildSlotModels(a,b,c,d){const e=[...new Set(c['map'](f=>f['spec'])['filter'](f=>f['kind']==='submission')['map'](f=>f['identifier']))];return e['map'](f=>{const g=a['find'](p=>p['identifier']===f),h=g?normalizeValueType(g['value_type']):undefined,i=h===ValueType['Address'],j=b['filter'](p=>p['slot']===f),k=c['filter'](p=>p['spec']['kind']==='submission'&&p['spec']['identifier']===f)['map'](p=>p['mode']??'Unknown'),l=d['filter'](p=>p['slot']===undefined||p['slot']===f),m=deriveReceiptRight(f,d),n=l['some'](p=>p['code']==='service_binding'||p['code']==='repository_crosscheck'||p['code']==='signer_permission_member'),o=[];if(h!==undefined&&!i)o['push']('RC-FIND-07');if(!n)o['push']('RC-FIND-02');if(m?.['object_type']==='order')o['push']('RC-FIND-03');return{'identifier':f,'externally_submitted':g?.['b_submission']??!![],...h!==undefined?{'declared_value_type':h}:{},'is_address':i,'usages':j,'recipient_modes':k,'constraints':l,...m?{'receipt':m}:{},'beneficial_owner':deriveBeneficialOwner({'kind':'submission','identifier':f},m),'assessment':{'address_typed':i,'scope_bound':n,'object_receipt':m?.['object_type']==='order'},'findings':o};});}function buildSlotFinding(a,b,c){const d=a['identifier'];switch(b){case'RC-FIND-07':return{'code':b,'severity':'medium','title':'Submission\x20slot\x20'+d+'\x20is\x20not\x20address-typed','explanation':'GuardIdentifier\x20recipients\x20require\x20an\x20address-typed\x20table\x20entry\x20'+'(enforced\x20at\x20allocator\x20registration\x20/\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS).','evidence_paths':c,'mitigation':'Set\x20the\x20slot\x20value_type\x20to\x20Address,\x20or\x20use\x20an\x20Entity\x20recipient.','unavoidable':![]};case'RC-FIND-02':return{'code':b,'severity':'high','title':'Submission\x20slot\x20'+d+'\x20has\x20no\x20scope\x20binding','explanation':'Nothing\x20constrains\x20which\x20submitted\x20objects/addresses\x20qualify:\x20no\x20'+'service\x20binding,\x20repository\x20cross-check\x20or\x20permission\x20membership.\x20A\x20caller\x20'+'can\x20submit\x20arbitrary\x20qualifying-by-other-conditions\x20inputs.','evidence_paths':c,'mitigation':'Add\x20a\x20constraint\x20binding\x20the\x20slot\x20(e.g.\x20order.service\x20==\x20host\x20service).','unavoidable':![]};case'RC-FIND-03':return{'code':b,'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','explanation':'The\x20submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20Allocation\x20being\x20settled\x20'+'(alloc\x20is\x20permissionless\x20and\x20allocation\x20context\x20is\x20not\x20a\x20Guard\x20input).\x20A\x20'+'caller\x20owning\x20ANY\x20qualifying\x20order\x20can\x20settle\x20OTHER\x20allocations;\x20funds\x20land\x20'+'at\x20the\x20submitted\x20order\x20and\x20are\x20receivable\x20by\x20its\x20owner.\x20Destination\x20is\x20safe\x20'+'(an\x20order\x20owner),\x20allocation\x20choice\x20is\x20the\x20residual.','evidence_paths':c,'mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20—\x20declare\x20that\x20any\x20qualifying\x20order\x20may\x20settle\x20'+'this\x20allocation\x20and\x20cap\x20the\x20exposure\x20(sharing\x20threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20—\x20use\x20a\x20fixed\x20Entity\x20(treasury)\x20recipient,\x20the\x20only\x20'+'exclusive\x20choice\x20on\x20the\x20automatic\x20order_allocators\x20route\x20(trust\x20shifts\x20to\x20'+'the\x20entity\x20operator);\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20—\x20abandon\x20automatic\x20order_allocators\x20and\x20attach\x20'+'a\x20per-order\x20Guard\x20pinning\x20the\x20order\x20id\x20(order.owner\x20==\x20constant),\x20the\x20'+'trustless\x20exclusive\x20route.','unavoidable':!![],'resolution_required':!![]};default:return{'code':b,'severity':'low','title':'Slot\x20'+d+'\x20finding\x20'+b,'explanation':'','evidence_paths':c,'mitigation':'','unavoidable':![]};}}function buildFindings(a,b){const c=[];let d=![],e=![];for(const f of b){const g=f['recipients']['flatMap'](h=>h['constraints'])['filter'](h=>h['caller_constraint']);if(g['length']>0x0)d=!![];if(f['slots']['some'](h=>h['assessment']['scope_bound']))e=!![];for(const h of f['recipients']){const i=h['constraints']['map'](j=>j['evidence']['path']);h['spec']['kind']==='signer'&&g['length']===0x0&&c['push']({'code':'RC-FIND-01','severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','explanation':'Funds\x20are\x20delivered\x20directly\x20to\x20the\x20transaction\x20caller,\x20but\x20the\x20Guard\x20'+'does\x20not\x20bind\x20the\x20Signer\x20to\x20an\x20authorized\x20identity.\x20Anyone\x20who\x20satisfies\x20the\x20'+'other\x20conditions\x20steals\x20the\x20funds.','evidence_paths':i,'mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.','unavoidable':![]});}for(const j of f['slots']){const k=j['constraints']['map'](l=>l['evidence']['path']);for(const l of j['findings']){c['push'](buildSlotFinding(j,l,k));}}a['trigger_source']==='service_order_allocators'&&f['recipients']['length']>0x0&&!f['recipients']['some'](m=>m['spec']['kind']==='submission')&&c['push']({'code':'RC-FIND-09','severity':'low','title':'Allocator\x20Guard\x20'+f['guard']+'\x20has\x20no\x20GuardIdentifier\x20sharing\x20row\x20—\x20bound\x20to\x20no\x20particular\x20order','explanation':'Every\x20sharing\x20row\x20is\x20a\x20fixed\x20recipient\x20(Entity/Signer),\x20which\x20resolves\x20no\x20'+'submission.\x20The\x20Guard\x20therefore\x20cannot\x20read\x20the\x20paying\x20order\x20(order.*\x20queries\x20have\x20'+'no\x20binding\x20target),\x20and\x20the\x20allocation\x20pays\x20the\x20same\x20fixed\x20destinations\x20for\x20EVERY\x20order.\x20'+'This\x20is\x20often\x20intended\x20—\x20confirm\x20it\x20is.','evidence_paths':[],'mitigation':'If\x20the\x20Guard\x20should\x20distinguish\x20orders,\x20add\x20a\x20zero-share\x20{GuardIdentifier:\x200}\x20'+'anchor\x20row\x20(Rate\x200)\x20so\x20the\x20Identifier\x20slot\x20resolves\x20to\x20the\x20paying\x20order\x20'+'(pattern.allocator_order_anchor).\x20If\x20fixed-pay\x20is\x20intended,\x20no\x20action.','unavoidable':![]});}a['trigger_source']==='standalone'&&!d&&c['push']({'code':'RC-FIND-04','severity':'high','title':'Standalone\x20allocation\x20without\x20issuer\x20identity\x20constraint','explanation':'Standalone\x20allocations\x20have\x20no\x20Service/Arbitration\x20access-control\x20layer.\x20'+'Without\x20a\x20Signer/permission\x20binding\x20in\x20the\x20Guard,\x20anyone\x20can\x20trigger\x20distribution.','evidence_paths':[],'mitigation':'Bind\x20the\x20issuer\x20(Signer==owner/admin)\x20or\x20move\x20the\x20allocation\x20into\x20a\x20Service.','unavoidable':![]});c['push']({'code':'RC-FIND-06','severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','explanation':'Once\x20the\x20Guard\x27s\x20conditions\x20are\x20satisfiable,\x20anyone\x20can\x20trigger\x20settlement\x20of\x20an\x20'+'order\x27s\x20allocation.\x20With\x20Entity/object\x20recipients\x20this\x20affects\x20timing\x20only,\x20not\x20destination.','evidence_paths':[],'mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.','unavoidable':!![]});for(const [m,n]of Object['entries'](a['guards']??{})){const o=asNode(n['root']);if(!o)continue;for(const q of findSessionQueries(o)){c['push']({'code':'RC-FIND-05','severity':'medium','title':'Guard\x20'+m+'\x20uses\x20session-only\x20query\x20at\x20'+q,'explanation':'Queries\x201270/1271\x20read\x20the\x20active\x20session;\x20after\x20the\x20session\x20migrates\x20to\x20'+'history\x20the\x20query\x20aborts\x20(W_FIELD_NOT_FOUND)\x20and\x20the\x20Guard\x20permanently\x20fails.','evidence_paths':[q],'mitigation':'Use\x20progress.current_time\x20(1272)\x20or\x20history\x20queries\x20(1274-1280).','unavoidable':![]});}}for(const [s,t]of Object['entries'](a['guards']??{})){const u=(t['relies']??[])['filter'](v=>typeof v==='string'&&v);if(u['length']===0x0)continue;c['push']({'code':'RC-FIND-08','severity':'low','title':'Guard\x20'+s+'\x20relies\x20on\x20'+u['length']+'\x20sub-guard(s)\x20—\x20not\x20credited\x20by\x20this\x20audit','explanation':'Guard\x20composition\x20(relies,\x20one\x20level,\x20≤4,\x20'+((t['relies_logic_and']===![]?'OR':'AND')+'-logic)\x20may\x20carry\x20the\x20scope/signer\x20')+'constraints\x20in\x20the\x20relied\x20sub-guards.\x20This\x20audit\x20evaluates\x20only\x20the\x20guard\x27s\x20own\x20root:\x20'+'sub-guard\x20constraints\x20are\x20NOT\x20credited,\x20so\x20scope-binding\x20gaps\x20(RC-FIND-02)\x20may\x20be\x20'+'over-reported\x20and\x20sub-guard-only\x20conditions\x20stay\x20unverified.','evidence_paths':u,'mitigation':'Resolve\x20the\x20relied\x20sub-guards\x20and\x20verify\x20their\x20constraints\x20manually,\x20or\x20re-run\x20'+'with\x20the\x20sub-guard\x20defs\x20included\x20(read-side\x20resolvers\x20attach\x20them\x20automatically).','unavoidable':![]});}if(!e&&a['trigger_source']==='service_order_allocators'){}return c;}function buildPayoff(a,b){const c=a['recipients']['some'](h=>h['constraints']['some'](i=>i['caller_constraint'])),d=c?'Caller\x20must\x20satisfy\x20the\x20Guard\x27s\x20Signer/identity\x20binding':b==='standalone'?'Any\x20caller\x20(no\x20identity\x20binding)':'Any\x20caller\x20who\x20satisfies\x20the\x20Guard\x27s\x20object/state\x20conditions',e=a['recipients']['map'](h=>h['beneficial_owner'])['join'](';\x20')||'(none)',f={},g=a['recipients']['some'](h=>h['spec']['kind']==='signer'&&!c);return f['caller']=g?'gains':c?'conditional':'neutral',f['provider']=a['recipients']['some'](h=>h['spec']['kind']==='entity')?'gains':'conditional',f['customer']=a['recipients']['some'](h=>h['receipt']?.['object_type']==='order')?'conditional':'neutral',f['system']='neutral',{'caller_eligibility':d,'beneficial_recipient':e,'positions':f};}export const RECIPIENT_CONSTRAINT_VERSION='1.2.0';export function analyzeRecipientConstraints(a){const b=a['allocators']['map'](h=>{const i=a['guards']?.[h['guard']],j=asNode(i?.['root']),k=i?.['table']??[],l=j?extractConstraints(j,k):[],m=j?collectSlotUsages(j):[],n=h['sharing']['map'](q=>{const r=classifyRecipient(q['who']);if(!r)return{'spec':{'kind':'entity','address':'(unclassifiable)'},'constraints':l,'beneficial_owner':'Unclassifiable\x20recipient\x20—\x20check\x20allocator\x20config'};const t=r['kind']==='submission'?r['identifier']:undefined,u=t!==undefined?k['find'](w=>w['identifier']===t):undefined,v=t!==undefined?deriveReceiptRight(t,l):undefined;return{'spec':r,'slot_value_type':u?normalizeValueType(u['value_type']):undefined,'constraints':t!==undefined?l['filter'](w=>w['slot']===undefined||w['slot']===t):l,'receipt':v,'beneficial_owner':deriveBeneficialOwner(r,v)};}),o=buildSlotModels(k,m,h['sharing']['map'](q=>({'spec':classifyRecipient(q['who'])??{'kind':'entity','address':'(unclassifiable)'},'mode':q['mode']})),l),p={'guard':h['guard'],'recipients':n,'slots':o,'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return p['payoff']=buildPayoff(p,a['trigger_source']),p;}),c=buildFindings(a,b),d=c['some'](h=>h['severity']==='critical')?'critical':c['some'](h=>h['severity']==='high')?'high':c['some'](h=>h['severity']==='medium')?'medium':'low',e=!c['some'](h=>h['code']==='RC-FIND-01'),f=c['some'](h=>h['resolution_required']),g=[{'code':'RC-FIND-03','title':'Cross-allocation\x20settlement','detail':'Submitted\x20order\x20is\x20not\x20bound\x20to\x20the\x20settled\x20allocation;\x20destination\x20stays\x20at\x20an\x20order\x20owner.'},{'code':'RC-FIND-06','title':'Forced\x20settlement\x20timing','detail':'alloc\x20is\x20permissionless;\x20settlement\x20can\x20be\x20triggered\x20by\x20anyone\x20once\x20conditions\x20hold.'},{'code':'RC-RES-01','title':'Published\x20immutability','detail':'order_allocators,\x20Machine\x20and\x20Guards\x20are\x20immutable\x20after\x20publish.'},{'code':'RC-RES-03','title':'Off-chain\x20arbitration\x20backstop','detail':'No\x20on-chain\x20clawback;\x20post-incident\x20recovery\x20relies\x20on\x20arbitration.'}];return{'version':RECIPIENT_CONSTRAINT_VERSION,'scope':{'trigger_source':a['trigger_source'],'host_service':a['host_service'],'allocation':a['allocation']},'allocators':b,'findings':c,'unavoidable':g,'safe_destination':e,'resolution_required':f,'overall':d,'summary':'Analyzed\x20'+b['length']+'\x20allocator(s):\x20'+c['filter'](h=>!h['unavoidable'])['length']+'\x20actionable,\x20'+(c['filter'](h=>h['unavoidable'])['length']+'\x20structural\x20finding(s).\x20Safe\x20destination:\x20'+e+'.')+(''+(f?'\x20Resolution\x20REQUIRED:\x20at\x20least\x20one\x20residual\x20demands\x20an\x20explicit\x20design\x20decision\x20before\x20publish.':''))};}export function derivePayoffFromSharing(a,b,c){const d=asNode(c?.['root']),e=c?.['table']??[],f=d?extractConstraints(d,e):[],g=a['map'](i=>{const j=classifyRecipient(i['who'])??{'kind':'entity','address':'(unclassifiable)'},k=j['kind']==='submission'?j['identifier']:undefined,l=k!==undefined?e['find'](n=>n['identifier']===k):undefined,m=k!==undefined?deriveReceiptRight(k,f):undefined;return{'spec':j,'slot_value_type':l?normalizeValueType(l['value_type']):undefined,'constraints':k!==undefined?f['filter'](n=>n['slot']===undefined||n['slot']===k):f,'receipt':m,'beneficial_owner':deriveBeneficialOwner(j,m)};}),h={'guard':'','recipients':g,'slots':[],'payoff':{'caller_eligibility':'','beneficial_recipient':'','positions':{}}};return buildPayoff(h,b);}function normalizeValueType(a){if(typeof a==='number')return a;const b={'bool':ValueType['Bool'],'address':ValueType['Address'],'string':ValueType['String'],'u64':ValueType['U64'],'u256':ValueType['U256']};return b[a['toLowerCase']()];}export function isUnboundSignerTheft(a){return a['recipient_is_signer']&&!a['caller_identity_constrained'];}export function canonicalDoctrine(a){switch(a){case'RC-FIND-01':return{'severity':'critical','title':'Signer\x20recipient\x20without\x20caller\x20constraint\x20—\x20fund\x20theft','mitigation':'Bind\x20the\x20Signer\x20(signer==order.owner\x20or\x20signer==fixed\x20address),\x20or\x20change\x20'+'the\x20recipient\x20to\x20an\x20Entity\x20/\x20submitted\x20object\x20slot.'};case'RC-FIND-03':return{'severity':'medium','title':'Cross-allocation\x20settlement\x20residual','mitigation':'Pick\x20ONE\x20resolution\x20and\x20record\x20it\x20in\x20the\x20service\x20description:\x20'+'(1)\x20competition\x20semantics\x20with\x20capped\x20exposure\x20(threshold\x20/\x20max\x20amount);\x20'+'(2)\x20Entity\x20routing\x20(treasury)\x20—\x20the\x20only\x20exclusive\x20choice\x20on\x20the\x20automatic\x20'+'order_allocators\x20route;\x20'+'(3)\x20per-order\x20pinned\x20Guards\x20(order.owner\x20==\x20constant)\x20—\x20the\x20trustless\x20'+'exclusive\x20route.','resolution_required':!![]};case'RC-FIND-06':return{'severity':'low','title':'Permissionless\x20alloc\x20—\x20forced\x20settlement\x20timing','mitigation':'Monitor\x20settlements;\x20constrain\x20time-sensitivity\x20via\x20Guard\x20conditions.'};}}export const RECIPIENT_DESIGN_OPTIONS=[{'id':'entity','move_recipient':'Recipient::Entity(address)','semantics':'Funds\x20flow\x20to\x20a\x20fixed\x20address\x20(a\x20constrained\x20user\x20account\x20/\x20treasury).\x20'+'Destination\x20never\x20depends\x20on\x20the\x20caller.','required_constraints':['The\x20address\x20is\x20chosen\x20at\x20design\x20time\x20and\x20recorded\x20in\x20the\x20allocator\x20table.']},{'id':'submitted_object','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20the\x20object\x20submitted\x20under\x20protocol\x20context\x20(e.g.\x20the\x20order\x20being\x20settled).\x20'+'Receivable\x20only\x20by\x20that\x20object\x27s\x20owner\x20—\x20object\x20receipt\x20=\x20owner\x20receipt.','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(which\x20query/object\x20type\x20the\x20slot\x20carries).','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-02\x20/\x20RC-FIND-07'},{'id':'signer','move_recipient':'Recipient::Signer','semantics':'Funds\x20flow\x20to\x20the\x20caller\x20who\x20executes\x20the\x20permissionless\x20alloc.\x20'+'Safe\x20only\x20when\x20the\x20Guard\x20proves\x20exactly\x20who\x20the\x20caller\x20may\x20be.','required_constraints':['The\x20Guard\x20constrains\x20the\x20Signer\x20identity\x20(signer\x20==\x20a\x20fixed\x20address\x20or\x20a\x20derived\x20legitimate\x20owner).'],'finding_if_unmet':'RC-FIND-01'},{'id':'constrained_submission','move_recipient':'Recipient::GuardIdentifier(u8)','semantics':'Funds\x20flow\x20to\x20an\x20object\x20address\x20supplied\x20by\x20the\x20signer,\x20but\x20the\x20Guard\x20constrains\x20'+'both\x20the\x20submission\x20scope\x20and\x20the\x20signer\x27s\x20relation\x20to\x20it\x20(e.g.\x20the\x20signer\x20owns\x20the\x20submitted\x20order).','required_constraints':['The\x20Guard\x20binds\x20the\x20submission\x27s\x20scope\x20(object/query\x20type).','The\x20Guard\x20binds\x20the\x20signer\x20to\x20the\x20submitted\x20object.','The\x20slot\x27s\x20table\x20value\x20type\x20is\x20address\x20(enforced\x20at\x20allocator\x20registration).'],'finding_if_unmet':'RC-FIND-01\x20/\x20RC-FIND-02\x20/\x20RC-FIND-07'}];export function recipientDesignGuidance(){return RECIPIENT_DESIGN_OPTIONS;}export const OBJECT_DRIVEABILITY=[{'object_type':'order','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20order','owner-side\x20object\x20extraction\x20from\x20the\x20order'],'anyone_drivable':!![],'funds_settle_to':'order.owner','rationale':'Order\x20is\x20a\x20shared\x20object\x20and\x20extraction\x20has\x20no\x20signer\x20gate;\x20'+'Receiving\x20is\x20restricted\x20to\x20objects\x20actually\x20delivered\x20to\x20that\x20order,\x20and\x20coins\x20settle\x20to\x20its\x20owner.'},{'object_type':'permission','receive_entries':['owner-side\x20coin\x20extraction\x20via\x20the\x20permission\x20object','owner-side\x20object\x20extraction\x20via\x20the\x20permission\x20object'],'anyone_drivable':!![],'funds_settle_to':'permission.owner','rationale':'Permission\x20is\x20the\x20final\x20authority;\x20anyone\x20can\x20drive\x20extraction\x20of\x20funds\x20sent\x20to\x20its\x20address,\x20but\x20the\x20destination\x20is\x20its\x20owner.'},{'object_type':'service','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20service','owner-side\x20object\x20extraction\x20from\x20the\x20service'],'anyone_drivable':![],'permission_index':0x13f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20319);\x20members\x20drive,\x20value\x20settles\x20to\x20the\x20organization\x20owner.'},{'object_type':'treasury','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20treasury','owner-side\x20object\x20extraction\x20from\x20the\x20treasury'],'anyone_drivable':![],'permission_index':0x101,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20257).'},{'object_type':'arbitration','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20arbitration','owner-side\x20object\x20extraction\x20from\x20the\x20arbitration'],'anyone_drivable':![],'permission_index':0x16f,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20367).'},{'object_type':'machine','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20machine','owner-side\x20object\x20extraction\x20from\x20the\x20machine'],'anyone_drivable':![],'permission_index':0xcf,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20207).'},{'object_type':'progress','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20progress','owner-side\x20object\x20extraction\x20from\x20the\x20progress'],'anyone_drivable':![],'permission_index':0xe1,'funds_settle_to':'machine\x27s\x20permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20225),\x20scoped\x20to\x20the\x20Machine\x20permission.'},{'object_type':'demand','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20demand','owner-side\x20object\x20extraction\x20from\x20the\x20demand'],'anyone_drivable':![],'permission_index':0x197,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20407).'},{'object_type':'contact','receive_entries':['owner-side\x20coin\x20extraction\x20from\x20the\x20contact','owner-side\x20object\x20extraction\x20from\x20the\x20contact'],'anyone_drivable':![],'permission_index':0x1c6,'funds_settle_to':'permission.owner','rationale':'Business\x20permission\x20gate\x20(index\x20454).'}];export function driveabilityOf(a){return OBJECT_DRIVEABILITY['find'](b=>b['object_type']===a);}function rewardRecipientKind(a){if(typeof a==='string'){const e=a['toLowerCase']();if(e==='signer')return{'kind':'signer'};return{'kind':'entity'};}if(typeof a!=='object'||a===null)return{'kind':'entity'};const b=a,c=f=>typeof b[f]==='number'?b[f]:undefined,d=c('GuardIdentifier')??c('guard_identifier')??c('identifier');if(d!==undefined)return{'kind':'submission','slot':d};if(b['Signer']!==undefined||b['signer']!==undefined)return{'kind':'signer'};return{'kind':'entity'};}const SLOT_BINDING_CODES=new Set(['service_binding','progress_node_state','signer_is_submitted_object_owner','repository_crosscheck','signer_permission_member']);export function analyzeRewardClaimGuard(a){const {kind:b,slot:c}=rewardRecipientKind(a['recipient']),d={'entry_index':a['entry_index'],'guard':a['guard'],'recipient_kind':b,...c!==undefined?{'recipient_slot':c}:{},'guard_resolved':![],'constraint_codes':[],'recipient_slot_usages':0x0,'caller_identity_constrained':![],'viability':'unverifiable','reason':'Guard\x20table/root\x20not\x20fetched\x20with\x20the\x20topology\x20—\x20the\x20deciding\x20predicate\x20is\x20outside\x20the\x20evidence;\x20the\x20owner\x20must\x20disclose\x20the\x20full\x20guard\x20definitions.'},e=asNode(a['guard_def']?.['root']);if(!e)return d;const f=a['guard_def']?.['table']??[],g=extractConstraints(e,f);d['guard_resolved']=!![],d['constraint_codes']=g['map'](k=>k['code']),d['caller_identity_constrained']=g['some'](k=>k['caller_constraint']);if(b==='entity')return d['viability']='blocked',d['reason']='Payout\x20address\x20is\x20fixed\x20at\x20guard\x20registration\x20(Entity\x20recipient);\x20the\x20claim\x20path\x20cannot\x20redirect\x20it.',d;if(b==='signer')return d['caller_identity_constrained']?(d['viability']='blocked',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20but\x20the\x20guard\x20binds\x20the\x20caller\x20identity\x20—\x20only\x20the\x20authorized\x20party\x20can\x20claim.'):(d['viability']='viable',d['reason']='Recipient\x20is\x20the\x20caller\x20(Signer)\x20with\x20no\x20identity\x20binding\x20—\x20anyone\x20satisfying\x20the\x20remaining\x20conditions\x20claims\x20to\x20their\x20own\x20address.'),d;const h=c??-0x1,i=collectSlotUsages(e)['filter'](k=>k['slot']===h);d['recipient_slot_usages']=i['length'];const j=g['filter'](k=>k['slot']===h&&SLOT_BINDING_CODES['has'](k['code']));if(j['length']>0x0)d['viability']='blocked',d['reason']='Submitted\x20address\x20is\x20constrained\x20inside\x20the\x20guard\x20('+j['map'](k=>k['code'])['join'](',\x20')+')\x20—\x20a\x20passerby\x20cannot\x20fill\x20the\x20slot\x20with\x20an\x20arbitrary\x20address.';else i['length']>0x0?(d['viability']='conditional',d['reason']='The\x20guard\x20reads\x20the\x20submitted\x20slot\x20('+i['length']+'\x20query\x20usage(s))\x20but\x20no\x20recognized\x20scope/equality\x20constraint\x20was\x20matched\x20—\x20manual\x20predicate\x20review\x20required.'):(d['viability']='viable',d['reason']='No\x20guard\x20query\x20consumes\x20the\x20submitted\x20slot\x20—\x20the\x20predicate\x20cannot\x20constrain\x20the\x20payout\x20address;\x20any\x20passing\x20party\x20claims\x20to\x20their\x20own\x20address.');return d;}
|
|
@@ -58,7 +58,7 @@ export declare const SERVICE_LISTING_REFUND_GATES: {
|
|
|
58
58
|
readonly rationale: "A zero-priced listing plus an allocation-free 0-amount order produced stores whose entire economics live outside the chain. Repricing an EXISTING sale down to zero stays legal and is caught at buy time by the zero-total order gate.";
|
|
59
59
|
};
|
|
60
60
|
readonly restock: {
|
|
61
|
-
readonly rule: "Refund restocking is opt-in per SKU: the merchant marks an ALIVE sale with the restock flag (305), then a refunded order's purchased units can be put back on shelf (305). Two-pass on-chain (validate every line, then apply) — ALL lines restock or NOTHING mutates. Unflagged or delisted lines abort E_RESTOCK_NOT_FLAGGED = 46 / E_SALE_ITEM_NOT_FOUND. Quantities come from the order's purchase rows.";
|
|
61
|
+
readonly rule: "Refund restocking is opt-in per SKU: the merchant marks an ALIVE sale with the restock flag (305), then a refunded order's purchased units can be put back on shelf (305). Two-pass on-chain (validate every line, then apply) — ALL lines restock or NOTHING mutates. Unflagged or delisted lines abort E_RESTOCK_NOT_FLAGGED = 46 / E_SALE_ITEM_NOT_FOUND. Quantities come from the order's purchase rows. ONCE-PER-ORDER: the restock operation stamps the order with a RestockStamp dynamic field and a second call for the same order aborts E_RESTOCK_ALREADY_APPLIED = 49 (a replay would stack the purchased units again, an unbounded +quantity). OWNERSHIP-BOUND: only an order whose service field is THIS service restocks here — a foreign order aborts E_ORDER_SERVICE_NOT_MATCH = 26. The applied state is readable via the public restock_applied flag.";
|
|
62
62
|
readonly events: "StockRestockedEvent per line (service, order, item, quantity, time).";
|
|
63
63
|
};
|
|
64
64
|
readonly dismissal_conclusion: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'create\x20a\x20new\x20Service','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'modify\x20the\x20Service\x20description','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'set\x20the\x20Service\x20location/URL','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'add/remove/clear\x20Repository\x20references','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items;\x20opt\x20SKUs\x20into\x20refund\x20restocking\x20(per-SKU\x20restock\x20flag\x20and\x20order\x20restock)','governed_operation':'add/set/remove/clear\x20sales\x20items;\x20restock\x20flags\x20+\x20order\x20restock','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'bind/unbind\x20the\x20Machine\x20workflow\x20template','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'set/clear\x20the\x20buy_guard\x20check','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'add/remove/clear\x20Arbitration\x20references','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'set\x20customer\x20required\x20info\x20fields','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'pause/resume\x20the\x20Service','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'publish\x20the\x20Service\x20(irreversible)','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'issue/destroy\x20discount\x20coupons','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'set\x20the\x20order_allocators\x20strategy','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'withdraw\x20from\x20the\x20compensation_fund\x20(time-locked)','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'deposit\x20to\x20the\x20compensation_fund','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'receive\x20the\x20compensation_fund\x20payout\x20(arbitration\x20payout)','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'extend\x20setting_lock_duration\x20(only-increase)','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'add/remove/clear\x20Reward\x20references','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'receive\x20Payments/objects\x20to\x20owner','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'bind/unbind\x20Contact\x20as\x20UM','post_publish_mutability':'mutable'},{'index':0x141,'name':'SERVICE_ARB_STATEMENT','description':'Append\x20seller\x20statement\x20to\x20an\x20Arb\x20case\x20(event-only)','governed_operation':'append\x20seller\x20text\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20this\x20service\x20(ArbStatementEvent;\x20no\x20Arb\x20state\x20change)','post_publish_mutability':'mutable'}];export const SERVICE_LISTING_REFUND_GATES={'price_floor':{'rule':'A\x20sale\x20listed\x20at\x20price\x200\x20is\x20REFUSED\x20at\x20construction\x20time\x20(aborts\x20E_PRICE_BELOW_FLOOR\x20=\x2044)\x20—\x20applies\x20to\x20every\x20sale-minting\x20path\x20(sales\x20add\x20/\x20sales\x20set\x20/\x20replace).\x20The\x20SDK\x20refuses\x20it\x20locally\x20in\x20the\x20sale\x20builder.','rationale':'A\x20zero-priced\x20listing\x20plus\x20an\x20allocation-free\x200-amount\x20order\x20produced\x20stores\x20whose\x20entire\x20economics\x20live\x20outside\x20the\x20chain.\x20Repricing\x20an\x20EXISTING\x20sale\x20down\x20to\x20zero\x20stays\x20legal\x20and\x20is\x20caught\x20at\x20buy\x20time\x20by\x20the\x20zero-total\x20order\x20gate.'},'restock':{'rule':'Refund\x20restocking\x20is\x20opt-in\x20per\x20SKU:\x20the\x20merchant\x20marks\x20an\x20ALIVE\x20sale\x20with\x20the\x20restock\x20flag\x20(305),\x20then\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20can\x20be\x20put\x20back\x20on\x20shelf\x20(305).\x20Two-pass\x20on-chain\x20(validate\x20every\x20line,\x20then\x20apply)\x20—\x20ALL\x20lines\x20restock\x20or\x20NOTHING\x20mutates.\x20Unflagged\x20or\x20delisted\x20lines\x20abort\x20E_RESTOCK_NOT_FLAGGED\x20=\x2046\x20/\x20E_SALE_ITEM_NOT_FOUND.\x20Quantities\x20come\x20from\x20the\x20order\x27s\x20purchase\x20rows.','events':'StockRestockedEvent\x20per\x20line\x20(service,\x20order,\x20item,\x20quantity,\x20time).'},'dismissal_conclusion':{'rule':'The\x20dismissal\x20conclusion\x20stamps\x20a\x20CONCLUDED,\x20DEFENDANT-FAVORED\x20ruling\x20onto\x20the\x20order\x20(claimed_by\x20=\x20case\x20address)\x20—\x20the\x20mirror\x20of\x20the\x20compensation\x20claim.\x20Requires:\x20order\x20belongs\x20to\x20this\x20service,\x20arbitration\x20on\x20the\x20merchant\x20allowlist,\x20no\x20self-judging\x20(E_ARBITRATION_PERMISSION_CONFLICT),\x20case\x20concluded\x20(Arbitrated/Withdrawn)\x20AND\x20indemnity\x20none/0\x20(E_CASE_NOT_DISMISSAL_CONCLUSION\x20=\x2048).\x20Permissionless\x20keeper\x20surface;\x20writes\x20a\x20flag,\x20moves\x20no\x20funds.','closes':'A\x20dismissal\x20ruling\x20would\x20otherwise\x20never\x20stamp\x20claimed_by\x20(the\x20zero-indemnity\x20claim\x20gate\x20refuses\x20the\x20claim\x20path),\x20so\x20a\x20buyer\x20who\x20LOST\x20the\x20case\x20kept\x20every\x20`claimed_by\x20none`\x20refund\x20rail\x20open\x20forever.'}};export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_NOT_PUBLISHED,\x20service:7)','Service.bPaused\x20==\x20false\x20(else\x20E_PAUSED,\x20service:19)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_ITEM_NOT_FOUND,\x20service:32)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_NOT_ENOUGH,\x20service:16)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20within\x20its\x20[time_start,\x20time_end]\x20window\x20(else\x20E_DISCOUNT_TIME_INVALID)'],'side_effects':['The\x20quote\x20step\x20computes\x20the\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','The\x20on-chain\x20quote\x20call\x20executes\x20(the\x20discount\x20path\x20validates\x20the\x20Clock\x20time-window\x20check)'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['The\x20atomic\x20on-chain\x20buy\x20call\x20executes\x20(passport-gated\x20variant\x20supported)','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['The\x20on-chain\x20allocation\x20call\x20executes','Allocation\x20object\x20created\x20(guard-selected\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['The\x20on-chain\x20progress-creation\x20call\x20executes','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['Attach\x20agents\x20to\x20the\x20order\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','Transfer\x20Order\x20ownership\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL','set\x20customer\x20required\x20info\x20fields'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','pause/resume\x20the\x20Service\x20(310)','add/set/remove/clear\x20sales\x20items\x20(305)','set\x20the\x20order_allocators\x20strategy\x20(313)','set/clear\x20the\x20buy_guard\x20check\x20(307)','issue/destroy\x20discount\x20coupons\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','bind\x20the\x20Machine\x20workflow\x20(306)\x20—\x20for\x20rental\x20workflow','add\x20Arbitration\x20references\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','issue\x20discount\x20coupons\x20(312)\x20—\x20promotional\x20rates','add\x20Reward\x20references\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['bind\x20the\x20Machine\x20workflow\x20(306)','publish\x20the\x20Service\x20(311)','set\x20the\x20order_allocators\x20strategy\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)','deposit\x20to\x20the\x20compensation_fund\x20(315)','extend\x20setting_lock_duration\x20(317)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','Arbitration\x20compensation\x20payout\x20triggered\x20by\x20the\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['deposit\x20to\x20the\x20compensation_fund\x20(315)','withdraw\x20from\x20the\x20compensation_fund\x20(314)\x20—\x20time-locked\x20after\x20publish','receive\x20the\x20compensation_fund\x20payout\x20(316)\x20—\x20arbitration\x20payout\x20(always\x20mutable)','extend\x20setting_lock_duration\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration\x20compensation\x20payout\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add/remove/clear\x20Reward\x20references\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','issue/destroy\x20discount\x20coupons\x20(312)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','remove\x20an\x20Arbitration\x20reference\x20(308)\x20—\x20pre-publish\x20only','clear\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['bind\x20the\x20buy_guard\x20Guard\x20(307)','clear\x20the\x20buy_guard\x20Guard\x20(307)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['issue\x20discount\x20coupons\x20(312)','add/set\x20sales\x20items\x20(305)\x20—\x20adjust\x20base\x20prices','remove\x20sales\x20items\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)','discount_send:\x20holder-only\x20transfer\x20of\x20owned\x20transferable:true\x20coupons\x20to\x20another\x20address\x20(no\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','Each\x20allocator\x20is\x20bound\x20to\x20a\x20DIFFERENT\x20guard\x20—\x20the\x20caller\x27s\x20submitted\x20guard\x20selects\x20which\x20path\x20fires'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|
|
1
|
+
export const SERVICE_PERMISSIONS=[{'index':0x12c,'name':'SERVICE_NEW','description':'Create\x20new\x20Service','governed_operation':'create\x20a\x20new\x20Service','post_publish_mutability':'na'},{'index':0x12d,'name':'SERVICE_DESCRIPTION','description':'Modify\x20Service\x20description','governed_operation':'modify\x20the\x20Service\x20description','post_publish_mutability':'mutable'},{'index':0x12f,'name':'SERVICE_LOCATION','description':'Set\x20Service\x20location/URL','governed_operation':'set\x20the\x20Service\x20location/URL','post_publish_mutability':'mutable'},{'index':0x130,'name':'SERVICE_REPOSITORY','description':'Add/remove\x20Repository\x20references','governed_operation':'add/remove/clear\x20Repository\x20references','post_publish_mutability':'mutable'},{'index':0x131,'name':'SERVICE_SALES','description':'Add/set/remove/clear\x20sales\x20items;\x20opt\x20SKUs\x20into\x20refund\x20restocking\x20(per-SKU\x20restock\x20flag\x20and\x20order\x20restock)','governed_operation':'add/set/remove/clear\x20sales\x20items;\x20restock\x20flags\x20+\x20order\x20restock','post_publish_mutability':'mutable'},{'index':0x132,'name':'SERVICE_MACHINE','description':'Bind/unbind\x20Machine\x20workflow\x20template','governed_operation':'bind/unbind\x20the\x20Machine\x20workflow\x20template','post_publish_mutability':'immutable'},{'index':0x133,'name':'SERVICE_BUY_GUARD','description':'Set/clear\x20buy\x20Guard\x20(post-publish\x20mutable)','governed_operation':'set/clear\x20the\x20buy_guard\x20check','post_publish_mutability':'mutable'},{'index':0x134,'name':'SERVICE_ARBITRATION','description':'Add/remove\x20Arbitration\x20references','governed_operation':'add/remove/clear\x20Arbitration\x20references','post_publish_mutability':'immutable'},{'index':0x135,'name':'SERVICE_CUSTOMER_INFO_REQUIRED','description':'Set\x20customer\x20required\x20info\x20fields','governed_operation':'set\x20customer\x20required\x20info\x20fields','post_publish_mutability':'mutable'},{'index':0x136,'name':'SERVICE_PAUSE','description':'Pause/resume\x20Service\x20(block\x20new\x20orders)','governed_operation':'pause/resume\x20the\x20Service','post_publish_mutability':'mutable'},{'index':0x137,'name':'SERVICE_PUBLISH','description':'Publish\x20Service\x20(IRREVERSIBLE)','governed_operation':'publish\x20the\x20Service\x20(irreversible)','post_publish_mutability':'one_shot'},{'index':0x138,'name':'SERVICE_DISCOUNT','description':'Issue/discount_destroy\x20discount\x20coupons','governed_operation':'issue/destroy\x20discount\x20coupons','post_publish_mutability':'mutable'},{'index':0x139,'name':'SERVICE_ORDER_ALLOCATOR','description':'Set\x20order\x20allocator\x20strategy','governed_operation':'set\x20the\x20order_allocators\x20strategy','post_publish_mutability':'immutable'},{'index':0x13a,'name':'SERVICE_COMPENSATION_FUND_WITHDRAW','description':'Withdraw\x20compensation\x20fund\x20(time-locked)','governed_operation':'withdraw\x20from\x20the\x20compensation_fund\x20(time-locked)','post_publish_mutability':'locked_by_duration'},{'index':0x13b,'name':'SERVICE_COMPENSATION_FUND_DEPOSIT','description':'Deposit\x20to\x20compensation\x20fund','governed_operation':'deposit\x20to\x20the\x20compensation_fund','post_publish_mutability':'mutable'},{'index':0x13c,'name':'SERVICE_COMPENSATION_FUND_RECEIVE','description':'Receive\x20compensation\x20fund\x20(arbitration\x20payout)','governed_operation':'receive\x20the\x20compensation_fund\x20payout\x20(arbitration\x20payout)','post_publish_mutability':'mutable'},{'index':0x13d,'name':'SERVICE_COMPENSATION_LOCK_DURATION_ADD','description':'Extend\x20setting_lock_duration\x20(only-increase)','governed_operation':'extend\x20setting_lock_duration\x20(only-increase)','post_publish_mutability':'mutable'},{'index':0x13e,'name':'SERVICE_REWARD','description':'Add/remove\x20Reward\x20references\x20(remove/clear\x20time-locked)','governed_operation':'add/remove/clear\x20Reward\x20references','post_publish_mutability':'locked_by_duration'},{'index':0x13f,'name':'SERVICE_OWNER_RECEIVE','description':'Receive\x20Payment/objects\x20to\x20owner','governed_operation':'receive\x20Payments/objects\x20to\x20owner','post_publish_mutability':'mutable'},{'index':0x140,'name':'SERVICE_UM','description':'Bind/unbind\x20Contact\x20as\x20UM','governed_operation':'bind/unbind\x20Contact\x20as\x20UM','post_publish_mutability':'mutable'},{'index':0x141,'name':'SERVICE_ARB_STATEMENT','description':'Append\x20seller\x20statement\x20to\x20an\x20Arb\x20case\x20(event-only)','governed_operation':'append\x20seller\x20text\x20to\x20a\x20case\x20against\x20an\x20order\x20of\x20this\x20service\x20(ArbStatementEvent;\x20no\x20Arb\x20state\x20change)','post_publish_mutability':'mutable'}];export const SERVICE_LISTING_REFUND_GATES={'price_floor':{'rule':'A\x20sale\x20listed\x20at\x20price\x200\x20is\x20REFUSED\x20at\x20construction\x20time\x20(aborts\x20E_PRICE_BELOW_FLOOR\x20=\x2044)\x20—\x20applies\x20to\x20every\x20sale-minting\x20path\x20(sales\x20add\x20/\x20sales\x20set\x20/\x20replace).\x20The\x20SDK\x20refuses\x20it\x20locally\x20in\x20the\x20sale\x20builder.','rationale':'A\x20zero-priced\x20listing\x20plus\x20an\x20allocation-free\x200-amount\x20order\x20produced\x20stores\x20whose\x20entire\x20economics\x20live\x20outside\x20the\x20chain.\x20Repricing\x20an\x20EXISTING\x20sale\x20down\x20to\x20zero\x20stays\x20legal\x20and\x20is\x20caught\x20at\x20buy\x20time\x20by\x20the\x20zero-total\x20order\x20gate.'},'restock':{'rule':'Refund\x20restocking\x20is\x20opt-in\x20per\x20SKU:\x20the\x20merchant\x20marks\x20an\x20ALIVE\x20sale\x20with\x20the\x20restock\x20flag\x20(305),\x20then\x20a\x20refunded\x20order\x27s\x20purchased\x20units\x20can\x20be\x20put\x20back\x20on\x20shelf\x20(305).\x20Two-pass\x20on-chain\x20(validate\x20every\x20line,\x20then\x20apply)\x20—\x20ALL\x20lines\x20restock\x20or\x20NOTHING\x20mutates.\x20Unflagged\x20or\x20delisted\x20lines\x20abort\x20E_RESTOCK_NOT_FLAGGED\x20=\x2046\x20/\x20E_SALE_ITEM_NOT_FOUND.\x20Quantities\x20come\x20from\x20the\x20order\x27s\x20purchase\x20rows.\x20ONCE-PER-ORDER:\x20the\x20restock\x20operation\x20stamps\x20the\x20order\x20with\x20a\x20RestockStamp\x20dynamic\x20field\x20and\x20a\x20second\x20call\x20for\x20the\x20same\x20order\x20aborts\x20E_RESTOCK_ALREADY_APPLIED\x20=\x2049\x20(a\x20replay\x20would\x20stack\x20the\x20purchased\x20units\x20again,\x20an\x20unbounded\x20+quantity).\x20OWNERSHIP-BOUND:\x20only\x20an\x20order\x20whose\x20service\x20field\x20is\x20THIS\x20service\x20restocks\x20here\x20—\x20a\x20foreign\x20order\x20aborts\x20E_ORDER_SERVICE_NOT_MATCH\x20=\x2026.\x20The\x20applied\x20state\x20is\x20readable\x20via\x20the\x20public\x20restock_applied\x20flag.','events':'StockRestockedEvent\x20per\x20line\x20(service,\x20order,\x20item,\x20quantity,\x20time).'},'dismissal_conclusion':{'rule':'The\x20dismissal\x20conclusion\x20stamps\x20a\x20CONCLUDED,\x20DEFENDANT-FAVORED\x20ruling\x20onto\x20the\x20order\x20(claimed_by\x20=\x20case\x20address)\x20—\x20the\x20mirror\x20of\x20the\x20compensation\x20claim.\x20Requires:\x20order\x20belongs\x20to\x20this\x20service,\x20arbitration\x20on\x20the\x20merchant\x20allowlist,\x20no\x20self-judging\x20(E_ARBITRATION_PERMISSION_CONFLICT),\x20case\x20concluded\x20(Arbitrated/Withdrawn)\x20AND\x20indemnity\x20none/0\x20(E_CASE_NOT_DISMISSAL_CONCLUSION\x20=\x2048).\x20Permissionless\x20keeper\x20surface;\x20writes\x20a\x20flag,\x20moves\x20no\x20funds.','closes':'A\x20dismissal\x20ruling\x20would\x20otherwise\x20never\x20stamp\x20claimed_by\x20(the\x20zero-indemnity\x20claim\x20gate\x20refuses\x20the\x20claim\x20path),\x20so\x20a\x20buyer\x20who\x20LOST\x20the\x20case\x20kept\x20every\x20`claimed_by\x20none`\x20refund\x20rail\x20open\x20forever.'}};export const SERVICE_ORDER_FLOW_STAGES=[{'stage':0x1,'name':'pre_check','preconditions':['Service.bPublished\x20==\x20true\x20(else\x20E_NOT_PUBLISHED,\x20service:7)','Service.bPaused\x20==\x20false\x20(else\x20E_PAUSED,\x20service:19)','buy_guard\x20(if\x20set)\x20added\x20to\x20guards[]\x20list\x20for\x20verification'],'side_effects':[],'always_executed':!![]},{'stage':0x2,'name':'wip_verify','preconditions':['buy.items\x20non-empty','Each\x20item.name\x20matches\x20a\x20sale\x20in\x20Service.sales\x20(else\x20E_SALE_ITEM_NOT_FOUND,\x20service:32)','sale.suspension\x20==\x20false\x20(else\x20E_SALE_SUSPENDED)'],'side_effects':['If\x20buyer\x20passes\x20empty\x20wip_hash,\x20SDK\x20auto-fills\x20with\x20sale.wip_hash','verifiedWipUrls\x20Set\x20avoids\x20re-verifying\x20same\x20WIP\x20URL\x20across\x20items','verify_wip()\x20fetches\x20WIP\x20file\x20and\x20compares\x20hash\x20(else\x20E_WIP_HASH_NOT_MATCH)'],'always_executed':!![]},{'stage':0x3,'name':'quote','preconditions':['All\x20items\x20have\x20valid\x20sale\x20+\x20wip_hash\x20match','stock\x20>=\x20purchase\x20quantity\x20(else\x20E_STOCK_NOT_ENOUGH,\x20service:16)','discount\x20object\x20(if\x20used)\x20is\x20valid\x20and\x20within\x20its\x20[time_start,\x20time_end]\x20window\x20(else\x20E_DISCOUNT_TIME_INVALID)'],'side_effects':['The\x20quote\x20step\x20computes\x20the\x20total\x20price\x20(with\x20discount\x20if\x20applicable)','⚠️\x20Stock\x20is\x20deducted\x20(split)\x20—\x20side\x20effect\x20is\x20NOT\x20auto-rolled-back\x20on\x20later\x20failure','The\x20on-chain\x20quote\x20call\x20executes\x20(the\x20discount\x20path\x20validates\x20the\x20Clock\x20time-window\x20check)'],'always_executed':!![]},{'stage':0x4,'name':'create_order','preconditions':['Quote\x20object\x20from\x20stage\x203','Registrar\x20+\x20Clock\x20objects\x20available'],'side_effects':['The\x20atomic\x20on-chain\x20buy\x20call\x20executes\x20(passport-gated\x20variant\x20supported)','Order\x20object\x20created\x20(builder=customer,\x20service=Service.id)','Order.id\x20recorded\x20for\x20stages\x205-7'],'always_executed':!![]},{'stage':0x5,'name':'create_allocation','preconditions':['Service.order_allocators\x20is\x20Some\x20(configured)','Order\x20from\x20stage\x204','CoinParam\x20for\x20total_pay\x20matches\x20Service<T>\x20type'],'side_effects':['The\x20on-chain\x20allocation\x20call\x20executes','Allocation\x20object\x20created\x20(guard-selected\x20fund\x20distribution)','Order.allocation\x20=\x20Allocation\x20address'],'always_executed':!![]},{'stage':0x6,'name':'create_progress','preconditions':['Service.machine\x20is\x20Some\x20(machine\x20bound)','Order\x20from\x20stage\x204','Machine\x20from\x20Service.machine'],'side_effects':['The\x20on-chain\x20progress-creation\x20call\x20executes','Progress\x20object\x20created\x20(Progress.machine\x20=\x20Service.machine,\x20Progress.task\x20=\x20Order.id)'],'always_executed':![]},{'stage':0x7,'name':'post_actions','preconditions':['Order/Allocation/Progress\x20objects\x20from\x20stages\x204-6'],'side_effects':['Attach\x20agents\x20to\x20the\x20order\x20(if\x20order_new.agents\x20provided)','order_required_info_update\x20(if\x20order_required_info\x20provided)','Transfer\x20Order\x20ownership\x20(if\x20transfer\x20provided\x20—\x20sets\x20new\x20Order\x20owner)','namedNewOrder\x20/\x20namedNewAllocation\x20/\x20namedNewProgress\x20(local\x20naming)'],'always_executed':![]},{'stage':0x8,'name':'return_result','preconditions':['All\x20preceding\x20stages\x20succeeded'],'side_effects':['Returns\x20BuyResult\x20{\x20order,\x20allocation?,\x20progress?\x20}','Caller\x20proceeds\x20to\x20sign\x20+\x20submit\x20transaction'],'always_executed':!![]}];export const SERVICE_CROSS_OBJECT_BINDINGS=[{'object':'Machine','field':'machine','required':![],'locked_after_publish':!![],'notes':'Workflow\x20template;\x20post-publish\x20immutable\x20(F-S-20).\x20Progress.machine\x20inherits\x20this\x20value.'},{'object':'Guard','field':'buy_guard','required':![],'locked_after_publish':![],'notes':'Buyer\x20eligibility\x20guard;\x20post-publish\x20STILL\x20MUTABLE\x20(unusual\x20—\x20see\x20F-S-26)'},{'object':'Allocation','field':'order_allocators','required':!![],'locked_after_publish':!![],'notes':'Order\x20fund\x20distribution\x20strategy;\x20publish\x20prerequisite\x20(F-S-18).\x20Post-publish\x20immutable\x20(F-S-22).'},{'object':'Arbitration','field':'arbitrations','required':![],'locked_after_publish':![],'notes':'Dispute\x20handlers;\x20required\x20if\x20compensation_fund\x20>\x200\x20(F-S-19).\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-21).'},{'object':'Repository','field':'repositories','required':![],'locked_after_publish':![],'notes':'Shared\x20data\x20stores;\x20mutable\x20post-publish'},{'object':'Reward','field':'rewards','required':![],'locked_after_publish':![],'notes':'Marketing\x20incentives;\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish\x20(F-S-24)'},{'object':'Contact','field':'um','required':![],'locked_after_publish':![],'notes':'User\x20Manager\x20(Contact\x20object);\x20mutable\x20post-publish'},{'object':'Treasury','field':'(indirect\x20via\x20order_allocators.sharing.who=Entity)','required':![],'locked_after_publish':![],'notes':'Treasury\x20is\x20referenced\x20by\x20Allocation.sharing.who,\x20not\x20by\x20Service\x20directly'}];export const SERVICE_SCENES=[{'id':'service_retail','name':'Retail\x20e-commerce\x20Service','category':'retail','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL','set\x20customer\x20required\x20info\x20fields'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','pause/resume\x20the\x20Service\x20(310)','add/set/remove/clear\x20sales\x20items\x20(305)','set\x20the\x20order_allocators\x20strategy\x20(313)','set/clear\x20the\x20buy_guard\x20check\x20(307)','issue/destroy\x20discount\x20coupons\x20(312)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)'],'common_patterns':['Multi-tier\x20pricing\x20via\x20sales[]\x20(Standard/Premium/Enterprise)','WIP\x20hash\x20per\x20sale\x20item\x20for\x20tamper-proof\x20product\x20info','buy_guard\x20for\x20KYC\x20whitelist\x20during\x20pre-sale,\x20then\x20null\x20for\x20public\x20sale','compensation_fund\x20deposited\x20before\x20publish\x20+\x20arbitrations\x20configured'],'recommended_templates':['T-S-01','T-S-06']},{'id':'service_rental','name':'Rental\x20Service\x20(short/long-term)','category':'rental','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','bind\x20the\x20Machine\x20workflow\x20(306)\x20—\x20for\x20rental\x20workflow','add\x20Arbitration\x20references\x20(308)\x20—\x20for\x20deposit\x20disputes'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20recommended\x20(rental\x20workflow\x20with\x20deposit/return\x20stages)','arbitrations\x20recommended\x20(deposit\x20refund\x20disputes)'],'common_patterns':['Machine\x20workflow\x20with\x20\x27Deposit\x20→\x20Use\x20→\x20Return\x20→\x20Refund\x27\x20nodes','compensation_fund\x20holds\x20deposit\x20guarantees','buy_guard\x20verifies\x20renter\x20identity/KYC','stock=1\x20per\x20rental\x20item\x20(unique\x20items)'],'recommended_templates':['T-S-02','T-S-04']},{'id':'service_subscription','name':'Subscription\x20Service\x20(recurring)','category':'subscription','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['publish\x20the\x20Service\x20(311)','add/set\x20sales\x20items\x20(305)','issue\x20discount\x20coupons\x20(312)\x20—\x20promotional\x20rates','add\x20Reward\x20references\x20(318)\x20—\x20loyalty\x20rewards'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Tiered\x20plans\x20(Free/Pro/Enterprise)\x20as\x20sales[]','Discount\x20coupons\x20for\x20trial\x20periods','Rewards\x20for\x20long-term\x20subscribers','Renewal\x20handled\x20by\x20repeat\x20orders\x20(no\x20native\x20recurring\x20billing)'],'recommended_templates':['T-S-03']},{'id':'service_workflow','name':'Workflow-bound\x20Service\x20(machine-bound)','category':'workflow','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description','set\x20the\x20location/URL'],'permission_index_operations':['bind\x20the\x20Machine\x20workflow\x20(306)','publish\x20the\x20Service\x20(311)','set\x20the\x20order_allocators\x20strategy\x20(313)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set','machine\x20must\x20be\x20published\x20before\x20binding','machine\x20recommended\x20for\x20any\x20multi-stage\x20service\x20delivery'],'common_patterns':['Machine\x20defines\x20Pay\x20→\x20Confirm\x20→\x20Deliver\x20→\x20Sign-off\x20nodes','Progress\x20created\x20per\x20order\x20(stage\x206\x20of\x20buy\x20flow)','Named\x20operators\x20assigned\x20per\x20Forward\x20in\x20Machine','Service.paused\x20does\x20NOT\x20affect\x20already-created\x20Progress\x20(existing\x20orders\x20continue)'],'recommended_templates':['T-S-04']},{'id':'service_arbitration','name':'Arbitration-bound\x20Service\x20(dispute-ready)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)','deposit\x20to\x20the\x20compensation_fund\x20(315)','extend\x20setting_lock_duration\x20(317)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['If\x20compensation_fund\x20>\x200,\x20arbitrations\x20must\x20be\x20non-empty\x20(F-S-19)','Arbitration\x20objects\x20must\x20be\x20created\x20before\x20binding','compensation_fund_add\x20before\x20publish\x20recommended\x20(else\x20post-publish\x20deposit\x20still\x20possible)'],'common_patterns':['2-3\x20Arbitration\x20objects\x20(different\x20arb\x20committees\x20for\x20different\x20dispute\x20types)','compensation_fund\x20deposited\x20as\x20%\x20of\x20expected\x20order\x20volume','setting_lock_duration\x20extended\x20by\x20owner\x20to\x20build\x20customer\x20trust','Arbitration\x20compensation\x20payout\x20triggered\x20by\x20the\x20arbitration\x20result\x20(not\x20by\x20Service\x20directly)'],'recommended_templates':['T-S-05','T-S-06']},{'id':'service_compensation_fund','name':'Compensation\x20Fund\x20Service\x20(embedded\x20balance)','category':'compensation_fund','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['deposit\x20to\x20the\x20compensation_fund\x20(315)','withdraw\x20from\x20the\x20compensation_fund\x20(314)\x20—\x20time-locked\x20after\x20publish','receive\x20the\x20compensation_fund\x20payout\x20(316)\x20—\x20arbitration\x20payout\x20(always\x20mutable)','extend\x20setting_lock_duration\x20(317)\x20—\x20extend\x20lock'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['compensation_fund\x20>\x200\x20→\x20arbitrations\x20non-empty\x20(F-S-19)','compensation_fund\x20coin\x20type\x20must\x20match\x20Service<T>\x20type\x20parameter'],'common_patterns':['Fund\x20inflow:\x20compensation_fund_add\x20(315)\x20—\x20always\x20mutable','Fund\x20outflow:\x20compensation_fund_withdraw\x20(314)\x20—\x20requires\x20bPaused\x20+\x20lock_duration\x20expired','Fund\x20receive:\x20compensation_fund_receive\x20(316)\x20—\x20arbitration\x20payout,\x20always\x20mutable','Fund\x20consumer:\x20arbitration\x20compensation\x20payout\x20(driven\x20by\x20arb\x20result)','Distinct\x20from\x20Treasury:\x20Service-internal,\x20arbitration-bound,\x20lock-protected'],'recommended_templates':['T-S-06']},{'id':'service_reward','name':'Reward-attached\x20Service\x20(marketing)','category':'reward','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add/remove/clear\x20Reward\x20references\x20(318)\x20—\x20add\x20always\x20mutable;\x20remove/clear\x20time-locked\x20after\x20publish','issue/destroy\x20discount\x20coupons\x20(312)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Rewards\x20added\x20post-publish\x20(always\x20allowed;\x20remove/clear\x20is\x20time-locked\x20after\x20publish)','Reward\x20objects\x20must\x20exist\x20before\x20binding\x20(queryObjectsWithType\x20validation)','MAX_REWARD_COUNT\x20=\x2020\x20per\x20Service','Reward\x20remove/clear\x20requires\x20Service\x20paused\x20+\x20setting_lock_duration\x20elapsed\x20(protects\x20customer\x20expectations)'],'recommended_templates':['T-S-08']},{'id':'service_arbitration_binding','name':'Arbitration\x20Binding\x20Service\x20(post-publish\x20immutable)','category':'arbitration','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['add\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','remove\x20an\x20Arbitration\x20reference\x20(308)\x20—\x20pre-publish\x20only','clear\x20Arbitration\x20references\x20(308)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['MAX_ARBITRATION_COUNT\x20=\x2020\x20per\x20Service\x20(F-S-04)','Each\x20Arbitration\x20object\x20must\x20be\x20valid\x20(queryObjectsWithType\x20validation)','Arbitration\x20bound\x20=\x20locked\x20post-publish\x20(F-S-21).\x20To\x20change:\x20create\x20new\x20Service.'],'common_patterns':['Pre-publish:\x20set\x201-3\x20Arbitration\x20objects\x20for\x20different\x20dispute\x20scopes','Post-publish:\x20immutable\x20—\x20clone\x20Service\x20if\x20change\x20needed','⚠️\x20Data\x20inconsistency:\x20dynamic-pricing.ts\x20marks\x20arbitrations\x20as\x20mutable,\x20but\x20SDK\x20blocks\x20it\x20(F-S-21)'],'recommended_templates':['T-S-05']},{'id':'service_buy_guard','name':'Buy\x20Guard\x20Service\x20(post-publish\x20mutable\x20guard)','category':'buy_guard','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['bind\x20the\x20buy_guard\x20Guard\x20(307)','clear\x20the\x20buy_guard\x20Guard\x20(307)','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Pre-sale\x20phase:\x20buy_guard\x20=\x20whitelist\x20Guard\x20(KYC\x20verified\x20buyers\x20only)','Public\x20sale:\x20buy_guard\x20=\x20null\x20(anyone\x20can\x20buy)','Restricted\x20phase:\x20buy_guard\x20=\x20KYC\x20Guard\x20(compliance)','⚠️\x20buy_guard\x20is\x20the\x20ONLY\x20publish-locked-field\x20exception\x20—\x20still\x20mutable\x20post-publish','buy_guard\x20verification\x20happens\x20at\x20Stage\x201\x20of\x20buy\x20flow\x20(pre_check)'],'recommended_templates':['T-S-01']},{'id':'service_order_allocator','name':'Order\x20Allocator\x20Service\x20(fund\x20distribution\x20config)','category':'order_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)\x20—\x20requires\x20order_allocators\x20(F-S-18)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set\x20(F-S-18,\x20E_NO_ALLOCATOR)','Allocators.sharing.who\x20can\x20reference\x20Treasury\x20addresses\x20(indirect\x20Treasury\x20binding)','MAX_SHARING_COUNT\x20=\x20100\x20per\x20allocator'],'common_patterns':['Multi-party\x20split:\x20merchant\x2080%\x20/\x20platform\x2010%\x20/\x20logistics\x2010%','Threshold-based:\x20different\x20allocators\x20for\x20different\x20order\x20sizes','Guard-bound\x20allocator:\x20allocation\x20execution\x20requires\x20Guard\x20verification','Post-publish\x20immutable\x20—\x20clone\x20Service\x20to\x20change\x20allocation\x20strategy'],'recommended_templates':['T-S-08']},{'id':'service_dynamic_pricing','name':'Dynamic\x20Pricing\x20Service\x20(discount-driven)','category':'dynamic_pricing','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['issue\x20discount\x20coupons\x20(312)','add/set\x20sales\x20items\x20(305)\x20—\x20adjust\x20base\x20prices','remove\x20sales\x20items\x20(305)\x20—\x20remove\x20deprecated\x20SKUs'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20must\x20be\x20set'],'common_patterns':['Discount\x20types:\x200=rates\x20(basis\x20points,\x20per\x2010000),\x201=minus\x20(direct\x20deduction)','MAX_DISCOUNT_COUNT_ONCE\x20=\x201000\x20per\x20issue\x20call','MAX_DISCOUNT_RECEIVER_ONCE\x20=\x201000\x20receivers\x20per\x20call','MAX_DISCOUNT_TOTAL_COUNT\x20=\x2020000\x20total\x20coupons','discount_destroy:\x20holder-only\x20(no\x20SERVICE_DISCOUNT\x20permission\x20needed)','discount_send:\x20holder-only\x20transfer\x20of\x20owned\x20transferable:true\x20coupons\x20to\x20another\x20address\x20(no\x20permission\x20needed)'],'recommended_templates':['T-S-07']},{'id':'service_multi_allocator','name':'Multi-Allocator\x20Service\x20(tiered\x20fund\x20distribution)','category':'multi_allocator','permission_index_range':'300-320','builtin_indexes':SERVICE_PERMISSIONS,'cross_object_bindings':SERVICE_CROSS_OBJECT_BINDINGS,'order_flow_stages':SERVICE_ORDER_FLOW_STAGES,'owner_operations':['bind/unbind\x20the\x20UM\x20Contact','builder\x20(transfer)'],'admin_operations':['update\x20the\x20description'],'permission_index_operations':['set\x20the\x20order_allocators\x20strategy\x20(313)\x20—\x20pre-publish\x20only','publish\x20the\x20Service\x20(311)'],'mutable_after_publish':{'machine':![],'arbitrations':![],'order_allocators':![],'buy_guard':!![],'rewards':'locked_by_duration','compensation_fund_withdraw':'locked_by_duration','compensation_fund_receive':'mutable','sales':!![],'description':!![],'location':!![],'repositories':!![],'customer_required':!![],'discount':!![],'um':!![],'pause':!![]},'publish_prerequisites':['order_allocators\x20MUST\x20be\x20set','Each\x20allocator\x20has\x20its\x20own\x20Guard\x20+\x20sharing\x20+\x20threshold','Each\x20allocator\x20is\x20bound\x20to\x20a\x20DIFFERENT\x20guard\x20—\x20the\x20caller\x27s\x20submitted\x20guard\x20selects\x20which\x20path\x20fires'],'common_patterns':['Tier\x201\x20(small\x20orders):\x20single-recipient\x20allocator\x20(low\x20fee)','Tier\x202\x20(medium\x20orders):\x20two-recipient\x20split\x20(merchant\x20+\x20platform)','Tier\x203\x20(large\x20orders):\x20three-recipient\x20split\x20(merchant\x20+\x20platform\x20+\x20logistics)','Each\x20tier\x20can\x20have\x20its\x20own\x20Guard\x20for\x20execution\x20authorization'],'recommended_templates':['T-S-08']}];export const SERVICE_LEDGER_VERSION='1.0.0';export function getScenesByCategory(a){return SERVICE_SCENES['filter'](b=>b['category']===a);}export function findSceneById(a){return SERVICE_SCENES['find'](b=>b['id']===a);}export function getServicePermissionByIndex(a){return SERVICE_PERMISSIONS['find'](b=>b['index']===a);}export function isServicePermission(a){return getServicePermissionByIndex(a)!==undefined;}export function getPermissionsByMutability(a){return SERVICE_PERMISSIONS['filter'](b=>b['post_publish_mutability']===a);}export function getImmutablePostPublishPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='immutable'||a['post_publish_mutability']==='one_shot');}export function getLockedByDurationPermissions(){return SERVICE_PERMISSIONS['filter'](a=>a['post_publish_mutability']==='locked_by_duration');}export function inferSceneFromIntent(a){const b=a['toLowerCase'](),c=[['retail','retail'],['ecommerce','retail'],['rental','rental'],['rent','rental'],['short-term\x20rental','rental'],['long-term\x20rental','rental'],['subscription','subscription'],['subscribe','subscription'],['workflow','workflow'],['machine-bound','workflow'],['arbitration','arbitration'],['dispute','arbitration'],['compensation','compensation_fund'],['compensation_fund','compensation_fund'],['reward','reward'],['marketing','reward'],['buy_guard','buy_guard'],['kyc','buy_guard'],['whitelist','buy_guard'],['allocator','order_allocator'],['discount','dynamic_pricing'],['coupon','dynamic_pricing'],['multi-allocator','multi_allocator'],['tiered','multi_allocator']];for(const [d,e]of c){if(b['includes'](d)){const f=getScenesByCategory(e);if(f['length']>0x0)return f[0x0];}}if(b['includes']('service'))return findSceneById('service_retail');return undefined;}export function getAllServiceScenes(){return[...SERVICE_SCENES];}export function getServiceScenesCount(){return SERVICE_SCENES['length'];}export function getServicePermissionsCount(){return SERVICE_PERMISSIONS['length'];}export function getOrderFlowStage(a){return SERVICE_ORDER_FLOW_STAGES['find'](b=>b['stage']===a);}export function getCrossObjectBindings(){return[...SERVICE_CROSS_OBJECT_BINDINGS];}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GUARD_TEMPLATES,fillGuardTemplate}from'./guard-templates.js';import{MACHINE_TEMPLATES,fillTemplate as
|
|
1
|
+
import{GUARD_TEMPLATES,fillGuardTemplate}from'./guard-templates.js';import{MACHINE_TEMPLATES,fillTemplate as a310a}from'./machine-templates.js';import{SERVICE_TEMPLATES,fillServiceTemplate}from'./service-templates.js';import{ORDER_TEMPLATES,fillTemplate as a310b}from'./order-templates.js';import{PROGRESS_TEMPLATES,fillProgressTemplate}from'./progress-templates.js';import{ARBITRATION_TEMPLATES,fillTemplate as a310c}from'./arbitration-templates.js';import{TREASURY_TEMPLATES,fillTemplate as a310d}from'./treasury-templates.js';import{PERMISSION_TEMPLATES,fillTemplate as a310e}from'./permission-templates.js';import{PASSPORT_TEMPLATES,fillTemplate as a310f}from'./passport-templates.js';import{ALLOCATION_TEMPLATES,fillTemplate as a310g}from'./allocation-templates.js';import{CONTACT_TEMPLATES,fillTemplate as a310h}from'./contact-templates.js';import{REWARD_TEMPLATES}from'./reward-templates.js';export const TEMPLATE_REGISTRY_VERSION=0x1;export const TEMPLATE_OBJECT_TYPES=['guard','machine','service','order','progress','arbitration','treasury','permission','passport','allocation','reward','contact'];function normalizeParam(a){return{'name':a['name'],'type':a['type'],'description':a['description']??'','required':a['required'],...a['default']!==undefined?{'default':a['default']}:{},...a['constraint']!==undefined?{'constraint':a['constraint']}:{}};}function guardMeta(a){return{'id':a['id'],'object_type':'guard','name':a['name'],'description':a['description'],'scenes':[a['scene_id']],'industries':a['applicable_industries'],'instantiable':!![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}function machineMeta(a){return{'id':a['id'],'object_type':'machine','name':a['name'],'description':a['description'],'scenes':[a['scene_id']],'industries':a['applicable_industries'],'instantiable':!![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}function bodyMeta(a,b,c,d){return{'id':a['id'],'object_type':b,'name':a['name'],'description':a['description'],'scenes':c,'industries':d,'instantiable':!![],'parameters':a['params']['map'](e=>normalizeParam(e))};}function rewardMeta(a){return{'id':a['type'],'object_type':'reward','name':a['name'],'description':a['description'],'scenes':[],'industries':[],'instantiable':![],'parameters':a['parameters']['map'](b=>normalizeParam(b))};}let REGISTRY=null,ID_COLLISIONS=[];function buildRegistry(){const a=new Map(),b=[],c=d=>{if(a['has'](d['meta']['id'])){b['push'](d['meta']['id']);return;}a['set'](d['meta']['id'],d);};for(const d of GUARD_TEMPLATES){c({'meta':guardMeta(d),'raw':d,'notes':d['creation_notes']});}for(const e of MACHINE_TEMPLATES){c({'meta':machineMeta(e),'raw':e,'notes':e['creation_notes']});}for(const f of SERVICE_TEMPLATES){c({'meta':bodyMeta(f,'service',f['applicable_scenes'],f['industry_tags']),'raw':f,'notes':f['notes']});}for(const g of ORDER_TEMPLATES){c({'meta':bodyMeta(g,'order',g['applicable_scenes'],g['industry_tags']),'raw':g,'notes':g['notes']});}for(const h of PROGRESS_TEMPLATES){c({'meta':bodyMeta(h,'progress',h['applicable_scenes'],h['industry_tags']),'raw':h,'notes':h['notes']});}for(const i of ARBITRATION_TEMPLATES){c({'meta':bodyMeta(i,'arbitration',i['applicable_scenes'],i['industry_tags']),'raw':i,'notes':i['notes']});}for(const j of TREASURY_TEMPLATES){c({'meta':bodyMeta(j,'treasury',j['applicable_scenes'],j['industry_tags']),'raw':j,'notes':j['notes']});}for(const k of PERMISSION_TEMPLATES){c({'meta':bodyMeta(k,'permission',k['applicable_scenes'],k['industry_tags']),'raw':k,'notes':k['notes']});}for(const l of PASSPORT_TEMPLATES){c({'meta':bodyMeta(l,'passport',l['applicable_scenarios'],l['industry_tags']),'raw':l,'notes':l['notes']});}for(const m of ALLOCATION_TEMPLATES){c({'meta':bodyMeta(m,'allocation',m['applicable_scenes'],m['industry_tags']),'raw':m,'notes':m['notes']});}for(const n of REWARD_TEMPLATES){c({'meta':rewardMeta(n),'raw':n,'guidance':{'guardCondition':n['guardCondition'],'amountRange':n['amountRange'],'allocationStrategy':n['allocationStrategy'],'example':n['example'],'relevantGuardOps':n['relevantGuardOps']}});}for(const o of CONTACT_TEMPLATES){c({'meta':bodyMeta(o,'contact',o['applicable_scenes'],o['industry_tags']),'raw':o,'notes':o['notes']});}return ID_COLLISIONS=b,a;}function registry(){return!REGISTRY&&(REGISTRY=buildRegistry()),REGISTRY;}export function getTemplateIdCollisions(){return registry(),ID_COLLISIONS;}export function getTemplateCounts(){const a=Object['fromEntries'](TEMPLATE_OBJECT_TYPES['map'](b=>[b,0x0]));for(const b of registry()['values']()){a[b['meta']['object_type']]+=0x1;}return a;}export function listTemplates(a){const b=[...registry()['values']()]['map'](c=>c['meta']);return a?b['filter'](c=>c['object_type']===a):b;}export function getTemplateDetail(a){const b=registry()['get'](a);if(!b)return null;return{...b['meta'],'raw':b['raw'],...b['notes']?{'notes':b['notes']}:{},...b['guidance']?{'guidance':b['guidance']}:{}};}export function findTemplateObjectType(a){return registry()['get'](a)?.['meta']['object_type']??null;}export function instantiateTemplate(a,b){const c=registry()['get'](a);if(!c)return{'ok':![],'object_type':null,'template_id':a,'error':'Template\x20not\x20found:\x20'+a+'.\x20Use\x20get_templates\x20without\x20\x27template\x27\x20to\x20list\x20all\x20template\x20ids.'};const d=c['meta']['object_type'];if(!c['meta']['instantiable'])return{'ok':![],'object_type':d,'template_id':a,'error':'Reward\x20templates\x20are\x20guidance-only\x20(prose\x20guard\x20conditions)\x20and\x20cannot\x20be\x20'+'instantiated\x20into\x20executable\x20JSON.\x20Use\x20the\x20guidance\x20payload\x20to\x20design\x20the\x20'+'Reward\x20+\x20Guard\x20manually.','guidance':c['guidance']};switch(d){case'guard':{const e=fillGuardTemplate(a,b);if(!e['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':e['error'],...e['missing']?{'missing_params':e['missing']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':{'table':e['table'],'root':e['root']},...c['notes']?{'notes':c['notes']}:{}};}case'machine':{const f=a310a(a,b);if(!f['success'])return{'ok':![],'object_type':d,'template_id':a,'error':f['validation_errors']?.['join'](';\x20')??'Machine\x20template\x20fill\x20failed',...f['missing_params']?{'missing_params':f['missing_params']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':{'nodes':f['filled_nodes'],'pairs':f['filled_pairs']},...c['notes']?{'notes':c['notes']}:{}};}case'service':{const g=fillServiceTemplate(a,b);if(!g['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':g['error']??'Service\x20template\x20fill\x20failed',...g['missing_required']?{'missing_params':g['missing_required']}:{}};return{'ok':!![],'object_type':d,'template_id':a,'body':g['body'],...c['notes']?{'notes':c['notes']}:{}};}case'order':case'arbitration':case'treasury':case'permission':case'passport':case'allocation':case'progress':case'contact':{const h=fillBodyTemplate(d,a,b);if(!h['ok'])return{'ok':![],'object_type':d,'template_id':a,'error':h['error']};return{'ok':!![],'object_type':d,'template_id':a,'body':h['body'],...c['notes']?{'notes':c['notes']}:{}};}default:return{'ok':![],'object_type':d,'template_id':a,'error':'Instantiation\x20not\x20supported\x20for\x20object_type\x20\x27'+d+'\x27'};}}function fillBodyTemplate(a,b,c){switch(a){case'order':return a310b(b,c);case'arbitration':return a310c(b,c);case'treasury':return a310d(b,c);case'permission':return a310e(b,c);case'passport':return a310f(b,c);case'allocation':return a310g(b,c);case'progress':return fillProgressTemplate(b,c);case'contact':return a310h(b,c);default:return{'ok':![],'error':'No\x20body-template\x20fill\x20for\x20\x27'+a+'\x27'};}}
|