@wowok/agent-mcp 3.3.5 → 3.3.7

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.
Files changed (243) hide show
  1. package/dist/chain-semantics/eval-order.d.ts +17 -0
  2. package/dist/chain-semantics/eval-order.js +1 -0
  3. package/dist/chain-semantics/field-capability.js +1 -1
  4. package/dist/chain-semantics/freeze-map.js +1 -1
  5. package/dist/chain-semantics/fund-flow.js +1 -1
  6. package/dist/chain-semantics/guard-verbs.js +1 -1
  7. package/dist/chain-semantics/index.d.ts +1 -0
  8. package/dist/chain-semantics/index.js +1 -1
  9. package/dist/chain-semantics/object-graph.js +1 -1
  10. package/dist/composition/audit.js +1 -1
  11. package/dist/composition/compile.d.ts +2 -1
  12. package/dist/composition/compile.js +1 -1
  13. package/dist/composition/materialize.js +1 -1
  14. package/dist/data/api/api.spec.d.ts +1 -0
  15. package/dist/data/api/api.spec.js +1 -0
  16. package/dist/data/api/cli.d.ts +1 -0
  17. package/dist/data/api/cli.js +1 -0
  18. package/dist/data/api/head.d.ts +16 -0
  19. package/dist/data/api/head.js +1 -0
  20. package/dist/data/api/head.spec.d.ts +1 -0
  21. package/dist/data/api/head.spec.js +1 -0
  22. package/dist/data/api/index.d.ts +2 -0
  23. package/dist/data/api/index.js +1 -0
  24. package/dist/data/api/match.d.ts +69 -0
  25. package/dist/data/api/match.js +1 -0
  26. package/dist/data/api/match.spec.d.ts +1 -0
  27. package/dist/data/api/match.spec.js +1 -0
  28. package/dist/data/api/server.d.ts +12 -0
  29. package/dist/data/api/server.js +1 -0
  30. package/dist/data/projection/cli.d.ts +1 -0
  31. package/dist/data/projection/cli.js +1 -0
  32. package/dist/data/projection/edges.d.ts +8 -0
  33. package/dist/data/projection/edges.js +1 -0
  34. package/dist/data/projection/edges.spec.d.ts +1 -0
  35. package/dist/data/projection/edges.spec.js +1 -0
  36. package/dist/data/projection/facets.d.ts +18 -0
  37. package/dist/data/projection/facets.js +1 -0
  38. package/dist/data/projection/facets.spec.d.ts +1 -0
  39. package/dist/data/projection/facets.spec.js +1 -0
  40. package/dist/data/projection/facts.d.ts +40 -0
  41. package/dist/data/projection/facts.js +1 -0
  42. package/dist/data/projection/index.d.ts +6 -0
  43. package/dist/data/projection/index.js +1 -0
  44. package/dist/data/projection/project.d.ts +10 -0
  45. package/dist/data/projection/project.js +1 -0
  46. package/dist/data/projection/projection.spec.d.ts +1 -0
  47. package/dist/data/projection/projection.spec.js +1 -0
  48. package/dist/data/projection/schema.d.ts +1 -0
  49. package/dist/data/projection/schema.js +1 -0
  50. package/dist/data/projection/store.d.ts +49 -0
  51. package/dist/data/projection/store.js +1 -0
  52. package/dist/data/projection/types.d.ts +137 -0
  53. package/dist/data/projection/types.js +1 -0
  54. package/dist/data/sync/cdc.d.ts +34 -0
  55. package/dist/data/sync/cdc.js +1 -0
  56. package/dist/data/sync/cdc.spec.d.ts +1 -0
  57. package/dist/data/sync/cdc.spec.js +1 -0
  58. package/dist/data/sync/graphql-source.d.ts +16 -0
  59. package/dist/data/sync/graphql-source.js +1 -0
  60. package/dist/data/sync/index.d.ts +5 -0
  61. package/dist/data/sync/index.js +1 -0
  62. package/dist/data/sync/reconciler.d.ts +14 -0
  63. package/dist/data/sync/reconciler.js +1 -0
  64. package/dist/data/sync/reconciler.spec.d.ts +1 -0
  65. package/dist/data/sync/reconciler.spec.js +1 -0
  66. package/dist/data/sync/schema.d.ts +1 -0
  67. package/dist/data/sync/schema.js +1 -0
  68. package/dist/data/sync/store.d.ts +19 -0
  69. package/dist/data/sync/store.js +1 -0
  70. package/dist/data/sync/sync.spec.d.ts +1 -0
  71. package/dist/data/sync/sync.spec.js +1 -0
  72. package/dist/data/sync/synchronizer.d.ts +10 -0
  73. package/dist/data/sync/synchronizer.js +1 -0
  74. package/dist/data/sync/types.d.ts +162 -0
  75. package/dist/data/sync/types.js +1 -0
  76. package/dist/evaluation/builtins/demand-match.js +1 -1
  77. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  78. package/dist/evaluation/capability.d.ts +1 -0
  79. package/dist/evaluation/engine.js +1 -1
  80. package/dist/evaluation/extract.d.ts +7 -1
  81. package/dist/evaluation/extract.js +1 -1
  82. package/dist/evaluation/match-policy.d.ts +142 -0
  83. package/dist/evaluation/match-policy.js +1 -0
  84. package/dist/evaluation/match-policy.spec.d.ts +1 -0
  85. package/dist/evaluation/match-policy.spec.js +1 -0
  86. package/dist/experience/realtime-feedback.js +1 -1
  87. package/dist/extensions/business-modules.js +1 -1
  88. package/dist/graph/onchain/expand.js +1 -1
  89. package/dist/graph/onchain/exposure.js +1 -1
  90. package/dist/harness/recover.js +1 -1
  91. package/dist/intent/types.d.ts +1 -1
  92. package/dist/intent/types.js +1 -1
  93. package/dist/keeper/detectors.d.ts +3 -0
  94. package/dist/keeper/detectors.js +1 -1
  95. package/dist/keeper/keeper.spec.js +1 -1
  96. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  97. package/dist/knowledge/arbitration-ledger.js +1 -1
  98. package/dist/knowledge/audit-rules.js +1 -1
  99. package/dist/knowledge/baselines/rules/plan.json +113 -3
  100. package/dist/knowledge/builtin-templates.d.ts +6 -1
  101. package/dist/knowledge/builtin-templates.js +1 -1
  102. package/dist/knowledge/event-semantics.js +1 -1
  103. package/dist/knowledge/getting-started.js +1 -1
  104. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  105. package/dist/knowledge/guard-design-patterns.js +1 -1
  106. package/dist/knowledge/guard-ledger.js +1 -1
  107. package/dist/knowledge/guard-puzzle.js +1 -1
  108. package/dist/knowledge/guard-render.js +1 -1
  109. package/dist/knowledge/guard-risk.js +1 -1
  110. package/dist/knowledge/guard-templates.d.ts +1 -1
  111. package/dist/knowledge/guard-templates.js +1 -1
  112. package/dist/knowledge/guard-translation.js +1 -1
  113. package/dist/knowledge/index.js +1 -1
  114. package/dist/knowledge/industry-generalizer.d.ts +4 -0
  115. package/dist/knowledge/industry-generalizer.js +1 -1
  116. package/dist/knowledge/industry-registry.js +1 -1
  117. package/dist/knowledge/jsonrpc-enum.d.ts +26 -10
  118. package/dist/knowledge/jsonrpc-enum.js +1 -1
  119. package/dist/knowledge/projection.d.ts +54 -0
  120. package/dist/knowledge/projection.js +1 -0
  121. package/dist/knowledge/projection.spec.d.ts +1 -0
  122. package/dist/knowledge/projection.spec.js +1 -0
  123. package/dist/knowledge/recipient-constraint.d.ts +1 -1
  124. package/dist/knowledge/recipient-constraint.js +1 -1
  125. package/dist/knowledge/semantic-ir.d.ts +113 -0
  126. package/dist/knowledge/semantic-ir.js +1 -0
  127. package/dist/knowledge/service-ledger.d.ts +1 -1
  128. package/dist/knowledge/service-ledger.js +1 -1
  129. package/dist/knowledge/strategy-manuals.js +1 -1
  130. package/dist/knowledge/template-loader.d.ts +34 -0
  131. package/dist/knowledge/template-loader.js +1 -1
  132. package/dist/knowledge/template-prose.d.ts +50 -0
  133. package/dist/knowledge/template-prose.js +1 -0
  134. package/dist/knowledge/template-registry.js +1 -1
  135. package/dist/knowledge/template-scanner.d.ts +1 -1
  136. package/dist/knowledge/template-scanner.js +1 -1
  137. package/dist/knowledge/tools-reference.js +1 -1
  138. package/dist/monitor/MonitorLoop.js +1 -1
  139. package/dist/monitor/normalize.d.ts +1 -1
  140. package/dist/monitor/normalize.js +1 -1
  141. package/dist/monitor/types.js +1 -1
  142. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  143. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  144. package/dist/playbooks/service-build/merchant-guide.d.ts +4 -0
  145. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  146. package/dist/playbooks/service-build/migration-planner.d.ts +2 -1
  147. package/dist/playbooks/service-build/migration-planner.js +1 -1
  148. package/dist/playbooks/service-build/mode-actions.d.ts +7 -0
  149. package/dist/playbooks/service-build/mode-actions.js +1 -1
  150. package/dist/playbooks/service-build/object-panorama.d.ts +22 -1
  151. package/dist/playbooks/service-build/object-panorama.js +1 -1
  152. package/dist/playbooks/service-build/participation-radar.js +1 -1
  153. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  154. package/dist/playbooks/service-build/reverse-mapping-nk4.spec.js +1 -1
  155. package/dist/playbooks/service-build/reverse-mapping.d.ts +1 -0
  156. package/dist/playbooks/service-build/reverse-mapping.js +1 -1
  157. package/dist/playbooks/service-build/service-panorama.js +1 -1
  158. package/dist/playbooks/service-build/service-quote.js +1 -1
  159. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  160. package/dist/review/index.js +1 -1
  161. package/dist/role/profiles.js +1 -1
  162. package/dist/safety/confirm-gate.js +1 -1
  163. package/dist/schema/benchmark-migration/index.d.ts +64 -10
  164. package/dist/schema/benchmark-migration/index.js +1 -1
  165. package/dist/schema/call/allocation.js +1 -1
  166. package/dist/schema/call/arbitration.js +1 -1
  167. package/dist/schema/call/base.d.ts +8 -0
  168. package/dist/schema/call/bridge.d.ts +2 -0
  169. package/dist/schema/call/error-codes.d.ts +1 -1
  170. package/dist/schema/call/error-codes.js +1 -1
  171. package/dist/schema/call/proof.js +1 -1
  172. package/dist/schema/call/reward.d.ts +10 -0
  173. package/dist/schema/call/reward.js +1 -1
  174. package/dist/schema/call/semantic.js +1 -1
  175. package/dist/schema/call/service.js +1 -1
  176. package/dist/schema/common/index.js +1 -1
  177. package/dist/schema/evaluation/index.d.ts +341 -0
  178. package/dist/schema/evaluation/index.js +1 -1
  179. package/dist/schema/goal/index.d.ts +2 -0
  180. package/dist/schema/goal/planning.d.ts +3 -0
  181. package/dist/schema/goal/planning.js +1 -1
  182. package/dist/schema/industry-pack/index.d.ts +62 -0
  183. package/dist/schema/industry-pack/modes.d.ts +62 -0
  184. package/dist/schema/industry-pack/modes.js +1 -1
  185. package/dist/schema/intent-radar/index.d.ts +3 -0
  186. package/dist/schema/intent-radar/index.js +1 -1
  187. package/dist/schema/local/index.d.ts +20 -0
  188. package/dist/schema/local/index.js +1 -1
  189. package/dist/schema/operations.d.ts +5 -0
  190. package/dist/schema/query/bi.d.ts +4 -0
  191. package/dist/schema/query/bi.js +1 -1
  192. package/dist/schema/query/index.d.ts +145 -47
  193. package/dist/schema/query/index.js +1 -1
  194. package/dist/schema/schema-version.js +1 -1
  195. package/dist/schema-query-impl/index.js +1 -1
  196. package/dist/schemas/account_operation.output.json +2 -0
  197. package/dist/schemas/benchmark_migration_operation.output.json +42 -0
  198. package/dist/schemas/benchmark_migration_operation.schema.json +208 -5
  199. package/dist/schemas/bridge_operation.output.json +2 -0
  200. package/dist/schemas/evaluation_operation.output.json +624 -2
  201. package/dist/schemas/evaluation_operation.schema.json +598 -4
  202. package/dist/schemas/goal_operation.schema.json +18 -10
  203. package/dist/schemas/index.json +1 -1
  204. package/dist/schemas/industry_pack_operation.output.json +86 -2
  205. package/dist/schemas/industry_pack_operation.schema.json +199 -0
  206. package/dist/schemas/intent_radar.output.json +2 -0
  207. package/dist/schemas/intent_radar.schema.json +1 -0
  208. package/dist/schemas/local_cache_operation.output.json +2 -0
  209. package/dist/schemas/local_history_operation.output.json +2 -0
  210. package/dist/schemas/local_info_operation.output.json +2 -0
  211. package/dist/schemas/local_mark_operation.output.json +2 -0
  212. package/dist/schemas/onchain_events.output.json +281 -11
  213. package/dist/schemas/onchain_events.schema.json +5 -1
  214. package/dist/schemas/onchain_operations.output.json +2 -0
  215. package/dist/schemas/onchain_operations.schema.json +914 -314
  216. package/dist/schemas/onchain_operations_allocation.schema.json +1 -1
  217. package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
  218. package/dist/schemas/onchain_operations_gen_proof.schema.json +1 -1
  219. package/dist/schemas/onchain_operations_guard.schema.json +660 -94
  220. package/dist/schemas/onchain_operations_reward.schema.json +35 -1
  221. package/dist/schemas/onchain_operations_service.schema.json +4 -4
  222. package/dist/schemas/query_toolkit.output.json +333 -0
  223. package/dist/tools/handlers/benchmark-migration.d.ts +5 -2
  224. package/dist/tools/handlers/benchmark-migration.js +1 -1
  225. package/dist/tools/handlers/config.js +1 -1
  226. package/dist/tools/handlers/evaluation.js +1 -1
  227. package/dist/tools/handlers/evaluation.spec.js +1 -1
  228. package/dist/tools/handlers/intent-radar.js +1 -1
  229. package/dist/tools/handlers/messenger.d.ts +1 -0
  230. package/dist/tools/handlers/messenger.js +1 -1
  231. package/dist/tools/handlers/onchain.d.ts +2 -0
  232. package/dist/tools/handlers/onchain.js +1 -1
  233. package/dist/tools/handlers/query.js +1 -1
  234. package/dist/tools/handlers/wip.js +1 -1
  235. package/dist/tools/index.js +1 -1
  236. package/dist/tools/registry/agent.js +1 -1
  237. package/dist/tools/registry/business.js +1 -1
  238. package/dist/tools/registry/query.js +1 -1
  239. package/dist/tools/wip-verify-ledger.d.ts +14 -0
  240. package/dist/tools/wip-verify-ledger.js +1 -0
  241. package/dist/tools/wrap.d.ts +4 -0
  242. package/dist/tools/wrap.js +1 -1
  243. package/package.json +7 -2
@@ -1 +1 @@
1
- import{fillGuardTemplate,getTemplateById}from'../knowledge/guard-templates.js';import{GUARD_DESIGN_PATTERNS}from'../knowledge/guard-design-patterns.js';import{SV2_UNARMED_PRESCRIPTION,TWO_TX_RENEW_RECIPE}from'../knowledge/protocol-facts.js';import{verifyAllocatorRails}from'../knowledge/allocator-rail-verifier.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{rootHasRewardRecordGate,afterSalesRailRegex as a11a,afterSalesRailNodeMatches}from'../knowledge/template-scanner.js';import{refsOf}from'./plan.js';const P=a=>a;function offTaskSlotIdentityLegs(a){const b=new Set(['order.owner','order.agent\x20has']),c=new Set(),d=[],e=f=>{if(f===null||typeof f!=='object')return;const g=f;if(g['type']==='logic_equal'&&Array['isArray'](g['nodes'])){const i=g['nodes']['filter'](j=>j!==null&&typeof j==='object'&&j['type']==='identifier'&&typeof j['identifier']==='number');if(i['some'](j=>j['identifier']===TASK_BINDING_SLOT)){for(const j of i)c['add'](j['identifier']);}}const h=g['object'];if(typeof g['query']==='string'&&b['has'](g['query'])&&h!==null&&typeof h==='object'&&typeof h['identifier']==='number'){const l=h['identifier'];if(l!==TASK_BINDING_SLOT)d['push']({'query':g['query'],'identifier':l});}if(Array['isArray'](g['nodes'])){for(const m of g['nodes'])e(m);}if(g['node']!==undefined&&typeof g['node']==='object')e(g['node']);};return e(a),d['filter'](f=>!c['has'](f['identifier']));}function safeId(a){return a['replace'](/[^a-zA-Z0-9_]/g,'_');}function ref(a){return{'$ref':a};}const MODE_MAP={'amount':'Amount','rate':'Rate','surplus':'Surplus'};export function compileTemplate(a,b,d={}){const h=d['nameBase']??a['id']['replace'](/\//g,'_'),i=d['merchantPermissionIndex']??0x3e8,j=[],k=[],l=new Set();for(const am of a['conditional_guards']??[]){const an=b[am['param']]??a['fee_params'][am['param']];if(an!==am['emit_value'])l['add'](am['guard_key']);}const p=new Map();for(const ao of a['conditional_guards']??[]){p['set'](ao['param'],(p['get'](ao['param'])??0x0)+0x1);}const q=new Set((a['conditional_guards']??[])['filter'](ap=>(p['get'](ap['param'])??0x0)>0x1)['map'](ap=>ap['guard_key'])),s=new Set([...l]['filter'](ap=>q['has'](ap))),t=s['size']>0x0?a['machine_shape']['map'](ap=>({...ap,'from':(ap['from']??[])['filter'](aq=>typeof aq==='string'||aq['guard_key']===undefined||!s['has'](aq['guard_key']))})):a['machine_shape'],u=s['size']>0x0?(a['allocator']['rows']??[])['filter'](ap=>ap['guard_key']===undefined||!s['has'](ap['guard_key'])):a['allocator']['rows']??[],v=[];for(const [ap,aq]of Object['entries'](d['guardResolutions']??{})){if(aq?.['kind']==='omit')v['push'](ap);}const w=new Set();if(v['length']>0x0){const ar=new Set(t['flatMap'](at=>(at['from']??[])['map'](au=>typeof au==='string'?undefined:au['guard_key'])['filter'](au=>typeof au==='string'))),as=new Set(u['map'](at=>at['guard_key'])['filter'](at=>typeof at==='string'));for(const at of v){const au=a['guards']['find']((aw,ax)=>(aw['key']??aw['template_id']+'#'+ax)===at);if(au===undefined)continue;const av=[];if(ar['has'](at))av['push']('a\x20machine\x20forward\x20edge\x20(guard_key)');if(as['has'](at))av['push']('an\x20allocator\x20rail\x20row\x20(guard_key)');if(au['policy']!==undefined)av['push']('a\x20Repository\x20write-policy\x20credential\x20(policy)');if(au['host']==='service'&&at==='buy')av['push']('the\x20Service\x20buy\x20gate\x20(buy_guard)');av['length']>0x0?j['push']({'code':'GUARD_OMIT_UNSUPPORTED','detail':'guard_resolutions[\x27'+at+'\x27]\x20=\x20{kind:\x27omit\x27}\x20refused:\x20this\x20design\x20is\x20bound\x20to\x20'+av['join']('\x20and\x20')+'\x20—\x20'+'omitting\x20it\x20would\x20orphan\x20the\x20binding\x20(open\x20rail\x20/\x20open\x20write\x20/\x20ungated\x20purchase).\x20'+'Fold\x20the\x20design\x27s\x20intent\x20into\x20the\x20bound\x20site\x20instead,\x20or\x20keep\x20the\x20guard\x20resolved.'}):w['add'](at);}}const x=a['guards']['map']((aw,ax)=>({'key':aw['key']??aw['template_id']+'#'+ax,'template_id':aw['template_id'],'host':aw['host'],'purpose':aw['purpose'],'policy':aw['policy'],'params':aw['params']}))['filter'](aw=>!l['has'](aw['key'])&&!w['has'](aw['key'])),y=new Map();{const aw=new Set(x['map'](ax=>ax['key']));for(const ax of t){for(const ay of ax['from']??[]){const az=typeof ay==='string'?{'prev':ay}:ay,aA=az['operator']??ax['operator']??(az['prev']===''?'order_payer':'merchant');if(aA!=='order_payer'||az['guard_key']!==undefined)continue;const aB=az['forward']??(az['prev']===''?'enter_'+ax['name']:az['prev']+'_to_'+ax['name']);if(y['has'](aB))continue;let aC='order_holder_'+aB;while(aw['has'](aC))aC=aC+'_x';aw['add'](aC),y['set'](aB,aC),x['push']({'key':aC,'template_id':'tpl_forward_order_holder','host':'machine','purpose':'F05\x20kernel-injected\x20order-holder\x20identity\x20binding\x20for\x20the\x20buyer-exclusive\x20forward\x20'+('\x27'+aB+'\x27\x20(edge\x20\x27'+az['prev']+'\x27->\x27'+ax['name']+'\x27):\x20namedOperator\x20\x22\x22\x20passes\x20for\x20')+'anyone\x20at\x20the\x20permission\x20layer\x20(progress.move:242-256),\x20so\x20without\x20this\x20guard\x20the\x20'+'buyer\x20rail\x20is\x20advanceable\x20by\x20ANY\x20passport\x20holder\x20attached\x20to\x20the\x20order\x20—\x20takeover\x20'+'risk.\x20Declare\x20an\x20explicit\x20order-holder\x20guard_key\x20on\x20the\x20edge\x20to\x20replace\x20this\x20'+'auto\x20key\x20with\x20a\x20named\x20credential.'});}}}const z=new Map(x['map'](aD=>[aD['key'],aD])),A=new Set(['wip_provenance','subscription_with_proof']),B=Array['isArray'](b['adopted_module_ids'])?b['adopted_module_ids']['filter'](aD=>typeof aD==='string'):[],C=x['some'](aD=>aD['host']==='repository'||aD['template_id']==='pattern.repository_data_check'||aD['template_id']==='pattern.repository_write_authorization'||aD['template_id']==='tpl_repository_row_present'||aD['template_id']==='tpl_repository_row_equals_order_field')||B['some'](aD=>A['has'](aD)),D=new Map(),E=[],F=x['map'](aD=>aD['key']);for(const aD of Object['keys'](d['guardResolutions']??{})){if(w['has'](aD))continue;!z['has'](aD)&&j['push']({'code':'GUARD_RESOLUTION_UNKNOWN','detail':'guard_resolutions\x20key\x20\x27'+aD+'\x27\x20matches\x20no\x20guard\x20spec\x20key\x20declared\x20by\x20\x27'+h+'\x27.\x20'+('Legal\x20keys:\x20'+(F['length']>0x0?F['join'](',\x20'):'(none\x20—\x20this\x20template\x20declares\x20no\x20keyed\x20guards)')+'.\x20')+'An\x20unknown\x20key\x20was\x20previously\x20dropped\x20silently,\x20leaving\x20the\x20intended\x20guard\x20pending\x20while\x20the\x20build\x20looked\x20resolved.'});}for(const aE of x){const aF='guard_'+safeId(aE['key']),aG=d['guardResolutions']?.[aE['key']];let aH=aE['purpose'],aI,aJ;if(aG?.['kind']==='inline')aI=aG['table'],aJ=aG['root'],aH=aG['description']??aE['purpose'];else{const aK=aG?.['kind']==='template'?aG['template_id']:aE['template_id']['startsWith']('tpl_')?aE['template_id']:undefined;if(aK!==undefined){const aL={'service_name':h+'_service',...C?{'repository_name':h+'_evidence'}:{},...a['fee_params'],...b,...aE['params'],...aG?.['kind']==='template'?aG['params']:{}},aM=fillGuardTemplate(aK,aL);!aM['ok']?j['push']({'code':'GUARD_TEMPLATE_PARAMS','detail':'guard\x20\x27'+aE['key']+'\x27\x20('+aK+'):\x20'+aM['error']}):(aI=aM['table'],aJ=aM['root']);}}aI!==undefined?(D['set'](aE['key'],{'stepId':aF,'description':aH,'table':aI,'root':aJ}),aE['step_id']=aF):(!aE['template_id']['startsWith']('tpl_')&&getTemplateById(aE['template_id'])===undefined&&!GUARD_DESIGN_PATTERNS['some'](aN=>aN['id']===aE['template_id'])&&j['push']({'code':'GUARD_PATTERN_UNKNOWN','detail':'guard\x20\x27'+aE['key']+'\x27\x20of\x20\x27'+h+'\x27\x20references\x20design\x20\x27'+aE['template_id']+'\x27,\x20which\x20exists\x20in\x20neither\x20the\x20Guard\x20design-pattern\x20catalog\x20nor\x20the\x20guard-template\x20registry\x20—\x20'+'no\x20resolution\x20path\x20can\x20ever\x20fill\x20it\x20(guide\x20confirm,\x20guard_resolutions\x20and\x20module\x20plumbing\x20all\x20key\x20off\x20real\x20ids).\x20'+'Keeping\x20it\x20as\x20a\x20pending\x20design\x20would\x20leave\x20its\x20bound\x20path\x20UNGUARDED\x20behind\x20a\x20plausible\x20pending\x20label\x20'+'(bs-mn-261022\x20TPL-01:\x20nine\x20such\x20specs\x20compiled\x20into\x20a\x20machine\x20with\x20no\x20guards\x20on\x20the\x20grant-lifecycle\x20forwards).\x20'+'Correct\x20the\x20template\x27s\x20guard\x20spec\x20id\x20to\x20a\x20known\x20pattern,\x20or\x20resolve\x20this\x20spec\x20explicitly\x20(guard_resolutions\x20with\x20kind\x20\x27inline\x27).'}),E['push'](aE));}const G=new Set(t['flatMap'](aN=>(aN['from']??[])['map'](aO=>typeof aO==='string'?undefined:aO['guard_key'])['filter'](aO=>typeof aO==='string')));for(const aN of u){typeof aN['guard_key']==='string'&&aN['recipient']==='guard_identifier'&&aN['recipient_key']===String(TASK_BINDING_SLOT)&&G['add'](aN['guard_key']);}const H=new Set();for(const aO of x){if(!G['has'](aO['key']))continue;const aP=D['get'](aO['key']);if(aP===undefined)continue;const aQ=aP['table']['some'](aR=>aR['identifier']===TASK_BINDING_SLOT);if(aQ)continue;D['set'](aO['key'],{...aP,'table':[...aP['table'],{'identifier':TASK_BINDING_SLOT,'b_submission':!![],'value_type':'Address','name':'task_binding\x20order\x20anchor\x20(protocol\x20slot\x20254;\x20written\x20by\x20order\x20creation)'}]}),H['add'](aO['key']);}const I=aR=>D['get'](aR)!==undefined&&refsOf({'table':D['get'](aR)['table'],'root':D['get'](aR)['root']})['has']('service'),J=aR=>{const aS=D['get'](aR),aT=z['get'](aR)?.['purpose'];return{'op':'create','id':aS['stepId'],'object':'guard','params':P({'description':aS['description'],'table':aS['table'],'root':aS['root']}),'notes':H['has'](aR)?(aT??'Guard')+'\x20[kernel:\x20protocol\x20slot\x20254\x20(task\x20binding)\x20auto-declared]':aT};};k['push']({'op':'create','id':'permission','object':'permission','params':{'name':h+'_permission'}});const K=a['arbitration_mode']!==undefined&&a['arbitration_mode']!=='none';K&&k['push']({'op':'create','id':'permission_arb','object':'permission','params':{'name':h+'_arb_permission'},'notes':'MUST\x20be\x20created\x20by\x20a\x20different\x20account\x20than\x20the\x20service\x20permission\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT=33):\x20dispute\x20neutrality.'});k['push']({'op':'create','id':'contact','object':'contact','params':{'name':h+'_contact'},'notes':'R8:\x20customer-service\x20channel;\x20mandatory\x20when\x20customer_required\x20is\x20set.'});const L=b['review_mode'],M=L==='review'||L==='review_reward'||L==='none'?L:undefined,N=M??a['review_mode']??'none',O=h+'_review_reward',Q=b['after_sales_mode'],R=Q==='return'||Q==='exchange'||Q==='warranty'||Q==='none'?Q:undefined,S=R??a['after_sales_mode']??'none',T=b['acceptance_mode'],U=T==='milestone'||T==='contest'||T==='bounty'||T==='agent'||T==='none'?T:undefined,V=U??a['acceptance_mode']??'none',W=V==='contest'||V==='bounty'||V==='agent',X=b['installment_mode'],Y=X==='deposit_balance'||X==='milestone_n'||X==='none'?X:undefined,Z=Y??a['installment_mode']??'none',a0=b['affiliate_mode'],a1=a0==='commission'||a0==='none'?a0:undefined,a2=a1??a['affiliate_mode']??'none',a3=b['crowdfunding_mode'],a4=a3==='threshold'||a3==='flexible'||a3==='none'?a3:undefined,a5=a4??a['crowdfunding_mode']??'none',a6=aR=>{const aS=new Set(),aT=aU=>{if(Array['isArray'](aU)){for(const aW of aU)aT(aW);return;}if(typeof aU!=='object'||aU===null)return;const aV=aU;if(typeof aV['type']==='string'&&aV['type']['startsWith']('query_reward_record')){const aX=aV['object'];if(aX!==undefined&&typeof aX['identifier']==='number')aS['add'](aX['identifier']);}for(const aY of Object['values'](aV))aT(aY);};return aT(aR),aS;},a7=N==='review_reward'?x['find'](aR=>aR['host']==='reward'):undefined;if(N==='review_reward'&&a7?.['step_id']!==undefined){const aR=D['get'](a7['key']);if(aR!==undefined){const aS=a6(aR['root']);D['set'](a7['key'],{...aR,'table':aR['table']['map'](aT=>{const aU=aT;if(aU['b_submission']===!![]||!aS['has'](aU['identifier']))return aT;return{...aU,'value':{'$late':{'by':'local_name','mark':O}}};})});}k['push']({'op':'create','id':'reward_review','object':'reward','params':P({'name':O,'description':'Review\x20incentive\x20pool\x20(sale-time\x20planned;\x20terms\x20disclosed\x20at\x20quote/buy):\x20claim\x20gated\x20by\x20guard\x20\x27'+a7['key']+'\x27.'}),'notes':'REVIEW-COMPONENT:\x20the\x20funded\x20reward\x20must\x20be\x20perceivable\x20by\x20the\x20buyer\x20BEFORE\x20ordering\x20—\x20the\x20full\x20terms\x20ride\x20the\x20quote/buy\x20surface\x20(REVIEW-COMPONENT-PLAN\x20§四).\x20'+'[ZR-08:\x20created\x20BEFORE\x20its\x20claim\x20guard\x20—\x20the\x20guard\x27s\x20Reward-address\x20row\x20freezes\x20at\x20creation\x20and\x20binds\x20this\x20pool\x20by\x20local\x20name]'});}const a8=[];for(const [aT]of D){I(aT)?a8['push'](aT):k['push'](J(aT));}if(C){const aU=Array['isArray'](b['repository_policies'])?b['repository_policies']['filter'](aX=>typeof aX==='object'&&aX!==null):[],aV=[...aU],aW=new Set(aU['map'](aX=>aX['name']));for(const aX of x){if(aX['host']!=='repository'||aX['step_id']===undefined)continue;const aY='host:\x22repository\x22\x20guard\x20\x27'+aX['key']+'\x27\x20(step\x20\x27'+aX['step_id']+'\x27)';if(aX['policy']===undefined){j['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':aY+'\x20declares\x20no\x20policy\x20on\x20the\x20guards[]\x20entry.\x20Its\x20Repository\x20policy\x20'+'(name\x20/\x20id_from\x20/\x20value_type)\x20is\x20business\x20data\x20the\x20kernel\x20must\x20not\x20fabricate,\x20'+'and\x20an\x20unbound\x20repository\x20guard\x20is\x20an\x20orphan\x20create\x20that\x20leaves\x20the\x20Repository\x20'+'open\x20to\x20any\x20writer.\x20Add\x20policy:{name,\x20id_from,\x20value_type}\x20to\x20the\x20spec,\x20or\x20bind\x20'+'the\x20guard\x20through\x20repository_policies\x20inputs\x20with\x20this\x20guard\x27s\x20own\x20write_guard\x20shape.'});continue;}if(I(aX['key'])){j['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':aY+'\x20refs\x20the\x20service,\x20so\x20it\x20is\x20created\x20AFTER\x20the\x20service\x20draft\x20—\x20but\x20the\x20'+'Repository\x20freezes\x20its\x20policies\x20at\x20creation,\x20which\x20happens\x20before.\x20Resolve\x20this\x20'+'guard\x20without\x20a\x20service\x20reference\x20(the\x20writers\x20are\x20asserted\x20by\x20identity,\x20not\x20by\x20'+'service\x20pin),\x20or\x20bind\x20the\x20policy\x20manually\x20via\x20repository_policies\x20inputs.'});continue;}const aZ=aX['policy']['name']??aX['key'],b0=(aX['policy']['id_from']??'signer')['toLowerCase'](),b1=aX['policy']['id_from_submission'],b2=aX['policy']['data_from_submission'];b1!==undefined&&(b0==='signer'||b0==='clock')&&j['push']({'code':'REPO_GUARD_SUBMISSION_ID_FORBIDDEN','detail':aY+'\x20declares\x20id_from_submission\x20'+b1+'\x20while\x20its\x20policy\x20id_from\x20is\x20'+('\x27'+b0+'\x27\x20—\x20the\x20row\x20id\x20is\x20AUTO-generated\x20from\x20the\x20'+b0+'\x20there,\x20and\x20a\x20')+'submission-derived\x20id\x20conflicts\x20with\x20that\x20routing\x20(the\x20chain\x20aborts\x20policy\x20creation\x20'+'with\x20E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN\x20=\x2023;\x20policies\x20freeze\x20at\x20Repository\x20'+'creation,\x20so\x20this\x20must\x20be\x20fixed\x20before\x20publish,\x20BK15-F13).\x20Drop\x20id_from_submission\x20'+'(keep\x20data_from_submission\x20—\x20the\x20value\x20leg\x20is\x20legal\x20under\x20signer\x20routing),\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22none\x22\x20(caller-supplied\x20row\x20key,\x20guarded\x20by\x20this\x20write_guard).'});{const b3=D['get'](aX['key']),b4=[['id_from_submission',b1],['data_from_submission',b2]];for(const [b5,b6]of b4){if(b6===undefined)continue;const b7=b3?.['table']['find'](b8=>b8['identifier']===b6);(b3===undefined||b7===undefined||b7['b_submission']!==!![])&&j['push']({'code':'REPO_GUARD_SUBMISSION_SLOT_UNKNOWN','detail':aY+'\x20declares\x20'+b5+'\x20'+b6+',\x20but\x20the\x20resolved\x20guard\x20table\x20has\x20'+'NO\x20b_submission=true\x20row\x20at\x20that\x20identifier\x20—\x20the\x20passport\x20builder\x20DROPS\x20'+'undeclared\x20slots,\x20so\x20this\x20pairing\x20leg\x20would\x20silently\x20derive\x20nothing\x20at\x20write\x20'+'time\x20(the\x20write\x20aborts\x20or\x20writes\x20caller-free\x20values,\x20BK15-F13).\x20Declare\x20a\x20'+('b_submission=true\x20table\x20row\x20at\x20identifier\x20'+b6+'\x20on\x20the\x20guard,\x20or\x20point\x20')+(b5+'\x20at\x20an\x20existing\x20submission\x20slot.')});}}if(aW['has'](aZ))continue;aV['push']({'name':aZ,'description':aX['policy']['description']??aX['purpose'],'write_guard':[{'guard':ref(aX['step_id']),...b1!==undefined?{'id_from_submission':b1}:{},...b2!==undefined?{'data_from_submission':b2}:{}}],'id_from':aX['policy']['id_from']??'signer','value_type':aX['policy']['value_type']??'String','write_once':aX['policy']['write_once']??![]});}k['push']({'op':'create','id':'repository','object':'repository','params':P({'name':h+'_evidence',...aV['length']>0x0?{'policies':aV}:{}}),'notes':'Evidence\x20rows\x20(tracking\x20hash,\x20receipts,\x20WTS\x20proofs).\x20[HOST-GRAPH-01:\x20created\x20after\x20wave-A\x20guards;\x20write_guard\x20policies\x20synthesized\x20from\x20resolved\x20host:\x22repository\x22\x20specs]'});}const a9=new Set(t['map'](b8=>b8['name'])),aa=[];for(const b8 of t){if(b8['from']===undefined||b8['from']['length']===0x0){j['push']({'code':'MACHINE_EDGES_MISSING','detail':'machine_shape\x20node\x20\x27'+b8['name']+'\x27\x20declares\x20no\x20\x27from\x27\x20edges.\x20Edges\x20are\x20data\x20'+'(REPORT\x20#10\x20A-2:\x20a\x20missing\x20paid->closed_cancel\x20edge\x20bricks\x20the\x20shop\x20at\x20publish).\x20'+'Annotate\x20the\x20node\x20with\x20from:\x20[...]\x20(use\x20prev:\x20\x22\x22\x20for\x20the\x20entry\x20edge).'});continue;}const b9=[],ba=new Map(),bb=new Map();for(const bd of b8['from']){const be=typeof bd==='string'?{'prev':bd}:bd;if(be['prev']!==''&&!a9['has'](be['prev'])){j['push']({'code':'EDGE_UNKNOWN_PREV','detail':'node\x20\x27'+b8['name']+'\x27\x20edge\x20prev\x20\x27'+be['prev']+'\x27\x20is\x20not\x20a\x20machine_shape\x20node'});continue;}const bf=be['operator']??b8['operator']??(be['prev']===''?'order_payer':'merchant'),bg=be['forward']??(be['prev']===''?'enter_'+b8['name']:be['prev']+'_to_'+b8['name']),bh={'name':bg,'weight':0x1,...bf==='order_payer'?{'namedOperator':''}:{'permissionIndex':be['permission_index']??i}};if(be['guard_key']!==undefined){const bl=z['get'](be['guard_key']);if(bl===undefined)j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20binds\x20unknown\x20guard_key\x20\x27'+be['guard_key']+'\x27'});else{for(const bm of bl['purpose']['matchAll'](/progress\.current\s*==\s*([a-z0-9_]+)/g)){const bn=bm[0x1];a9['has'](bn)&&bn!==be['prev']&&j['push']({'code':'FORWARD_GUARD_PINNED_TO_NON_PREV','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20pins\x20progress.current\x20==\x20\x27'+bn+'\x27,\x20but\x20a\x20'+('forward\x20guard\x20evaluates\x20BEFORE\x20the\x20advance\x20(progress.current\x20==\x20prev\x20\x27'+be['prev']+'\x27),\x20so\x20the\x20pin\x20')+'can\x20never\x20pass\x20—\x20dead\x20rail\x20(bkng\x20F22).\x20Keep\x20the\x20pin\x20on\x20the\x20allocator\x20row\x20(evaluated\x20at\x20alloc,\x20'+'current\x20=\x20the\x20reached\x20node);\x20put\x20only\x20time/identity\x20legs\x20on\x20the\x20forward.'});}(bl['template_id']==='pattern.identity_check_order_holder'||bl['template_id']==='tpl_forward_order_holder'||bl['template_id']==='tpl_forward_order_holder_or_time'||bl['template_id']==='tpl_time_window_upper_order_holder')&&bf!=='order_payer'&&j['push']({'code':'FORWARD_GUARD_IDENTITY_PERM_CONFLICT','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+'check\x20but\x20the\x20forward\x20rides\x20a\x20permissionIndex\x20rail\x20(merchant-side\x20slot).\x20The\x20identity\x20layer\x20'+'runs\x20BEFORE\x20the\x20guard,\x20and\x20the\x20two\x20signer\x20sets\x20are\x20disjoint\x20—\x20nobody\x20can\x20pass\x20both\x20(bkng\x20F23).\x20'+'Use\x20operator\x20\x27order_payer\x27\x20(namedOperator\x20\x22\x22\x20—\x20the\x20buyer\x20self-advance)\x20for\x20this\x20edge.'});{const bo=D['get'](bl['key']);if(bo!==undefined){const bp=bo['table']['some'](br=>br['identifier']===TASK_BINDING_SLOT),bq=offTaskSlotIdentityLegs(bo['root'])['filter'](br=>{if(!bp)return![];const bs=bo['table']['find'](bt=>bt['identifier']===br['identifier']);return bs!==undefined&&bs['b_submission']===!![];});for(const br of bq){j['push']({'code':'GUARD_IDENTITY_SLOT_NOT_TASKBOUND','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20reads\x20'+br['query']+'\x20off\x20free\x20'+('submission\x20slot\x20'+br['identifier']+'\x20—\x20hijackable\x20(rex-mn-261021\x20T10):\x20the\x20caller\x20fills\x20free\x20')+'slots,\x20so\x20an\x20attacker\x20submits\x20their\x20OWN\x20order\x20there\x20(signer\x20==\x20order.owner\x20passes\x20against\x20'+('their\x20own\x20order)\x20and\x20advances\x20the\x20VICTIM\x27s\x20order\x20carried\x20by\x20slot\x20'+TASK_BINDING_SLOT+';\x20with\x20')+'namedOperator\x20\x22\x22\x20the\x20permission\x20layer\x20passes\x20for\x20anyone\x20(progress.move:242-256),\x20so\x20this\x20'+('guard\x20is\x20the\x20only\x20identity\x20leg.\x20Anchor\x20the\x20'+br['query']+'\x20query\x20on\x20identifier\x20')+(TASK_BINDING_SLOT+'\x20(the\x20task-binding\x20order\x20anchor\x20—\x20the\x20order\x20the\x20forward\x20actually\x20mutates).')});}}}bl['step_id']!==undefined&&(I(bl['key'])?j['push']({'code':'GUARD_CYCLE','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20binds\x20guard\x20\x27'+bl['key']+'\x27\x20which\x20itself\x20'+'refs\x20the\x20service\x20(created\x20after\x20the\x20machine)\x20—\x20an\x20F-05\x20cycle.\x20Rebind\x20or\x20split\x20the\x20guard.'}):bh['guard']=ref(bl['step_id']));}}else{const bs=y['get'](bg);if(bs!==undefined){const bt=z['get'](bs);bt?.['step_id']!==undefined&&(bh['guard']=ref(bt['step_id']));}}const bi=ba['get'](be['prev']);bi!==undefined?bi['push'](bh):ba['set'](be['prev'],[bh]);const bj=bb['get'](be['prev']),bk=bf==='order_payer'?'namedOperator:':'permissionIndex:'+(be['permission_index']??i);bj!==undefined?bj['add'](bk):bb['set'](be['prev'],new Set([bk]));}const bc=b8['threshold']??0x0;for(const [bu,bv]of ba){bc>bv['length']&&j['push']({'code':'PAIR_THRESHOLD_UNREACHABLE','detail':'node\x20\x27'+b8['name']+'\x27\x20pair\x20from\x20\x27'+(bu===''?'(entry)':bu)+'\x27\x20declares\x20threshold\x20'+bc+'\x20'+('but\x20the\x20pair\x20merges\x20only\x20'+bv['length']+'\x20forward(s)\x20at\x20weight\x201\x20each\x20—\x20the\x20pair\x20can\x20never\x20')+'migrate\x20and\x20the\x20publish\x20aborts.\x20Add\x20one\x20distinct-operator\x20forward\x20per\x20required\x20signature,\x20or\x20'+'lower\x20the\x20threshold\x20to\x20the\x20forward\x20count.'});if(bc>=0x2){const bw=bb['get'](bu)?.['size']??0x0;bw<0x2&&j['push']({'code':'PAIR_THRESHOLD_SINGLE_OPERATOR','detail':'node\x20\x27'+b8['name']+'\x27\x20pair\x20from\x20\x27'+(bu===''?'(entry)':bu)+'\x27\x20declares\x20threshold\x20'+bc+'\x20'+'but\x20every\x20forward\x20rides\x20the\x20SAME\x20operator\x20rail\x20—\x20one\x20party\x20can\x20tap\x20all\x20of\x20them\x20and\x20the\x20'+'declared\x20dual\x20confirmation\x20silently\x20dissolves\x20(each\x20forward\x20locks\x20to\x20its\x20first\x20operator).\x20'+'Give\x20each\x20required\x20signature\x20its\x20own\x20rail\x20(e.g.\x20permission_index\x201001\x20+\x20operator\x20\x27order_payer\x27).'});}b9['push']({'prev_node':bu,'threshold':bc,'forwards':bv});}aa['push']({'name':b8['name'],...b8['semantic_role']!==undefined?{'role':b8['semantic_role']}:{},...b8['optional']===!![]?{'optional':!![]}:{},'pairs':b9});}k['push']({'op':'create','id':'machine','object':'machine','params':P({'name':h+'_machine','nodes':aa})}),k['push']({'op':'publish','id':'machine_publish','target':ref('machine'),'preflight':[{'check':'machine_publish','status':'pending'},{'check':'TASKBIND-01','status':'pending'}]});const ab=typeof b['currency']==='string'?b['currency']:'0x2::wow::WOW',ac=x['find'](bx=>bx['host']==='service'&&bx['key']==='buy');k['push']({'op':'create','id':'service','object':'service','params':P({'name':h+'_service','type_parameter':ab,'permission':ref('permission'),'machine':ref('machine'),'um':ref('contact'),'description':a['id']+'\x20—\x20compiled\x20by\x20composition/compile',...C?{'repositories':[ref('repository')]}:{},...ac?.['step_id']!==undefined?{'buy_guard':ref(ac['step_id'])}:{},...Array['isArray'](b['customer_required'])?{'customer_required':b['customer_required']}:{}}),'notes':'Draft\x20only:\x20machine/order_allocators\x20are\x20L1-frozen\x20at\x20publish;\x20allocators\x20attach\x20in\x20the\x20configure\x20step.'});for(const bx of a8)k['push'](J(bx));const ad=u['length']>0x0?u:[{'track':'settlement','recipient':a['allocator']['recipient']==='fixed'?'entity':a['allocator']['recipient'],'recipient_key':a['allocator']['recipient_key'],'mode':a['allocator']['mode'],'value':a['allocator']['mode']==='rate'?0x2710:a['allocator']['mode']==='surplus'?'0':undefined}],ae=[],af=new Map();for(const by of ad){if(by['guard_key']!==undefined){let bz=af['get'](by['guard_key']);bz===undefined&&(bz={'key':by['guard_key'],'rows':[]},af['set'](by['guard_key'],bz),ae['push'](bz)),bz['rows']['push'](by);}else ae['push']({'rows':[by]});}const ag=[];for(const bA of ae){const bB=[];let bC;for(const bE of bA['rows']){let bF=bE['value'];bF===undefined&&bE['value_from']!==undefined&&(bF=b[bE['value_from']]??a['fee_params'][bE['value_from']]);if(bF===undefined&&bE['mode']!=='surplus'){j['push']({'code':'ALLOCATOR_VALUE_MISSING','detail':'allocator\x20row\x20('+bE['track']+'/'+bE['recipient']+')\x20has\x20neither\x20value\x20nor\x20a\x20resolvable\x20value_from'});continue;}(bE['fix']!==undefined||bE['fix_from']!==undefined)&&j['push']({'code':'ALLOCATOR_FIX_UNSUPPORTED','detail':'allocator\x20row\x20('+bE['track']+'/'+bE['recipient']+')\x20declares\x20fix/fix_from\x20—\x20the\x20chain\x20has\x20no\x20holdback\x20'+'parameter:\x20fix\x20is\x20computed\x20on-chain\x20as\x20the\x20sum\x20of\x20the\x20Amount\x20legs\x20and\x20those\x20legs\x20are\x20PAID\x20'+'(allocation.move:399,540),\x20and\x20the\x20allocator-registration\x20call\x20surface\x20(guard,\x20sharing,\x20max)\x20has\x20no\x20fix\x20'+'argument,\x20so\x20this\x20value\x20never\x20reaches\x20the\x20chain.\x20To\x20keep\x20funds\x20in\x20the\x20pool,\x20do\x20not\x20distribute\x20them\x20'+'(a\x20separate\x20Allocation\x20object,\x20or\x20a\x20later\x20guard-gated\x20allocator);\x20to\x20combine\x20fixed\x20fees\x20with\x20a\x20'+'proportional\x20split,\x20use\x20explicit\x20Amount\x20legs\x20plus\x20Rate\x20legs\x20summing\x2010000.'});bC??=bE['note'];let bG;if(bE['recipient']==='entity')bG={'Entity':{'$late':{'by':'local_name','mark':bE['recipient_key']??'merchant'}}};else{if(bE['recipient']==='guard_identifier'){const bH=Number(bE['recipient_key']??0x0);bG={'GuardIdentifier':bH};const bI=bA['key']!==undefined?D['get'](bA['key']):undefined;if(bI!==undefined){const bJ=bI['table']['find'](bK=>bK['identifier']===bH);(bJ===undefined||bJ['b_submission']!==!![]||bJ['value_type']!=='Address')&&j['push']({'code':'GUARD_SLOT_UNKNOWN','detail':'allocator\x20leg\x20{GuardIdentifier:\x20'+bH+'}\x20on\x20guard\x20\x27'+bA['key']+'\x27\x20of\x20\x27'+h+'\x27:\x20the\x20bound\x20'+('Guard\x20table\x20has\x20no\x20slot\x20'+bH+'\x20Address\x20submission\x20row\x20(b_submission:\x20true).\x20On\x20chain\x20the\x20leg\x20')+('reads\x20slot\x20'+bH+'\x20as\x20its\x20payee\x20and\x20asserts\x20it\x20equals\x20the\x20paying\x20order\x20')+'(payment_info.for_object)\x20—\x20an\x20undeclared\x20or\x20STATIC\x20slot\x20aborts\x20at\x20alloc\x20time\x20with\x20code\x2015\x20'+'(ERECIPIENT_NOT_FOR_OBJECT,\x20allocation.move:500-520)\x20and\x20the\x20leg\x27s\x20funds\x20stranded\x20'+'(az3/abnb7\x20mainnet\x20261013:\x20static\x20GuardIdentifier\x20legs\x20bricked\x20every\x20refund\x20rail).\x20'+'Guard/allocators/forwards\x20are\x20all\x20publish-frozen.\x20Declare\x20'+('{identifier:\x20'+bH+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20in\x20the\x20Guard\x20table\x20')+'(templates\x20anchor\x20refund\x20rails\x20on\x20user\x20slot\x200\x20and\x20submit\x20the\x20Order\x20address\x20there).\x20Protocol\x20'+'slot\x20254\x20is\x20the\x20task-binding/once\x20slot:\x20naming\x20it\x20as\x20the\x20payee\x20arms\x20once-per-order,\x20so\x20a\x20'+'second\x20fire\x20aborts\x20E_ONCE_TRIGGERED\x20(16).'});}}else bG='Signer';}bB['push']({'who':bG,'sharing':String(bF??'0'),'mode':MODE_MAP[bE['mode']]});}if(bB['length']===0x0)continue;const bD=bA['key']!==undefined?z['get'](bA['key'])?.['step_id']:undefined;bA['key']!==undefined&&!z['has'](bA['key'])&&j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'allocator\x20row\x20('+bA['rows'][0x0]['track']+')\x20binds\x20unknown\x20guard_key\x20\x27'+bA['key']+'\x27'}),ag['push']({...bD!==undefined?{'guard':ref(bD)}:{},...bA['key']!==undefined?{'guard_key':bA['key']}:{},'track':bA['rows'][0x0]['track'],'sharing':bB,...bC!==undefined?{'note':bC}:{}});}const ah=ae['map'](bK=>{if(bK['key']===undefined)return undefined;const bL=D['get'](bK['key']);return{'key':bK['key'],'track':bK['rows'][0x0]['track'],'table':bL?.['table']??[],'root':bL?.['root']};})['filter'](bK=>bK!==undefined);if(ah['length']>0x0){const bK=verifyAllocatorRails(ah,t['map'](bN=>({'name':bN['name'],'semanticRole':bN['semantic_role']}))),bL=ae['map'](bN=>bN['key'])['filter'](bN=>bN!==undefined&&!D['has'](bN)),bM=bL['length']>0x0?'\x20UNRESOLVED\x20ALLOCATOR\x20GUARD\x20REFS\x20(likely\x20the\x20real\x20cause\x20—\x20these\x20guard_keys\x20match\x20no\x20resolved\x20guard,\x20e.g.\x20a\x20name\x20typo):\x20'+bL['join'](',\x20')+'.':'';for(const bN of bK){j['push']({'code':bN['code'],'detail':bN['detail']+bM});}}k['push']({'op':'configure','id':'service_allocators','target':ref('service'),'method':'order_allocators','params':P({'description':a['allocator']['description'],'threshold':Number(a['fee_params']['threshold']??a['fee_params']['monthly_rent_amount']??0x0)||0x0,'allocators':ag}),'requires':['machine_publish']});Array['isArray'](b['sales'])&&b['sales']['length']>0x0&&k['push']({'op':'configure','id':'service_sales','target':ref('service'),'method':'sales','params':{'op':'add','sales':b['sales']}});if(S!=='none'){const bO=a11a(S),bP=t['some'](bQ=>afterSalesRailNodeMatches(S,bQ['name']));!bP&&j['push']({'code':'AFTER_SALES_RAIL_MISSING','detail':'after_sales_mode\x20\x27'+S+'\x27\x20declares\x20a\x20buyer\x20after-sales\x20remedy,\x20but\x20machine_shape\x20has\x20no\x20'+('backing\x20rail\x20(no\x20node\x20matching\x20'+bO+').\x20Add\x20the\x20'+S+'\x20node\x20family\x20')+'(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20with\x20its\x20claimed_by\x20polarity\x20pair\x20—\x20refund\x20leg\x20'+'some==false,\x20merchant-recovery\x20leg\x20some==true\x20(INV-C1)\x20—\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20'+'(INV-C2,\x20TIME-ANCHOR-01),\x20and\x20de-conflicted\x20against\x20the\x20settlement\x20rail\x20so\x20the\x20two\x20never\x20both\x20pay\x20'+'(INV-C3,\x20DUAL-RAIL-01).\x20Or\x20set\x20after_sales_mode\x20\x27none\x27\x20if\x20this\x20shop\x20ships\x20no\x20such\x20remedy.'});}if(V!=='none'){W&&a['arbitration_mode']!=='third_party'&&j['push']({'code':'ACCEPTANCE_JUDGE_NOT_INDEPENDENT','detail':'acceptance_mode\x20\x27'+V+'\x27\x20is\x20a\x20judge-decided\x20acceptance\x20(a\x20third\x20party\x20rules\x20on\x20'+('release),\x20but\x20arbitration_mode\x20is\x20\x27'+(a['arbitration_mode']??'none')+'\x27,\x20not\x20\x27third_party\x27.\x20')+'The\x20party\x20owing\x20the\x20payout\x20must\x20not\x20also\x20decide\x20whether\x20it\x20is\x20owed\x20(merchant\x20self-adjudication,\x20'+'INV-A3).\x20Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20'+'(R2;\x20enforced\x20at\x20publish\x20by\x20controller-disjointness),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20if\x20the\x20'+'buyer\x20genuinely\x20self-adjudicates.'});const bQ=a['fee_params']['revision_rounds_max'],bR=typeof bQ==='number'||typeof bQ==='string'&&bQ['trim']()!==''&&/^\d+$/['test'](bQ['trim']());if(bR){const bS=x['some'](bT=>bT['host']==='repository'||/repository/i['test'](bT['template_id']));!bS&&j['push']({'code':'ACCEPTANCE_REVISION_UNBOUNDED','detail':'acceptance_mode\x20\x27'+V+'\x27\x20declares\x20a\x20bounded\x20revision\x20loop\x20'+('(fee_params.revision_rounds_max\x20=\x20'+String(bQ)+'),\x20but\x20no\x20counter-backed\x20Repository\x20')+'guard\x20exists.\x20progress.move\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20'+'so\x20a\x20finite\x20cap\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20(INV-A1).\x20Either\x20declare\x20'+'revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20revision\x20loop\x20is\x20then\x20genuinely\x20'+'unbounded)\x20or\x20mount\x20a\x20counter-backed\x20Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20'+'per-order\x20revision\x20tally\x20written\x20via\x20pattern.repository_write_authorization)\x20that\x20gates\x20the\x20'+'redelivery\x20forward\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}}if(Z!=='none'){const bT=/(due|owed|owing|unpaid|awaiting|pending)/i,bU=/(paid|captured|funded|settled)/i,bV=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,bW=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,bX=[];for(const c0 of t){const c1=c0['name'];for(const c2 of c0['from']??[]){typeof c2==='string'?bX['push']({'prev':c2,'target':c1}):bX['push']({'prev':c2['prev'],'target':c1,'guardKey':c2['guard_key']});}}const bY=bX['filter'](c3=>bT['test'](c3['prev'])&&bU['test'](c3['target'])&&(c3['guardKey']===undefined||c3['guardKey']['trim']()===''));bY['length']>0x0&&j['push']({'code':'INSTALLMENT_FUNDING_UNGATED','detail':'installment_mode\x20\x27'+Z+'\x27\x20captures\x20a\x20later\x20payment,\x20but\x20the\x20funding\x20forward(s)\x20'+bY['map'](c3=>'\x27'+c3['prev']+'\x27\x20→\x20\x27'+c3['target']+'\x27')['join'](',\x20')+'\x20carry\x20NO\x20guard_key.\x20A\x20bare\x20advance\x20records\x20the\x20balance\x20as\x20paid\x20WITHOUT\x20the\x20capture\x20landing\x20in\x20the\x20'+'Allocation\x20—\x20a\x20zero-value\x20advance\x20(INV-B1,\x20H4).\x20Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20'+'(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20allocation.balance\x20query\x201051\x20>=\x20the\x20'+'capture\x20amount).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20guards\x20read\x20the\x20'+'COMMITTED\x20pre-transaction\x20balance\x20—\x20funding\x20that\x20lands\x20in\x20the\x20SAME\x20PTB\x20(the\x20one-PTB\x20order_renew\x20'+'payment\x20half)\x20is\x20INVISIBLE\x20to\x20the\x20forward\x27s\x20guard,\x20so\x20a\x20balance-gated\x20capture\x20advanced\x20by\x20'+('order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20the\x20once\x20slot\x20')+'(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once)\x20so\x20a\x20replay\x20cannot\x20re-capture.'});const bZ=[];for(const c3 of t){if(!bV['test'](c3['name']))continue;const c4=bX['filter'](c6=>c6['prev']===c3['name']),c5=c4['some'](c6=>bW['test'](c6['target']));if(!c5)bZ['push'](c3['name']);}bZ['length']>0x0&&j['push']({'code':'INSTALLMENT_DEPOSIT_STRANDED','detail':'installment_mode\x20\x27'+Z+'\x27\x20holds\x20a\x20buyer\x20payment\x20at\x20state(s)\x20'+bZ['map'](c6=>'\x27'+c6+'\x27')['join'](',\x20')+'\x20with\x20NO\x20deposit-exit\x20rail\x20(no\x20outgoing\x20refund\x20/\x20cancel\x20/\x20forfeit\x20/\x20expire\x20edge).\x20There\x20is\x20no\x20on-chain\x20'+'obligation\x20to\x20pay\x20the\x20balance\x20(INV-B2,\x20H1),\x20so\x20a\x20buyer\x20who\x20walks\x20away\x20strands\x20the\x20already-paid\x20portion\x20'+'at\x20that\x20node\x20permanently\x20(Machine\x20+\x20Allocator\x20immutable,\x20IMMUT-001).\x20Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20'+'held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20funds\x20to\x20the\x20'+'order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'});}if(a2!=='none'){const c6=/(commission|affiliate|referr|attribut|partner_?payout)/i,c7=t['some'](cb=>c6['test'](cb['name'])),c8=ad['some'](cb=>c6['test'](cb['value_from']??'')||c6['test'](cb['recipient_key']??''));!c7&&!c8&&j['push']({'code':'AFFILIATE_RAIL_MISSING','detail':'affiliate_mode\x20\x27'+a2+'\x27\x20declares\x20a\x20referral/affiliate\x20commission\x20overlay,\x20but\x20machine_shape\x20has\x20no\x20'+'commission-family\x20node\x20and\x20the\x20allocator\x20has\x20no\x20commission\x20row\x20—\x20a\x20declared\x20partner\x20payout\x20with\x20no\x20rail\x20to\x20'+'walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time\x20(INV-D3).\x20Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20'+'dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20escrow\x20—\x20防抢池)\x20to\x20an\x20explicit\x20'+'non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.'});const c9=/(post-?lock|锁后|clawback|不可追偿|不可撤销|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,ca=(a['build_notes']??[])['some'](cb=>c9['test'](cb));!ca&&j['push']({'code':'AFFILIATE_CLAWBACK_UNDISCLOSED','detail':'affiliate_mode\x20\x27'+a2+'\x27\x20declares\x20a\x20commission\x20but\x20no\x20build_note\x20discloses\x20the\x20post-lock\x20no-clawback\x20'+'truth\x20(INV-D2).\x20SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20'+'so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20release\x20leaves\x20the\x20'+'affiliate\x20commission\x20unrecoverable.\x20Add\x20a\x20build_note\x20stating\x20this\x20honestly\x20(e.g.\x20\x22post-lock:\x20a\x20released\x20'+'affiliate\x20commission\x20is\x20unrecoverable\x20/\x20不可追偿\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20'+'partner\x20payout\x22).\x20L-04/D-5:\x20never\x20imply\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have.'});}if(a5!=='none'){const cb=/(releas|settle|funded|disburs|project)/i,cc=/(refund|missed|unmet|return|reimburse)/i,cd=t['some'](cq=>cb['test'](cq['name'])),ce=ad['some'](cq=>cq['track']==='settlement'&&(cb['test'](cq['guard_key']??'')||cb['test'](cq['recipient_key']??''))),cf=t['some'](cq=>cc['test'](cq['name'])),cg=ad['some'](cq=>cq['track']==='refund'||cc['test'](cq['guard_key']??''));!cd&&!ce&&j['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27'+a5+'\x27\x20declares\x20a\x20campaign\x20but\x20machine_shape\x20has\x20no\x20release/settlement\x20'+'node\x20and\x20the\x20allocator\x20has\x20no\x20settlement\x20row\x20to\x20the\x20project\x20Entity\x20—\x20the\x20escrowed\x20contributions\x20would\x20'+'strand\x20at\x20the\x20deadline\x20with\x20no\x20exit\x20rail\x20(INV-E1).\x20Add\x20a\x20release\x20leg\x20(Rate\x2010000\x20to\x20a\x20NON-EMPTY\x20project\x20'+'Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal)\x20and,\x20for\x20a\x20threshold\x20campaign,\x20its\x20D-BUG-2\x20'+'refund\x20twin.'});a5==='threshold'&&!cf&&!cg&&j['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20but\x20there\x20is\x20NO\x20refund-family\x20node/row\x20—\x20'+'a\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it\x20(INV-E1\x20/\x20D-BUG-2).\x20Add\x20the\x20refund\x20'+'leg\x20(per-contributor,\x20order-anchored\x20user\x20slot\x200\x20—\x20the\x20submitted\x20Order,\x20never\x20slot\x20254,\x20claimed_by\x20some==false)\x20as\x20the\x20mutually-exclusive\x20twin\x20of\x20the\x20'+'release\x20leg:\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.'});if(a5==='threshold'){const cq=x['some'](cr=>(cr['host']==='repository'||/repository_write/i['test'](cr['template_id']))&&(cr['policy']?.['id_from']??'')['toLowerCase']()==='signer');!cq&&j['push']({'code':'CROWDFUNDING_AGGREGATE_UNBOUND','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20no\x20host:\x22repository\x22\x20'+'write\x20policy\x20is\x20writer-bound\x20(id_from\x20signer)\x20—\x20the\x20sum-where\x20(1174)\x20total\x20would\x20be\x20forgeable,\x20so\x20'+'anyone\x20could\x20inflate\x20the\x20aggregate\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(INV-E2\x20/\x20R-X1-17:\x20existence-is-not-trust).\x20'+'Bind\x20the\x20contribution\x20Repository\x20write_guard\x20to\x20the\x20contributing\x20backer\x20'+'(pattern.repository_write_authorization,\x20id_from\x20signer,\x20an\x20identity\x20leaf\x20order.owner==Signer).'});}const ch=a['build_notes']??[],ci=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|只读求和|聚合值|独立重算)/i,cj=/(not investment|non-?investment|不构成投资|收益承诺|no (?:investment )?return|never promise)/i,ck=/(kyc|aml|securities|money-?transmission|regulatory|跨境|合规)/i,cl=/(no-?refund|non-?refundable|keep-?it-?all|不退|不提供退款|不设达标)/i,cm=ch['some'](cr=>cj['test'](cr)),cn=ch['some'](cr=>ck['test'](cr)),co=a5==='threshold'?ch['some'](cr=>ci['test'](cr)):!![],cp=a5==='flexible'?ch['some'](cr=>cl['test'](cr)):!![];if(!co||!cm||!cn||!cp){const cr=[!co?'the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)':null,!cm?'the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20不构成投资建议或收益承诺)':null,!cn?'the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)':null,!cp?'the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20不提供退款)':null]['filter'](Boolean);j['push']({'code':'CROWDFUNDING_DISCLOSURE_MISSING','detail':'crowdfunding_mode\x20\x27'+a5+'\x27\x20declares\x20a\x20campaign\x20but\x20no\x20build_note\x20carries:\x20'+cr['join'](';\x20')+'\x20'+'(INV-E3\x20/\x20L-04\x20/\x20L-01\x20/\x20L-05).\x20Add\x20these\x20as\x20honest\x20build_notes\x20—\x20never\x20present\x20an\x20attested\x20aggregate\x20as\x20a\x20'+'chain-verified\x20custody\x20proof,\x20never\x20imply\x20investment\x20returns,\x20and\x20flag\x20the\x20compliance\x20surface.'});}}if(N!=='none'){const cs=t['some'](cy=>/review/i['test'](cy['name']));N==='review'&&!cs&&j['push']({'code':'REVIEW_NODE_MISSING','detail':'review_mode\x20\x27'+N+'\x27\x20declares\x20the\x20buyer\x20review\x20reputation\x20rail,\x20but\x20machine_shape\x20has\x20no\x20'+'\x27reviewed\x27\x20node.\x20Add\x20a\x20buyer-advanced\x20review\x20node\x20(operator\x20order_payer)\x20with\x20an\x20EXIT\x20edge\x20back\x20to\x20the\x20'+'settlement\x20rail\x20(R-DEAD-END:\x20a\x20zero-exit\x20review\x20node\x20strands\x20the\x20escrow),\x20or\x20anchor\x20the\x20claim\x20on\x20the\x20'+'delivered\x20terminal\x20via\x20a\x20host:\x22reward\x22\x20guard\x20(review_mode\x20\x22review_reward\x22\x20variant).'});const ct=x['find'](cy=>cy['host']==='reward'),cu=t['find'](cy=>/review/i['test'](cy['name']))?.['name'];let cv,cw;if(cu!==undefined){const cy=[];for(const cB of t){for(const cC of cB['from']??[]){const cD=typeof cC==='string'?{'prev':cC,'guard_key':undefined}:cC;cy['push']({'prev':cD['prev'],'guard_key':cD['guard_key'],'target':cB['name']});}}const cz=cy['find'](cE=>cE['target']===cu&&cE['guard_key']!==undefined)?.['guard_key']??cy['find'](cE=>cE['prev']===cu&&cE['guard_key']!==undefined)?.['guard_key'],cA=cz!==undefined?z['get'](cz):undefined;cv=cA?.['step_id'],cw=cz;}cv===undefined&&ct?.['step_id']!==undefined&&(cv=ct['step_id'],cw=ct['key']);const cx=b['review_decision_enabled']===!![]&&N==='review_reward'&&ct?.['step_id']!==undefined&&cv!==undefined;cx&&k['push']({'op':'create','id':'guard_review_decision','object':'guard','params':P({'description':'Merchant\x20review-decision\x20write\x20credential:\x20only\x20the\x20service\x20provider\x20(permission\x20owner\x20or\x20admin)\x20may\x20write\x20U64\x20decision\x20rows\x20(row\x20id\x20=\x20order\x20address,\x20value\x20=\x20approved\x20payout)\x20under\x20the\x20review\x20repository\x27s\x20\x27review_decision\x27\x20policy.','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_approved'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},{'identifier':0x2,'b_submission':!![],'value_type':'Address','name':'service_permission'}],'root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'query','query':'service.permission','object':{'identifier':0x1},'parameters':[]},{'type':'identifier','identifier':0x2}]},{'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'permission.owner','object':{'identifier':0x2},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'permission.admin\x20has','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'}]}]}]}}),'notes':'REVIEW-DECISION\x20write\x20credential\x20(allocator\x20dynamic-permission\x20shape,\x20service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20decision\x20write\x20itself:\x20repository.data_add\x20'+'{name:\x27review_decision\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<approved\x20payout\x20U64>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order\x20and\x20the\x20permission.'});if(cv!==undefined){const cE=b['buyer_review_enabled']===!![];k['push']({'op':'create','id':'repository_review','object':'repository','params':P({'name':h+'_review','description':'Structured\x20buyer\x20reputation\x20rows\x20(AR-1:\x20emitted\x20by\x20the\x20build\x20plan\x20—\x20no\x20manual\x20setup).','policies':[{'name':'review','description':'One\x20immutable\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address\x20—\x20F09\x20yfd-ln-261024:\x20a\x20repeat\x20buyer\x20must\x20be\x20able\x20to\x20review\x20every\x20order;\x20the\x20old\x20Signer-keyed\x20row\x20made\x20order\x20#2\x20unwritable).\x20Write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a).\x20Writes\x20require\x20the\x20review\x20credential\x20(guard\x20key\x20\x27'+cw+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','write_guard':[{'guard':ref(cv)}],'id_from':'none','value_type':'String','write_once':!![]},{'name':'rating','description':'Order-keyed\x20numeric\x20rating\x20(F-62):\x20one\x20U64\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20stars,\x20e.g.\x201..5;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20Writes\x20require\x20the\x20same\x20review\x20credential\x20as\x20the\x20\x27review\x27\x20text\x20policy\x20—\x20a\x20verified\x20completed-order\x20buyer.\x20This\x20—\x20not\x20the\x20\x27review\x27\x20text\x20row\x20(same\x20order\x20key,\x20String\x20payload)\x20—\x20is\x20the\x20row\x20a\x20reward\x20good-review\x20leg\x20must\x20query\x20(query\x20repository.data:\x20the\x20policy-name\x20row\x20+\x20the\x20order-address\x20identifier\x20row,\x20compared\x20against\x20the\x20rating\x20floor).\x20The\x20text\x20row\x20is\x20display;\x20this\x20row\x20is\x20payout\x20authority.','write_guard':[{'guard':ref(cv)}],'id_from':'none','value_type':'U64','write_once':!![]},...cE?[{'name':'buyer_review','description':'Merchant-side\x20structured\x20feedback\x20on\x20the\x20order/buyer\x20(D-R7\x20bidirectional\x20reputation,\x20opt-in).\x20One\x20immutable\x20row\x20per\x20writer\x20(id_from=Signer;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20NO\x20write\x20guard\x20by\x20design:\x20merchant\x20authority\x20is\x20verified\x20at\x20READ\x20time\x20(the\x20writer\x20must\x20control\x20the\x20order\x27s\x20service\x20—\x20graph\x20ControlIndex).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','id_from':'signer','value_type':'String','write_once':!![]}]:[],...cx?[{'name':'review_decision','description':'Merchant\x20approval\x20ledger\x20for\x20the\x20review\x20bounty\x20(professional\x20form):\x20one\x20U64\x20row\x20per\x20order\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20approved\x20payout\x20in\x20smallest\x20units).\x20A\x20row\x20whose\x20value\x20>=\x20the\x20promised\x20payout\x20IS\x20the\x20approval\x20the\x20claim\x20guard\x27s\x20decision\x20leg\x20reads\x20(tpl_repository_review_decision_gate).\x20Writes\x20REQUIRE\x20the\x20merchant\x20decision\x20credential\x20(guard\x20step\x20\x27guard_review_decision\x27);\x20buyers\x20hold\x20no\x20write\x20path.','write_guard':[{'guard':ref('guard_review_decision')}],'id_from':'none','value_type':'U64'}]:[]]}),'notes':'REVIEW-COMPONENT\x20AR-1:\x20the\x20review\x20TEXT\x20still\x20rides\x20the\x20forward\x20message\x20(D-R1\x20dual\x20carrier);\x20this\x20repository\x20carries\x20ONLY\x20the\x20structured\x20row.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time,\x20both\x20ORDER-KEYED\x20(F09):\x20\x27review\x27\x20(text\x20JSON,\x20id\x20=\x20the\x20ORDER\x20address)\x20AND\x20\x27rating\x27\x20(U64\x20stars,\x20id\x20=\x20the\x20ORDER\x20address\x20—\x20repository.data_add\x20{name:\x27rating\x27,\x20items:[{data:[{id:<order\x20address>,\x20data:<stars>}]}]},\x20same\x20passport\x20as\x20the\x20forward).\x20The\x20\x27rating\x27\x20row\x20is\x20what\x20a\x20reward\x20good-review\x20leg\x20reads\x20(F-62):\x20a\x20good-review\x20bounty\x20claim\x20guard\x20must\x20query\x20this\x20order-keyed\x20U64\x20row,\x20never\x20the\x20text\x20row.\x20Buyers\x20resolve\x20this\x20object\x20by\x20name\x20(workspace/onchain_objects)\x20—\x20never\x20guess\x20an\x20address.'+(cx?'\x20[review_decision\x20policy\x20frozen\x20AFTER\x20its\x20write\x20credential\x20—\x20the\x20guard\x20exists\x20before\x20this\x20create\x20(HOST-GRAPH-01\x20discipline).]':'')}),k['push']({'op':'configure','id':'service_review_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository_review')]}),'requires':['service','repository_review']});}if(N==='review_reward'){const cF=ct;if(cF===undefined||cF['step_id']===undefined)j['push']({'code':'REVIEW_REWARD_GUARD_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20promises\x20a\x20claim\x20reward,\x20but\x20no\x20RESOLVED\x20host:\x22reward\x22\x20guard\x20spec\x20'+'exists\x20to\x20gate\x20the\x20claim.\x20Mount\x20a\x20reward\x20claim\x20guard\x20(e.g.\x20pattern.progress_state_check\x20anchored\x20'+'on\x20the\x20review\x20node\x20or\x20the\x20delivered\x20terminal\x20+\x20review\x20evidence\x20hash)\x20and\x20keep\x20it\x20resolvable\x20—\x20'+'an\x20unguarded\x20incentive\x20promise\x20must\x20not\x20publish\x20(INV-4).\x20The\x20root\x20must\x20also\x20carry\x20the\x20BKN-P2\x20'+'positive-amount\x20leg\x20(order.amount\x20>=\x201)\x20so\x20zero-total\x20orders\x20can\x20never\x20claim.'});else{const cG=b['reward_funding'],cH=D['get'](cF['key']);cH!==undefined&&!rootHasRewardRecordGate(cH['root'])&&j['push']({'code':'REVIEW_REWARD_UNARMED','detail':'review_reward\x20claim\x20guard\x20\x27'+cF['key']+'\x27\x20carries\x20no\x20record-gate:\x20Reward.claim\x20has\x20no\x20order\x20binding\x20of\x20its\x20own\x20'+'(OFN-C1),\x20so\x20a\x20funded\x20pool\x20behind\x20this\x20guard\x20is\x20a\x20replay-drain\x20target.\x20'+SV2_UNARMED_PRESCRIPTION+'\x20—\x20wrapped\x20in\x20'+'logic_and\x20with\x20the\x20identity\x20leg\x20(Signer\x20==\x20order.owner),\x20the\x20BKN-P2\x20positive-amount\x20'+'leg\x20(order.amount\x20>=\x201\x20—\x20zero-total\x20orders\x20must\x20never\x20claim)\x20and\x20the\x20existing\x20checks\x20'+'(see\x20tpl_reward_one_time_claim\x20v55\x20notes;\x20guard-risk\x20R-X1-14\x20audits\x20the\x20built\x20guard).\x20'+'Professional\x20approval\x20form\x20(F10\x20opt-in):\x20set\x20review_decision_enabled=true\x20to\x20have\x20this\x20'+'plan\x20emit\x20the\x20decision\x20channel\x20(guard\x20step\x20\x27guard_review_decision\x27\x20+\x20the\x20repository\x27s\x20'+'\x27review_decision\x27\x20policy),\x20then\x20compose\x20the\x20decision\x20leg\x20from\x20'+'tpl_repository_review_decision_gate\x20into\x20the\x20root\x20(find_where\x20over\x20\x27review_decision\x27\x20'+'with\x20vec_contains_address\x20pinning\x20the\x20submitted\x20order)\x20so\x20the\x20bounty\x20pays\x20only\x20'+'merchant-approved\x20orders.\x20'+'Until\x20armed,\x20do\x20not\x20fund\x20the\x20pool.'});let cI;if(cH!==undefined&&rootHasRewardRecordGate(cH['root']))for(const cJ of cH['table']){const cK=cJ;if(cK['b_submission']===!![]&&String(cK['value_type']??'')['toLowerCase']()==='address'&&(String(cK['object_type']??'')==='Order'||/order/i['test'](String(cK['name']??'')))){cI=cK['identifier'];break;}}k['push']({'op':'configure','id':'reward_review_guard_add','target':ref('reward_review'),'method':'guard_add','params':P({'guard':ref(cF['step_id']),'recipient':{'Signer':'signer'},...cI!==undefined?{'store_from_id':cI}:{}}),'requires':['reward_review'],'notes':'RECIPIENT\x20(crs-mn-261015\x20F-12):\x20recipient\x20is\x20pinned\x20to\x20{Signer:\x27signer\x27}\x20—\x20the\x20claim\x20entry\x20'+'requires\x20recipient\x20==\x20the\x20transaction\x20sender\x20(E_CLAIM_RECIPIENT_NOT_SIGNER\x20otherwise);\x20a\x20GuardIdentifier\x20recipient\x20'+'resolves\x20to\x20the\x20submitted\x20Order\x20and\x20can\x20never\x20be\x20paid.\x20Fill\x20amount\x20=\x20the\x20per-claim\x20bounty\x20'+'(smallest\x20units)\x20when\x20executing.'+(cI!==undefined?'\x20SV-2\x20entry\x20stamp:\x20store_from_id\x20pins\x20the\x20per-order\x20stamp\x20slot\x20(the\x20submitted\x20Order\x20'+'address)\x20so\x20claim\x20records\x20key\x20per\x20order\x20—\x20once\x20per\x20buyer\x20per\x20order\x20(azx7-mn-261014\x20T8).':'')}),k['push']({'op':'configure','id':'service_rewards','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_review')]}),'requires':['service']}),typeof cG==='string'||typeof cG==='number'?k['push']({'op':'configure','id':'reward_review_coin_add','target':ref('reward_review'),'method':'coin_add','params':{'coin':String(cG)},'requires':['reward_review']}):j['push']({'code':'REVIEW_REWARD_UNFUNDED','detail':'review_mode\x20\x27review_reward\x27\x20without\x20a\x20\x27reward_funding\x27\x20input\x20(INV-4\x20R-REWARD-FUNDED):\x20the\x20incentive\x20'+'is\x20a\x20marketing\x20promise\x20that\x20must\x20be\x20FUNDED\x20when\x20the\x20Service\x20is\x20built\x20(sale-time\x20planning\x20—\x20pool\x20>=\x20'+'expected\x20orders\x20x\x20per-order\x20reward,\x20benchmark\x20fee_param\x20review_reward_pool).\x20Pass\x20reward_funding\x20'+'(smallest-unit\x20string)\x20to\x20fund\x20the\x20Reward\x20object,\x20or\x20drop\x20to\x20review_mode\x20\x22review\x22.'});}}}if(K){k['push']({'op':'create','id':'arbitration','object':'arbitration','params':P({'name':h+'_arbitration','permission':ref('permission_arb'),'type_parameter':ab}),'notes':'Independent\x20venue\x20(R2).\x20New\x20arbitrations\x20default\x20bPaused=true\x20—\x20unpause\x20is\x20a\x20separate\x20operator\x20step.'}),k['push']({'op':'configure','id':'service_arbitrations','target':ref('service'),'method':'arbitrations','params':P({'op':'add','objects':[ref('arbitration')]})});const cL=b['compensation_fund'];(typeof cL==='string'||typeof cL==='number')&&k['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':String(cL)}});}k['push']({'op':'publish','id':'service_publish','target':ref('service'),'preflight':[{'check':'service_publish','status':'pending'},{'check':'FUND-EXIT-01','status':'pending'},{'check':'PLAN-ALLOC-01','status':'pending'},{'check':'TASKBIND-02','status':'pending'}]});const ai=new Set(u['map'](cM=>cM['guard_key'])['filter'](cM=>typeof cM==='string')),aj=/^0x[0-9a-fA-F]{20,64}$/,ak=cM=>{const cN=D['get'](cM);if(cN===undefined)return undefined;for(const cO of cN['table']){const cP=cO;if(cP['b_submission']===!![]||cP['value_type']!=='Address')continue;const cQ=cP['value'];if(typeof cQ==='string'&&aj['test'](cQ))return String(cP['identifier']??'?');}return undefined;};for(const cM of D['keys']()){if(!G['has'](cM)&&!ai['has'](cM))continue;const cN=ak(cM);cN!==undefined&&j['push']({'code':'GUARD_FOREIGN_SERVICE','detail':'guard\x20\x27'+cM+'\x27\x20pins\x20an\x20on-chain\x20address\x20literal\x20(table\x20slot\x20'+cN+')\x20while\x20bound\x20into\x20this\x20build.\x20'+'The\x20plan\x27s\x20Service\x20is\x20created\x20BY\x20this\x20plan\x20and\x20cannot\x20equal\x20a\x20pre-existing\x20address,\x20so\x20the\x20pin\x20names\x20a\x20foreign\x20or\x20'+'stale\x20object:\x20each\x20object\x20is\x20well-formed\x20alone,\x20but\x20the\x20cross-object\x20identity\x20assert\x20aborts\x20every\x20guarded\x20forward\x20'+'(klook\x20B11\x20class),\x20and\x20Guard\x20+\x20machine\x20are\x20both\x20create/publish-frozen\x20—\x20unrepairable.\x20'+'Bind\x20by\x20plan\x20reference\x20({\x22$ref\x22:\x22service\x22})\x20or\x20by\x20the\x20P16\x20circular\x20service\x20NAME\x20instead.'});}const al=E['flatMap'](cO=>{const cP=ai['has'](cO['key'])?'allocator':G['has'](cO['key'])?'machine_edge':cO['host']==='service'&&cO['key']==='buy'?'service_buy':undefined;return cP?[{'key':cO['key'],'template_id':cO['template_id'],'host':cO['host'],'site':cP,'purpose':cO['purpose']}]:[];});return{'plan':{'version':0x1,'intent':d['intent']??'compile\x20'+a['id'],'templateId':a['id'],'inputs':b,'steps':k,...al['length']>0x0?{'pending_guards':al}:{}},'guardSpecs':x,'unresolved':E,'blockers':j,'omitted':[...w]};}
1
+ import{fillGuardTemplate,getTemplateById}from'../knowledge/guard-templates.js';import{GUARD_DESIGN_PATTERNS}from'../knowledge/guard-design-patterns.js';import{SV2_UNARMED_PRESCRIPTION,TWO_TX_RENEW_RECIPE}from'../knowledge/protocol-facts.js';import{verifyAllocatorRails}from'../knowledge/allocator-rail-verifier.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{rootHasRewardRecordGate,afterSalesRailRegex as a12a,afterSalesRailNodeMatches}from'../knowledge/template-scanner.js';import{refsOf}from'./plan.js';const P=a=>a;function toByteVector(a){if(Array['isArray'](a))return a['every'](c=>typeof c==='number'&&Number['isInteger'](c)&&c>=0x0&&c<=0xff)?a:undefined;if(typeof a==='string'&&a['length']>0x0)return Array['from'](new TextEncoder()['encode'](a));return undefined;}function offTaskSlotIdentityLegs(a){const b=new Set(['order.owner','order.agent\x20has']),c=new Set(),d=[],e=f=>{if(f===null||typeof f!=='object')return;const g=f;if(g['type']==='logic_equal'&&Array['isArray'](g['nodes'])){const i=g['nodes']['filter'](j=>j!==null&&typeof j==='object'&&j['type']==='identifier'&&typeof j['identifier']==='number');if(i['some'](j=>j['identifier']===TASK_BINDING_SLOT)){for(const j of i)c['add'](j['identifier']);}}const h=g['object'];if(typeof g['query']==='string'&&b['has'](g['query'])&&h!==null&&typeof h==='object'&&typeof h['identifier']==='number'){const l=h['identifier'];if(l!==TASK_BINDING_SLOT)d['push']({'query':g['query'],'identifier':l});}if(Array['isArray'](g['nodes'])){for(const m of g['nodes'])e(m);}if(g['node']!==undefined&&typeof g['node']==='object')e(g['node']);};return e(a),d['filter'](f=>!c['has'](f['identifier']));}export function normalizeInlineGuardTable(a,b){const c=b+'_service',d=f=>f['replace'](/\//g,'_'),e=d(c);return a['map'](f=>{if(f===null||typeof f!=='object'||Array['isArray'](f))return f;const g={...f};typeof g['value']==='string'&&d(g['value'])===e&&(g['value']=ref('service'));if(g['b_submission']===undefined)g['b_submission']=![];return g;});}function safeId(a){return a['replace'](/[^a-zA-Z0-9_]/g,'_');}function ref(a){return{'$ref':a};}const MODE_MAP={'amount':'Amount','rate':'Rate','surplus':'Surplus'};export function compileTemplate(a,b,d={}){const h=d['nameBase']??a['id']['replace'](/\//g,'_'),i=d['merchantPermissionIndex']??0x3e8,j=[],k=[],l=new Set();for(const am of a['conditional_guards']??[]){const an=b[am['param']]??a['fee_params'][am['param']];if(an!==am['emit_value'])l['add'](am['guard_key']);}const p=new Map();for(const ao of a['conditional_guards']??[]){p['set'](ao['param'],(p['get'](ao['param'])??0x0)+0x1);}const q=new Set((a['conditional_guards']??[])['filter'](ap=>(p['get'](ap['param'])??0x0)>0x1)['map'](ap=>ap['guard_key'])),s=new Set([...l]['filter'](ap=>q['has'](ap))),t=s['size']>0x0?a['machine_shape']['map'](ap=>({...ap,'from':(ap['from']??[])['filter'](aq=>typeof aq==='string'||aq['guard_key']===undefined||!s['has'](aq['guard_key']))})):a['machine_shape'],u=s['size']>0x0?(a['allocator']['rows']??[])['filter'](ap=>ap['guard_key']===undefined||!s['has'](ap['guard_key'])):a['allocator']['rows']??[],v=[];for(const [ap,aq]of Object['entries'](d['guardResolutions']??{})){if(aq?.['kind']==='omit')v['push'](ap);}const w=new Set();if(v['length']>0x0){const ar=new Set(t['flatMap'](at=>(at['from']??[])['map'](au=>typeof au==='string'?undefined:au['guard_key'])['filter'](au=>typeof au==='string'))),as=new Set(u['map'](at=>at['guard_key'])['filter'](at=>typeof at==='string'));for(const at of v){const au=a['guards']['find']((aw,ax)=>(aw['key']??aw['template_id']+'#'+ax)===at);if(au===undefined)continue;const av=[];if(ar['has'](at))av['push']('a\x20machine\x20forward\x20edge\x20(guard_key)');if(as['has'](at))av['push']('an\x20allocator\x20rail\x20row\x20(guard_key)');if(au['policy']!==undefined)av['push']('a\x20Repository\x20write-policy\x20credential\x20(policy)');if(au['host']==='service'&&at==='buy')av['push']('the\x20Service\x20buy\x20gate\x20(buy_guard)');av['length']>0x0?j['push']({'code':'GUARD_OMIT_UNSUPPORTED','detail':'guard_resolutions[\x27'+at+'\x27]\x20=\x20{kind:\x27omit\x27}\x20refused:\x20this\x20design\x20is\x20bound\x20to\x20'+av['join']('\x20and\x20')+'\x20—\x20'+'omitting\x20it\x20would\x20orphan\x20the\x20binding\x20(open\x20rail\x20/\x20open\x20write\x20/\x20ungated\x20purchase).\x20'+'Fold\x20the\x20design\x27s\x20intent\x20into\x20the\x20bound\x20site\x20instead,\x20or\x20keep\x20the\x20guard\x20resolved.'}):w['add'](at);}}const x=a['guards']['map']((aw,ax)=>({'key':aw['key']??aw['template_id']+'#'+ax,'template_id':aw['template_id'],'host':aw['host'],'purpose':aw['purpose'],'policy':aw['policy'],'params':aw['params']}))['filter'](aw=>!l['has'](aw['key'])&&!w['has'](aw['key'])),y=new Map();{const aw=new Set(x['map'](ax=>ax['key']));for(const ax of t){for(const ay of ax['from']??[]){const az=typeof ay==='string'?{'prev':ay}:ay,aA=az['operator']??ax['operator']??(az['prev']===''?'order_payer':'merchant');if(aA!=='order_payer'||az['guard_key']!==undefined)continue;const aB=az['forward']??(az['prev']===''?'enter_'+ax['name']:az['prev']+'_to_'+ax['name']);if(y['has'](aB))continue;let aC='order_holder_'+aB;while(aw['has'](aC))aC=aC+'_x';aw['add'](aC),y['set'](aB,aC),x['push']({'key':aC,'template_id':'tpl_forward_order_holder','host':'machine','purpose':'F05\x20kernel-injected\x20order-holder\x20identity\x20binding\x20for\x20the\x20buyer-exclusive\x20forward\x20'+('\x27'+aB+'\x27\x20(edge\x20\x27'+az['prev']+'\x27->\x27'+ax['name']+'\x27):\x20namedOperator\x20\x22\x22\x20passes\x20for\x20')+'anyone\x20at\x20the\x20permission\x20layer\x20(progress.move:242-256),\x20so\x20without\x20this\x20guard\x20the\x20'+'buyer\x20rail\x20is\x20advanceable\x20by\x20ANY\x20passport\x20holder\x20attached\x20to\x20the\x20order\x20—\x20takeover\x20'+'risk.\x20Declare\x20an\x20explicit\x20order-holder\x20guard_key\x20on\x20the\x20edge\x20to\x20replace\x20this\x20'+'auto\x20key\x20with\x20a\x20named\x20credential.'});}}}const z=new Map(x['map'](aD=>[aD['key'],aD])),A=new Set(['wip_provenance','subscription_with_proof']),B=Array['isArray'](b['adopted_module_ids'])?b['adopted_module_ids']['filter'](aD=>typeof aD==='string'):[],C=x['some'](aD=>aD['host']==='repository'||aD['template_id']==='pattern.repository_data_check'||aD['template_id']==='pattern.repository_write_authorization'||aD['template_id']==='tpl_repository_row_present'||aD['template_id']==='tpl_repository_row_equals_order_field')||B['some'](aD=>A['has'](aD)),D=new Map(),E=[],F=x['map'](aD=>aD['key']);for(const aD of Object['keys'](d['guardResolutions']??{})){if(w['has'](aD))continue;!z['has'](aD)&&j['push']({'code':'GUARD_RESOLUTION_UNKNOWN','detail':'guard_resolutions\x20key\x20\x27'+aD+'\x27\x20matches\x20no\x20guard\x20spec\x20key\x20declared\x20by\x20\x27'+h+'\x27.\x20'+('Legal\x20keys:\x20'+(F['length']>0x0?F['join'](',\x20'):'(none\x20—\x20this\x20template\x20declares\x20no\x20keyed\x20guards)')+'.\x20')+'An\x20unknown\x20key\x20was\x20previously\x20dropped\x20silently,\x20leaving\x20the\x20intended\x20guard\x20pending\x20while\x20the\x20build\x20looked\x20resolved.'});}for(const aE of x){const aF='guard_'+safeId(aE['key']),aG=d['guardResolutions']?.[aE['key']];let aH=aE['purpose'],aI,aJ;if(aG?.['kind']==='inline')aI=normalizeInlineGuardTable(aG['table'],h),aJ=aG['root'],aH=aG['description']??aE['purpose'];else{const aK=aG?.['kind']==='template'?aG['template_id']:aE['template_id']['startsWith']('tpl_')?aE['template_id']:undefined;if(aK!==undefined){const aL={'service_name':h+'_service',...C?{'repository_name':h+'_evidence'}:{},...a['fee_params'],...b,...aE['params'],...aG?.['kind']==='template'?aG['params']:{}},aM=fillGuardTemplate(aK,aL);!aM['ok']?j['push']({'code':'GUARD_TEMPLATE_PARAMS','detail':'guard\x20\x27'+aE['key']+'\x27\x20('+aK+'):\x20'+aM['error']}):(aI=aM['table'],aJ=aM['root']);}}aI!==undefined?(D['set'](aE['key'],{'stepId':aF,'description':aH,'table':aI,'root':aJ}),aE['step_id']=aF):(!aE['template_id']['startsWith']('tpl_')&&getTemplateById(aE['template_id'])===undefined&&!GUARD_DESIGN_PATTERNS['some'](aN=>aN['id']===aE['template_id'])&&j['push']({'code':'GUARD_PATTERN_UNKNOWN','detail':'guard\x20\x27'+aE['key']+'\x27\x20of\x20\x27'+h+'\x27\x20references\x20design\x20\x27'+aE['template_id']+'\x27,\x20which\x20exists\x20in\x20neither\x20the\x20Guard\x20design-pattern\x20catalog\x20nor\x20the\x20guard-template\x20registry\x20—\x20'+'no\x20resolution\x20path\x20can\x20ever\x20fill\x20it\x20(guide\x20confirm,\x20guard_resolutions\x20and\x20module\x20plumbing\x20all\x20key\x20off\x20real\x20ids).\x20'+'Keeping\x20it\x20as\x20a\x20pending\x20design\x20would\x20leave\x20its\x20bound\x20path\x20UNGUARDED\x20behind\x20a\x20plausible\x20pending\x20label\x20'+'(bs-mn-261022\x20TPL-01:\x20nine\x20such\x20specs\x20compiled\x20into\x20a\x20machine\x20with\x20no\x20guards\x20on\x20the\x20grant-lifecycle\x20forwards).\x20'+'Correct\x20the\x20template\x27s\x20guard\x20spec\x20id\x20to\x20a\x20known\x20pattern,\x20or\x20resolve\x20this\x20spec\x20explicitly\x20(guard_resolutions\x20with\x20kind\x20\x27inline\x27).'}),E['push'](aE));}const G=new Set(t['flatMap'](aN=>(aN['from']??[])['map'](aO=>typeof aO==='string'?undefined:aO['guard_key'])['filter'](aO=>typeof aO==='string')));for(const aN of u){typeof aN['guard_key']==='string'&&aN['recipient']==='guard_identifier'&&aN['recipient_key']===String(TASK_BINDING_SLOT)&&G['add'](aN['guard_key']);}const H=new Set();for(const aO of x){if(!G['has'](aO['key']))continue;const aP=D['get'](aO['key']);if(aP===undefined)continue;const aQ=aP['table']['some'](aR=>aR['identifier']===TASK_BINDING_SLOT);if(aQ)continue;D['set'](aO['key'],{...aP,'table':[...aP['table'],{'identifier':TASK_BINDING_SLOT,'b_submission':!![],'value_type':'Address','name':'task_binding\x20order\x20anchor\x20(protocol\x20slot\x20254;\x20written\x20by\x20order\x20creation)'}]}),H['add'](aO['key']);}const I=aR=>D['get'](aR)!==undefined&&refsOf({'table':D['get'](aR)['table'],'root':D['get'](aR)['root']})['has']('service'),J=aR=>{const aS=D['get'](aR),aT=z['get'](aR)?.['purpose'];return{'op':'create','id':aS['stepId'],'object':'guard','params':P({'description':aS['description'],'table':aS['table'],'root':aS['root']}),'notes':H['has'](aR)?(aT??'Guard')+'\x20[kernel:\x20protocol\x20slot\x20254\x20(task\x20binding)\x20auto-declared]':aT};};k['push']({'op':'create','id':'permission','object':'permission','params':{'name':h+'_permission'}});const K=a['arbitration_mode']!==undefined&&a['arbitration_mode']!=='none';K&&k['push']({'op':'create','id':'permission_arb','object':'permission','params':{'name':h+'_arb_permission'},'notes':'MUST\x20be\x20created\x20by\x20a\x20different\x20account\x20than\x20the\x20service\x20permission\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT=33):\x20dispute\x20neutrality.'});k['push']({'op':'create','id':'contact','object':'contact','params':{'name':h+'_contact'},'notes':'R8:\x20customer-service\x20channel;\x20mandatory\x20when\x20customer_required\x20is\x20set.'});const L=b['review_mode'],M=L==='review'||L==='review_reward'||L==='none'?L:undefined,N=M??a['review_mode']??'none',O=h+'_review_reward',Q=b['after_sales_mode'],R=Q==='return'||Q==='exchange'||Q==='warranty'||Q==='none'?Q:undefined,S=R??a['after_sales_mode']??'none',T=b['acceptance_mode'],U=T==='milestone'||T==='contest'||T==='bounty'||T==='agent'||T==='none'?T:undefined,V=U??a['acceptance_mode']??'none',W=V==='contest'||V==='bounty'||V==='agent',X=b['installment_mode'],Y=X==='deposit_balance'||X==='milestone_n'||X==='none'?X:undefined,Z=Y??a['installment_mode']??'none',a0=b['affiliate_mode'],a1=a0==='commission'||a0==='none'?a0:undefined,a2=a1??a['affiliate_mode']??'none',a3=b['crowdfunding_mode'],a4=a3==='threshold'||a3==='flexible'||a3==='none'?a3:undefined,a5=a4??a['crowdfunding_mode']??'none',a6=aR=>{const aS=new Set(),aT=aU=>{if(Array['isArray'](aU)){for(const aW of aU)aT(aW);return;}if(typeof aU!=='object'||aU===null)return;const aV=aU;if(typeof aV['type']==='string'&&aV['type']['startsWith']('query_reward_record')){const aX=aV['object'];if(aX!==undefined&&typeof aX['identifier']==='number')aS['add'](aX['identifier']);}for(const aY of Object['values'](aV))aT(aY);};return aT(aR),aS;},a7=N==='review_reward'?x['find'](aR=>aR['host']==='reward'):undefined;if(N==='review_reward'&&a7?.['step_id']!==undefined){const aR=D['get'](a7['key']);if(aR!==undefined){const aS=a6(aR['root']);D['set'](a7['key'],{...aR,'table':aR['table']['map'](aT=>{const aU=aT;if(aU['b_submission']===!![]||!aS['has'](aU['identifier']))return aT;return{...aU,'value':{'$late':{'by':'local_name','mark':O}}};})});}k['push']({'op':'create','id':'reward_review','object':'reward','params':P({'name':O,'description':'Review\x20incentive\x20pool\x20(sale-time\x20planned;\x20terms\x20disclosed\x20at\x20quote/buy):\x20claim\x20gated\x20by\x20guard\x20\x27'+a7['key']+'\x27.'}),'notes':'REVIEW-COMPONENT:\x20the\x20funded\x20reward\x20must\x20be\x20perceivable\x20by\x20the\x20buyer\x20BEFORE\x20ordering\x20—\x20the\x20full\x20terms\x20ride\x20the\x20quote/buy\x20surface\x20(REVIEW-COMPONENT-PLAN\x20§4).\x20'+'[ZR-08:\x20created\x20BEFORE\x20its\x20claim\x20guard\x20—\x20the\x20guard\x27s\x20Reward-address\x20row\x20freezes\x20at\x20creation\x20and\x20binds\x20this\x20pool\x20by\x20local\x20name]'});}const a8=[];for(const [aT]of D){I(aT)?a8['push'](aT):k['push'](J(aT));}if(C){const aU=Array['isArray'](b['repository_policies'])?b['repository_policies']['filter'](aX=>typeof aX==='object'&&aX!==null):[],aV=[...aU],aW=new Set(aU['map'](aX=>aX['name']));for(const aX of x){if(aX['host']!=='repository'||aX['step_id']===undefined)continue;const aY='host:\x22repository\x22\x20guard\x20\x27'+aX['key']+'\x27\x20(step\x20\x27'+aX['step_id']+'\x27)';if(aX['policy']===undefined){j['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':aY+'\x20declares\x20no\x20policy\x20on\x20the\x20guards[]\x20entry.\x20Its\x20Repository\x20policy\x20'+'(name\x20/\x20id_from\x20/\x20value_type)\x20is\x20business\x20data\x20the\x20kernel\x20must\x20not\x20fabricate,\x20'+'and\x20an\x20unbound\x20repository\x20guard\x20is\x20an\x20orphan\x20create\x20that\x20leaves\x20the\x20Repository\x20'+'open\x20to\x20any\x20writer.\x20Add\x20policy:{name,\x20id_from,\x20value_type}\x20to\x20the\x20spec,\x20or\x20bind\x20'+'the\x20guard\x20through\x20repository_policies\x20inputs\x20with\x20this\x20guard\x27s\x20own\x20write_guard\x20shape.'});continue;}if(I(aX['key'])){j['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':aY+'\x20refs\x20the\x20service,\x20so\x20it\x20is\x20created\x20AFTER\x20the\x20service\x20draft\x20—\x20but\x20the\x20'+'Repository\x20freezes\x20its\x20policies\x20at\x20creation,\x20which\x20happens\x20before.\x20Resolve\x20this\x20'+'guard\x20without\x20a\x20service\x20reference\x20(the\x20writers\x20are\x20asserted\x20by\x20identity,\x20not\x20by\x20'+'service\x20pin),\x20or\x20bind\x20the\x20policy\x20manually\x20via\x20repository_policies\x20inputs.'});continue;}const aZ=aX['policy']['name']??aX['key'],b0=(aX['policy']['id_from']??'none')['toLowerCase'](),b1=aX['policy']['id_from_submission'],b2=aX['policy']['data_from_submission'];b1!==undefined&&(b0==='signer'||b0==='clock')&&j['push']({'code':'REPO_GUARD_SUBMISSION_ID_FORBIDDEN','detail':aY+'\x20declares\x20id_from_submission\x20'+b1+'\x20while\x20its\x20policy\x20id_from\x20is\x20'+('\x27'+b0+'\x27\x20—\x20the\x20row\x20id\x20is\x20AUTO-generated\x20from\x20the\x20'+b0+'\x20there,\x20and\x20a\x20')+'submission-derived\x20id\x20conflicts\x20with\x20that\x20routing\x20(the\x20chain\x20aborts\x20policy\x20creation\x20'+'with\x20E_POLICY_ID_FROM_SUBMISSION_FORBIDDEN\x20=\x2023;\x20policies\x20freeze\x20at\x20Repository\x20'+'creation,\x20so\x20this\x20must\x20be\x20fixed\x20before\x20publish,\x20BK15-F13).\x20Drop\x20id_from_submission\x20'+'(keep\x20data_from_submission\x20—\x20the\x20value\x20leg\x20is\x20legal\x20under\x20signer\x20routing),\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22none\x22\x20(caller-supplied\x20row\x20key,\x20guarded\x20by\x20this\x20write_guard).'});{const b3=D['get'](aX['key']),b4=[['id_from_submission',b1],['data_from_submission',b2]];for(const [b5,b6]of b4){if(b6===undefined)continue;const b7=b3?.['table']['find'](b8=>b8['identifier']===b6);(b3===undefined||b7===undefined||b7['b_submission']!==!![])&&j['push']({'code':'REPO_GUARD_SUBMISSION_SLOT_UNKNOWN','detail':aY+'\x20declares\x20'+b5+'\x20'+b6+',\x20but\x20the\x20resolved\x20guard\x20table\x20has\x20'+'NO\x20b_submission=true\x20row\x20at\x20that\x20identifier\x20—\x20the\x20passport\x20builder\x20DROPS\x20'+'undeclared\x20slots,\x20so\x20this\x20pairing\x20leg\x20would\x20silently\x20derive\x20nothing\x20at\x20write\x20'+'time\x20(the\x20write\x20aborts\x20or\x20writes\x20caller-free\x20values,\x20BK15-F13).\x20Declare\x20a\x20'+('b_submission=true\x20table\x20row\x20at\x20identifier\x20'+b6+'\x20on\x20the\x20guard,\x20or\x20point\x20')+(b5+'\x20at\x20an\x20existing\x20submission\x20slot.')});}}if(aW['has'](aZ))continue;aV['push']({'name':aZ,'description':aX['policy']['description']??aX['purpose'],'write_guard':[{'guard':ref(aX['step_id']),...b1!==undefined?{'id_from_submission':b1}:{},...b2!==undefined?{'data_from_submission':b2}:{}}],'id_from':aX['policy']['id_from']??'none','value_type':aX['policy']['value_type']??'String','write_once':aX['policy']['write_once']??![]});}k['push']({'op':'create','id':'repository','object':'repository','params':P({'name':h+'_evidence',...aV['length']>0x0?{'policies':aV}:{}}),'notes':'Evidence\x20rows\x20(tracking\x20hash,\x20receipts,\x20WTS\x20proofs).\x20[HOST-GRAPH-01:\x20created\x20after\x20wave-A\x20guards;\x20write_guard\x20policies\x20synthesized\x20from\x20resolved\x20host:\x22repository\x22\x20specs]'});}const a9=new Set(t['map'](b8=>b8['name'])),aa=[];for(const b8 of t){if(b8['from']===undefined||b8['from']['length']===0x0){j['push']({'code':'MACHINE_EDGES_MISSING','detail':'machine_shape\x20node\x20\x27'+b8['name']+'\x27\x20declares\x20no\x20\x27from\x27\x20edges.\x20Edges\x20are\x20data\x20'+'(REPORT\x20#10\x20A-2:\x20a\x20missing\x20paid->closed_cancel\x20edge\x20bricks\x20the\x20shop\x20at\x20publish).\x20'+'Annotate\x20the\x20node\x20with\x20from:\x20[...]\x20(use\x20prev:\x20\x22\x22\x20for\x20the\x20entry\x20edge).'});continue;}const b9=[],ba=new Map(),bb=new Map();for(const bd of b8['from']){const be=typeof bd==='string'?{'prev':bd}:bd;if(be['prev']!==''&&!a9['has'](be['prev'])){j['push']({'code':'EDGE_UNKNOWN_PREV','detail':'node\x20\x27'+b8['name']+'\x27\x20edge\x20prev\x20\x27'+be['prev']+'\x27\x20is\x20not\x20a\x20machine_shape\x20node'});continue;}const bf=be['operator']??b8['operator']??(be['prev']===''?'order_payer':'merchant'),bg=be['forward']??(be['prev']===''?'enter_'+b8['name']:be['prev']+'_to_'+b8['name']);be['permission_index']!==undefined&&bf==='order_payer'&&j['push']({'code':'PERMISSION_INDEX_DROPPED','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20declares\x20permission_index\x20'+be['permission_index']+'\x20on\x20operator\x20\x27order_payer\x27.\x20'+'The\x20two\x20are\x20contradictory\x20rails:\x20\x27order_payer\x27\x20compiles\x20to\x20the\x20on-chain\x20order-holder\x20check\x20(namedOperator\x20\x22\x22),\x20which\x20the\x20chain\x20evaluates\x20FIRST,\x20'+'so\x20the\x20declared\x20permission\x20index\x20is\x20silently\x20dropped\x20and\x20the\x20forward\x20remains\x20open\x20to\x20EVERY\x20order\x20agent\x20—\x20the\x20opposite\x20of\x20the\x20entity-only\x20intent\x20'+'(alg2-tn-261025\x20T8e:\x20the\x20provider\x20self-advanced\x20the\x20evaluation\x20forward\x20and\x20settled\x20the\x20escrow\x20to\x20itself).\x20Pick\x20ONE\x20rail:\x20remove\x20permission_index\x20to\x20keep\x20the\x20'+('buyer\x20rail,\x20or\x20remove\x20the\x20\x27order_payer\x27\x20operator\x20(node-level\x20or\x20edge-level)\x20so\x20this\x20forward\x20binds\x20permission_index\x20'+be['permission_index']+'\x20only')});const bh={'name':bg,'weight':0x1,...bf==='order_payer'?{'namedOperator':''}:{'permissionIndex':be['permission_index']??i}};if(be['guard_key']!==undefined){const bl=z['get'](be['guard_key']);if(bl===undefined)j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20binds\x20unknown\x20guard_key\x20\x27'+be['guard_key']+'\x27'});else{for(const bm of bl['purpose']['matchAll'](/progress\.current\s*==\s*([a-z0-9_]+)/g)){const bn=bm[0x1];a9['has'](bn)&&bn!==be['prev']&&j['push']({'code':'FORWARD_GUARD_PINNED_TO_NON_PREV','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20pins\x20progress.current\x20==\x20\x27'+bn+'\x27,\x20but\x20a\x20'+('forward\x20guard\x20evaluates\x20BEFORE\x20the\x20advance\x20(progress.current\x20==\x20prev\x20\x27'+be['prev']+'\x27),\x20so\x20the\x20pin\x20')+'can\x20never\x20pass\x20—\x20dead\x20rail\x20(bkng\x20F22).\x20Keep\x20the\x20pin\x20on\x20the\x20allocator\x20row\x20(evaluated\x20at\x20alloc,\x20'+'current\x20=\x20the\x20reached\x20node);\x20put\x20only\x20time/identity\x20legs\x20on\x20the\x20forward.'});}(bl['template_id']==='pattern.identity_check_order_holder'||bl['template_id']==='tpl_forward_order_holder'||bl['template_id']==='tpl_forward_order_holder_or_time'||bl['template_id']==='tpl_time_window_upper_order_holder')&&bf!=='order_payer'&&j['push']({'code':'FORWARD_GUARD_IDENTITY_PERM_CONFLICT','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+'check\x20but\x20the\x20forward\x20rides\x20a\x20permissionIndex\x20rail\x20(merchant-side\x20slot).\x20The\x20identity\x20layer\x20'+'runs\x20BEFORE\x20the\x20guard,\x20and\x20the\x20two\x20signer\x20sets\x20are\x20disjoint\x20—\x20nobody\x20can\x20pass\x20both\x20(bkng\x20F23).\x20'+'Use\x20operator\x20\x27order_payer\x27\x20(namedOperator\x20\x22\x22\x20—\x20the\x20buyer\x20self-advance)\x20for\x20this\x20edge.'});{const bo=D['get'](bl['key']);if(bo!==undefined){const bp=bo['table']['some'](br=>br['identifier']===TASK_BINDING_SLOT),bq=offTaskSlotIdentityLegs(bo['root'])['filter'](br=>{if(!bp)return![];const bs=bo['table']['find'](bt=>bt['identifier']===br['identifier']);return bs!==undefined&&bs['b_submission']===!![];});for(const br of bq){j['push']({'code':'GUARD_IDENTITY_SLOT_NOT_TASKBOUND','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20guard\x20\x27'+bl['key']+'\x27\x20reads\x20'+br['query']+'\x20off\x20free\x20'+('submission\x20slot\x20'+br['identifier']+'\x20—\x20hijackable\x20(rex-mn-261021\x20T10):\x20the\x20caller\x20fills\x20free\x20')+'slots,\x20so\x20an\x20attacker\x20submits\x20their\x20OWN\x20order\x20there\x20(signer\x20==\x20order.owner\x20passes\x20against\x20'+('their\x20own\x20order)\x20and\x20advances\x20the\x20VICTIM\x27s\x20order\x20carried\x20by\x20slot\x20'+TASK_BINDING_SLOT+';\x20with\x20')+'namedOperator\x20\x22\x22\x20the\x20permission\x20layer\x20passes\x20for\x20anyone\x20(progress.move:242-256),\x20so\x20this\x20'+('guard\x20is\x20the\x20only\x20identity\x20leg.\x20Anchor\x20the\x20'+br['query']+'\x20query\x20on\x20identifier\x20')+(TASK_BINDING_SLOT+'\x20(the\x20task-binding\x20order\x20anchor\x20—\x20the\x20order\x20the\x20forward\x20actually\x20mutates).')});}}}bl['step_id']!==undefined&&(I(bl['key'])?j['push']({'code':'GUARD_CYCLE','detail':'edge\x20\x27'+be['prev']+'\x27->\x27'+b8['name']+'\x27\x20binds\x20guard\x20\x27'+bl['key']+'\x27\x20which\x20itself\x20'+'refs\x20the\x20service\x20(created\x20after\x20the\x20machine)\x20—\x20an\x20F-05\x20cycle.\x20Rebind\x20or\x20split\x20the\x20guard.'}):bh['guard']=ref(bl['step_id']));}}else{const bs=y['get'](bg);if(bs!==undefined){const bt=z['get'](bs);bt?.['step_id']!==undefined&&(bh['guard']=ref(bt['step_id']));}}const bi=ba['get'](be['prev']);bi!==undefined?bi['push'](bh):ba['set'](be['prev'],[bh]);const bj=bb['get'](be['prev']),bk=bf==='order_payer'?'namedOperator:':'permissionIndex:'+(be['permission_index']??i);bj!==undefined?bj['add'](bk):bb['set'](be['prev'],new Set([bk]));}const bc=b8['threshold']??0x0;for(const [bu,bv]of ba){bc>bv['length']&&j['push']({'code':'PAIR_THRESHOLD_UNREACHABLE','detail':'node\x20\x27'+b8['name']+'\x27\x20pair\x20from\x20\x27'+(bu===''?'(entry)':bu)+'\x27\x20declares\x20threshold\x20'+bc+'\x20'+('but\x20the\x20pair\x20merges\x20only\x20'+bv['length']+'\x20forward(s)\x20at\x20weight\x201\x20each\x20—\x20the\x20pair\x20can\x20never\x20')+'migrate\x20and\x20the\x20publish\x20aborts.\x20Add\x20one\x20distinct-operator\x20forward\x20per\x20required\x20signature,\x20or\x20'+'lower\x20the\x20threshold\x20to\x20the\x20forward\x20count.'});if(bc>=0x2){const bw=bb['get'](bu)?.['size']??0x0;bw<0x2&&j['push']({'code':'PAIR_THRESHOLD_SINGLE_OPERATOR','detail':'node\x20\x27'+b8['name']+'\x27\x20pair\x20from\x20\x27'+(bu===''?'(entry)':bu)+'\x27\x20declares\x20threshold\x20'+bc+'\x20'+'but\x20every\x20forward\x20rides\x20the\x20SAME\x20operator\x20rail\x20—\x20one\x20party\x20can\x20tap\x20all\x20of\x20them\x20and\x20the\x20'+'declared\x20dual\x20confirmation\x20silently\x20dissolves\x20(each\x20forward\x20locks\x20to\x20its\x20first\x20operator).\x20'+'Give\x20each\x20required\x20signature\x20its\x20own\x20rail\x20(e.g.\x20permission_index\x201001\x20+\x20operator\x20\x27order_payer\x27).'});}b9['push']({'prev_node':bu,'threshold':bc,'forwards':bv});}aa['push']({'name':b8['name'],...b8['semantic_role']!==undefined?{'role':b8['semantic_role']}:{},...b8['optional']===!![]?{'optional':!![]}:{},'pairs':b9});}k['push']({'op':'create','id':'machine','object':'machine','params':P({'name':h+'_machine','nodes':aa})}),k['push']({'op':'publish','id':'machine_publish','target':ref('machine'),'preflight':[{'check':'machine_publish','status':'pending'},{'check':'TASKBIND-01','status':'pending'}]});const ab=typeof b['currency']==='string'?b['currency']:'0x2::wow::WOW',ac=x['find'](bx=>bx['host']==='service'&&bx['key']==='buy');k['push']({'op':'create','id':'service','object':'service','params':P({'name':h+'_service','type_parameter':ab,'permission':ref('permission'),'machine':ref('machine'),'um':ref('contact'),'description':a['id']+'\x20—\x20compiled\x20by\x20composition/compile',...C?{'repositories':[ref('repository')]}:{},...ac?.['step_id']!==undefined?{'buy_guard':ref(ac['step_id'])}:{},...Array['isArray'](b['customer_required'])?{'customer_required':b['customer_required']}:{}}),'notes':'Draft\x20only:\x20machine/order_allocators\x20are\x20L1-frozen\x20at\x20publish;\x20allocators\x20attach\x20in\x20the\x20configure\x20step.'});for(const bx of a8)k['push'](J(bx));const ad=u['length']>0x0?u:[{'track':'settlement','recipient':a['allocator']['recipient']==='fixed'?'entity':a['allocator']['recipient'],'recipient_key':a['allocator']['recipient_key'],'mode':a['allocator']['mode'],'value':a['allocator']['mode']==='rate'?0x2710:a['allocator']['mode']==='surplus'?'0':undefined}],ae=[],af=new Map();for(const by of ad){if(by['guard_key']!==undefined){let bz=af['get'](by['guard_key']);bz===undefined&&(bz={'key':by['guard_key'],'rows':[]},af['set'](by['guard_key'],bz),ae['push'](bz)),bz['rows']['push'](by);}else ae['push']({'rows':[by]});}const ag=[];for(const bA of ae){const bB=[];let bC;for(const bE of bA['rows']){let bF=bE['value'];bF===undefined&&bE['value_from']!==undefined&&(bF=b[bE['value_from']]??a['fee_params'][bE['value_from']]);if(bF===undefined&&bE['mode']!=='surplus'){j['push']({'code':'ALLOCATOR_VALUE_MISSING','detail':'allocator\x20row\x20('+bE['track']+'/'+bE['recipient']+')\x20has\x20neither\x20value\x20nor\x20a\x20resolvable\x20value_from'});continue;}(bE['fix']!==undefined||bE['fix_from']!==undefined)&&j['push']({'code':'ALLOCATOR_FIX_UNSUPPORTED','detail':'allocator\x20row\x20('+bE['track']+'/'+bE['recipient']+')\x20declares\x20fix/fix_from\x20—\x20the\x20chain\x20has\x20no\x20holdback\x20'+'parameter:\x20fix\x20is\x20computed\x20on-chain\x20as\x20the\x20sum\x20of\x20the\x20Amount\x20legs\x20and\x20those\x20legs\x20are\x20PAID\x20'+'(allocation.move:399,540),\x20and\x20the\x20allocator-registration\x20call\x20surface\x20(guard,\x20sharing,\x20max)\x20has\x20no\x20fix\x20'+'argument,\x20so\x20this\x20value\x20never\x20reaches\x20the\x20chain.\x20To\x20keep\x20funds\x20in\x20the\x20pool,\x20do\x20not\x20distribute\x20them\x20'+'(a\x20separate\x20Allocation\x20object,\x20or\x20a\x20later\x20guard-gated\x20allocator);\x20to\x20combine\x20fixed\x20fees\x20with\x20a\x20'+'proportional\x20split,\x20use\x20explicit\x20Amount\x20legs\x20plus\x20Rate\x20legs\x20summing\x2010000.'});bC??=bE['note'];let bG;if(bE['recipient']==='entity')bG={'Entity':{'$late':{'by':'local_name','mark':bE['recipient_key']??'merchant'}}};else{if(bE['recipient']==='guard_identifier'){const bH=Number(bE['recipient_key']??0x0);bG={'GuardIdentifier':bH};const bI=bA['key']!==undefined?D['get'](bA['key']):undefined;if(bI!==undefined){const bJ=bI['table']['find'](bK=>bK['identifier']===bH);(bJ===undefined||bJ['b_submission']!==!![]||bJ['value_type']!=='Address')&&j['push']({'code':'GUARD_SLOT_UNKNOWN','detail':'allocator\x20leg\x20{GuardIdentifier:\x20'+bH+'}\x20on\x20guard\x20\x27'+bA['key']+'\x27\x20of\x20\x27'+h+'\x27:\x20the\x20bound\x20'+('Guard\x20table\x20has\x20no\x20slot\x20'+bH+'\x20Address\x20submission\x20row\x20(b_submission:\x20true).\x20On\x20chain\x20the\x20leg\x20')+('reads\x20slot\x20'+bH+'\x20as\x20its\x20payee\x20and\x20asserts\x20it\x20equals\x20the\x20paying\x20order\x20')+'(payment_info.for_object)\x20—\x20an\x20undeclared\x20or\x20STATIC\x20slot\x20aborts\x20at\x20alloc\x20time\x20with\x20code\x2015\x20'+'(ERECIPIENT_NOT_FOR_OBJECT,\x20allocation.move:500-520)\x20and\x20the\x20leg\x27s\x20funds\x20stranded\x20'+'(az3/abnb7\x20mainnet\x20261013:\x20static\x20GuardIdentifier\x20legs\x20bricked\x20every\x20refund\x20rail).\x20'+'Guard/allocators/forwards\x20are\x20all\x20publish-frozen.\x20Declare\x20'+('{identifier:\x20'+bH+',\x20b_submission:\x20true,\x20value_type:\x20\x22Address\x22}\x20in\x20the\x20Guard\x20table\x20')+'(templates\x20anchor\x20refund\x20rails\x20on\x20user\x20slot\x200\x20and\x20submit\x20the\x20Order\x20address\x20there).\x20Protocol\x20'+'slot\x20254\x20is\x20the\x20task-binding/once\x20slot:\x20naming\x20it\x20as\x20the\x20payee\x20arms\x20once-per-order,\x20so\x20a\x20'+'second\x20fire\x20aborts\x20E_ONCE_TRIGGERED\x20(16).'});}}else bG='Signer';}bB['push']({'who':bG,'sharing':String(bF??'0'),'mode':MODE_MAP[bE['mode']]});}if(bB['length']===0x0)continue;const bD=bA['key']!==undefined?z['get'](bA['key'])?.['step_id']:undefined;bA['key']!==undefined&&!z['has'](bA['key'])&&j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'allocator\x20row\x20('+bA['rows'][0x0]['track']+')\x20binds\x20unknown\x20guard_key\x20\x27'+bA['key']+'\x27'}),ag['push']({...bD!==undefined?{'guard':ref(bD)}:{},...bA['key']!==undefined?{'guard_key':bA['key']}:{},'track':bA['rows'][0x0]['track'],'sharing':bB,...bC!==undefined?{'note':bC}:{}});}const ah=ae['map'](bK=>{if(bK['key']===undefined)return undefined;const bL=D['get'](bK['key']);return{'key':bK['key'],'track':bK['rows'][0x0]['track'],'table':bL?.['table']??[],'root':bL?.['root']};})['filter'](bK=>bK!==undefined);if(ah['length']>0x0){const bK=verifyAllocatorRails(ah,t['map'](bN=>({'name':bN['name'],'semanticRole':bN['semantic_role']}))),bL=ae['map'](bN=>bN['key'])['filter'](bN=>bN!==undefined&&!D['has'](bN)),bM=bL['length']>0x0?'\x20UNRESOLVED\x20ALLOCATOR\x20GUARD\x20REFS\x20(likely\x20the\x20real\x20cause\x20—\x20these\x20guard_keys\x20match\x20no\x20resolved\x20guard,\x20e.g.\x20a\x20name\x20typo):\x20'+bL['join'](',\x20')+'.':'';for(const bN of bK){j['push']({'code':bN['code'],'detail':bN['detail']+bM});}}k['push']({'op':'configure','id':'service_allocators','target':ref('service'),'method':'order_allocators','params':P({'description':a['allocator']['description'],'threshold':Number(a['fee_params']['threshold']??a['fee_params']['monthly_rent_amount']??0x0)||0x0,'allocators':ag}),'requires':['machine_publish']});Array['isArray'](b['sales'])&&b['sales']['length']>0x0&&k['push']({'op':'configure','id':'service_sales','target':ref('service'),'method':'sales','params':{'op':'add','sales':b['sales']}});if(S!=='none'){const bO=a12a(S),bP=t['some'](bQ=>afterSalesRailNodeMatches(S,bQ['name']));!bP&&j['push']({'code':'AFTER_SALES_RAIL_MISSING','detail':'after_sales_mode\x20\x27'+S+'\x27\x20declares\x20a\x20buyer\x20after-sales\x20remedy,\x20but\x20machine_shape\x20has\x20no\x20'+('backing\x20rail\x20(no\x20node\x20matching\x20'+bO+').\x20Add\x20the\x20'+S+'\x20node\x20family\x20')+'(e.g.\x20return_requested\x20->\x20returned\x20for\x20\x27return\x27)\x20with\x20its\x20claimed_by\x20polarity\x20pair\x20—\x20refund\x20leg\x20'+'some==false,\x20merchant-recovery\x20leg\x20some==true\x20(INV-C1)\x20—\x20anchored\x20on\x20the\x20delivered\x20ENTRY\x20time\x20'+'(INV-C2,\x20TIME-ANCHOR-01),\x20and\x20de-conflicted\x20against\x20the\x20settlement\x20rail\x20so\x20the\x20two\x20never\x20both\x20pay\x20'+'(INV-C3,\x20DUAL-RAIL-01).\x20Or\x20set\x20after_sales_mode\x20\x27none\x27\x20if\x20this\x20shop\x20ships\x20no\x20such\x20remedy.'});}if(V!=='none'){W&&a['arbitration_mode']!=='third_party'&&j['push']({'code':'ACCEPTANCE_JUDGE_NOT_INDEPENDENT','detail':'acceptance_mode\x20\x27'+V+'\x27\x20is\x20a\x20judge-decided\x20acceptance\x20(a\x20third\x20party\x20rules\x20on\x20'+('release),\x20but\x20arbitration_mode\x20is\x20\x27'+(a['arbitration_mode']??'none')+'\x27,\x20not\x20\x27third_party\x27.\x20')+'The\x20party\x20owing\x20the\x20payout\x20must\x20not\x20also\x20decide\x20whether\x20it\x20is\x20owed\x20(merchant\x20self-adjudication,\x20'+'INV-A3).\x20Set\x20arbitration_mode\x20\x27third_party\x27\x20so\x20an\x20independent\x20venue/judge\x20Permission\x20rules\x20'+'(R2;\x20enforced\x20at\x20publish\x20by\x20controller-disjointness),\x20or\x20use\x20acceptance_mode\x20\x27milestone\x27\x20if\x20the\x20'+'buyer\x20genuinely\x20self-adjudicates.'});const bQ=a['fee_params']['revision_rounds_max'],bR=typeof bQ==='number'||typeof bQ==='string'&&bQ['trim']()!==''&&/^\d+$/['test'](bQ['trim']());if(bR){const bS=x['some'](bT=>bT['host']==='repository'||/repository/i['test'](bT['template_id']));!bS&&j['push']({'code':'ACCEPTANCE_REVISION_UNBOUNDED','detail':'acceptance_mode\x20\x27'+V+'\x27\x20declares\x20a\x20bounded\x20revision\x20loop\x20'+('(fee_params.revision_rounds_max\x20=\x20'+String(bQ)+'),\x20but\x20no\x20counter-backed\x20Repository\x20')+'guard\x20exists.\x20progress.move\x20caps\x20EDGE\x20count\x20(MAX_FORWARD\x20/\x20MAX_NODE_PAIR),\x20never\x20VISIT\x20count,\x20'+'so\x20a\x20finite\x20cap\x20in\x20fee_params\x20alone\x20is\x20a\x20promise\x20the\x20chain\x20cannot\x20keep\x20(INV-A1).\x20Either\x20declare\x20'+'revision_rounds_max\x20\x27unlimited\x27\x20(the\x20honest\x20form\x20—\x20the\x20revision\x20loop\x20is\x20then\x20genuinely\x20'+'unbounded)\x20or\x20mount\x20a\x20counter-backed\x20Repository\x20guard\x20(pattern.repository_data_check\x20reading\x20a\x20'+'per-order\x20revision\x20tally\x20written\x20via\x20pattern.repository_write_authorization)\x20that\x20gates\x20the\x20'+'redelivery\x20forward\x20once\x20the\x20tally\x20reaches\x20the\x20cap.'});}}if(Z!=='none'){const bT=/(due|owed|owing|unpaid|awaiting|pending)/i,bU=/(paid|captured|funded|settled)/i,bV=/(deposit|down_?pay|balance_due|balance_owed|awaiting|installment|milestone)/i,bW=/(refund|cancel|exit|forfeit|kill|void|abandon|release|expire|lapse)/i,bX=[];for(const c0 of t){const c1=c0['name'];for(const c2 of c0['from']??[]){typeof c2==='string'?bX['push']({'prev':c2,'target':c1}):bX['push']({'prev':c2['prev'],'target':c1,'guardKey':c2['guard_key']});}}const bY=bX['filter'](c3=>bT['test'](c3['prev'])&&bU['test'](c3['target'])&&(c3['guardKey']===undefined||c3['guardKey']['trim']()===''));bY['length']>0x0&&j['push']({'code':'INSTALLMENT_FUNDING_UNGATED','detail':'installment_mode\x20\x27'+Z+'\x27\x20captures\x20a\x20later\x20payment,\x20but\x20the\x20funding\x20forward(s)\x20'+bY['map'](c3=>'\x27'+c3['prev']+'\x27\x20→\x20\x27'+c3['target']+'\x27')['join'](',\x20')+'\x20carry\x20NO\x20guard_key.\x20A\x20bare\x20advance\x20records\x20the\x20balance\x20as\x20paid\x20WITHOUT\x20the\x20capture\x20landing\x20in\x20the\x20'+'Allocation\x20—\x20a\x20zero-value\x20advance\x20(INV-B1,\x20H4).\x20Bind\x20a\x20fund-gate\x20Guard\x20on\x20each\x20capture\x20forward\x20'+'(constant\x20=\x20order\x20address,\x20convert_witness\x20OrderAllocation(109),\x20allocation.balance\x20query\x201051\x20>=\x20the\x20'+'capture\x20amount).\x20PRE-STATE\x20CONSTRAINT\x20(esound-mn-261021\x20B-1,\x20mainnet-verified):\x20guards\x20read\x20the\x20'+'COMMITTED\x20pre-transaction\x20balance\x20—\x20funding\x20that\x20lands\x20in\x20the\x20SAME\x20PTB\x20(the\x20one-PTB\x20order_renew\x20'+'payment\x20half)\x20is\x20INVISIBLE\x20to\x20the\x20forward\x27s\x20guard,\x20so\x20a\x20balance-gated\x20capture\x20advanced\x20by\x20'+('order_renew\x20ALWAYS\x20aborts.\x20'+TWO_TX_RENEW_RECIPE+'\x20Pair\x20the\x20balance\x20gate\x20with\x20the\x20once\x20slot\x20')+'(H5\x20—\x20the\x20fund\x20gate\x20is\x20a\x20STATE\x20READ,\x20not\x20a\x20once)\x20so\x20a\x20replay\x20cannot\x20re-capture.'});const bZ=[];for(const c3 of t){if(!bV['test'](c3['name']))continue;const c4=bX['filter'](c6=>c6['prev']===c3['name']),c5=c4['some'](c6=>bW['test'](c6['target']));if(!c5)bZ['push'](c3['name']);}bZ['length']>0x0&&j['push']({'code':'INSTALLMENT_DEPOSIT_STRANDED','detail':'installment_mode\x20\x27'+Z+'\x27\x20holds\x20a\x20buyer\x20payment\x20at\x20state(s)\x20'+bZ['map'](c6=>'\x27'+c6+'\x27')['join'](',\x20')+'\x20with\x20NO\x20deposit-exit\x20rail\x20(no\x20outgoing\x20refund\x20/\x20cancel\x20/\x20forfeit\x20/\x20expire\x20edge).\x20There\x20is\x20no\x20on-chain\x20'+'obligation\x20to\x20pay\x20the\x20balance\x20(INV-B2,\x20H1),\x20so\x20a\x20buyer\x20who\x20walks\x20away\x20strands\x20the\x20already-paid\x20portion\x20'+'at\x20that\x20node\x20permanently\x20(Machine\x20+\x20Allocator\x20immutable,\x20IMMUT-001).\x20Add\x20a\x20deposit-exit\x20rail\x20from\x20each\x20'+'held\x20state\x20—\x20a\x20refund/cancel\x20forward\x20into\x20an\x20exit\x20node\x20whose\x20allocator\x20returns\x20the\x20held\x20funds\x20to\x20the\x20'+'order\x20payer\x20(GuardIdentifier(0))\x20or\x20applies\x20the\x20declared\x20deposit_exit_policy\x20(full\x20refund\x20vs\x20a\x20kill\x20fee\x20'+'compensating\x20the\x20merchant\x20for\x20the\x20reserved\x20capacity).'});}if(a2!=='none'){const c6=/(commission|affiliate|referr|attribut|partner_?payout)/i,c7=t['some'](cb=>c6['test'](cb['name'])),c8=ad['some'](cb=>c6['test'](cb['value_from']??'')||c6['test'](cb['recipient_key']??''));!c7&&!c8&&j['push']({'code':'AFFILIATE_RAIL_MISSING','detail':'affiliate_mode\x20\x27'+a2+'\x27\x20declares\x20a\x20referral/affiliate\x20commission\x20overlay,\x20but\x20machine_shape\x20has\x20no\x20'+'commission-family\x20node\x20and\x20the\x20allocator\x20has\x20no\x20commission\x20row\x20—\x20a\x20declared\x20partner\x20payout\x20with\x20no\x20rail\x20to\x20'+'walk\x20it\x20is\x20a\x20false\x20promise\x20at\x20quote\x20time\x20(INV-D3).\x20Add\x20an\x20INDEPENDENT\x20commission\x20leg:\x20a\x20Rate\x20row\x20off\x20a\x20'+'dedicated\x20commission\x20pool\x20(never\x20a\x20Surplus/Rate\x20drain\x20of\x20the\x20buyer\x27s\x20goods\x20escrow\x20—\x20anti-grab-pool)\x20to\x20an\x20explicit\x20'+'non-empty\x20partner\x20Entity,\x20gated\x20by\x20a\x20window-anchored\x20claim\x20guard\x20(INV-D1\x20rides\x20TIME-ANCHOR-01)\x20so\x20the\x20'+'commission\x20is\x20claimable\x20only\x20after\x20the\x20attribution/refund\x20window\x20closes.'});const c9=/(post-?lock|clawback|unrecoverable|irrevocab|no\s*(?:revers|recov|clawback)|cannot be reversed|once released|released commission)/i,ca=(a['build_notes']??[])['some'](cb=>c9['test'](cb));!ca&&j['push']({'code':'AFFILIATE_CLAWBACK_UNDISCLOSED','detail':'affiliate_mode\x20\x27'+a2+'\x27\x20declares\x20a\x20commission\x20but\x20no\x20build_note\x20discloses\x20the\x20post-lock\x20no-clawback\x20'+'truth\x20(INV-D2).\x20SOLE\x20TRUTH:\x20Allocation\x20distribute\x20is\x20a\x20ONE-WAY\x20outflow\x20(no\x20debit/clawback\x20primitive,\x20§11.0\x20G2),\x20'+'so\x20once\x20a\x20commission\x20is\x20RELEASED\x20it\x20CANNOT\x20be\x20reversed\x20on\x20chain\x20—\x20a\x20refund/chargeback\x20after\x20release\x20leaves\x20the\x20'+'affiliate\x20commission\x20unrecoverable.\x20Add\x20a\x20build_note\x20stating\x20this\x20honestly\x20(e.g.\x20\x22post-lock:\x20a\x20released\x20'+'affiliate\x20commission\x20is\x20unrecoverable\x20—\x20refunds\x20after\x20the\x20attribution\x20window\x20do\x20NOT\x20claw\x20back\x20the\x20'+'partner\x20payout\x22).\x20L-04/D-5:\x20never\x20imply\x20a\x20recovery\x20capability\x20the\x20chain\x20does\x20not\x20have.'});}if(a5!=='none'){const cb=/(releas|settle|funded|disburs|project)/i,cc=/(refund|missed|unmet|return|reimburse)/i,cd=t['some'](cq=>cb['test'](cq['name'])),ce=ad['some'](cq=>cq['track']==='settlement'&&(cb['test'](cq['guard_key']??'')||cb['test'](cq['recipient_key']??''))),cf=t['some'](cq=>cc['test'](cq['name'])),cg=ad['some'](cq=>cq['track']==='refund'||cc['test'](cq['guard_key']??''));!cd&&!ce&&j['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27'+a5+'\x27\x20declares\x20a\x20campaign\x20but\x20machine_shape\x20has\x20no\x20release/settlement\x20'+'node\x20and\x20the\x20allocator\x20has\x20no\x20settlement\x20row\x20to\x20the\x20project\x20Entity\x20—\x20the\x20escrowed\x20contributions\x20would\x20'+'strand\x20at\x20the\x20deadline\x20with\x20no\x20exit\x20rail\x20(INV-E1).\x20Add\x20a\x20release\x20leg\x20(Rate\x2010000\x20to\x20a\x20NON-EMPTY\x20project\x20'+'Entity,\x20gated\x20at\x20the\x20campaign-deadline\x20settlement\x20terminal)\x20and,\x20for\x20a\x20threshold\x20campaign,\x20its\x20D-BUG-2\x20'+'refund\x20twin.'});a5==='threshold'&&!cf&&!cg&&j['push']({'code':'CROWDFUNDING_THRESHOLD_GATE_MISSING','detail':'crowdfunding_mode\x20\x27threshold\x27\x20declares\x20an\x20all-or-nothing\x20campaign\x20but\x20there\x20is\x20NO\x20refund-family\x20node/row\x20—\x20'+'a\x20missed\x20goal\x20would\x20strand\x20every\x20contribution\x20instead\x20of\x20returning\x20it\x20(INV-E1\x20/\x20D-BUG-2).\x20Add\x20the\x20refund\x20'+'leg\x20(per-contributor,\x20order-anchored\x20user\x20slot\x200\x20—\x20the\x20submitted\x20Order,\x20never\x20slot\x20254,\x20claimed_by\x20some==false)\x20as\x20the\x20mutually-exclusive\x20twin\x20of\x20the\x20'+'release\x20leg:\x20aggregate\x20>=\x20goal\x20→\x20release;\x20aggregate\x20<\x20goal\x20→\x20refund.'});if(a5==='threshold'){const cq=x['filter'](ct=>ct['host']==='repository'||/repository_write/i['test'](ct['template_id'])),cr=cq['length']>0x0,cs=cq['some'](ct=>{const cu=(ct['policy']?.['id_from']??'')['toLowerCase']();return cu==='signer'||cu==='clock';});if(!cr)j['push']({'code':'CROWDFUNDING_AGGREGATE_UNBOUND','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20no\x20host:\x22repository\x22\x20'+'write\x20policy\x20declares\x20the\x20contribution\x20rows\x20—\x20with\x20no\x20write-bound\x20policy\x20the\x20total\x20is\x20forgeable,\x20so\x20'+'anyone\x20could\x20inflate\x20the\x20aggregate\x20and\x20fake\x20a\x20\x27goal\x20met\x27\x20(INV-E2\x20/\x20R-X1-17:\x20existence-is-not-trust).\x20'+'Mount\x20pattern.repository_write_authorization\x20(identity\x20leaf\x20order.owner==Signer\x20/\x20order.agent\x20has\x20Signer)\x20'+'and\x20key\x20the\x20contribution\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20(policy\x20id_from\x20unset;\x20row\x20id\x20=\x20the\x20Order\x20address).'});else{if(cs){const ct=cq['filter'](cu=>{const cv=(cu['policy']?.['id_from']??'')['toLowerCase']();return cv==='signer'||cv==='clock';})['map'](cu=>'\x27'+cu['key']+'\x27');j['push']({'code':'CROWDFUNDING_SIGNER_KEYED_ROWS','detail':'crowdfunding_mode\x20\x27threshold\x27\x20gates\x20release\x20on\x20an\x20aggregate\x20funding\x20total,\x20but\x20the\x20contribution\x20'+('policy\x20'+ct['join'](',\x20')+'\x20keys\x20rows\x20by\x20the\x20WALLET\x20(id_from\x20signer/clock)\x20—\x20the\x20OLD\x20pre-migration\x20')+'shape\x20(ksc-tn-261024\x20F-01/F-05).\x20Wallet-keyed\x20rows\x20feed\x20the\x20escrow-bound\x20sum\x20(query\x201179,\x20per-row\x20'+'min(row,\x20order.amount))\x20ZERO\x20—\x20the\x20goal\x20gate\x20silently\x20bricks\x20—\x20and\x20the\x20free-form\x20sum-where\x20(1174)\x20stays\x20'+'self-reported,\x20so\x20a\x20backer\x20can\x20still\x20record\x201.0\x20for\x20a\x200.1\x20pledge.\x20Key\x20the\x20rows\x20by\x20the\x20funder\x27s\x20ORDER\x20'+'instead\x20(policy\x20id_from\x20unset;\x20the\x20backer\x27s\x20tooling\x20submits\x20the\x20row\x20id\x20=\x20their\x20Order\x20address\x20through\x20'+'the\x20passport-bearing\x20data\x20write),\x20pass\x20those\x20ORDER\x20addresses\x20as\x20the\x20aggregate\x27s\x20candidate\x20ids,\x20and\x20pair\x20the\x20gate\x20'+'with\x20the\x20live-escrow\x20leg\x20(allocation.balance\x20query\x201051\x20via\x20convert_witness\x20OrderAllocation\x20109,\x20'+'>=\x20order.amount)\x20so\x20a\x20refunded/never-funded\x20order\x20can\x20neither\x20count\x20toward\x20the\x20goal\x20nor\x20be\x20settled.'});}}}const ch=a['build_notes']??[],ci=/(attest|keeper|aggregate trust|read-?only sum|not a chain-?verified|independent recomputation)/i,cj=/(not investment|non-?investment|no (?:investment )?return|never promise)/i,ck=/(kyc|aml|securities|money-?transmission|regulatory|cross-border|compliance)/i,cl=/(no-?refund|non-?refundable|keep-?it-?all)/i,cm=ch['some'](cu=>cj['test'](cu)),cn=ch['some'](cu=>ck['test'](cu)),co=a5==='threshold'?ch['some'](cu=>ci['test'](cu)):!![],cp=a5==='flexible'?ch['some'](cu=>cl['test'](cu)):!![];if(!co||!cm||!cn||!cp){const cu=[!co?'the\x20aggregate-trust\x20boundary\x20(the\x20funding\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum,\x20NOT\x20a\x20chain-verified\x20money\x20oracle)':null,!cm?'the\x20L-01\x20non-investment\x20statement\x20(never\x20promise\x20returns\x20/\x20promote\x20coin\x20price;\x20not\x20investment\x20advice\x20or\x20a\x20return\x20promise)':null,!cn?'the\x20L-05\x20KYC/AML\x20+\x20cross-border\x20regulatory\x20caution\x20(HIGH\x20intensity)':null,!cp?'the\x20flexible\x20keep-it-all\x20NO-REFUND\x20posture\x20(contributions\x20non-refundable\x20once\x20the\x20deadline\x20passes;\x20no\x20refunds)':null]['filter'](Boolean);j['push']({'code':'CROWDFUNDING_DISCLOSURE_MISSING','detail':'crowdfunding_mode\x20\x27'+a5+'\x27\x20declares\x20a\x20campaign\x20but\x20no\x20build_note\x20carries:\x20'+cu['join'](';\x20')+'\x20'+'(INV-E3\x20/\x20L-04\x20/\x20L-01\x20/\x20L-05).\x20Add\x20these\x20as\x20honest\x20build_notes\x20—\x20never\x20present\x20an\x20attested\x20aggregate\x20as\x20a\x20'+'chain-verified\x20custody\x20proof,\x20never\x20imply\x20investment\x20returns,\x20and\x20flag\x20the\x20compliance\x20surface.'});}}if(N!=='none'){const cv=t['some'](cB=>/review/i['test'](cB['name']));N==='review'&&!cv&&j['push']({'code':'REVIEW_NODE_MISSING','detail':'review_mode\x20\x27'+N+'\x27\x20declares\x20the\x20buyer\x20review\x20reputation\x20rail,\x20but\x20machine_shape\x20has\x20no\x20'+'\x27reviewed\x27\x20node.\x20Add\x20a\x20buyer-advanced\x20review\x20node\x20(operator\x20order_payer)\x20with\x20an\x20EXIT\x20edge\x20back\x20to\x20the\x20'+'settlement\x20rail\x20(R-DEAD-END:\x20a\x20zero-exit\x20review\x20node\x20strands\x20the\x20escrow),\x20or\x20anchor\x20the\x20claim\x20on\x20the\x20'+'delivered\x20terminal\x20via\x20a\x20host:\x22reward\x22\x20guard\x20(review_mode\x20\x22review_reward\x22\x20variant).'});const cw=x['find'](cB=>cB['host']==='reward'),cx=t['find'](cB=>/review/i['test'](cB['name']))?.['name'];let cy,cz;if(cx!==undefined){const cB=[];for(const cE of t){for(const cF of cE['from']??[]){const cG=typeof cF==='string'?{'prev':cF,'guard_key':undefined}:cF;cB['push']({'prev':cG['prev'],'guard_key':cG['guard_key'],'target':cE['name']});}}const cC=cB['find'](cH=>cH['target']===cx&&cH['guard_key']!==undefined)?.['guard_key']??cB['find'](cH=>cH['prev']===cx&&cH['guard_key']!==undefined)?.['guard_key'],cD=cC!==undefined?z['get'](cC):undefined;cy=cD?.['step_id'],cz=cC;}cy===undefined&&cw?.['step_id']!==undefined&&(cy=cw['step_id'],cz=cw['key']);const cA=b['review_decision_enabled']===!![]&&N==='review_reward'&&cw?.['step_id']!==undefined&&cy!==undefined;cA&&k['push']({'op':'create','id':'guard_review_decision','object':'guard','params':P({'description':'Merchant\x20review-decision\x20write\x20credential:\x20only\x20the\x20service\x20provider\x20(permission\x20owner\x20or\x20admin)\x20may\x20write\x20U64\x20decision\x20rows\x20(row\x20id\x20=\x20order\x20address,\x20value\x20=\x20approved\x20payout)\x20under\x20the\x20review\x20repository\x27s\x20\x27review_decision\x27\x20policy.','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_approved'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},{'identifier':0x2,'b_submission':!![],'value_type':'Address','name':'service_permission'}],'root':{'type':'logic_and','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},{'type':'logic_equal','nodes':[{'type':'query','query':'service.permission','object':{'identifier':0x1},'parameters':[]},{'type':'identifier','identifier':0x2}]},{'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'permission.owner','object':{'identifier':0x2},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'permission.admin\x20has','object':{'identifier':0x2},'parameters':[{'type':'context','context':'Signer'}]}]}]}}),'notes':'REVIEW-DECISION\x20write\x20credential\x20(allocator\x20dynamic-permission\x20shape,\x20service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20decision\x20write\x20itself:\x20repository.data_add\x20'+'{name:\x27review_decision\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<approved\x20payout\x20U64>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order\x20and\x20the\x20permission.'});if(cy!==undefined){const cH=b['buyer_review_enabled']===!![];k['push']({'op':'create','id':'repository_review','object':'repository','params':P({'name':h+'_review','description':'Structured\x20buyer\x20reputation\x20rows\x20(AR-1:\x20emitted\x20by\x20the\x20build\x20plan\x20—\x20no\x20manual\x20setup).','policies':[{'name':'review','description':'One\x20immutable\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address\x20—\x20F09\x20yfd-ln-261024:\x20a\x20repeat\x20buyer\x20must\x20be\x20able\x20to\x20review\x20every\x20order;\x20the\x20old\x20Signer-keyed\x20row\x20made\x20order\x20#2\x20unwritable).\x20Write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a).\x20Writes\x20require\x20the\x20review\x20credential\x20(guard\x20key\x20\x27'+cz+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','write_guard':[{'guard':ref(cy)}],'id_from':'none','value_type':'String','write_once':!![]},{'name':'rating','description':'Order-keyed\x20numeric\x20rating\x20(F-62):\x20one\x20U64\x20row\x20per\x20ORDER\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20stars,\x20e.g.\x201..5;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20Writes\x20require\x20the\x20same\x20review\x20credential\x20as\x20the\x20\x27review\x27\x20text\x20policy\x20—\x20a\x20verified\x20completed-order\x20buyer.\x20This\x20—\x20not\x20the\x20\x27review\x27\x20text\x20row\x20(same\x20order\x20key,\x20String\x20payload)\x20—\x20is\x20the\x20row\x20a\x20reward\x20good-review\x20leg\x20must\x20query\x20(query\x20repository.data:\x20the\x20policy-name\x20row\x20+\x20the\x20order-address\x20identifier\x20row,\x20compared\x20against\x20the\x20rating\x20floor).\x20The\x20text\x20row\x20is\x20display;\x20this\x20row\x20is\x20payout\x20authority.','write_guard':[{'guard':ref(cy)}],'id_from':'none','value_type':'U64','write_once':!![]},...cH?[{'name':'buyer_review','description':'Merchant-side\x20structured\x20feedback\x20on\x20the\x20order/buyer\x20(D-R7\x20bidirectional\x20reputation,\x20opt-in).\x20One\x20immutable\x20row\x20per\x20writer\x20(id_from=Signer;\x20write-once\x20—\x20a\x20rewrite\x20attempt\x20aborts\x20on-chain,\x20K3(a)).\x20NO\x20write\x20guard\x20by\x20design:\x20merchant\x20authority\x20is\x20verified\x20at\x20READ\x20time\x20(the\x20writer\x20must\x20control\x20the\x20order\x27s\x20service\x20—\x20graph\x20ControlIndex).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','id_from':'signer','value_type':'String','write_once':!![]}]:[],...cA?[{'name':'review_decision','description':'Merchant\x20approval\x20ledger\x20for\x20the\x20review\x20bounty\x20(professional\x20form):\x20one\x20U64\x20row\x20per\x20order\x20(id_from=None;\x20row\x20id\x20=\x20the\x20order\x20address;\x20value\x20=\x20approved\x20payout\x20in\x20smallest\x20units).\x20A\x20row\x20whose\x20value\x20>=\x20the\x20promised\x20payout\x20IS\x20the\x20approval\x20the\x20claim\x20guard\x27s\x20decision\x20leg\x20reads\x20(tpl_repository_review_decision_gate).\x20Writes\x20REQUIRE\x20the\x20merchant\x20decision\x20credential\x20(guard\x20step\x20\x27guard_review_decision\x27);\x20buyers\x20hold\x20no\x20write\x20path.','write_guard':[{'guard':ref('guard_review_decision')}],'id_from':'none','value_type':'U64'}]:[]]}),'notes':'REVIEW-COMPONENT\x20AR-1:\x20the\x20review\x20TEXT\x20still\x20rides\x20the\x20forward\x20message\x20(D-R1\x20dual\x20carrier);\x20this\x20repository\x20carries\x20ONLY\x20the\x20structured\x20row.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time,\x20both\x20ORDER-KEYED\x20(F09):\x20\x27review\x27\x20(text\x20JSON,\x20id\x20=\x20the\x20ORDER\x20address)\x20AND\x20\x27rating\x27\x20(U64\x20stars,\x20id\x20=\x20the\x20ORDER\x20address\x20—\x20repository.data_add\x20{name:\x27rating\x27,\x20items:[{data:[{id:<order\x20address>,\x20data:<stars>}]}]},\x20same\x20passport\x20as\x20the\x20forward).\x20The\x20\x27rating\x27\x20row\x20is\x20what\x20a\x20reward\x20good-review\x20leg\x20reads\x20(F-62):\x20a\x20good-review\x20bounty\x20claim\x20guard\x20must\x20query\x20this\x20order-keyed\x20U64\x20row,\x20never\x20the\x20text\x20row.\x20Buyers\x20resolve\x20this\x20object\x20by\x20name\x20(workspace/onchain_objects)\x20—\x20never\x20guess\x20an\x20address.'+(cA?'\x20[review_decision\x20policy\x20frozen\x20AFTER\x20its\x20write\x20credential\x20—\x20the\x20guard\x20exists\x20before\x20this\x20create\x20(HOST-GRAPH-01\x20discipline).]':'')}),k['push']({'op':'configure','id':'service_review_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository_review')]}),'requires':['service','repository_review']});}if(N==='review_reward'){const cI=cw;if(cI===undefined||cI['step_id']===undefined)j['push']({'code':'REVIEW_REWARD_GUARD_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20promises\x20a\x20claim\x20reward,\x20but\x20no\x20RESOLVED\x20host:\x22reward\x22\x20guard\x20spec\x20'+'exists\x20to\x20gate\x20the\x20claim.\x20Mount\x20a\x20reward\x20claim\x20guard\x20(e.g.\x20pattern.progress_state_check\x20anchored\x20'+'on\x20the\x20review\x20node\x20or\x20the\x20delivered\x20terminal\x20+\x20review\x20evidence\x20hash)\x20and\x20keep\x20it\x20resolvable\x20—\x20'+'an\x20unguarded\x20incentive\x20promise\x20must\x20not\x20publish\x20(INV-4).\x20The\x20root\x20must\x20also\x20carry\x20the\x20BKN-P2\x20'+'positive-amount\x20leg\x20(order.amount\x20>=\x201)\x20so\x20zero-total\x20orders\x20can\x20never\x20claim.'});else{const cJ=b['reward_funding'],cK=cI['params']?.['reward_claim_amount']??b['reward_claim_amount'],cL=D['get'](cI['key']);cL!==undefined&&!rootHasRewardRecordGate(cL['root'])&&j['push']({'code':'REVIEW_REWARD_UNARMED','detail':'review_reward\x20claim\x20guard\x20\x27'+cI['key']+'\x27\x20carries\x20no\x20record-gate:\x20Reward.claim\x20has\x20no\x20order\x20binding\x20of\x20its\x20own\x20'+'(OFN-C1),\x20so\x20a\x20funded\x20pool\x20behind\x20this\x20guard\x20is\x20a\x20replay-drain\x20target.\x20'+SV2_UNARMED_PRESCRIPTION+'\x20—\x20wrapped\x20in\x20'+'logic_and\x20with\x20the\x20identity\x20leg\x20(Signer\x20==\x20order.owner),\x20the\x20BKN-P2\x20positive-amount\x20'+'leg\x20(order.amount\x20>=\x201\x20—\x20zero-total\x20orders\x20must\x20never\x20claim)\x20and\x20the\x20existing\x20checks\x20'+'(see\x20tpl_reward_one_time_claim\x20v55\x20notes;\x20guard-risk\x20R-X1-14\x20audits\x20the\x20built\x20guard).\x20'+'Professional\x20approval\x20form\x20(F10\x20opt-in):\x20set\x20review_decision_enabled=true\x20to\x20have\x20this\x20'+'plan\x20emit\x20the\x20decision\x20channel\x20(guard\x20step\x20\x27guard_review_decision\x27\x20+\x20the\x20repository\x27s\x20'+'\x27review_decision\x27\x20policy),\x20then\x20compose\x20the\x20decision\x20leg\x20from\x20'+'tpl_repository_review_decision_gate\x20into\x20the\x20root\x20(find_where\x20over\x20\x27review_decision\x27\x20'+'with\x20vec_contains_address\x20pinning\x20the\x20submitted\x20order)\x20so\x20the\x20bounty\x20pays\x20only\x20'+'merchant-approved\x20orders.\x20'+'Until\x20armed,\x20do\x20not\x20fund\x20the\x20pool.'});let cM;if(cL!==undefined&&rootHasRewardRecordGate(cL['root']))for(const cP of cL['table']){const cQ=cP;if(cQ['b_submission']===!![]&&String(cQ['value_type']??'')['toLowerCase']()==='address'&&(String(cQ['object_type']??'')==='Order'||/order/i['test'](String(cQ['name']??'')))){cM=cQ['identifier'];break;}}const cN=cI['params']?.['evidence']??b['review_claim_evidence'];let cO;if(cN!==undefined&&cN!==null&&typeof cN==='object'){const cR=cN,cS=toByteVector(cR['key']),cT=toByteVector(cR['predicate']);cS!==undefined&&cT!==undefined&&(cM===undefined?j['push']({'code':'REVIEW_REWARD_EVIDENCE_NO_STAMP','detail':'review_reward\x20resolved\x20an\x20evidence\x20binding\x20request,\x20but\x20the\x20claim\x20guard\x20mount\x20carries\x20no\x20'+'store_from_id\x20stamp\x20slot\x20—\x20the\x20evidence\x20binding\x20reads\x20THE\x20store_from\x20row\x20(the\x20submitted\x20'+'Order\x20address),\x20so\x20the\x20chain\x20refuses\x20the\x20guard\x20at\x20build\x20time\x20(reward::evidence_bind,\x20'+'E_EVIDENCE_NEEDS_STORE_FROM).\x20Give\x20the\x20claim\x20guard\x27s\x20table\x20an\x20address-typed\x20Order\x20'+'submission\x20row\x20(b_submission)\x20so\x20the\x20mount\x20can\x20pin\x20store_from_id,\x20then\x20rebuild.'}):cO={'repo':ref('repository_review'),'key':cS,'predicate':cT});}cK===undefined&&j['push']({'code':'REVIEW_REWARD_AMOUNT_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20resolved\x20a\x20claim\x20guard\x20but\x20no\x20per-claim\x20bounty\x20was\x20provided.\x20'+'The\x20reward\x20guard_add\x20mount\x20REQUIRES\x20an\x20amount\x20(schema-required)\x20—\x20a\x20plan\x20step\x20emitted\x20without\x20'+'it\x20fails\x20mid-execution\x20(the\x20old\x20note\x20told\x20the\x20executor\x20to\x20\x22fill\x20the\x20amount\x22,\x20but\x20nothing\x20can\x20'+'patch\x20a\x20plan\x20step\x20at\x20run\x20time).\x20Pass\x20\x27reward_claim_amount\x27\x20(a\x20display\x20string\x20with\x20the\x20token\x20'+'symbol\x20like\x20\x271WOW\x27,\x20or\x20a\x20smallest-unit\x20integer\x20like\x20\x27100000000\x27)\x20or\x20set\x20it\x20in\x20the\x20guard\x20'+'spec\x27s\x20params\x20to\x20emit\x20the\x20mount\x20with\x20a\x20fixed\x20per-claim\x20bounty.'}),k['push']({'op':'configure','id':'reward_review_guard_add','target':ref('reward_review'),'method':'guard_add','params':P({'guard':ref(cI['step_id']),'recipient':{'Signer':'signer'},...cK!==undefined?{'amount':{'type':'Fixed','value':String(cK)}}:{},...cM!==undefined?{'store_from_id':cM}:{},...cO!==undefined?{'evidence':cO}:{}}),'requires':['reward_review'],'notes':'RECIPIENT\x20(crs-mn-261015\x20F-12):\x20recipient\x20is\x20pinned\x20to\x20{Signer:\x27signer\x27}\x20—\x20the\x20claim\x20entry\x20'+'requires\x20recipient\x20==\x20the\x20transaction\x20sender\x20(E_CLAIM_RECIPIENT_NOT_SIGNER\x20otherwise);\x20a\x20GuardIdentifier\x20recipient\x20'+'resolves\x20to\x20the\x20submitted\x20Order\x20and\x20can\x20never\x20be\x20paid.'+(cK!==undefined?'\x20AMOUNT\x20(BK15-F09):\x20per-claim\x20bounty\x20pinned\x20at\x20plan\x20time\x20('+String(cK)+')\x20—\x20no\x20execution-time\x20fill\x20needed.':'')+(cM!==undefined?'\x20SV-2\x20entry\x20stamp:\x20store_from_id\x20pins\x20the\x20per-order\x20stamp\x20slot\x20(the\x20submitted\x20Order\x20'+'address)\x20so\x20claim\x20records\x20key\x20per\x20order\x20—\x20once\x20per\x20buyer\x20per\x20order\x20(azx7-mn-261014\x20T8).':'')+(cO!==undefined?'\x20EVIDENCE\x20(ksk9d2-tn-261026\x20F-01):\x20the\x20guard\x20carries\x20an\x20evidence\x20binding\x20—\x20at\x20claim\x20the\x20'+'chain\x20counts\x20repository\x20rows\x20under\x20the\x20binding\x27s\x20(repo,\x20key)\x20matching\x20the\x20predicate\x20for\x20'+'THIS\x20claim\x27s\x20own\x20store_from\x20value\x20(the\x20submitted\x20order)\x20and\x20aborts\x2015\x20'+'(E_EVIDENCE_NOT_OWNED)\x20when\x20none:\x20a\x20borrowed\x20foreign\x20row\x20can\x20never\x20satisfy\x20the\x20bounty;\x20'+'the\x20order\x27s\x20attestation\x20row\x20must\x20exist\x20before\x20the\x20claim.':'')}),k['push']({'op':'configure','id':'service_rewards','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_review')]}),'requires':['service']}),typeof cJ==='string'||typeof cJ==='number'?k['push']({'op':'configure','id':'reward_review_coin_add','target':ref('reward_review'),'method':'coin_add','params':{'coin':String(cJ)},'requires':['reward_review']}):j['push']({'code':'REVIEW_REWARD_UNFUNDED','detail':'review_mode\x20\x27review_reward\x27\x20without\x20a\x20\x27reward_funding\x27\x20input\x20(INV-4\x20R-REWARD-FUNDED):\x20the\x20incentive\x20'+'is\x20a\x20marketing\x20promise\x20that\x20must\x20be\x20FUNDED\x20when\x20the\x20Service\x20is\x20built\x20(sale-time\x20planning\x20—\x20pool\x20>=\x20'+'expected\x20orders\x20x\x20per-order\x20reward,\x20benchmark\x20fee_param\x20review_reward_pool).\x20Pass\x20reward_funding\x20'+'(smallest-unit\x20string)\x20to\x20fund\x20the\x20Reward\x20object,\x20or\x20drop\x20to\x20review_mode\x20\x22review\x22.'});}}}if(K){k['push']({'op':'create','id':'arbitration','object':'arbitration','params':P({'name':h+'_arbitration','permission':ref('permission_arb'),'type_parameter':ab}),'notes':'Independent\x20venue\x20(R2).\x20New\x20arbitrations\x20default\x20bPaused=true\x20—\x20unpause\x20is\x20a\x20separate\x20operator\x20step.'}),k['push']({'op':'configure','id':'service_arbitrations','target':ref('service'),'method':'arbitrations','params':P({'op':'add','objects':[ref('arbitration')]})});const cU=b['compensation_fund'];if(typeof cU==='string'||typeof cU==='number')k['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':String(cU)}});else{const cV=t['some'](cW=>{if(cW['semantic_role']!=='final')return![];for(const cX of cW['from']??[]){if(typeof cX==='string')continue;const cY=cX['guard_key']===undefined?undefined:z['get'](cX['guard_key']);if(cY?.['template_id']==='tpl_forward_arb_ruling_won')return!![];}return![];});cV&&j['push']({'code':'COMPENSATION_FUND_REQUIRED','detail':'This\x20build\x20routes\x20a\x20POST-settlement\x20arbitration\x20re-route\x20(an\x20arb-ruling-won\x20guard\x20on\x20an\x20edge\x20'+'leaving\x20a\x20settled\x20terminal):\x20the\x20escrow\x20is\x20already\x20drained\x20when\x20that\x20ruling\x20lands,\x20so\x20the\x20buyer\x27s\x20'+'only\x20remedy\x20is\x20the\x20compensation\x20fund\x20—\x20which\x20this\x20build\x20never\x20creates.\x20Pass\x20'+'inputs.compensation_fund\x20(>=\x20the\x20largest\x20single-order\x20exposure)\x20so\x20the\x20indemnity\x20is\x20real,\x20'+'or\x20rebuild\x20on\x20a\x20template\x20without\x20the\x20post-settlement\x20arb\x20edge.'});}}k['push']({'op':'publish','id':'service_publish','target':ref('service'),'preflight':[{'check':'service_publish','status':'pending'},{'check':'FUND-EXIT-01','status':'pending'},{'check':'PLAN-ALLOC-01','status':'pending'},{'check':'TASKBIND-02','status':'pending'}]});const ai=new Set(u['map'](cW=>cW['guard_key'])['filter'](cW=>typeof cW==='string')),aj=/^0x[0-9a-fA-F]{20,64}$/,ak=cW=>{const cX=D['get'](cW);if(cX===undefined)return undefined;for(const cY of cX['table']){const cZ=cY;if(cZ['b_submission']===!![]||cZ['value_type']!=='Address')continue;const d0=cZ['value'];if(typeof d0==='string'&&aj['test'](d0))return String(cZ['identifier']??'?');}return undefined;};for(const cW of D['keys']()){if(!G['has'](cW)&&!ai['has'](cW))continue;const cX=ak(cW);cX!==undefined&&j['push']({'code':'GUARD_FOREIGN_SERVICE','detail':'guard\x20\x27'+cW+'\x27\x20pins\x20an\x20on-chain\x20address\x20literal\x20(table\x20slot\x20'+cX+')\x20while\x20bound\x20into\x20this\x20build.\x20'+'The\x20plan\x27s\x20Service\x20is\x20created\x20BY\x20this\x20plan\x20and\x20cannot\x20equal\x20a\x20pre-existing\x20address,\x20so\x20the\x20pin\x20names\x20a\x20foreign\x20or\x20'+'stale\x20object:\x20each\x20object\x20is\x20well-formed\x20alone,\x20but\x20the\x20cross-object\x20identity\x20assert\x20aborts\x20every\x20guarded\x20forward\x20'+'(klook\x20B11\x20class),\x20and\x20Guard\x20+\x20machine\x20are\x20both\x20create/publish-frozen\x20—\x20unrepairable.\x20'+'Bind\x20by\x20plan\x20reference\x20({\x22$ref\x22:\x22service\x22})\x20or\x20by\x20the\x20P16\x20circular\x20service\x20NAME\x20instead.'});}const al=E['flatMap'](cY=>{const cZ=ai['has'](cY['key'])?'allocator':G['has'](cY['key'])?'machine_edge':cY['host']==='service'&&cY['key']==='buy'?'service_buy':undefined;return cZ?[{'key':cY['key'],'template_id':cY['template_id'],'host':cY['host'],'site':cZ,'purpose':cY['purpose']}]:[];});return{'plan':{'version':0x1,'intent':d['intent']??'compile\x20'+a['id'],'templateId':a['id'],'inputs':b,'steps':k,...al['length']>0x0?{'pending_guards':al}:{}},'guardSpecs':x,'unresolved':E,'blockers':j,'omitted':[...w]};}
@@ -1 +1 @@
1
- import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent'],g=f?.['result'];return{'outcome':f?.['outcome']==='executed'?'executed':f?.['outcome']==='pending_input'?'pending_input':'failed','digest':g?.['digest'],'created':Array['isArray'](g?.['created'])?g['created']:[],'error':g?.['error']};};}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return b;case'permission':case'contact':case'repository':default:return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g};}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical'),e=a['steps']['map'](f=>{if(f['op']!=='publish')return f;const g=f['preflight']['map'](h=>{const i=h['check']['endsWith']('_publish')?d:!c['has'](h['check']);return{...h,'status':i?'pass':'fail'};});return{...f,'preflight':g};});return{'plan':{...a,'steps':e},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b){const {plan:c,audit:d}=preflightPlan(a),f=new Map(),g=[],h=b['resolveLate']??DEFAULT_LATE,i=new Map(c['steps']['filter'](m=>m['op']==='create')['map'](m=>[m['id'],m['object']])),j=m=>resolveValue(m,f,h);let k=![];for(const m of c['steps']){if(k){g['push']({'stepId':m['id'],'status':'blocked','error':'halted\x20by\x20earlier\x20failure/blocked\x20publish'});continue;}try{if(m['op']==='publish'){const q=m['preflight']['filter'](t=>t['status']==='fail');if(q['length']>0x0){g['push']({'stepId':m['id'],'status':'blocked','error':'preflight\x20failed:\x20'+q['map'](t=>t['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const r=j(m['target']),s=await b['execute'](i['get'](m['target']['$ref'])??'',{'object':r,'publish':!![]},b['env']);if(s['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':s['error']??s['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':s['digest'],'address':r});continue;}const n=Object['fromEntries'](Object['entries'](m['params'])['map'](([t,u])=>[t,j(u)]));if(m['op']==='create'){const t=adaptCreateData(m,n),u=await b['execute'](m['object'],t,b['env']);if(u['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':u['error']??u['outcome']}),k=!![];continue;}const v=matchCreated(u,CREATABLE_OBJECTS[m['object']]);if(v===undefined){g['push']({'stepId':m['id'],'status':'failed','error':'created\x20'+m['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),k=!![];continue;}f['set'](m['id'],v),g['push']({'stepId':m['id'],'status':'executed','digest':u['digest'],'address':v});continue;}const o=j(m['target']),p=await b['execute'](i['get'](isRef(m['target'])?m['target']['$ref']:'')??'',{'object':o,[m['method']]:n},b['env']);if(p['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':p['error']??p['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':p['digest'],'address':o});}catch(w){g['push']({'stepId':m['id'],'status':'failed','error':w instanceof Error?w['message']:String(w)}),k=!![];}}const l=await verifyMaterialization(c,f,b);return{'steps':g,'outputs':Object['fromEntries'](f),'completed':g['every'](x=>x['status']==='executed'),'preflight':d,'readback':l};}export function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=new Map();for(const e of b){const f=e['track']??'settlement';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [g,h]of c){const i=h['flatMap'](l=>(l['sharing']??[])['map'](m=>m['mode']));if(i['some'](l=>l==='Amount')){d['push']({'name':'conservation:'+g,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});continue;}let j=0x0;for(const l of h){for(const m of l['sharing']??[]){if(m['mode']==='Rate'||m['mode']==='RateGross')j+=Number(m['sharing']??0x0);}}const k=i['some'](n=>n==='Surplus');if(j>0x2710)d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20track\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):d['push']({'name':'conservation:'+g,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}return d;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
1
+ import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent'],g=f?.['result'];return{'outcome':f?.['outcome']==='executed'?'executed':f?.['outcome']==='pending_input'?'pending_input':'failed','digest':g?.['digest'],'created':Array['isArray'](g?.['created'])?g['created']:[],'error':g?.['error']};};}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return b;case'permission':case'contact':case'repository':default:return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g};}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b){const {plan:c,audit:d}=preflightPlan(a),f=new Map(),g=[],h=b['resolveLate']??DEFAULT_LATE,i=new Map(c['steps']['filter'](m=>m['op']==='create')['map'](m=>[m['id'],m['object']])),j=m=>resolveValue(m,f,h);let k=![];for(const m of c['steps']){if(k){g['push']({'stepId':m['id'],'status':'blocked','error':'halted\x20by\x20earlier\x20failure/blocked\x20publish'});continue;}try{if(m['op']==='publish'){const q=m['preflight']['filter'](t=>t['status']==='fail');if(q['length']>0x0){g['push']({'stepId':m['id'],'status':'blocked','error':'preflight\x20failed:\x20'+q['map'](t=>t['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const r=j(m['target']),s=await b['execute'](i['get'](m['target']['$ref'])??'',{'object':r,'publish':!![]},b['env']);if(s['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':s['error']??s['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':s['digest'],'address':r});continue;}const n=Object['fromEntries'](Object['entries'](m['params'])['map'](([t,u])=>[t,j(u)]));if(m['op']==='create'){const t=adaptCreateData(m,n),u=await b['execute'](m['object'],t,b['env']);if(u['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':u['error']??u['outcome']}),k=!![];continue;}const v=matchCreated(u,CREATABLE_OBJECTS[m['object']]);if(v===undefined){g['push']({'stepId':m['id'],'status':'failed','error':'created\x20'+m['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),k=!![];continue;}f['set'](m['id'],v),g['push']({'stepId':m['id'],'status':'executed','digest':u['digest'],'address':v});continue;}const o=j(m['target']),p=await b['execute'](i['get'](isRef(m['target'])?m['target']['$ref']:'')??'',{'object':o,[m['method']]:n},b['env']);if(p['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':p['error']??p['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':p['digest'],'address':o});}catch(w){g['push']({'stepId':m['id'],'status':'failed','error':w instanceof Error?w['message']:String(w)}),k=!![];}}const l=await verifyMaterialization(c,f,b);return{'steps':g,'outputs':Object['fromEntries'](f),'completed':g['every'](x=>x['status']==='executed'),'preflight':d,'readback':l};}export function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=new Map();for(const e of b){const f=e['track']??'settlement';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [g,h]of c){const i=h['flatMap'](l=>(l['sharing']??[])['map'](m=>m['mode']));if(i['some'](l=>l==='Amount')){d['push']({'name':'conservation:'+g,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});continue;}let j=0x0;for(const l of h){for(const m of l['sharing']??[]){if(m['mode']==='Rate'||m['mode']==='RateGross')j+=Number(m['sharing']??0x0);}}const k=i['some'](n=>n==='Surplus');if(j>0x2710)d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20track\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):d['push']({'name':'conservation:'+g,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}return d;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{toBase58}from'@wowok/wowok';import{DataType,newDb}from'pg-mem';import{afterEach,beforeEach,describe,expect,it}from'vitest';import{PostgresProjectionStore}from'../projection/store.js';import{PostgresSyncStore}from'../sync/store.js';import{createProjectionApi}from'./server.js';const digest=toBase58(new Uint8Array(0x20)['fill'](0x7)),objectId='0x14'+'01'['repeat'](0x1f);describe('projection\x20read-only\x20API',()=>{let a,b,c,d;beforeEach(async()=>{const e=newDb();e['public']['registerFunction']({'name':'pg_advisory_xact_lock','args':[DataType['integer'],DataType['integer']],'returns':DataType['integer'],'implementation':()=>0x0});const {Pool:f}=e['adapters']['createPg']();a=new PostgresProjectionStore(new f(),0x10),b=new PostgresSyncStore(new f()),await a['migrate'](),await b['migrate'](),await a['apply']({'chain_id':'chain_a','object_id':objectId,'object_version':'1','move_type':'0x2::service::Service<0x2::wow::WOW>','owner_kind':'Shared','payload_uri':'test://raw/service-1','payload_hash':'0x'+'41'['repeat'](0x20),'payload_format':'json+bcs-v1','payload_json':{'name':'Indexed\x20service','stock':0x3},'checkpoint':'100','tx_digest':digest,'state':'active','observed_at':'2026-10-24T00:00:00.000Z'});const g=await b['start']({'chainId':'chain_a','stream':'graphql-shared:Service','scope':{'kind':'Service'},'checkpoint':'100'});await b['savePage']({'chainId':g['chainId'],'stream':g['stream'],'runId':g['runId'],'cursor':null,'checkpoint':'100','objects':[{'objectId':objectId,'objectVersion':0x1n}]}),await b['complete']({'chainId':g['chainId'],'stream':g['stream'],'runId':g['runId']}),c=createProjectionApi({'chainId':'chain_a','projection':a,'sync':b}),await new Promise(i=>c['listen'](0x0,'127.0.0.1',i));const h=c['address']();d='http://127.0.0.1:'+h['port'];}),afterEach(async()=>{await new Promise((e,f)=>{c['close'](g=>g?f(g):e());}),await a['close'](),await b['close']();}),it('returns\x20projection\x20and\x20persisted\x20sync\x20status',async()=>{const e=await fetch(d+'/v1/status'),f=await e['json']();expect(e['status'])['toBe'](0xc8),expect(f)['toMatchObject']({'chain_id':'chain_a','read_only':!![],'projection':{'active_objects':0x1,'coverage':{'complete':![]}},'sync':[{'state':'complete','pages':0x1,'objects':0x1}],'head':null,'freshness':null}),expect(f['watermarks'])['toEqual']([{'verified_kind':'Service','max_checkpoint':'100','active_objects':0x1}]);}),it('reports\x20chain-head\x20lag\x20and\x20staleness\x20when\x20a\x20probe\x20is\x20configured',async()=>{const e=createProjectionApi({'chainId':'chain_a','projection':a,'sync':b,'staleLag':0x3,'head':{'read':async()=>({'checkpoint':'105','observed_at':'2026-10-24T12:00:00.000Z','source':'probe'})}});await new Promise(g=>e['listen'](0x0,'127.0.0.1',g));const f=e['address']();try{const g=await fetch('http://127.0.0.1:'+f['port']+'/v1/status'),h=await g['json']();expect(h['head'])['toMatchObject']({'checkpoint':'105','source':'probe'}),expect(h['freshness'])['toEqual']({'head_checkpoint':'105','projection_checkpoint':'100','head_lag':'5','stale':!![]});}finally{await new Promise((i,j)=>{e['close'](k=>k?j(k):i());});}}),it('lists\x20current\x20objects\x20with\x20coverage\x20and\x20version\x20metadata',async()=>{const e=await fetch(d+'/v1/objects?kind=Service&limit=1'),f=await e['json']();expect(e['status'])['toBe'](0xc8),expect(f['objects'])['toHaveLength'](0x1),expect(f['objects'][0x0])['toMatchObject']({'objectId':objectId,'objectVersion':'1','verifiedKind':'Service','payloadJson':{'name':'Indexed\x20service','stock':0x3}}),expect(f['coverage'])['toMatchObject']({'mode':'known_objects','complete':![]}),expect(e['headers']['get']('cache-control'))['toBe']('no-store');}),it('rejects\x20invalid\x20selectors\x20without\x20exposing\x20internal\x20errors',async()=>{const e=await fetch(d+'/v1/objects?kind=Unknown'),f=await fetch(d+'/v1/objects?cursor=invalid'),g=await fetch(d+'/v1/objects?shard_count=16');expect(e['status'])['toBe'](0x190),expect(f['status'])['toBe'](0x190),expect(g['status'])['toBe'](0x190),expect(await e['json']())['toEqual']({'error':{'code':'BAD_REQUEST','message':'Unknown\x20object\x20kind:\x20Unknown'}});}),it('exposes\x20graph\x20edges\x20with\x20orphan\x20annotation',async()=>{const e='0x15'+'02'['repeat'](0x1f);await a['apply']({'chain_id':'chain_a','object_id':objectId,'object_version':'2','move_type':'0x2::service::Service<0x2::wow::WOW>','owner_kind':'Shared','payload_uri':'test://raw/service-2','payload_hash':'0x'+'43'['repeat'](0x20),'payload_format':'rpc-content-v1','payload_json':{'machine':e,'name':'Indexed\x20service'},'checkpoint':'101','tx_digest':digest,'state':'active','observed_at':'2026-10-24T01:00:00.000Z'});const f=await fetch(d+'/v1/edges?src='+objectId),g=await f['json']();expect(f['status'])['toBe'](0xc8),expect(g)['toMatchObject']({'direction':'out','object_id':objectId,'orphan_count':0x1}),expect(g['edges'])['toEqual']([{'src':objectId,'srcKind':'Service','edge':'machine','dst':e,'dstKind':'Machine','objectVersion':'2','dstProjected':![]}]);const h=await fetch(d+'/v1/edges?dst='+e),i=await h['json']();expect(h['status'])['toBe'](0xc8),expect(i['direction'])['toBe']('in'),expect(i['edges'][0x0])['toMatchObject']({'src':objectId,'edge':'machine'});const j=await fetch(d+'/v1/edges'),k=await fetch(d+'/v1/edges?src=invalid');expect(j['status'])['toBe'](0x190),expect(k['status'])['toBe'](0x190);}),it('has\x20no\x20write\x20or\x20catch-all\x20endpoints',async()=>{const e=await fetch(d+'/v1/objects',{'method':'POST','body':'{}'}),f=await fetch(d+'/v1/unknown');expect(e['status'])['toBe'](0x195),expect(e['headers']['get']('allow'))['toBe']('GET'),expect(f['status'])['toBe'](0x194);});}),describe('match\x20API',()=>{let a,b,c,d;const e=j=>'0x14'+j['repeat'](0x1f),f=e('01'),g=e('02'),h=e('03');function i(j,k,l){return{'chain_id':'chain_a','object_id':j,'object_version':k,'move_type':'0x2::service::Service<0x2::wow::WOW>','owner_kind':'Shared','payload_uri':'test://raw/'+j+'-'+k,'payload_hash':'0x'+'41'['repeat'](0x20),'payload_format':'rpc-content-v1','payload_json':l,'checkpoint':'100','tx_digest':toBase58(new Uint8Array(0x20)['fill'](0x7)),'state':'active','observed_at':'2026-10-24T00:00:00.000Z'};}beforeEach(async()=>{const j=newDb();j['public']['registerFunction']({'name':'pg_advisory_xact_lock','args':[DataType['integer'],DataType['integer']],'returns':DataType['integer'],'implementation':()=>0x0});const {Pool:k}=j['adapters']['createPg']();a=new PostgresProjectionStore(new k(),0x10),b=new PostgresSyncStore(new k()),await a['migrate'](),await b['migrate'](),await a['apply'](i(f,'1',{'description':'Exclusive\x20beat\x20license\x20for\x20hip\x20hop\x20producers','location':'remote','sales':[{'fields':{'name':'Beat\x20License','price':'6000000000','wip_hash':'0xabc'}}],'arbitrations':['0x12'+'04'['repeat'](0x1f)],'compensation_fund':'1000000000','machine':'0x15'+'05'['repeat'](0x1f),'um':'0x24'+'06'['repeat'](0x1f),'bPublished':!![],'bPaused':![]})),await a['apply'](i(g,'1',{'description':'Coffee\x20shop\x20interior\x20mural\x20painting','location':'Shanghai','sales':[{'fields':{'name':'Mural','price':'15000000000'}}],'arbitrations':[],'compensation_fund':'0','bPublished':!![],'bPaused':![]})),await a['apply'](i(h,'1',{'description':'Beat\x20store\x20on\x20holiday','sales':[{'fields':{'name':'Beat\x20Pack','price':'1000000000'}}],'bPublished':!![],'bPaused':!![]})),c=createProjectionApi({'chainId':'chain_a','projection':a,'sync':b}),await new Promise(l=>c['listen'](0x0,'127.0.0.1',l)),d='http://127.0.0.1:'+c['address']()['port'];}),afterEach(async()=>{await new Promise((j,k)=>{c['close'](l=>l?k(l):j());}),await a['close'](),await b['close']();}),it('matches\x20materialized\x20facets\x20end-to-end\x20with\x20honest\x20coverage',async()=>{const j=new URLSearchParams({'kind':'Service','q':'beat\x20license','capabilities':'has_arbitration','budget':'10','limit':'10'}),k=await fetch(d+'/v1/match?'+j),l=await k['json']();expect(k['status'])['toBe'](0xc8),expect(l['chain_id'])['toBe']('chain_a'),expect(l['policy_version'])['toBe']('public-baseline-1'),expect(l['coverage'])['toMatchObject']({'mode':'known_objects','complete':![]}),expect(l['recall'])['toMatchObject']({'live_set':0x3,'gated':0x2,'merged':0x2,'channels_active':['structured','bm25']}),expect(l['candidates']['map'](o=>o['object_id']))['toEqual']([f,g]);const m=l['candidates'][0x0];expect(m['server_evaluation']['policy_version'])['toBe']('public-baseline-1'),expect(m['server_evaluation']['total'])['toBe'](0x64),expect(m['server_evaluation']['unknown_rules']['some'](o=>o['startsWith']('trust:')))['toBe'](!![]),expect(m['public_features']['capabilities'])['toContain']('has_refund_path');const n=l['candidates'][0x1];expect(n['server_evaluation']['red_flags'])['toEqual'](['price_over_budget','missing_capability:has_arbitration']);}),it('rejects\x20invalid\x20match\x20parameters',async()=>{const j=['/v1/match','/v1/match?kind=Arb','/v1/match?kind=Service&capabilities=has_wings','/v1/match?kind=Service&budget=abc','/v1/match?kind=Service&budget=1.2345678901','/v1/match?kind=Service&budget=-5','/v1/match?kind=Service&limit=0','/v1/match?kind=Service&limit=101','/v1/match?kind=Service&recall_limit=1001'];for(const k of j){const l=await fetch(''+d+k);expect(l['status'],k)['toBe'](0x190),expect((await l['json']())['error']['code'])['toBe']('BAD_REQUEST');}});});
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{PostgresProjectionStore}from'../projection/store.js';import{PostgresSyncStore}from'../sync/store.js';import{createChainHeadProbe}from'./head.js';import{createProjectionApi}from'./server.js';async function main(){const a=process['argv']['slice'](0x2);if(a[0x0]==='--help'||a[0x0]==='help'){console['log']('Usage:\x20index-api\x20<chain-id>\x0aEnvironment:\x20DATABASE_URL,\x20WOWOK_INDEX_HOST=127.0.0.1,\x20WOWOK_INDEX_PORT=8787,\x20WOWOK_HEAD_RPC_URL\x20(optional),\x20WOWOK_INDEX_STALE_LAG=0\x20(optional)');return;}if(a['length']!==0x1||!a[0x0]){console['error']('Usage:\x20index-api\x20<chain-id>'),process['exitCode']=0x2;return;}const b=process['env']['DATABASE_URL'];if(!b)throw new Error('DATABASE_URL\x20is\x20required');const c=process['env']['WOWOK_INDEX_HOST']??'127.0.0.1',d=Number(process['env']['WOWOK_INDEX_PORT']??0x2253);if(!Number['isInteger'](d)||d<0x0||d>0xffff)throw new Error('Invalid\x20API\x20port');const e=Number(process['env']['WOWOK_INDEX_SHARD_COUNT']??0x100),f=Number(process['env']['WOWOK_INDEX_STALE_LAG']??0x0),g=process['env']['WOWOK_HEAD_RPC_URL'],h=PostgresProjectionStore['fromDatabaseUrl'](b,e),i=PostgresSyncStore['fromDatabaseUrl'](b),j=createProjectionApi({'chainId':a[0x0],'projection':h,'sync':i,'staleLag':f,'head':g?createChainHeadProbe(g):undefined});try{await new Promise((k,l)=>{j['once']('error',l),j['listen'](d,c,()=>{const n=j['address']();console['log'](JSON['stringify']({'status':'listening','host':n['address'],'port':n['port'],'read_only':!![]}));});const m=()=>{j['close'](n=>n?l(n):k());};process['once']('SIGINT',m),process['once']('SIGTERM',m);});}finally{await h['close'](),await i['close']();}}await main();
@@ -0,0 +1,16 @@
1
+ export interface ChainHeadState {
2
+ checkpoint: string | null;
3
+ observed_at: string | null;
4
+ source: "probe" | "cache" | null;
5
+ error?: string;
6
+ }
7
+ export interface ChainHeadProbe {
8
+ read(): Promise<ChainHeadState>;
9
+ }
10
+ interface HeadProbeOptions {
11
+ cacheMs?: number;
12
+ timeoutMs?: number;
13
+ fetchImpl?: typeof fetch;
14
+ }
15
+ export declare function createChainHeadProbe(rpcUrl: string, options?: HeadProbeOptions): ChainHeadProbe;
16
+ export {};
@@ -0,0 +1 @@
1
+ export function createChainHeadProbe(a,b={}){const c=b['cacheMs']??0x2710,d=b['timeoutMs']??0x1388,e=b['fetchImpl']??fetch;let f=null;return{async 'read'(){const g=Date['now']();if(f&&g-f['at']<c)return{...f['state'],'source':'cache'};try{const h=await e(a,{'method':'POST','headers':{'Content-Type':'application/json'},'body':JSON['stringify']({'jsonrpc':'2.0','id':0x1,'method':'w_getLatestCheckpointSequenceNumber','params':[]}),'signal':AbortSignal['timeout'](d)});if(!h['ok'])throw new Error('HTTP\x20'+h['status']);const i=await h['json']();if(i['error']||typeof i['result']!=='string'||!/^\d+$/['test'](i['result']))throw new Error(i['error']?.['message']??'Unexpected\x20JSON-RPC\x20response');const j={'checkpoint':i['result'],'observed_at':new Date()['toISOString'](),'source':'probe'};return f={'state':j,'at':g},j;}catch(k){const l={'checkpoint':null,'observed_at':null,'source':null,'error':k instanceof Error?k['message']['slice'](0x0,0xc8):String(k)['slice'](0x0,0xc8)};return l;}}};}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{describe,expect,it,vi}from'vitest';import{createChainHeadProbe}from'./head.js';function jsonResponse(a,b=0xc8){return new Response(JSON['stringify'](a),{'status':b,'headers':{'Content-Type':'application/json'}});}describe('createChainHeadProbe',()=>{it('reads\x20the\x20latest\x20checkpoint\x20through\x20JSON-RPC',async()=>{const a=vi['fn'](async(e,f)=>jsonResponse({'jsonrpc':'2.0','id':0x1,'result':'12345'})),b=createChainHeadProbe('http://127.0.0.1:9000',{'fetchImpl':a}),c=await b['read']();expect(c)['toMatchObject']({'checkpoint':'12345','source':'probe'});const d=a['mock']['calls'][0x0][0x1];expect(JSON['parse'](String(d?.['body']))['method'])['toBe']('w_getLatestCheckpointSequenceNumber');}),it('serves\x20repeated\x20reads\x20from\x20cache\x20within\x20the\x20cache\x20window',async()=>{const a=vi['fn'](async()=>jsonResponse({'jsonrpc':'2.0','id':0x1,'result':'7'})),b=createChainHeadProbe('http://127.0.0.1:9000',{'cacheMs':0xea60,'fetchImpl':a});await b['read']();const c=await b['read']();expect(c)['toMatchObject']({'checkpoint':'7','source':'cache'}),expect(a)['toHaveBeenCalledTimes'](0x1);}),it('degrades\x20to\x20a\x20null\x20checkpoint\x20when\x20the\x20endpoint\x20fails',async()=>{const a=vi['fn'](async()=>{throw new Error('connect\x20ECONNREFUSED');}),b=createChainHeadProbe('http://127.0.0.1:9000',{'fetchImpl':a}),c=await b['read']();expect(c['checkpoint'])['toBeNull'](),expect(c['source'])['toBeNull'](),expect(c['error'])['toContain']('ECONNREFUSED');}),it('degrades\x20on\x20JSON-RPC\x20errors\x20and\x20malformed\x20results',async()=>{const a=createChainHeadProbe('http://x',{'fetchImpl':vi['fn'](async()=>jsonResponse({'jsonrpc':'2.0','id':0x1,'error':{'message':'method\x20not\x20found'}}))});expect(await a['read']())['toMatchObject']({'checkpoint':null,'error':'method\x20not\x20found'});const b=createChainHeadProbe('http://x',{'fetchImpl':vi['fn'](async()=>jsonResponse({'jsonrpc':'2.0','id':0x1,'result':'not-a-number'}))});expect((await b['read']())['checkpoint'])['toBeNull']();});});
@@ -0,0 +1,2 @@
1
+ export { createProjectionApi } from "./server.js";
2
+ export type { ProjectionApiOptions } from "./server.js";
@@ -0,0 +1 @@
1
+ export{createProjectionApi}from'./server.js';
@@ -0,0 +1,69 @@
1
+ import type { ObjectFacetRow } from "../projection/types.js";
2
+ export declare const PUBLIC_POLICY_VERSION = "public-baseline-1";
3
+ export declare const KNOWN_CAPABILITIES: readonly ["has_arbitration", "has_refund_path", "has_milestone_nodes", "has_compensation_fund", "has_wip_verification", "has_messenger", "has_buy_guard"];
4
+ declare const DIMENSION_WEIGHTS: {
5
+ readonly text: 30;
6
+ readonly region: 15;
7
+ readonly industry: 20;
8
+ readonly price: 15;
9
+ readonly capabilities: 20;
10
+ };
11
+ export interface MatchQuery {
12
+ kind: "Service" | "Demand";
13
+ q?: string;
14
+ location?: string;
15
+ budgetWei?: string;
16
+ industry?: string;
17
+ capabilities?: string[];
18
+ limit?: number;
19
+ recallLimit?: number;
20
+ }
21
+ export interface MatchBreakdownEntry {
22
+ dimension: keyof typeof DIMENSION_WEIGHTS;
23
+ weight: number;
24
+ score: number | null;
25
+ }
26
+ export interface MatchServerEvaluation {
27
+ policy_version: typeof PUBLIC_POLICY_VERSION;
28
+ total: number;
29
+ breakdown: MatchBreakdownEntry[];
30
+ unknown_rules: string[];
31
+ red_flags: string[];
32
+ }
33
+ export interface MatchCandidate {
34
+ object_id: string;
35
+ verified_kind: string;
36
+ object_version: string;
37
+ facet_version: string;
38
+ channels: string[];
39
+ rrf: number;
40
+ public_features: {
41
+ industry: string | null;
42
+ industry_confidence: number;
43
+ location: string | null;
44
+ price_min: string | null;
45
+ price_max: string | null;
46
+ capabilities: string[];
47
+ published: boolean;
48
+ paused: boolean;
49
+ keywords: string[];
50
+ };
51
+ server_evaluation: MatchServerEvaluation;
52
+ }
53
+ export interface MatchResult {
54
+ policy_version: typeof PUBLIC_POLICY_VERSION;
55
+ kind: string;
56
+ query: MatchQuery;
57
+ recall: {
58
+ live_set: number;
59
+ gated: number;
60
+ structured: number;
61
+ bm25: number;
62
+ merged: number;
63
+ channels_active: string[];
64
+ };
65
+ candidates: MatchCandidate[];
66
+ truncated: boolean;
67
+ }
68
+ export declare function runMatch(facets: ObjectFacetRow[], query: MatchQuery): MatchResult;
69
+ export {};