@wowok/agent-mcp 3.4.2 → 3.4.3

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 (308) hide show
  1. package/dist/.build-stamp.json +5 -0
  2. package/dist/chain-semantics/composition-truth.js +1 -1
  3. package/dist/chain-semantics/eval-order.js +1 -1
  4. package/dist/chain-semantics/field-capability.js +1 -1
  5. package/dist/chain-semantics/freeze-map.js +1 -1
  6. package/dist/chain-semantics/fund-flow.js +1 -1
  7. package/dist/chain-semantics/guard-verbs.js +1 -1
  8. package/dist/chain-semantics/object-graph.js +1 -1
  9. package/dist/composition/audit.js +1 -1
  10. package/dist/composition/compile.d.ts +10 -3
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/emit-phases.d.ts +30 -2
  13. package/dist/composition/emit-phases.js +1 -1
  14. package/dist/composition/guard-fill.d.ts +8 -0
  15. package/dist/composition/guard-fill.js +1 -1
  16. package/dist/composition/inflight.js +1 -1
  17. package/dist/composition/input-normalize.js +1 -1
  18. package/dist/composition/materialize.d.ts +2 -0
  19. package/dist/composition/materialize.js +1 -1
  20. package/dist/composition/mode-gates.js +1 -1
  21. package/dist/composition/param-disclosure.js +1 -1
  22. package/dist/composition/plan-retry-ledger.d.ts +16 -0
  23. package/dist/composition/plan-retry-ledger.js +1 -1
  24. package/dist/composition/plan.d.ts +15 -1
  25. package/dist/composition/plan.js +1 -1
  26. package/dist/config/config-audit.spec.js +1 -1
  27. package/dist/config/judgment.d.ts +5 -0
  28. package/dist/config/judgment.js +1 -1
  29. package/dist/evaluation/builtins/arbitration-score.d.ts +1 -0
  30. package/dist/evaluation/builtins/arbitration-score.js +1 -1
  31. package/dist/evaluation/builtins/demand-match.js +1 -1
  32. package/dist/evaluation/builtins/graph-service.d.ts +8 -0
  33. package/dist/evaluation/builtins/graph-service.js +1 -1
  34. package/dist/evaluation/capability.d.ts +9 -0
  35. package/dist/evaluation/engine.js +1 -1
  36. package/dist/evaluation/extract.d.ts +9 -1
  37. package/dist/evaluation/extract.js +1 -1
  38. package/dist/evaluation/match-operation.js +1 -1
  39. package/dist/evaluation/match-policy.d.ts +5 -3
  40. package/dist/evaluation/match-policy.js +1 -1
  41. package/dist/evaluation/standards.d.ts +1 -0
  42. package/dist/evaluation/standards.js +1 -1
  43. package/dist/evaluation/structured-lines.js +1 -1
  44. package/dist/evaluation/types.d.ts +1 -0
  45. package/dist/extensions/capability.js +1 -1
  46. package/dist/harness/recover.js +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/intent/types.d.ts +1 -1
  49. package/dist/intent/types.js +1 -1
  50. package/dist/knowledge/allocation-ledger.js +1 -1
  51. package/dist/knowledge/allocator-rail-verifier.d.ts +17 -1
  52. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  53. package/dist/knowledge/arb-fund-facts.d.ts +7 -0
  54. package/dist/knowledge/arb-fund-facts.js +1 -1
  55. package/dist/knowledge/arbitration-rail-verifier.d.ts +35 -0
  56. package/dist/knowledge/arbitration-rail-verifier.js +1 -0
  57. package/dist/knowledge/audit-rules.d.ts +11 -0
  58. package/dist/knowledge/audit-rules.js +1 -1
  59. package/dist/knowledge/baselines/judgment-baselines.json +1 -0
  60. package/dist/knowledge/baselines/rules/guard.json +7 -6
  61. package/dist/knowledge/baselines/rules/progress.json +4 -4
  62. package/dist/knowledge/baselines/rules/reward.json +118 -3
  63. package/dist/knowledge/builtin-templates.d.ts +3 -2
  64. package/dist/knowledge/builtin-templates.js +1 -1
  65. package/dist/knowledge/chain-query-registry.d.ts +14 -0
  66. package/dist/knowledge/chain-query-registry.js +1 -0
  67. package/dist/knowledge/event-semantics.js +1 -1
  68. package/dist/knowledge/fee-param-bindings.d.ts +2 -0
  69. package/dist/knowledge/fee-param-bindings.js +1 -1
  70. package/dist/knowledge/getting-started.js +1 -1
  71. package/dist/knowledge/guard-binding-table.js +1 -1
  72. package/dist/knowledge/guard-binding-verifier.d.ts +7 -0
  73. package/dist/knowledge/guard-binding-verifier.js +1 -1
  74. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  75. package/dist/knowledge/guard-design-patterns.js +1 -1
  76. package/dist/knowledge/guard-host-context.js +1 -1
  77. package/dist/knowledge/guard-lint.js +1 -1
  78. package/dist/knowledge/guard-node-gates.d.ts +3 -1
  79. package/dist/knowledge/guard-node-gates.js +1 -1
  80. package/dist/knowledge/guard-puzzle.js +1 -1
  81. package/dist/knowledge/guard-render.js +1 -1
  82. package/dist/knowledge/guard-risk.js +1 -1
  83. package/dist/knowledge/guard-templates.d.ts +2 -1
  84. package/dist/knowledge/guard-templates.js +1 -1
  85. package/dist/knowledge/guard-translation.js +1 -1
  86. package/dist/knowledge/index.d.ts +2 -0
  87. package/dist/knowledge/index.js +1 -1
  88. package/dist/knowledge/industry-registry.js +1 -1
  89. package/dist/knowledge/jsonrpc-enum.js +1 -1
  90. package/dist/knowledge/knob-docs.js +1 -1
  91. package/dist/knowledge/param-schema.d.ts +1 -1
  92. package/dist/knowledge/param-schema.js +1 -1
  93. package/dist/knowledge/param-tiers.d.ts +2 -0
  94. package/dist/knowledge/param-tiers.js +1 -1
  95. package/dist/knowledge/path-oracle/products/food-delivery.js +1 -1
  96. package/dist/knowledge/pattern-resolutions.d.ts +2 -0
  97. package/dist/knowledge/pattern-resolutions.js +1 -1
  98. package/dist/knowledge/product-detail-source.d.ts +37 -0
  99. package/dist/knowledge/product-detail-source.js +1 -0
  100. package/dist/knowledge/product-doc-b5.d.ts +16 -0
  101. package/dist/knowledge/product-doc-b5.js +1 -0
  102. package/dist/knowledge/progress-ledger.js +1 -1
  103. package/dist/knowledge/projection.spec.js +1 -1
  104. package/dist/knowledge/publish-gate.d.ts +20 -0
  105. package/dist/knowledge/publish-gate.js +1 -0
  106. package/dist/knowledge/publish-readiness.d.ts +25 -0
  107. package/dist/knowledge/publish-readiness.js +1 -0
  108. package/dist/knowledge/publish-surface-contract.d.ts +16 -0
  109. package/dist/knowledge/publish-surface-contract.js +1 -0
  110. package/dist/knowledge/rail-exit-satisfiability.d.ts +25 -0
  111. package/dist/knowledge/rail-exit-satisfiability.js +1 -0
  112. package/dist/knowledge/reward-ledger.d.ts +1 -1
  113. package/dist/knowledge/reward-ledger.js +1 -1
  114. package/dist/knowledge/reward-risk.d.ts +1 -1
  115. package/dist/knowledge/reward-risk.js +1 -1
  116. package/dist/knowledge/service-ledger.d.ts +3 -1
  117. package/dist/knowledge/service-ledger.js +1 -1
  118. package/dist/knowledge/template-loader.d.ts +41 -2
  119. package/dist/knowledge/template-loader.js +1 -1
  120. package/dist/knowledge/template-registry.js +1 -1
  121. package/dist/knowledge/template-scanner.d.ts +17 -0
  122. package/dist/knowledge/template-scanner.js +1 -1
  123. package/dist/knowledge/workflow-guidance.d.ts +4 -0
  124. package/dist/knowledge/workflow-guidance.js +1 -1
  125. package/dist/monitor/MonitorLoop.js +1 -1
  126. package/dist/monitor/normalize.d.ts +1 -1
  127. package/dist/monitor/normalize.js +1 -1
  128. package/dist/monitor/types.js +1 -1
  129. package/dist/participation/game-context.js +1 -1
  130. package/dist/participation/radar-core.js +1 -1
  131. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  132. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  133. package/dist/playbooks/service-build/merchant-guide.d.ts +28 -3
  134. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  135. package/dist/playbooks/service-build/object-panorama.d.ts +4 -0
  136. package/dist/playbooks/service-build/object-panorama.js +1 -1
  137. package/dist/playbooks/service-build/participation-radar.js +1 -1
  138. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  139. package/dist/playbooks/service-build/service-panorama.js +1 -1
  140. package/dist/playbooks/service-build/service-quote.js +1 -1
  141. package/dist/review/index.js +1 -1
  142. package/dist/review/order.js +1 -1
  143. package/dist/safety/confirm-gate.js +1 -1
  144. package/dist/schema/benchmark-migration/index.d.ts +24 -0
  145. package/dist/schema/benchmark-migration/index.js +1 -1
  146. package/dist/schema/call/allocation.d.ts +11 -7
  147. package/dist/schema/call/allocation.js +1 -1
  148. package/dist/schema/call/arbitration.d.ts +4 -0
  149. package/dist/schema/call/arbitration.js +1 -1
  150. package/dist/schema/call/base.d.ts +28 -0
  151. package/dist/schema/call/base.js +1 -1
  152. package/dist/schema/call/bridge.d.ts +21 -0
  153. package/dist/schema/call/contact.d.ts +4 -0
  154. package/dist/schema/call/demand.d.ts +4 -0
  155. package/dist/schema/call/guard.d.ts +12 -0
  156. package/dist/schema/call/handler.d.ts +1 -0
  157. package/dist/schema/call/handler.js +1 -1
  158. package/dist/schema/call/machine.d.ts +16 -8
  159. package/dist/schema/call/normalize-error.d.ts +1 -0
  160. package/dist/schema/call/normalize-error.js +1 -0
  161. package/dist/schema/call/order.d.ts +7 -3
  162. package/dist/schema/call/order.js +1 -1
  163. package/dist/schema/call/payment.d.ts +7 -3
  164. package/dist/schema/call/permission.d.ts +4 -0
  165. package/dist/schema/call/personal.d.ts +4 -0
  166. package/dist/schema/call/progress.d.ts +4 -0
  167. package/dist/schema/call/progress.js +1 -1
  168. package/dist/schema/call/proof.d.ts +8 -0
  169. package/dist/schema/call/receipt.js +1 -1
  170. package/dist/schema/call/repository.d.ts +4 -0
  171. package/dist/schema/call/reward.d.ts +6 -2
  172. package/dist/schema/call/reward.js +1 -1
  173. package/dist/schema/call/semantic.d.ts +2 -2
  174. package/dist/schema/call/semantic.js +1 -1
  175. package/dist/schema/call/service.d.ts +6 -2
  176. package/dist/schema/call/treasury.d.ts +10 -6
  177. package/dist/schema/common/index.js +1 -1
  178. package/dist/schema/envelope-unify.d.ts +1 -0
  179. package/dist/schema/envelope-unify.js +1 -1
  180. package/dist/schema/evaluation/index.d.ts +43 -0
  181. package/dist/schema/evaluation/index.js +1 -1
  182. package/dist/schema/goal/index.d.ts +14 -2
  183. package/dist/schema/goal/planning.d.ts +18 -0
  184. package/dist/schema/goal/planning.js +1 -1
  185. package/dist/schema/intent-radar/index.d.ts +12 -0
  186. package/dist/schema/intent-radar/index.js +1 -1
  187. package/dist/schema/keeper/index.d.ts +1 -0
  188. package/dist/schema/local/index.d.ts +10 -0
  189. package/dist/schema/local/index.js +1 -1
  190. package/dist/schema/local/wip.js +1 -1
  191. package/dist/schema/messenger/index.d.ts +1 -0
  192. package/dist/schema/messenger/index.js +1 -1
  193. package/dist/schema/operations.d.ts +95 -12
  194. package/dist/schema/operations.js +1 -1
  195. package/dist/schema/persona/index.d.ts +22 -0
  196. package/dist/schema/query/bi.d.ts +28 -2
  197. package/dist/schema/query/bi.js +1 -1
  198. package/dist/schema/query/index.d.ts +67 -61
  199. package/dist/schema/query/index.js +1 -1
  200. package/dist/schema/schema-version.js +1 -1
  201. package/dist/schema/workflow/index.js +1 -1
  202. package/dist/schema-query-impl/index.d.ts +1 -0
  203. package/dist/schema-query-impl/index.js +1 -1
  204. package/dist/schemas/account_operation.output.json +2 -1
  205. package/dist/schemas/benchmark_migration_operation.output.json +74 -0
  206. package/dist/schemas/benchmark_migration_operation.schema.json +32 -0
  207. package/dist/schemas/bridge_operation.output.json +2 -1
  208. package/dist/schemas/bridge_operation.schema.json +40 -0
  209. package/dist/schemas/evaluation_operation.output.json +96 -0
  210. package/dist/schemas/evaluation_operation.schema.json +39 -0
  211. package/dist/schemas/goal_operation.schema.json +32 -0
  212. package/dist/schemas/guard2file.schema.json +8 -0
  213. package/dist/schemas/index.json +1 -1
  214. package/dist/schemas/intent_radar.output.json +10 -2
  215. package/dist/schemas/intent_radar.schema.json +5 -1
  216. package/dist/schemas/keeper_operation.output.json +2 -1
  217. package/dist/schemas/local_cache_operation.output.json +2 -1
  218. package/dist/schemas/local_history_operation.output.json +2 -1
  219. package/dist/schemas/local_info_operation.output.json +2 -1
  220. package/dist/schemas/local_mark_operation.output.json +2 -1
  221. package/dist/schemas/local_mark_operation.schema.json +10 -1
  222. package/dist/schemas/machineNode2file.schema.json +8 -0
  223. package/dist/schemas/messenger_operation.output.json +2 -1
  224. package/dist/schemas/messenger_operation.schema.json +2 -1
  225. package/dist/schemas/monitor_events.output.json +2 -1
  226. package/dist/schemas/monitor_subscription.output.json +2 -1
  227. package/dist/schemas/onchain_events.output.json +206 -13
  228. package/dist/schemas/onchain_events.schema.json +16 -0
  229. package/dist/schemas/onchain_operations.output.json +22 -3
  230. package/dist/schemas/onchain_operations.schema.json +971 -326
  231. package/dist/schemas/onchain_operations_allocation.schema.json +19 -12
  232. package/dist/schemas/onchain_operations_arbitration.schema.json +9 -1
  233. package/dist/schemas/onchain_operations_contact.schema.json +8 -0
  234. package/dist/schemas/onchain_operations_demand.schema.json +8 -0
  235. package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
  236. package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
  237. package/dist/schemas/onchain_operations_guard.schema.json +654 -114
  238. package/dist/schemas/onchain_operations_machine.schema.json +11 -3
  239. package/dist/schemas/onchain_operations_order.schema.json +14 -11
  240. package/dist/schemas/onchain_operations_payment.schema.json +12 -9
  241. package/dist/schemas/onchain_operations_permission.schema.json +8 -0
  242. package/dist/schemas/onchain_operations_personal.schema.json +8 -0
  243. package/dist/schemas/onchain_operations_progress.schema.json +9 -1
  244. package/dist/schemas/onchain_operations_proof.schema.json +8 -0
  245. package/dist/schemas/onchain_operations_repository.schema.json +8 -0
  246. package/dist/schemas/onchain_operations_reward.schema.json +14 -11
  247. package/dist/schemas/onchain_operations_service.schema.json +13 -10
  248. package/dist/schemas/onchain_operations_treasury.schema.json +17 -19
  249. package/dist/schemas/onchain_table_data.output.json +52 -10
  250. package/dist/schemas/persona_operation.output.json +57 -0
  251. package/dist/schemas/persona_operation.schema.json +9 -0
  252. package/dist/schemas/query_toolkit.output.json +325 -22
  253. package/dist/schemas/query_toolkit.schema.json +18 -5
  254. package/dist/schemas/wip_file.output.json +2 -2
  255. package/dist/schemas/wip_file.schema.json +2 -2
  256. package/dist/schemas/workflow_operation.schema.json +1 -1
  257. package/dist/tools/error-catalog.d.ts +17 -0
  258. package/dist/tools/error-catalog.js +1 -0
  259. package/dist/tools/handlers/benchmark-migration.d.ts +20 -8
  260. package/dist/tools/handlers/benchmark-migration.js +1 -1
  261. package/dist/tools/handlers/config.js +1 -1
  262. package/dist/tools/handlers/entry-edge-recipe.d.ts +101 -0
  263. package/dist/tools/handlers/entry-edge-recipe.js +1 -0
  264. package/dist/tools/handlers/escrow-deficit.d.ts +10 -0
  265. package/dist/tools/handlers/escrow-deficit.js +1 -0
  266. package/dist/tools/handlers/evaluation.js +1 -1
  267. package/dist/tools/handlers/fund-rail-recipe.d.ts +10 -0
  268. package/dist/tools/handlers/fund-rail-recipe.js +1 -0
  269. package/dist/tools/handlers/intent-radar.js +1 -1
  270. package/dist/tools/handlers/local.js +1 -1
  271. package/dist/tools/handlers/mark-namespace.d.ts +30 -0
  272. package/dist/tools/handlers/mark-namespace.js +1 -0
  273. package/dist/tools/handlers/messenger.js +1 -1
  274. package/dist/tools/handlers/onchain-name-registration.d.ts +1 -0
  275. package/dist/tools/handlers/onchain-name-registration.js +1 -1
  276. package/dist/tools/handlers/onchain-name-registration.spec.js +1 -1
  277. package/dist/tools/handlers/onchain.d.ts +30 -1
  278. package/dist/tools/handlers/onchain.js +1 -1
  279. package/dist/tools/handlers/publish-binding-echo.d.ts +22 -0
  280. package/dist/tools/handlers/publish-binding-echo.js +1 -0
  281. package/dist/tools/handlers/query.d.ts +1 -1
  282. package/dist/tools/handlers/query.js +1 -1
  283. package/dist/tools/handlers/review-chain.d.ts +1 -0
  284. package/dist/tools/handlers/review-chain.js +1 -1
  285. package/dist/tools/handlers/schema-query.js +1 -1
  286. package/dist/tools/handlers/stale-build-check.d.ts +9 -0
  287. package/dist/tools/handlers/stale-build-check.js +1 -0
  288. package/dist/tools/handlers/submission-assembly.d.ts +55 -0
  289. package/dist/tools/handlers/submission-assembly.js +1 -0
  290. package/dist/tools/handlers/wip.js +1 -1
  291. package/dist/tools/index.d.ts +1 -0
  292. package/dist/tools/index.js +1 -1
  293. package/dist/tools/move-fn-index.gen.js +1 -1
  294. package/dist/tools/publish-gate-state.d.ts +5 -0
  295. package/dist/tools/publish-gate-state.js +1 -0
  296. package/dist/tools/registry/business.js +1 -1
  297. package/dist/tools/registry/onchain.js +1 -1
  298. package/dist/tools/registry/query.js +1 -1
  299. package/dist/tools/retry.js +1 -1
  300. package/dist/tools/runtime-health.js +1 -1
  301. package/dist/tools/shared.js +1 -1
  302. package/dist/tools/upgrade-check.d.ts +1 -0
  303. package/dist/tools/upgrade-check.js +1 -1
  304. package/dist/tools/wip-verify-ledger.d.ts +2 -0
  305. package/dist/tools/wip-verify-ledger.js +1 -1
  306. package/dist/tools/wrap.d.ts +15 -1
  307. package/dist/tools/wrap.js +1 -1
  308. package/package.json +5 -3
@@ -1 +1 @@
1
- import{SV2_UNARMED_PRESCRIPTION}from'../knowledge/protocol-facts.js';import{verifyAllocatorRails}from'../knowledge/allocator-rail-verifier.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{rootHasRewardRecordGate}from'../knowledge/template-scanner.js';import{guardTemplateHasIdentityLeg}from'../knowledge/builtin-templates.js';import{numericAmount}from'../knowledge/audit-rules.js';import{emitSupplyChainPromise}from'./supply-chain-emit.js';import{P,ref}from'./plan.js';function lowestSalePrice(a){if(!Array['isArray'](a))return undefined;let b;for(const c of a){const d=numericAmount(c?.['price']);if(d!==undefined&&d>0x0)b=b===undefined?d:Math['min'](b,d);}return b;}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;}const CANONICAL_CURRENCY='0x2::wow::WOW',QUALIFIED_TYPE_RE=/^0x[0-9a-fA-F]{1,64}::[a-zA-Z_][a-zA-Z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;export function normalizeCurrency(a){const b=a['trim']();if(QUALIFIED_TYPE_RE['test'](b))return b;if(/^\$?wow$/i['test'](b))return CANONICAL_CURRENCY;return undefined;}const capUtf8=(a,b)=>{const c=new TextEncoder();if(c['encode'](a)['length']<=b)return a;let d=a;while(d['length']>0x0&&c['encode'](d+'…')['length']>b)d=d['slice'](0x0,-0x1);return d+'…';};function offTaskSlotIdentityLegs(a){const b=new Set(['order.owner','order.agent\x20has']),c=new Set(['query_order_named_operator_member']),d=new Set(),e=[],f=g=>{if(g===null||typeof g!=='object')return;const h=g;if(h['type']==='logic_equal'&&Array['isArray'](h['nodes'])){const l=h['nodes']['filter'](m=>m!==null&&typeof m==='object'&&m['type']==='identifier'&&typeof m['identifier']==='number');if(l['some'](m=>m['identifier']===TASK_BINDING_SLOT)){for(const m of l)d['add'](m['identifier']);}}const i=h['object'],j=typeof h['query']==='string'&&b['has'](h['query'])||typeof h['type']==='string'&&c['has'](h['type']);if(j&&i!==null&&typeof i==='object'&&typeof i['identifier']==='number'){const o=i['identifier'],p=typeof h['query']==='string'?h['query']:h['type'];if(o!==TASK_BINDING_SLOT)e['push']({'query':p,'identifier':o});}if(Array['isArray'](h['nodes'])){for(const q of h['nodes'])f(q);}if(h['node']!==undefined&&typeof h['node']==='object')f(h['node']);};return f(a),e['filter'](g=>!d['has'](g['identifier']));}const MODE_MAP={'amount':'Amount','rate':'Rate','surplus':'Surplus'};export function emitIdentityPhase({template:a,base:b}){const c=[];c['push']({'op':'create','id':'permission','object':'permission','params':{'name':b+'_permission'}});const d=a['arbitration_mode']!==undefined&&a['arbitration_mode']!=='none';return d&&c['push']({'op':'create','id':'permission_arb','object':'permission','params':{'name':b+'_arb_permission'},...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'notes':'MUST\x20be\x20created\x20by\x20a\x20different\x20account\x20than\x20the\x20service\x20permission\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT=33):\x20dispute\x20neutrality.\x20'+'third_party\x20builds\x20declare\x20account\x20\x27arb_controller\x27\x20—\x20provide\x20'+'accounts.arb_controller\x20to\x20plan_execute.'}),c['push']({'op':'create','id':'contact','object':'contact','params':{'name':b+'_contact'},'notes':'R8:\x20customer-service\x20channel;\x20mandatory\x20when\x20customer_required\x20is\x20set.\x20'+'required_info\x20is\x20SELF-ATTESTED\x20—\x20the\x20chain\x20stores\x20the\x20buyer\x27s\x20claim\x20verbatim\x20and\x20nothing\x20verifies\x20it\x20'+'(the\x20bind\x20path\x20only\x20proves\x20the\x20claim\x20came\x20from\x20this\x20order\x27s\x20owner).\x20A\x20genuine\x20credential\x20gate\x20requires\x20'+'a\x20Proof-backed\x20delivery\x20guard\x20(see\x20the\x20privacy-delivery\x20design;\x20not\x20wired\x20by\x20default).'}),{'steps':c,'needsArbitration':d};}const rewardRowIdentifiers=a=>{const b=new Set(),c=d=>{if(Array['isArray'](d)){for(const f of d)c(f);return;}if(typeof d!=='object'||d===null)return;const e=d;if(typeof e['type']==='string'&&e['type']['startsWith']('query_reward_record')){const g=e['object'];if(g!==undefined&&typeof g['identifier']==='number')b['add'](g['identifier']);}for(const h of Object['values'](e))c(h);};return c(a),b;};export function emitRewardClaimEarly({reviewMode:a,guardSpecs:b,resolvedGuards:c,rewardMark:d}){const e=[],f=a==='review_reward'?b['find'](g=>g['host']==='reward'):undefined;if(a==='review_reward'&&f?.['step_id']!==undefined){const g=c['get'](f['key']);if(g!==undefined){const h=rewardRowIdentifiers(g['root']);c['set'](f['key'],{...g,'table':g['table']['map'](i=>{const j=i;if(j['b_submission']===!![]||!h['has'](j['identifier']))return i;return{...j,'value':ref('reward_review')};})});}e['push']({'op':'create','id':'reward_review','object':'reward','params':P({'name':d,'description':'Review\x20incentive\x20pool\x20(sale-time\x20planned;\x20terms\x20disclosed\x20at\x20quote/buy):\x20claim\x20gated\x20by\x20guard\x20\x27'+f['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\x20plan\x20ref\x20{\x22$ref\x22:\x22reward_review\x22}]'});}return{'steps':e};}export function checkDaysUnitSlots({resolvedGuards:a}){const b=[];{const c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=f['table'],i=h['filter'](m=>typeof m?.['name']==='string'&&/day/i['test'](m['name'])),j=i['find'](m=>/ms[_\s]?per[_\s]?day/i['test'](m['name']));if(j===undefined)continue;const k=d(j);if(k===undefined||k===c)continue;const l=i['some'](m=>m!==j&&(d(m)??0x0)>0xe42);if(!l)continue;b['push']({'code':'DAYS_SLOT_UNIT_MISMATCH','detail':'guard\x20\x27'+e+'\x27:\x20a\x20day-denominated\x20slot\x20is\x20stuffed\x20with\x20MILLISECONDS\x20while\x20its\x20ms_per_day\x20row\x20reads\x20'+k+'\x20'+'(tbpr7\x20F-V3-04:\x20DAYS\x20slots\x20carrying\x20173000/864000\x20beside\x20ms_per_day\x20=\x201).\x20Guards\x20are\x20immutable\x20—\x20a\x20wrong\x20'+'unit\x20is\x20PERMANENT:\x20the\x20window\x20runs\x20~6\x20orders\x20of\x20magnitude\x20long\x20(or\x20short)\x20and\x20no\x20keeper\x20call\x20can\x20fix\x20it.\x20'+'Day\x20slots\x20carry\x20DAY\x20COUNTS\x20(twin\x20templates\x20scale\x20by\x2086400000\x20at\x20compile;\x20on-chain\x20day\x20twins\x20keep\x20the\x20'+'ms_per_day\x20=\x2086400000\x20row):\x20set\x20ms_per_day\x20back\x20to\x2086400000\x20and\x20re-derive\x20the\x20day\x20slots\x20via\x20fee-param\x20bindings.'});}}return{'blockers':b};}export function checkWindowTruncation({resolvedGuards:a}){const b=[],c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=new Map();for(const m of f['table']){if(!m||typeof m!=='object'||Array['isArray'](m))continue;const n=m;typeof n['identifier']==='number'&&n['b_submission']!==!![]&&h['set'](n['identifier'],n);}const i=o=>typeof o==='number'?h['get'](o):undefined,j=o=>{const p=[];for(const q of['nodes','and','or','left','right']){const s=o[q];if(Array['isArray'](s))p['push'](...s);else{if(s!==undefined)p['push'](s);}}return p;},k=o=>{if(!o||typeof o!=='object'||Array['isArray'](o))return{'multiplies':0x0,'total':0x0};const p=o,q=typeof p['type']==='string'?p['type']:'';if(q==='calc_number_multiply'&&Array['isArray'](p['nodes'])&&p['nodes']['length']===0x2){const [u,w]=p['nodes'],x=u!==null&&typeof u==='object'&&u['type']==='identifier'?i(u['identifier']):undefined,y=w!==null&&typeof w==='object'&&w['type']==='identifier'?i(w['identifier']):undefined;if(x===undefined||y===undefined)return undefined;const z=d(x)===c?x:d(y)===c?y:undefined;if(z===undefined)return undefined;const A=z===x?y:x;if(A['value_type']!=='U64'||z['value_type']!=='U64')return undefined;const B=d(A);if(B===undefined)return undefined;return{'multiplies':0x1,'total':B};}let s=0x0,t=0x0;for(const C of j(p)){const D=k(C);if(D===undefined)return undefined;s+=D['multiplies'],t+=D['total'];}return{'multiplies':s,'total':t};},l=(o,p)=>{if(!o||typeof o!=='object'||Array['isArray'](o))return;const q=o,s=typeof q['type']==='string'?q['type']:'',t=s['includes']('lesser')?!![]:s['includes']('greater')?![]:p;if(s['includes']('lesser')){const u=q['nodes'],v=Array['isArray'](u)?u[0x1]:undefined,w=v!==undefined?k(v):{'multiplies':0x0,'total':0x0};w!==undefined&&w['multiplies']>0x0&&w['total']<0x1&&b['push']({'code':'WINDOW_TRUNCATION_ZERO','detail':'guard\x20\x27'+e+'\x27:\x20a\x20CLOSING\x20window\x27s\x20day\x20slots\x20total\x20'+String(w['total'])+'\x20day(s)\x20—\x20a\x20zero\x20(or\x20'+'sub-1\x20fraction,\x20which\x20the\x20U64\x20slot\x20truncates\x20to\x200\x20at\x20BCS\x20encode)\x20makes\x20the\x20leg\x20compute\x20'+'anchor\x20+\x200\x20×\x2086400000\x20on-chain,\x20so\x20the\x20`<=`\x20window\x20welds\x20shut\x20the\x20instant\x20its\x20anchor\x20entry\x20'+'lands\x20and\x20never\x20reopens\x20(Guards\x20are\x20immutable;\x20the\x20live\x20run\x20compiled\x20a\x200.002-day\x20test\x20window\x20'+'into\x20exactly\x20this\x20shape).\x20Pass\x20whole\x20days,\x20or\x20switch\x20the\x20window\x20to\x20a\x20millisecond-denominated\x20'+'slot\x20pair\x20(duration\x20in\x20ms\x20beside\x20ms_per_day\x20=\x201)\x20for\x20sub-day\x20test\x20windows.'});}for(const x of j(q))l(x,t);};l(f['root'],![]);}return{'blockers':b};}export function emitServiceDraft({template:a,base:b,inputs:c}){const d=[],e=[],f=typeof c['currency']==='string'?c['currency']['trim']():'',g=f===''?CANONICAL_CURRENCY:normalizeCurrency(f);g===undefined&&e['push']({'code':'CURRENCY_UNRESOLVED','detail':'inputs.currency\x20\x27'+String(c['currency'])+'\x27\x20is\x20not\x20a\x20resolvable\x20token\x20type.\x20Pass\x20the\x20'+'fully-qualified\x20form\x20\x270x2::wow::WOW\x27\x20or\x20the\x20bare\x20symbol\x20\x27WOW\x27\x20(aliased\x20here).\x20The\x20plan\x20carries\x20the\x20'+'canonical\x20default\x20so\x20the\x20shape\x20stays\x20inspectable,\x20but\x20the\x20verdict\x20is\x20blocked:\x20an\x20unqualified\x20symbol\x20'+'aborts\x20at\x20the\x20service\x20create\x20(type_parameter\x20validation)\x20AFTER\x20earlier\x20steps\x20already\x20ran\x20—\x20plan_execute\x20'+'is\x20not\x20transactional\x20(algr9\x20F-03:\x204\x20orphan\x20objects\x20behind\x20the\x20failed\x20step).'});const h=g??CANONICAL_CURRENCY;return d['push']({'op':'create','id':'service','object':'service','params':P({'name':b+'_service','type_parameter':h,'permission':ref('permission'),'um':ref('contact'),'description':a['id']+'\x20—\x20compiled\x20by\x20the\x20composition\x20compiler',...Array['isArray'](c['customer_required'])?{'customer_required':c['customer_required']}:{}}),'notes':'Draft\x20first\x20(F-01):\x20registers\x20the\x20LocalMark\x20name\x20every\x20guard\x20resolves\x20at\x20runtime.\x20'+'machine/repositories/buy_guard\x20attach\x20in\x20configure\x20steps\x20after\x20machine_publish\x20'+'(schema-sanctioned\x20phased\x20build;\x20machine/order_allocators\x20remain\x20publish-frozen).'}),{'steps':d,'currency':h,'blockers':e};}export function emitEvidenceRepository({needsRepository:a,base:b,inputs:c,guardSpecs:d,resolvedGuards:e}){const f=[],g=[],h=[],i=[];if(a){const j=Array['isArray'](c['repository_policies'])?c['repository_policies']['filter'](m=>typeof m==='object'&&m!==null):[],k=j['map'](m=>Array['isArray'](m['write_guard'])?m:{'write_guard':[],...m});for(const m of j){const n=typeof m['id_from']==='string'?m['id_from']['toLowerCase']():'none',o=Array['isArray'](m['write_guard'])?m['write_guard']['length']:0x0;n==='none'&&o===0x0&&g['push']({'code':'REPO_POLICY_WRITE_GUARD_REQUIRED','detail':'repository_policies\x20entry\x20\x27'+String(m['name']??'(unnamed)')+'\x27\x20declares\x20id_from\x20'+'\x27none\x27\x20(caller-supplied\x20row\x20key)\x20with\x20NO\x20write_guard\x20—\x20the\x20chain\x20aborts\x20policy\x20'+'creation\x20with\x20E_POLICY_WRITE_GUARD_REQUIRED\x20=\x2022\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'policy\x20add\x20(the\x20id\x20is\x20caller-chosen,\x20so\x20an\x20ungated\x20rule\x20'+'would\x20let\x20anyone\x20write\x20the\x20row).\x20Attach\x20a\x20write_guard:[{guard:...}]\x20leg,\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22signer\x22/\x22clock\x22\x20if\x20the\x20row\x20key\x20may\x20be\x20derived\x20from\x20the\x20writer.'});}const l=new Set(j['map'](q=>q['name']));for(const p of d){if(p['host']!=='repository'||p['step_id']===undefined)continue;const q='host:\x22repository\x22\x20guard\x20\x27'+p['key']+'\x27\x20(step\x20\x27'+p['step_id']+'\x27)';if(p['policy']===undefined){g['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':q+'\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;}const r=p['policy']['name']??p['key'],s=(p['policy']['id_from']??'none')['toLowerCase'](),t=p['policy']['id_from_submission'],u=p['policy']['data_from_submission'];t!==undefined&&(s==='signer'||s==='clock')&&g['push']({'code':'REPO_GUARD_SUBMISSION_ID_FORBIDDEN','detail':q+'\x20declares\x20id_from_submission\x20'+t+'\x20while\x20its\x20policy\x20id_from\x20is\x20'+('\x27'+s+'\x27\x20—\x20the\x20row\x20id\x20is\x20AUTO-generated\x20from\x20the\x20'+s+'\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\x20—\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'permission-102\x20policy\x20add\x20—\x20so\x20this\x20must\x20be\x20fixed,\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 w=e['get'](p['key']),x=[['id_from_submission',t],['data_from_submission',u]];for(const [y,z]of x){if(z===undefined)continue;const A=w?.['table']['find'](B=>B['identifier']===z);(w===undefined||A===undefined||A['b_submission']!==!![])&&g['push']({'code':'REPO_GUARD_SUBMISSION_SLOT_UNKNOWN','detail':q+'\x20declares\x20'+y+'\x20'+z+',\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'+z+'\x20on\x20the\x20guard,\x20or\x20point\x20')+(y+'\x20at\x20an\x20existing\x20submission\x20slot.')});}}if(l['has'](r))continue;const v={'name':r,'description':capUtf8(p['policy']['description']??p['purpose'],0x1f4),'id_from':p['policy']['id_from']??'none','value_type':p['policy']['value_type']??'String','write_once':p['policy']['write_once']??![]};h['push']({...v,'write_guard':[{'guard':ref(p['step_id']),...t!==undefined?{'id_from_submission':t}:{},...u!==undefined?{'data_from_submission':u}:{}}]}),i['push'](p['step_id']);}f['push']({'op':'create','id':'repository','object':'repository','params':P({'name':b+'_evidence',...k['length']>0x0?{'policies':k}:{}}),'notes':'Evidence\x20rows\x20(tracking\x20hash,\x20receipts,\x20WTS\x20proofs).\x20Created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20the\x20guards\x27\x20table\x20rows\x20reach\x20this\x20repository\x20by\x20plan\x20ref.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20create\x20ships\x20ONLY\x20caller-supplied\x20policies\x20that\x20are\x20legal\x20at\x20construction\x20—\x20every\x20guard-derived\x20policy\x20lands\x20at\x20the\x20repository_write_guards\x20configure\x20step\x20right\x20after\x20the\x20wave,\x20in\x20its\x20credential-bound\x20(write_guard-attached)\x20form,\x20the\x20ONLY\x20legal\x20shape\x20for\x20id_from=none.]'});}return{'steps':f,'repoBoundPolicies':h,'repoBoundStepIds':i,'blockers':g};}export function emitReviewRepositoryEarly({reviewMode:a,base:b,inputs:c}){const d=[];return a!=='none'&&d['push']({'op':'create','id':'repository_review','object':'repository','params':P({'name':b+'_review','description':'Structured\x20buyer\x20reputation\x20rows\x20(AR-1:\x20emitted\x20by\x20the\x20build\x20plan\x20—\x20no\x20manual\x20setup).',...c['buyer_review_enabled']===!![]?{'policies':[{'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':!![],'write_guard':[]}]}:{}}),'notes':'REVIEW-COMPONENT\x20AR-1\x20(F-05\x20early\x20form):\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).\x20The\x20\x27rating\x27\x20row\x20is\x20what\x20a\x20reward\x20good-review\x20leg\x20reads\x20(F-62).\x20Buyers\x20resolve\x20this\x20object\x20by\x20name\x20(workspace/onchain_objects)\x20—\x20never\x20guess\x20an\x20address.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20\x27review\x27/\x27rating\x27\x20policies\x20(id_from=none,\x20order-keyed)\x20ship\x20ONLY\x20on\x20the\x20repository_review_write_guards\x20configure\x20step\x20in\x20their\x20credential-bound\x20form\x20—\x20an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain\x20(the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20BOTH\x20the\x20create\x20path\x20and\x20every\x20later\x20policy\x20add).\x20buyer_review\x20(id_from=signer)\x20is\x20the\x20one\x20create-legal\x20policy.]'}),{'steps':d};}export function rewritePlanRefs({base:a,resolvedGuards:b}){{const c=new Map([[a+'_service','service'],[a+'_evidence','repository'],[a+'_review','repository_review'],[a+'_arbitration','arbitration']]);for(const [,d]of b){for(const e of d['table']){const f=e,h=typeof f['value']==='string'?c['get'](f['value']):undefined;if(h!==undefined)f['value']=ref(h);}}}}export function dropEmptyVecGuards({resolvedGuards:a,guardSpecs:b,steps:c}){const d=[],e=[];{const f=new Map();for(const [i,j]of a){const k=new Set();for(const l of j['table']){const m=l;m['b_submission']===![]&&Array['isArray'](m['value'])&&m['value']['length']===0x0&&typeof m['identifier']==='number'&&k['add'](m['identifier']);}if(k['size']>0x0)f['set'](i,k);}const h=(n,o)=>{if(n===null||typeof n!=='object')return![];const p=n;if(p['type']!=='vec_contains_address'||!Array['isArray'](p['nodes']))return![];const q=p['nodes']['find'](s=>s['type']==='identifier');return q!==undefined&&typeof q['identifier']==='number'&&o['has'](q['identifier']);};for(const [n,o]of f){const p=a['get'](n),q=p['root'],s=b['find'](v=>v['key']===n),t=q['type']==='logic_not'&&h(q['node'],o);if(t&&s?.['host']==='service'&&n==='buy'){a['delete'](n),s['step_id']=undefined,e['push'](n);continue;}const u=[...o]['map'](String);d['push']({'code':'GUARD_EMPTY_VEC_ROW','detail':'guard\x20\x27'+n+'\x27\x20declares\x20static\x20vec\x20row(s)\x20'+u['join'](',\x20')+'\x20with\x20an\x20EMPTY\x20array\x20—\x20'+'the\x20executor\x20refuses\x20empty\x20static\x20vec\x20slots\x20(LE-10:\x20the\x20chain\x27s\x20table\x20builder\x20silently\x20DROPS\x20empty\x20'+'vectors,\x20so\x20the\x20created\x20Guard\x20would\x20diverge\x20from\x20the\x20reviewed\x20spec\x20—\x20mainnet\x207\x20submitted\x20->\x206\x20stored).\x20'+'Two\x20legal\x20exits:\x20(a)\x20arm\x20the\x20list\x20with\x20at\x20least\x20one\x20address\x20(the\x20blocklist\x20twin\x27s\x20intended\x20armed\x20form:\x20'+'list\x20the\x20provider-side\x20account(s)\x20to\x20ban\x20self-purchase);\x20or\x20(b)\x20if\x20the\x20empty\x20list\x20IS\x20the\x20intended\x20open\x20'+('polarity,\x20omit\x20the\x20guard:\x20guard_resolutions\x20{\x22'+n+'\x22:\x20{\x22kind\x22:\x20\x22omit\x22}}\x20—\x20the\x20compile\x20honors\x20omission\x20')+'and\x20the\x20attached\x20rail\x20ships\x20un-gated\x20(there\x20is\x20no\x20constant-true\x20Guard\x20object\x20to\x20fabricate).'});}}if(e['length']>0x0){const v=c['find'](w=>w['op']==='create'&&w['id']==='service');v!==undefined&&(v['notes']=(v['notes']??'')+'\x20[F-04\x20open-store\x20drop:\x20the\x20blocklist\x20buy\x20guard\x20('+e['join'](',\x20')+')\x20resolved\x20to\x20an\x20EMPTY\x20blocklist\x20—\x20NOT(vec_contains(empty))\x20is\x20constant\x20true,\x20a\x20no-op\x20gate,\x20and\x20the\x20executor\x20refuses\x20empty\x20vec\x20rows\x20(LE-10)\x20—\x20so\x20the\x20guard\x20and\x20its\x20buy\x20mount\x20are\x20OMITTED:\x20this\x20store\x20ships\x20OPEN.\x20To\x20arm\x20the\x20self-purchase\x20ban,\x20fill\x20the\x20blocklist\x20at\x20generation.]');}return{'blockers':d};}export function emitArbitrationHoist({needsArbitration:a,template:b,base:c,currency:d}){const e=[];return a&&e['push']({'op':'create','id':'arbitration','object':'arbitration',...b['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'params':P({'name':c+'_arbitration','permission':ref('permission_arb'),'type_parameter':d,'pause':![]}),'notes':'Independent\x20venue\x20(R2);\x20activates\x20atomically\x20(create+unpause\x20same\x20PTB).\x20[W5-05:\x20created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20arb-ruling\x20guard\x20tables\x20bind\x20it\x20by\x20plan\x20ref]'}),{'steps':e};}export function emitGuardWave({resolvedGuards:a,specByKey:b,slot254Injected:c,repoBoundPolicies:d,repoBoundStepIds:e}){const f=[],g=h=>{const i=a['get'](h),j=b['get'](h)?.['purpose'];return{'op':'create','id':i['stepId'],'object':'guard','params':P({'description':i['description'],'table':i['table'],'root':i['root']}),'notes':c['has'](h)?(j??'Guard')+'\x20[kernel:\x20protocol\x20slot\x20254\x20(task\x20binding)\x20auto-declared]':j};};for(const [h]of a)f['push'](g(h));return d['length']>0x0&&f['push']({'op':'configure','id':'repository_write_guards','target':ref('repository'),'method':'policies','params':P({'op':'add','policy':d}),'requires':['repository',...e],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20ONLY\x20landing\x20place\x20for\x20the\x20evidence\x20repository\x27s\x20guard-derived\x20policies\x20—\x20the\x20create\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20the\x20credential-bound\x20forms\x20(write_guard\x20attached)\x20are\x20added\x20to\x20the\x20live\x20repository\x20here,\x20now\x20that\x20the\x20guards\x20exist\x20(the\x20plan-ref\x20rewrite\x20closed\x20the\x20double-object\x20cycle).'}),{'steps':f};}export function emitMachine({template:a,base:b,shape:c,resolvedGuards:d,specByKey:e,injectedOrderHolderKeys:f,merchantIndex:h}){const i=[],j=[],k=new Set(c['map'](q=>q['name'])),l=new Set((a['allocator']?.['rows']??[])['filter'](q=>q['track']==='settlement')['map'](q=>q['guard_key'])['filter'](q=>typeof q==='string'&&q['trim']()!=='')),n=[],p=new Set();for(const q of c){if(q['from']===undefined||q['from']['length']===0x0){j['push']({'code':'MACHINE_EDGES_MISSING','detail':'machine_shape\x20node\x20\x27'+q['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 r=[],s=new Map(),t=new Map();for(const v of q['from']){const w=typeof v==='string'?{'prev':v}:v;if(w['prev']!==''&&!k['has'](w['prev'])){j['push']({'code':'EDGE_UNKNOWN_PREV','detail':'node\x20\x27'+q['name']+'\x27\x20edge\x20prev\x20\x27'+w['prev']+'\x27\x20is\x20not\x20a\x20machine_shape\x20node'});continue;}const x=w['operator']??q['operator']??(w['prev']===''?'order_payer':'merchant'),y=w['named_operator']??q['named_operator'],z=w['forward']??(w['prev']===''?'enter_'+q['name']:w['prev']+'_to_'+q['name']);w['permission_index']!==undefined&&x==='order_payer'&&j['push']({'code':'PERMISSION_INDEX_DROPPED','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20permission_index\x20'+w['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'+w['permission_index']+'\x20only')});y!==undefined&&w['permission_index']!==undefined&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20named_operator\x20\x27'+y+'\x27\x20AND\x20permission_index\x20'+w['permission_index']+'.\x20'+'namedOperator\x20and\x20permissionIndex\x20are\x20OR-options\x20in\x20the\x20on-chain\x20pre-check\x20(namedOperator\x20first),\x20so\x20both\x20rails\x20on\x20one\x20forward\x20'+'is\x20a\x20widening\x20ambiguity\x20—\x20the\x20forward\x20stays\x20open\x20to\x20whichever\x20rail\x20matches\x20and\x20neither\x20the\x20roster-only\x20nor\x20the\x20entity-only\x20intent\x20binds.\x20'+'Pick\x20ONE\x20rail:\x20drop\x20permission_index\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20permission\x20entity\x20rail'});y!==undefined&&(w['operator']==='order_payer'||q['operator']==='order_payer')&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20declares\x20named_operator\x20\x27'+y+'\x27\x20on\x20an\x20EXPLICIT\x20operator:\x27order_payer\x27.\x20'+'Both\x20ride\x20the\x20namedOperator\x20rail\x20with\x20different\x20payloads\x20—\x20the\x20buyer\x20self-advance\x20(\x27\x27\x20resolves\x20to\x20the\x20order\x20payer)\x20and\x20the\x20'+('third-party\x20namespace\x20(\x27'+y+'\x27\x20resolves\x20to\x20the\x20per-order\x20roster)\x20cannot\x20share\x20one\x20forward;\x20one\x20of\x20them\x20would\x20silently\x20lose.\x20')+'Pick\x20ONE\x20rail:\x20drop\x20the\x20operator\x20declaration\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20buyer\x20self-advance'});const A=w['guard_key']!==undefined&&w['guard_key']['trim']()!==''&&l['has'](w['guard_key'])||/settle|release|payout/i['test'](z);{A&&w['permission_index']===undefined&&y===undefined&&x!=='order_payer'&&j['push']({'code':'RELEASE_EDGE_PERMISSIONLESS','detail':'settlement\x20edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20(forward\x20\x27'+z+'\x27,\x20guard\x20\x27'+(w['guard_key']??'none')+'\x27)\x20binds\x20NO\x20permission_index\x20and\x20NO\x20named_operator\x20rail\x20—\x20it\x20compiles\x20PERMISSIONLESS:\x20the\x20on-chain\x20permission\x20layer\x20checks\x20namedOperator\x20then\x20permissionIndex,\x20and\x20with\x20neither\x20present\x20ANYONE\x20with\x20a\x20valid\x20order\x20passport\x20can\x20advance\x20the\x20release\x20and\x20move\x20the\x20escrow\x20(5R-07①\x20F-56,\x20tbp\x20T17\x20live:\x20an\x20unrelated\x20buyer\x27s\x20wallet\x20executed\x20the\x20payout).\x20Bind\x20ONE\x20rail:\x20permission_index\x201002\x20(the\x20keeper\x20or\x20merchant\x20release\x20slot\x20—\x20recommended\x20default\x20C:\x20the\x20time-lock\x20guard\x20+\x20keeper\x20duty\x20+\x20bounty\x20schedule\x20the\x20release)\x20or\x20a\x20stricter\x20merchant-approval\x20rail\x20for\x20high-ticket\x20builds\x20(default\x20A:\x20the\x20merchant\x27s\x20own\x20approval\x20BEFORE\x20the\x20escrow\x20moves).\x20Pair\x20the\x20rail\x20with\x20the\x20guard\x27s\x20identity\x20leg\x20(Signer\x20binding)\x20as\x20defense\x20in\x20depth\x20—\x20declared\x20in\x20the\x20guard\x20table,\x20verified\x20by\x20the\x20audit\x20face'});}const B={'name':z,'weight':0x1,...y!==undefined?{'namedOperator':y}:x==='order_payer'?{'namedOperator':''}:{'permissionIndex':w['permission_index']??h}};if(w['guard_key']!==undefined){const F=e['get'](w['guard_key']);if(F===undefined)j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20binds\x20unknown\x20guard_key\x20\x27'+w['guard_key']+'\x27'});else{for(const H of F['purpose']['matchAll'](/progress\.current\s*==\s*([a-z0-9_]+)/g)){const I=H[0x1];k['has'](I)&&I!==w['prev']&&j['push']({'code':'FORWARD_GUARD_PINNED_TO_NON_PREV','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20pins\x20progress.current\x20==\x20\x27'+I+'\x27,\x20but\x20a\x20'+('forward\x20guard\x20evaluates\x20BEFORE\x20the\x20advance\x20(progress.current\x20==\x20prev\x20\x27'+w['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.'});}const G=F['template_id']==='pattern.identity_check_order_holder'||F['template_id']==='tpl_forward_order_holder'||F['template_id']==='tpl_forward_order_holder_or_time'||F['template_id']==='tpl_time_window_upper_order_holder'||F['template_id']==='tpl_time_window_band_abs_order_holder'||F['template_id']==='tpl_forward_order_holder_time_lock_absolute';if(G&&y!==undefined)j['push']({'code':'FORWARD_GUARD_IDENTITY_NAMED_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+('check\x20but\x20the\x20forward\x20rides\x20a\x20named_operator\x20rail\x20(\x27'+y+'\x27\x20—\x20a\x20third\x20party\x20that\x20is\x20')+'neither\x20the\x20merchant\x20entity\x20nor\x20the\x20buyer).\x20The\x20identity\x20layer\x20runs\x20BEFORE\x20the\x20guard\x20and\x20the\x20'+'roster\x20signer\x20is\x20never\x20the\x20order\x20owner\x20—\x20nobody\x20can\x20pass\x20both.\x20Move\x20the\x20buyer-identity\x20leg\x20'+'off\x20this\x20forward\x20(the\x20roster\x20forward\x20may\x20carry\x20only\x20evidence/time\x20guards),\x20or\x20split\x20the\x20hop.'});else G&&x!=='order_payer'&&j['push']({'code':'FORWARD_GUARD_IDENTITY_PERM_CONFLICT','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['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 J=d['get'](F['key']);if(J!==undefined){const K=J['table']['some'](M=>M['identifier']===TASK_BINDING_SLOT),L=offTaskSlotIdentityLegs(J['root'])['filter'](M=>{if(!K)return![];const N=J['table']['find'](O=>O['identifier']===M['identifier']);return N!==undefined&&N['b_submission']===!![];});for(const M of L){j['push']({'code':'GUARD_IDENTITY_SLOT_NOT_TASKBOUND','detail':'edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20guard\x20\x27'+F['key']+'\x27\x20reads\x20'+M['query']+'\x20off\x20free\x20'+('submission\x20slot\x20'+M['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,\x20so\x20this\x20'+('guard\x20is\x20the\x20only\x20identity\x20leg.\x20Anchor\x20the\x20'+M['query']+'\x20query\x20on\x20identifier\x20')+(TASK_BINDING_SLOT+'\x20(the\x20task-binding\x20order\x20anchor\x20—\x20the\x20order\x20the\x20forward\x20actually\x20mutates).')});}}}if(F['step_id']!==undefined){B['guard']=ref(F['step_id']);if(A&&x==='order_payer'&&y===undefined){const N=d['get'](F['key']);N!==undefined&&!guardTemplateHasIdentityLeg(N['root'])&&j['push']({'code':'RELEASE_EDGE_NO_IDENTITY','detail':'settlement\x20edge\x20\x27'+w['prev']+'\x27->\x27'+q['name']+'\x27\x20(forward\x20\x27'+z+'\x27,\x20guard\x20'+('\x27'+F['key']+'\x27,\x20design\x20\x27'+F['template_id']+'\x27)\x20rides\x20the\x20buyer\x20rail\x20(operator\x20')+'\x27order_payer\x27\x20→\x20namedOperator\x20\x22\x22\x20with\x20NO\x20permissionIndex)\x20and\x20its\x20guard\x20carries\x20NO\x20'+'order-holder\x20identity\x20leg\x20—\x20on\x20a\x20guard-bound\x20forward\x20the\x20chain\x20skips\x20the\x20'+'permission\x20assert,\x20so\x20ANY\x20signer\x20holding\x20a\x20passport\x20for\x20this\x20guard\x20can\x20drive\x20the\x20'+'settlement\x20(gfm35-tn-261029\x20F02\x20live:\x20an\x20outsider\x20force-released\x20and\x20settled\x20order).\x20'+'Bind\x20a\x20guard\x20whose\x20root\x20carries\x20the\x20owner/agent\x20identity\x20legs\x20over\x20slot\x20254\x20—\x20e.g.\x20'+'tpl_forward_order_holder_time_lock_absolute\x20for\x20a\x20deadline\x20self-heal\x20(split\x20guard\x20'+'key:\x20keep\x20the\x20pure\x20time\x20lock\x20on\x20the\x20keeper/merchant\x20edge),\x20'+'tpl_time_window_upper_absolute_ms\x20for\x20a\x20closing\x20window.\x20The\x20STATE_AUTHORIZING\x20'+'exemption\x20covers\x20keeper/merchant\x20rails\x20only,\x20never\x20the\x20buyer\x20release\x20rail'});}}}}if(B['guard']===undefined&&x==='order_payer'&&y===undefined){const O=f['get'](z);if(O!==undefined){const Q=e['get'](O);Q?.['step_id']!==undefined&&(B['guard']=ref(Q['step_id']));}}const C=s['get'](w['prev']);C!==undefined?C['push'](B):s['set'](w['prev'],[B]);const D=t['get'](w['prev']),E=y!==undefined?'namedOperator:'+y:x==='order_payer'?'namedOperator:':'permissionIndex:'+(w['permission_index']??h);y!==undefined&&p['add'](y),D!==undefined?D['add'](E):t['set'](w['prev'],new Set([E]));}const u=q['threshold']??0x0;for(const [R,S]of s){u>S['length']&&j['push']({'code':'PAIR_THRESHOLD_UNREACHABLE','detail':'node\x20\x27'+q['name']+'\x27\x20pair\x20from\x20\x27'+(R===''?'(entry)':R)+'\x27\x20declares\x20threshold\x20'+u+'\x20'+('but\x20the\x20pair\x20merges\x20only\x20'+S['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(u>=0x2){const T=t['get'](R)?.['size']??0x0;T<0x2&&j['push']({'code':'PAIR_THRESHOLD_SINGLE_OPERATOR','detail':'node\x20\x27'+q['name']+'\x27\x20pair\x20from\x20\x27'+(R===''?'(entry)':R)+'\x27\x20declares\x20threshold\x20'+u+'\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).'});}r['push']({'prev_node':R,'threshold':u,'forwards':S});}n['push']({'name':q['name'],...q['semantic_role']!==undefined?{'role':q['semantic_role']}:{},...q['optional']===!![]?{'optional':!![]}:{},'pairs':r});}if(p['size']>0x0){const U=/(named[-_ ]?operator|operator roster|\broster\b|dispatch|permission.{0,12}221)/i,V=(a['build_notes']??[])['some'](W=>U['test'](W));!V&&j['push']({'code':'NAMED_OPERATOR_ROSTER_UNDISCLOSED','detail':'machine_shape\x20binds\x20a\x20named\x20third-party\x20operator\x20namespace\x20('+[...p]['map'](W=>'\x27'+W+'\x27')['join'](',\x20')+')\x20'+'but\x20no\x20build_note\x20discloses\x20the\x20roster\x20management.\x20The\x20per-order\x20NamedOperator\x20roster\x20(max\x2060\x20rosters\x20/\x2080\x20addresses)\x20is\x20written\x20at\x20'+'runtime\x20by\x20the\x20account\x20holding\x20permission\x20index\x20221\x20—\x20without\x20a\x20disclosed\x20dispatch\x20duty\x20the\x20forward\x20compiles\x20but\x20nobody\x20can\x20ever\x20'+'pass\x20it\x20(silent\x20brick).\x20Add\x20a\x20build_note\x20stating\x20WHO\x20writes\x20the\x20roster,\x20WHEN\x20(per\x20order?\x20per\x20shift?),\x20and\x20what\x20happens\x20on\x20a\x20miss\x20'+'(e.g.\x20\x22namedOperator\x20\x27delivery_team\x27\x20roster\x20is\x20written\x20per\x20order\x20by\x20the\x20dispatch\x20keeper\x20via\x20permission\x20221;\x20an\x20unassigned\x20order\x20'+'waits\x20until\x20the\x20keeper\x20assigns\x20a\x20courier\x22).\x20K-4\x20stance:\x20dispatch\x20assignment\x20is\x20an\x20OFF-CHAIN\x20keeper\x20optimization,\x20never\x20a\x20chain\x20scheduler'});}return i['push']({'op':'create','id':'machine','object':'machine','params':P({'name':b+'_machine','permission':ref('permission'),'nodes':n})}),i['push']({'op':'publish','id':'machine_publish','target':ref('machine'),'preflight':[{'check':'machine_publish','status':'pending'},{'check':'TASKBIND-01','status':'pending'}]}),{'steps':i,'blockers':j};}export function emitServiceConfigure({guardSpecs:a,needsRepository:b}){const c=[],d=a['find'](e=>e['host']==='service'&&e['key']==='buy');return c['push']({'op':'configure','id':'service_machine','target':ref('service'),'method':'machine','params':ref('machine'),'requires':['machine_publish']}),b&&c['push']({'op':'configure','id':'service_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository')]}),'requires':['service','repository']}),d?.['step_id']!==undefined&&c['push']({'op':'configure','id':'service_buy_guard','target':ref('service'),'method':'buy_guard','params':ref(d['step_id']),'requires':['service',d['step_id']]}),{'steps':c};}export function emitAllocators({template:a,base:b,inputs:c,rowsWithAttachments:d,resolvedGuards:e,specByKey:f}){const h=[],i=d['length']>0x0?d:[{'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}],j=[],k=new Map();for(const n of i){if(n['guard_key']!==undefined){let o=k['get'](n['guard_key']);o===undefined&&(o={'key':n['guard_key'],'rows':[]},k['set'](n['guard_key'],o),j['push'](o)),o['rows']['push'](n);}else j['push']({'rows':[n]});}const l=[],m=new Set();for(const p of j){const q=[];let r;for(const w of p['rows']){let x=w['value'];x===undefined&&w['value_from']!==undefined&&(x=c[w['value_from']]??a['fee_params'][w['value_from']]);if(x===undefined&&w['value_from_complement']!==undefined){const A=w['value_from_complement'],B=c[A]??a['fee_params'][A],C=typeof B==='number'?B:typeof B==='string'&&/^\d+(?:\.\d+)?$/['test'](B['trim']())?Number(B):undefined;if(w['mode']!=='rate'){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20declares\x20value_from_complement\x20\x27'+A+'\x27\x20but\x20'+('mode\x20\x27'+w['mode']+'\x27\x20—\x20the\x20complement\x20is\x20RATE-domain\x20only\x20(10000\x20-\x20bps).\x20Use\x20value/value_from\x20for\x20Amount\x20rows.')});continue;}if(C===undefined||!Number['isFinite'](C)||C<0x0||C>0x2710){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20value_from_complement\x20\x27'+A+'\x27\x20resolves\x20to\x20'+('\x27'+String(B)+'\x27\x20—\x20not\x20a\x20bps\x20value\x20in\x20[0,\x2010000];\x20the\x20complement\x20leg\x20cannot\x20be\x20computed.')});continue;}x=0x2710-C;}if(x===undefined&&w['mode']!=='surplus'){h['push']({'code':'ALLOCATOR_VALUE_MISSING','detail':'allocator\x20row\x20('+w['track']+'/'+w['recipient']+')\x20has\x20neither\x20value\x20nor\x20a\x20resolvable\x20value_from'});continue;}(w['fix']!==undefined||w['fix_from']!==undefined)&&h['push']({'code':'ALLOCATOR_FIX_UNSUPPORTED','detail':'allocator\x20row\x20('+w['track']+'/'+w['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'+'in\x20full\x20at\x20release,\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.'});r??=w['note'];let y;if(w['recipient']==='entity'){const D=w['recipient_key']??'merchant';m['add'](D),y={'Entity':{'name_or_address':{'$late':{'by':'local_name','mark':D}}}};}else{if(w['recipient']==='guard_identifier'){const E=Number(w['recipient_key']??0x0);y={'GuardIdentifier':E};const F=p['key']!==undefined?e['get'](p['key']):undefined;if(F!==undefined){const G=F['table']['find'](H=>H['identifier']===E);(G===undefined||G['b_submission']!==!![]||G['value_type']!=='Address')&&h['push']({'code':'GUARD_SLOT_UNKNOWN','detail':'allocator\x20leg\x20{GuardIdentifier:\x20'+E+'}\x20on\x20guard\x20\x27'+p['key']+'\x27\x20of\x20\x27'+b+'\x27:\x20the\x20bound\x20'+('Guard\x20table\x20has\x20no\x20slot\x20'+E+'\x20Address\x20submission\x20row\x20(b_submission:\x20true).\x20On\x20chain\x20the\x20leg\x20')+('reads\x20slot\x20'+E+'\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)\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'+E+',\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 y='Signer';}const z=typeof x==='number'?x===0x0:typeof x==='string'&&/^\s*0+(?:\.0+)?\s*$/['test'](x);q['push']({'who':y,'sharing':String(x??'0'),'mode':MODE_MAP[w['mode']],'zeroEntityRate':w['recipient']==='entity'&&w['mode']==='rate'&&z});}const s=q['filter'](H=>H['zeroEntityRate']),t=s['length']>0x0&&s['length']<q['length']?q['filter'](H=>!H['zeroEntityRate']):q,u=t['map'](H=>({'who':H['who'],'sharing':H['sharing'],'mode':H['mode']}));if(u['length']===0x0)continue;if(t['length']>0x0&&t['every'](H=>H['mode']==='Rate')){const H=t['map'](I=>/^\d+$/['test'](I['sharing']['trim']())?Number(I['sharing']):Number['NaN']);if(H['every'](I=>Number['isFinite'](I))){const I=H['reduce']((J,K)=>J+K,0x0);if(I!==0x2710){const J=K=>{if(typeof K==='string')return K;const L=K;if(L['GuardIdentifier']!==undefined)return'GuardIdentifier('+String(L['GuardIdentifier'])+')';const M=L['Entity']?.['name_or_address']?.['$late']?.['mark'];return M!==undefined?'Entity('+M+')':JSON['stringify'](K);};h['push']({'code':'RATE_SUM_INVALID','detail':'Rate\x20group\x20\x27'+(p['key']??p['rows'][0x0]['track']+'/signer')+'\x27\x20sums\x20to\x20'+I+'\x20bps,\x20not\x2010000\x20'+('('+t['map'](K=>J(K['who'])+'='+K['sharing'])['join']('\x20+\x20')+').\x20The\x20chain\x20aborts\x20the\x20')+'allocator\x20with\x20ERATE_NOT_10000\x20at\x20apply\x20time,\x20when\x20the\x20plan\x20is\x20already\x20publish-frozen\x20—\x20fix\x20'+'the\x20split\x20now:\x20the\x20legs\x20of\x20one\x20guard_key\x20must\x20add\x20up\x20to\x20the\x20whole\x20pool\x20(a\x20two-party\x20split\x20'+'leaves\x20the\x20remainder\x20to\x20value_from_complement,\x20never\x20to\x20a\x20guessed\x20literal).'});}}}const v=p['key']!==undefined?f['get'](p['key'])?.['step_id']:undefined;p['key']!==undefined&&!f['has'](p['key'])&&h['push']({'code':'GUARD_KEY_UNKNOWN','detail':'allocator\x20row\x20('+p['rows'][0x0]['track']+')\x20binds\x20unknown\x20guard_key\x20\x27'+p['key']+'\x27'}),l['push']({...v!==undefined?{'guard':ref(v)}:{},...p['key']!==undefined?{'guard_key':p['key']}:{},'track':p['rows'][0x0]['track'],'sharing':u,...r!==undefined?{'note':r}:{}});}return{'rows':i,'rowGroups':j,'allocatorRows':l,'externalMarks':m,'blockers':h};}export function checkAllocatorRails({rowGroups:a,resolvedGuards:b,shape:c,recoverTwinRails:d,declares:e}){const g=[],h=a['map'](j=>{if(j['key']===undefined)return undefined;const k=b['get'](j['key']);return{'key':j['key'],'track':j['rows'][0x0]['track'],'table':k?.['table']??[],'root':k?.['root'],'recoverTwin':d['has'](j['key'])};})['filter'](j=>j!==undefined),i=[];if(h['length']>0x0){const j=verifyAllocatorRails(h,c['map'](m=>({'name':m['name'],'semanticRole':m['semantic_role'],'fromNodes':(m['from']??[])['map'](o=>typeof o==='string'?o:o['prev'])['filter'](o=>typeof o==='string'&&o!=='')})),{'declaredKeys':new Set(e['keys']())}),k=a['map'](m=>m['key'])['filter'](m=>m!==undefined&&!b['has'](m)),l=k['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'+k['join'](',\x20')+'.':'';for(const m of j){if(m['level']==='info'&&m['railKey']!==undefined&&e['has'](m['railKey'])){i['push']('merchant-declared\x20exemption:\x20rail\x20\x27'+m['railKey']+'\x27\x20ships\x20without\x20a\x20caller\x20identity\x20leg\x20—\x20'+e['get'](m['railKey']));continue;}m['level']==='critical'&&g['push']({'code':m['code'],'detail':m['detail']+l});}}return{'blockers':g,'disclosures':i};}export function emitServiceAllocators({template:a,inputs:b,allocatorRows:c}){const d=[];return d['push']({'op':'configure','id':'service_allocators','target':ref('service'),'method':'order_allocators','params':P({'description':a['allocator']['description'],'threshold':Number(b['threshold']??b['monthly_rent_amount']??a['fee_params']['threshold']??a['fee_params']['monthly_rent_amount']??0x0)||0x0,'allocators':c}),'requires':['machine_publish']}),{'steps':d};}export function emitSales({inputs:a}){const b=[],c=[];if(Array['isArray'](a['sales'])&&a['sales']['length']>0x0){for(const d of a['sales']){const e=numericAmount(d?.['price']);e===0x0&&c['push']({'code':'SALE_ZERO_PRICE','detail':'sales\x20SKU\x20\x27'+String(d?.['name']??'?')+'\x27\x20lists\x20price\x20\x220\x22\x20—\x20a\x20zero-priced\x20'+'LISTING\x20is\x20refused\x20(E_ZERO_TOTAL_ORDER=42:\x20a\x20zero-total\x20order\x20carries\x20an\x20empty\x20'+'escrow\x20and\x20nothing\x20to\x20settle).\x20The\x20sanctioned\x20free\x20tier:\x20price\x20the\x20SKU\x20at\x201\x20smallest\x20unit\x20'+'(the\x20minimum\x20buyable\x20price),\x20or\x20deliver\x20it\x20outside\x20the\x20sales\x20rails.'});}b['push']({'op':'configure','id':'service_sales','target':ref('service'),'method':'sales','params':{'op':'add','sales':a['sales']}});}return{'steps':b,'blockers':c};}export function emitReviewComponent({template:a,inputs:b,reviewMode:c,shape:d,guardSpecs:f,resolvedGuards:g,specByKey:h}){const i=[],j=[],k=[];if(c!=='none'){const l=d['some'](v=>/review/i['test'](v['name']));c==='review'&&!l&&k['push']({'code':'REVIEW_NODE_MISSING','detail':'review_mode\x20\x27'+c+'\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 m=f['find'](v=>v['host']==='reward'),o=v=>{const w=new Set(),x=v!==undefined?g['get'](v):undefined;if(x===undefined)return w;const y=new Map();for(const A of x['table']){typeof A['identifier']==='number'&&typeof A['value']==='string'&&y['set'](A['identifier'],A['value']);}const z=B=>{if(Array['isArray'](B)){for(const D of B)z(D);return;}if(B===null||typeof B!=='object')return;const C=B;if(Array['isArray'](C['nodes'])){const [E,F]=C['nodes'];if(E?.['query']==='progress.current'&&typeof F?.['identifier']==='number'){const G=y['get'](F['identifier']);if(G!==undefined)w['add'](G);}z(C['nodes']);}};return z(x['root']),w;},p=d['find'](v=>/review/i['test'](v['name']))?.['name'];let q,s,t=[];if(p!==undefined){const v=[];for(const E of d){for(const F of E['from']??[]){const G=typeof F==='string'?{'prev':F,'guard_key':undefined}:F;v['push']({'prev':G['prev'],'guard_key':G['guard_key'],'target':E['name']});}}const w=v['filter'](H=>H['target']===p&&H['prev']!=='');t=[...new Set(w['map'](H=>H['prev']))];const x=[...new Set(w['flatMap'](H=>H['guard_key']!==undefined?[H['guard_key']]:[]))],y=x['length']===0x1?x[0x0]:x['length']===0x0?v['find'](H=>H['prev']===p&&H['guard_key']!==undefined)?.['guard_key']:undefined,z=o(y),A=z['size']===0x0||z['size']===0x1&&t['length']===0x1&&t[0x0]===[...z][0x0],B=A?y:undefined,C=B!==undefined?h['get'](B):undefined,D=C?.['template_id']==='tpl_review_submit_content_gate';q=D?undefined:C?.['step_id'],s=D?undefined:B;}if(q===undefined){const H=[...new Set([...d['filter'](O=>/review/i['test'](O['name'])||O['semantic_role']==='final')['map'](O=>O['name']),...t])],I={'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.owner','object':{'identifier':0x0},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'order.agent\x20has','object':{'identifier':0x0},'parameters':[{'type':'context','context':'Signer'}]}]},J={'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},K=H['map']((O,Q)=>({'type':'logic_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x2+Q}]})),L=K['length']===0x1?K[0x0]:K['length']>0x1?{'type':'logic_or','nodes':K}:undefined,M=d['find'](O=>O['semantic_role']==='delivered'&&!/review/i['test'](O['name']))?.['name'],N=M===undefined?undefined:{'type':'logic_as_u256_greater_or_equal','nodes':[{'type':'query_progress_history_find','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'where':{'nextNode':M},'find':'last'},{'type':'identifier','identifier':0x2+H['length']}]};i['push']({'op':'create','id':'guard_review_write','object':'guard','params':P({'description':'Review\x20write\x20credential\x20(AR-3,\x20kernel-emitted):\x20the\x20signer\x20owns\x20or\x20administers\x20an\x20order\x20of\x20THIS\x20service'+(L!==undefined?',\x20anchored\x20on\x20the\x20order\x20having\x20reached\x20'+H['join']('\x20/\x20'):'')+(N!==undefined?',\x20and\x20the\x20order\x20must\x20have\x20ENTERED\x20the\x20\x27'+M+'\x27\x20node\x20at\x20least\x20once\x20(history\x20probe\x20—\x20a\x20never-delivered\x20order\x20cannot\x20write\x20the\x20rating\x20row,\x20ksk4\x20F-04).\x20':'.\x20')+'Gates\x20the\x20\x27review\x27\x20and\x20\x27rating\x27\x20policies\x20of\x20the\x20plan-created\x20review\x20repository\x20—\x20reads\x20nothing\x20from\x20that\x20repository,\x20so\x20the\x20write\x20path\x20is\x20satisfiable\x20by\x20construction\x20(no\x20credential\x20cycle).','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_reviewed'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},...H['map']((O,Q)=>({'identifier':0x2+Q,'b_submission':![],'value_type':'String','value':O})),...N!==undefined?[{'identifier':0x2+H['length'],'b_submission':![],'value_type':'U64','value':'0'}]:[]],'root':{'type':'logic_and','nodes':[...L!==undefined?[L]:[],...N!==undefined?[N]:[],I,J]}}),'notes':'AR-3\x20review\x20write\x20credential\x20(service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20buyer\x20writes\x20both\x20rows\x20at\x20review\x20time:\x20repository.data_add\x20{name:\x27review\x27|\x27rating\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<stars/text>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order.\x20Ordering\x20(F-05):\x20repository_review\x27s\x20create\x20is\x20EARLY\x20(pre-wave,\x20unguarded);\x20THIS\x20credential\x20exists\x20before\x20the\x20repository_review_write_guards\x20configure\x20step\x20that\x20freezes\x20the\x20credential\x20ref\x20(HOST-GRAPH-01).'}),q='guard_review_write',s='review_write';}const u=b['review_decision_enabled']===!![]&&c==='review_reward'&&m?.['step_id']!==undefined&&q!==undefined;u&&i['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(q!==undefined){const O=[{'guard':ref(q)}];i['push']({'op':'configure','id':'repository_review_write_guards','target':ref('repository_review'),'method':'policies','params':P({'op':'add','policy':[{'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'+s+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','write_guard':O,'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':O,'id_from':'none','value_type':'U64','write_once':!![]},...u?[{'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'}]:[]]}),'requires':['repository_review',q,...u?['guard_review_decision']:[]],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20credential-bound\x20and\x20ONLY\x20forms\x20of\x20the\x20review\x20repository\x27s\x20\x27review\x27/\x27rating\x27\x20policies\x20—\x20the\x20early\x20create\x20(pre-wave)\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20they\x20land\x20here\x20now\x20that\x20the\x20credential\x20guards\x20exist.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time\x20(repository.data_add\x20{name:\x27rating\x27,\x20items:[{data:[{id:<order\x20address>,\x20data:<stars>}]}]}\x20with\x20the\x20same\x20passport\x20as\x20the\x20forward);\x20a\x20good-review\x20bounty\x20claim\x20guard\x20must\x20query\x20the\x20order-keyed\x20U64\x20\x27rating\x27\x20row,\x20never\x20the\x20text\x20row.'+(u?'\x20[review_decision\x27s\x20write\x20credential\x20frozen\x20AFTER\x20guard_review_decision\x20—\x20HOST-GRAPH-01\x20discipline.]':'')}),i['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(c==='review_reward'){const Q=m;if(Q===undefined||Q['step_id']===undefined)k['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 R=b['reward_funding'],S=Q['params']?.['reward_claim_amount'];let T=S!==undefined&&S!==null?S:b['reward_claim_amount'],U='';if(T===undefined){const a0=b['review_reward_per_claim'];a0!==undefined&&a0!==null&&Number(a0)>0x0&&(T=a0,U='input\x20review_reward_per_claim');}if(T===undefined){const a1=a['fee_params']?.['review_reward_per_claim'];typeof a1==='number'&&a1>0x0&&(T=a1,U='template\x20fee_param\x20review_reward_per_claim\x20(override\x20with\x20the\x20reward_claim_amount\x20input)');}if(T===undefined){const a2=lowestSalePrice(b['sales']);a2!==undefined&&(T=String(Math['max'](Math['floor'](a2*0.02),0x1)),U='derived:\x202%\x20of\x20the\x20cheapest\x20SKU\x20('+a2+'\x20smallest\x20units),\x20floored\x20at\x201\x20(T-02)');}let V='';if(T!==undefined){const a3=numericAmount(String(T)),a4=lowestSalePrice(b['sales']);if(a3!==undefined&&a4!==undefined&&a4>0x0&&a3>0.5*a4){const a5=numericAmount(String(b['reward_funding']??'')),a6=a5!==undefined&&a3>0x0?'\x20the\x20reward_funding\x20pool\x20covers\x20~'+Math['floor'](a5/a3)+'\x20claim(s)':'';V='\x20⚠\x20T-02\x20SCALE:\x20the\x20per-claim\x20bounty\x20('+a3+')\x20exceeds\x20half\x20the\x20cheapest\x20SKU\x20price\x20('+a4+')\x20—\x20'+('each\x20claimed\x20order\x20pays\x20out\x20more\x20than\x20the\x20sale\x20earns;\x20a\x20low-price\x20SKU\x20makes\x20the\x20rail\x20a\x20bounty-farm\x20target.'+a6);}}const W=g['get'](Q['key']);W!==undefined&&!rootHasRewardRecordGate(W['root'])&&k['push']({'code':'REVIEW_REWARD_UNARMED','detail':'review_reward\x20claim\x20guard\x20\x27'+Q['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 X;if(W!==undefined&&rootHasRewardRecordGate(W['root']))for(const a7 of W['table']){const a8=a7;if(a8['b_submission']===!![]&&String(a8['value_type']??'')['toLowerCase']()==='address'&&(String(a8['object_type']??'')==='Order'||/order/i['test'](String(a8['name']??'')))){X=a8['identifier'];break;}}const Y=Q['params']?.['evidence']??b['review_claim_evidence'];let Z;if(Y!==undefined&&Y!==null&&typeof Y==='object'){const a9=Y,aa=toByteVector(a9['key']),ab=toByteVector(a9['predicate']);aa!==undefined&&ab!==undefined&&(X===undefined?k['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.'}):Z={'repo':ref('repository_review'),'key':aa,'predicate':ab});}T===undefined&&k['push']({'code':'REVIEW_REWARD_AMOUNT_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20resolved\x20a\x20claim\x20guard\x20but\x20no\x20per-claim\x20bounty\x20was\x20provided\x20or\x20derivable.\x20'+'The\x20reward\x20guard_add\x20mount\x20REQUIRES\x20an\x20amount\x20(schema-required)\x20—\x20a\x20plan\x20step\x20emitted\x20without\x20'+'it\x20fails\x20mid-execution.\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),\x20set\x20it\x20in\x20the\x20guard\x20'+'spec\x27s\x20params,\x20or\x20include\x20a\x20parseable\x20sales\x20catalog\x20(inputs.sales\x20with\x20numeric\x20prices)\x20so\x20the\x20'+'T-02\x20default\x20applies\x20(2%\x20of\x20the\x20cheapest\x20SKU,\x20floored\x20at\x201\x20smallest\x20unit).'}),i['push']({'op':'configure','id':'reward_review_guard_add','target':ref('reward_review'),'method':'guard_add','params':P({'guard':ref(Q['step_id']),'recipient':{'Signer':'signer'},...T!==undefined?{'amount':{'type':'Fixed','value':String(T)}}:{},...X!==undefined?{'store_from_id':X}:{},...Z!==undefined?{'evidence':Z}:{}}),'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.'+(T!==undefined?'\x20AMOUNT\x20(BK15-F09):\x20per-claim\x20bounty\x20pinned\x20at\x20plan\x20time\x20('+String(T)+')'+(U?'\x20—\x20'+U+';\x20override\x20with\x20the\x20reward_claim_amount\x20input':'')+'\x20—\x20no\x20execution-time\x20fill\x20needed.'+V:'')+(X!==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).':'')+(Z!==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.'+'\x20PACKAGE\x20AVAILABILITY\x20(ksr-tn-261026\x20Q8-F04):\x20the\x20native\x20evidence-pinning\x20entry\x20is\x20'+'UNAVAILABLE\x20on\x20the\x20currently\x20deployed\x20package\x20—\x20batch\x20guard_add\x20submissions\x20silently\x20'+'DROP\x20the\x20pin\x20and\x20the\x20direct\x20face\x20hard-fails\x20with\x20a\x20missing-entry\x20error\x20(classified\x20'+'capability_unavailable,\x20non-retryable).\x20The\x20reward\x20guard_add\x20read-back\x20contract\x20'+'reports\x20EVIDENCE\x20BINDING\x20VERIFIED\x20/\x20NOT\x20ON\x20CHAIN\x20after\x20the\x20landed\x20call\x20—\x20treat\x20NOT\x20ON\x20'+'CHAIN\x20as\x20the\x20truth:\x20fall\x20back\x20to\x20the\x20repository-floor\x20guard\x20leg\x20and\x20disclose\x20that\x20it\x20'+'proves\x20only\x20\x27a\x20qualifying\x20row\x20exists\x20for\x20this\x20order\x27,\x20not\x20who\x20wrote\x20it.\x20Do\x20not\x20'+'re-send\x20guard_add\x20to\x20\x27fix\x27\x20a\x20dropped\x20pin.':'')}),i['push']({'op':'configure','id':'service_rewards','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_review')]}),'requires':['service']}),typeof R==='string'||typeof R==='number'?j['push']({'op':'configure','id':'reward_review_coin_add','target':ref('reward_review'),'method':'coin_add','params':{'balance':typeof R==='number'?R:String(R)},'requires':['reward_review']}):k['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.'});}}}return{'steps':i,'fundingSteps':j,'blockers':k};}export function emitArbitrationBindings({template:a,inputs:b,needsArbitration:c,shape:d,guardSpecs:e,specByKey:f}){const g=[],h=[],i=[];if(c){g['push']({'op':'configure','id':'service_arbitrations','target':ref('service'),'method':'arbitrations','params':P({'op':'add','objects':[ref('arbitration')]})});const j=e['find'](l=>l['template_id']==='tpl_voting_guard_open_vote'&&l['step_id']!==undefined);j?.['step_id']!==undefined&&g['push']({'op':'configure','id':'arbitration_voting_guard','target':ref('arbitration'),'method':'voting_guard','params':P({'op':'set','guards':[{'guard':ref(j['step_id']),'vote_weight':{'FixedValue':0x1}}]}),...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{}});const k=b['compensation_fund'];if(typeof k==='string'||typeof k==='number')h['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':String(k)}});else{const l=d['some'](m=>{if(m['semantic_role']!=='final')return![];for(const o of m['from']??[]){if(typeof o==='string')continue;const p=o['guard_key']===undefined?undefined:f['get'](o['guard_key']);if(p?.['template_id']==='tpl_forward_arb_ruling_won')return!![];}return![];});l&&i['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.'});}}return{'steps':g,'fundingSteps':h,'blockers':i};}export function emitServicePublish(){const a=[];return a['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'}]}),{'steps':a};}export function computeMoneyRailKeys({rowsWithAttachments:a,guardSpecs:b}){const c=new Set(a['map'](f=>f['guard_key'])['filter'](f=>typeof f==='string')),d=new Set(b['filter'](f=>f['host']==='reward'&&f['step_id']!==undefined)['map'](f=>f['key'])),e=new Set([...c,...d]);return{'allocatorBoundKeys':c,'moneyRailKeys':e};}export function checkForeignServicePins({resolvedGuards:a,edgeBoundKeys:b,moneyRailKeys:c}){const d=[],e=/^0x[0-9a-fA-F]{20,64}$/,f=h=>{const i=a['get'](h);if(i===undefined)return[];const j=new Set(),k=m=>{if(Array['isArray'](m)){for(const o of m)k(o);return;}if(m===null||typeof m!=='object')return;const n=m;if(n['type']==='logic_equal'){const p=Array['isArray'](n['nodes'])?n['nodes']:n['left']!==undefined||n['right']!==undefined?[n['left'],n['right']]:[],s=p['find'](u=>u!==null&&typeof u==='object'&&typeof u['query']==='string'&&u['query']['startsWith']('order.service')),t=p['find'](u=>u!==s);s!==undefined&&t!==undefined&&t!==null&&typeof t==='object'&&t['type']==='identifier'&&j['add'](String(t['identifier']));}for(const u of Object['values'](n))k(u);};k(i['root']);const l=[];for(const m of i['table']){const n=m;if(n['b_submission']===!![]||n['value_type']!=='Address')continue;const o=n['value'];if(typeof o!=='string'||!e['test'](o))continue;if(!j['has'](String(n['identifier']??'?')))continue;l['push'](String(n['identifier']??'?'));}return l;};for(const g of a['keys']()){if(!b['has'](g)&&!c['has'](g))continue;for(const h of f(g)){d['push']({'code':'GUARD_FOREIGN_SERVICE','detail':'guard\x20\x27'+g+'\x27\x20pins\x20the\x20Service\x20by\x20on-chain\x20address\x20literal\x20(table\x20slot\x20'+h+'\x20on\x20an\x20'+'order.service\x20comparison\x20leg)\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.\x20'+'(A\x200x\x20literal\x20in\x20a\x20NON-service\x20slot\x20—\x20e.g.\x20a\x20judge\x20account\x20pin,\x20R-C4-04\x20—\x20is\x20a\x20legal\x20business\x20pin\x20and\x20not\x20flagged.)'});}}return{'blockers':d};}export function auditRepoIntegrityAndCallerLegs({steps:a,resolvedGuards:b,moneyRailKeys:c,recoverTwinRails:d}){const e=[],f=new Map(),h=new Map(),i=(v,w)=>{for(const x of w){const y=typeof x['name']==='string'?x['name']:undefined;if(y!==undefined)v['keys']['add'](y);const z=Array['isArray'](x['write_guard'])?x['write_guard']:[];for(const A of z){const B=A['guard'],C=typeof B==='string'?B:B!==null&&typeof B==='object'&&typeof B['$ref']==='string'?B['$ref']:undefined;if(C===undefined||y===undefined)continue;const D=v['writeGuards']['get'](y)??new Set();D['add'](C),v['writeGuards']['set'](y,D);}}};for(const v of a){if(v['op']!=='create'||v['object']!=='repository')continue;const w=v['params'],x={'keys':new Set(),'writeGuards':new Map()};i(x,Array['isArray'](w['policies'])?w['policies']:[]),f['set'](v['id'],x);if(typeof w['name']==='string')h['set'](w['name'],x);}for(const y of a){if(y['op']!=='configure'||y['method']!=='policies')continue;const z=y['target'],A=z!==null&&typeof z==='object'&&typeof z['$ref']==='string'?z['$ref']:undefined,B=A!==undefined?f['get'](A):undefined;if(B===undefined)continue;const C=y['params']['policy'];i(B,Array['isArray'](C)?C:[]);}const j=(D,E)=>E===undefined?undefined:D['find'](F=>F['identifier']===E),k=(D,E)=>{const F=j(D,E)?.['value'];if(F!==null&&typeof F==='object'&&typeof F['$ref']==='string')return f['get'](F['$ref']);return typeof F==='string'?h['get'](F):undefined;},l=(D,E)=>{const F=j(D,E)?.['value'];return typeof F==='string'?F:undefined;},m=new Map([['vec_contains_string',![]],['vec_indexof_string',![]],['vec_contains_string_nocase',!![]],['vec_indexof_string_nocase',!![]]]),n=new Set(['query_repository_data_keys_where','query_repository_policies_keys']),o=(D,E)=>{const F=[],G=I=>{const J=I?.['identifier'];return typeof J==='number'?J:undefined;},H=I=>{if(I===null||typeof I!=='object')return;if(Array['isArray'](I)){for(const L of I)H(L);return;}const J=I;if(J['type']==='query_repository_data_find_where'||J['type']==='query_repository_data_count_where'||J['type']==='query_repository_data_sum_where'||J['type']==='query_repository_data_sum_where_bound'){const M=k(D,G(J['object'])),N=l(D,G(J['key']));if(M!==undefined&&N!==undefined)F['push']({'repo':M,'key':N,'nocase':![]});}if(J['type']==='query'&&typeof J['query']==='string'&&/^repository\.data\b/i['test'](J['query'])){const O=k(D,G(J['object'])),Q=Array['isArray'](J['parameters'])?J['parameters']:[],R=l(D,G(Q[0x0]));if(O!==undefined&&R!==undefined)F['push']({'repo':O,'key':R,'nocase':![]});}if(J['type']==='query_repository_data'||J['type']==='query_repository_data_has'){const S=k(D,G(J['object'])),T=typeof J['key']==='string'?J['key']:undefined;if(S!==undefined&&T!==undefined)F['push']({'repo':S,'key':T,'nocase':![]});}const K=typeof J['type']==='string'?m['get'](J['type']):undefined;if(K!==undefined){const U=Array['isArray'](J['nodes'])?J['nodes']:[J['nodeLeft'],J['nodeRight']],V=U[0x0];if(V!==null&&typeof V==='object'&&typeof V['type']==='string'&&n['has'](V['type'])){const W=k(D,G(V['object']));if(W!==undefined)for(const X of U['slice'](0x1)){const Y=l(D,G(X));if(Y!==undefined)F['push']({'repo':W,'key':Y,'nocase':K});}}}for(const Z of Object['keys'](J))H(J[Z]);};return H(E),F;},p=(D,E,F)=>F?[...D['keys']]['some'](G=>G['toLowerCase']()===E['toLowerCase']()):D['keys']['has'](E),q=(D,E,F)=>F?[...D['writeGuards']]['find'](([G])=>G['toLowerCase']()===E['toLowerCase']())?.[0x1]:D['writeGuards']['get'](E);for(const [D,E]of b){if(E['stepId']===undefined)continue;for(const F of o(E['table'],E['root'])){!p(F['repo'],F['key'],F['nocase'])&&e['push']({'code':'POLICY_KEY_UNRESOLVED','detail':'guard\x20\x27'+D+'\x27\x20reads\x20repository\x20policy\x20key\x20\x27'+F['key']+'\x27,\x20but\x20NO\x20repository\x20create\x20step\x20in\x20this\x20'+'plan\x20defines\x20that\x20policy\x20—\x20as\x20built\x20the\x20read\x20'+'is\x20identically\x20ZERO\x20or\x20an\x20empty\x20key\x20list\x20(REPO-GATE-KEY-01):\x20the\x20gated\x20forward\x20never\x20opens\x20and\x20every\x20order\x20freezes\x20mid-rail\x20(bsx\x20BSX-F01:\x20'+'the\x20delivery\x20gate\x20read\x20\x27license_grant\x27\x20while\x20the\x20repository\x20stored\x20\x27grant\x27).\x20Policies\x20are\x20NOT\x20chain-frozen\x20—\x20'+'the\x20repository\x27s\x20policy-management\x20permission\x20(index\x20102)\x20can\x20add\x20the\x20missing\x20key\x20post-publish\x20—\x20but\x20do\x20not\x20ship\x20the\x20dead\x20rail:\x20'+'align\x20the\x20guard\x27s\x20row\x20'+'key\x20with\x20a\x20policy\x20name\x20this\x20plan\x20actually\x20creates.'}),q(F['repo'],F['key'],F['nocase'])?.['has'](E['stepId'])&&e['push']({'code':'CREDENTIAL_CYCLE','detail':'guard\x20\x27'+D+'\x27\x20is\x20a\x20write\x20credential\x20of\x20a\x20repository\x20policy\x20it\x20also\x20READS\x20(\x27'+F['key']+'\x27)\x20—\x20to\x20write\x20'+'the\x20row\x20you\x20must\x20first\x20pass\x20a\x20guard\x20requiring\x20the\x20row.\x20Unsatisfiable\x20by\x20construction\x20(bsn7\x20T-01\x20/\x20'+'bsx\x20BSX-F02:\x20the\x20review\x20write\x20credential\x20fell\x20back\x20to\x20the\x20reward-claim\x20guard,\x20which\x20requires\x20the\x20'+'rating\x20row\x20it\x20gates).\x20The\x20write\x20credential\x20must\x20be\x20an\x20identity/progress\x20credential\x20that\x20reads\x20'+'nothing\x20from\x20that\x20repository.'});}}const r=(G,H)=>{let I=![];const J=K=>{if(I||K===null||typeof K!=='object')return;if(Array['isArray'](K)){for(const M of K)J(M);return;}const L=K;if(L['type']==='context'&&L['context']===H)I=!![];for(const N of Object['keys'](L))J(L[N]);};return J(G),I;},u=G=>{let H=![];const I=J=>{if(H||J===null||typeof J!=='object')return;if(Array['isArray'](J)){for(const L of J)I(L);return;}const K=J;K['type']==='query'&&typeof K['query']==='string'&&/named_operator|permission|arb\./i['test'](K['query'])&&(H=!![]);for(const M of Object['keys'](K))I(K[M]);};return I(G),H;};for(const G of b['keys']()){if(!c['has'](G))continue;if(d['has'](G)||/recover/i['test'](G))continue;const H=b['get'](G);if(r(H['root'],'Signer'))continue;if(u(H['root']))continue;if(r(H['root'],'Clock'))continue;e['push']({'code':'MONEY_RAIL_CALLER_LEG_MISSING','detail':'money\x20rail\x20\x27'+G+'\x27\x20(allocator\x20row\x20or\x20reward\x20claim)\x20has\x20NO\x20caller-authorization\x20leg:\x20'+'alloc_by_guard\x20and\x20Reward\x20claims\x20are\x20NOT\x20forwards\x20—\x20'+'the\x20chain\x20injects\x20the\x20order-holder\x20rail\x20on\x20forward\x20ops\x20only\x20and\x20neither\x20op\x20has\x20a\x20'+'chain-side\x20caller\x20check,\x20so\x20this\x20rail\x20is\x20driveable\x20by\x20ANY\x20passport\x20holder\x20(gf30\x20A2\x20'+'settle_BY_OUTSIDER_v2\x20drained\x20o4;\x20rex5\x20T-27\x20rex-buy2\x20drained\x20a\x20third\x20party\x27s\x20escrow).\x20Bind\x20one:\x20'+'order.owner\x20==\x20Signer\x20OR\x20order.agent\x20has\x20Signer\x20(buyer),\x20or\x20the\x20dynamic-permission\x20leg\x20—\x20'+'service.permission\x20==\x20a\x20submitted\x20Permission\x20slot,\x20then\x20permission.owner\x20==\x20Signer\x20OR\x20'+'permission.admin\x20has\x20Signer\x20(merchant\x20or\x20keeper,\x20survives\x20rotation;\x20K-4).\x20State-determined\x20'+'exception\x20stays\x20open:\x20context\x20Clock\x20(time\x20gates).\x20Decision\x2011:\x20order.claimed_by\x20is\x20NEVER\x20an\x20'+'authorization\x20on\x20a\x20fund\x20rail\x20—\x20a\x20claimed_by\x20leg\x20there\x20is\x20the\x20RAIL_CLAIMED_BY_LEG\x20critical,\x20'+'blocked\x20by\x20the\x20rail\x20verifier\x20regardless\x20of\x20caller\x20identity.'});}return{'blockers':e};}export function emitSupplyChain({supplyChain:a,steps:b,derivedParams:c}){const d=[],e=[];let f;if(a!==undefined&&a['length']>0x0){const g=b['find'](n=>n['op']==='create'&&n['object']==='service'),h=g!==undefined&&g['op']==='create'&&typeof g['params']['name']==='string'?g['params']['name']:'',i=new Set(b['map'](n=>n['id'])),j=new Set(),k=new Set(),l=((()=>{for(let n=b['length']-0x1;n>=0x0;n-=0x1){const o=b[n];if(o['op']==='publish'&&o['target']['$ref']==='service')return n;}return b['length'];})());let m=0x0;a['forEach']((n,o)=>{const p=n['id_prefix']??(o===0x0?'sc':'sc'+String(o+0x1)),q='supply-chain\x20promise\x20#'+String(o+0x1)+'\x20(\x27'+(n['sub_service']||'unset\x20provider')+'\x27,\x20'+String(n['axis'])+')';if(n['service_step_id']!==undefined&&n['service_step_id']!=='service'){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20service_step_id\x20\x27'+n['service_step_id']+'\x27\x20names\x20no\x20step\x20in\x20this\x20plan.\x20Compile\x20'+'attaches\x20a\x20promise\x20to\x20its\x20own\x20Service\x20create,\x20whose\x20id\x20is\x20always\x20\x27service\x27\x20—\x20drop\x20the\x20field\x20'+'or\x20pass\x20\x27service\x27.'});return;}let r=n['repository_name'];if(r!==undefined&&j['has'](r)){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20repository_name\x20\x27'+r+'\x27\x20is\x20already\x20created\x20by\x20an\x20earlier\x20promise\x20—\x20one\x20'+('Repository\x20cannot\x20be\x20created\x20twice.\x20Pass\x20\x27repository:\x20'+r+'\x27\x20on\x20this\x20promise\x20to\x20')+'REUSE\x20the\x20shared\x20ledger\x20instead\x20of\x20creating\x20it.'});return;}if(n['repository']===undefined&&r===undefined){const u=(n['service_name']||h||'service')+'_supply_chain';if(j['has'](u))r=u+'_'+p;}const s=emitSupplyChainPromise({...n,'service_name':n['service_name']||h,'service_step_id':'service','id_prefix':p,...r!==undefined?{'repository_name':r}:{}});for(const v of s['blockers'])d['push']({'code':v['code'],'detail':q+':\x20'+v['detail']});const t=s['steps']['find'](w=>i['has'](w['id']));if(t!==undefined){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20emitted\x20step\x20id\x20\x27'+t['id']+'\x27\x20already\x20exists\x20in\x20the\x20plan.\x20Each\x20promise\x20names\x20its\x20'+'objects\x20\x27<prefix>_gate\x27\x20/\x20\x27_write\x27\x20/\x20\x27_ack\x27\x20/\x20\x27_rendezvous\x27\x20/\x20\x27_bind_repository\x27\x20/\x20\x27_alloc\x27,\x20'+'so\x20give\x20this\x20promise\x20a\x20distinct\x20id_prefix.'});return;}for(const w of s['steps']){i['add'](w['id']),w['op']==='create'&&w['object']==='repository'&&typeof w['params']['name']==='string'&&j['add'](w['params']['name']);}b['splice'](l+m,0x0,...s['steps']),m+=s['steps']['length'],c['push'](...s['derived_params']??[]);if(s['steps']['length']===0x0)return;e['push'](s),k['add'](n['axis']);});if(k['size']>0x0){const n=[...k];f=n['length']===0x1?n[0x0]:'mixed';}}return{'supplyChainEmissions':e,'fulfillmentAxis':f,'blockers':d};}
1
+ import{SV2_UNARMED_PRESCRIPTION}from'../knowledge/protocol-facts.js';import{verifyAllocatorRails}from'../knowledge/allocator-rail-verifier.js';import{TASK_BINDING_SLOT}from'../knowledge/onchain-constants.js';import{rootHasRewardRecordGate,SERVICE_SALE_FIELDS}from'../knowledge/template-scanner.js';import{guardTemplateHasIdentityLeg}from'../knowledge/builtin-templates.js';import{numericAmount}from'../knowledge/audit-rules.js';import{emitSupplyChainPromise}from'./supply-chain-emit.js';import{P,ref}from'./plan.js';import{truncateProseUtf8}from'./materialize.js';import{validateGuardTreeShape}from'../knowledge/guard-render.js';import{MAX_POLICY_DESCRIPTION_LEN}from'@wowok/wowok';function lowestSalePrice(a){if(!Array['isArray'](a))return undefined;let b;for(const c of a){const d=numericAmount(c?.['price']);if(d!==undefined&&d>0x0)b=b===undefined?d:Math['min'](b,d);}return b;}const BOUNTY_TO_MIN_SKU_ADVISORY_RATIO=0xa;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;}const CANONICAL_CURRENCY='0x2::wow::WOW',QUALIFIED_TYPE_RE=/^0x[0-9a-fA-F]{1,64}::[a-zA-Z_][a-zA-Z0-9_]*::[A-Za-z_][A-Za-z0-9_]*$/;export function normalizeCurrency(a){const b=a['trim']();if(QUALIFIED_TYPE_RE['test'](b))return b;if(/^\$?wow$/i['test'](b))return CANONICAL_CURRENCY;return undefined;}const capUtf8=(a,b)=>{if(Buffer['byteLength'](a,'utf8')<=b)return[a,![]];return[truncateProseUtf8(a,b-0x3)+'…',!![]];},MAX_DESCRIPTION_CONTENT_BYTES=0xf9e,proseTruncatedAdvisory=(a,b,c,d)=>'PROSE_TRUNCATED\x20(F-08,\x20ADVISORY\x20—\x20not\x20a\x20blocker):\x20'+a+'\x20measured\x20'+b+'\x20UTF-8\x20bytes,\x20over\x20the\x20'+('on-chain\x20cap\x20of\x20'+c+'\x20('+d+')\x20—\x20it\x20shipped\x20truncated\x20to\x20a\x20semantic\x20summary\x20(leading\x20template-id/purpose\x20')+'sentences\x20preserved).\x20The\x20build\x20is\x20NOT\x20blocked;\x20tighten\x20the\x20prose\x20at\x20authoring\x20time\x20if\x20the\x20full\x20wording\x20matters.';function offTaskSlotIdentityLegs(a){const b=new Set(['order.owner','order.agent\x20has']),c=new Set(['query_order_named_operator_member']),d=new Set(),e=[],f=g=>{if(g===null||typeof g!=='object')return;const h=g;if(h['type']==='logic_equal'&&Array['isArray'](h['nodes'])){const l=h['nodes']['filter'](m=>m!==null&&typeof m==='object'&&m['type']==='identifier'&&typeof m['identifier']==='number');if(l['some'](m=>m['identifier']===TASK_BINDING_SLOT)){for(const m of l)d['add'](m['identifier']);}}const i=h['object'],j=typeof h['query']==='string'&&b['has'](h['query'])||typeof h['type']==='string'&&c['has'](h['type']);if(j&&i!==null&&typeof i==='object'&&typeof i['identifier']==='number'){const o=i['identifier'],p=typeof h['query']==='string'?h['query']:h['type'];if(o!==TASK_BINDING_SLOT)e['push']({'query':p,'identifier':o});}if(Array['isArray'](h['nodes'])){for(const q of h['nodes'])f(q);}if(h['node']!==undefined&&typeof h['node']==='object')f(h['node']);};return f(a),e['filter'](g=>!d['has'](g['identifier']));}const MODE_MAP={'amount':'Amount','rate':'Rate','surplus':'Surplus','formula':'Formula'};export function emitIdentityPhase({template:a,base:b}){const c=[];c['push']({'op':'create','id':'permission','object':'permission','params':{'name':b+'_permission'}});const d=a['arbitration_mode']!==undefined&&a['arbitration_mode']!=='none';return d&&c['push']({'op':'create','id':'permission_arb','object':'permission','params':{'name':b+'_arb_permission'},...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'notes':'MUST\x20be\x20created\x20by\x20a\x20different\x20account\x20than\x20the\x20service\x20permission\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT=33):\x20dispute\x20neutrality.\x20'+'third_party\x20builds\x20declare\x20account\x20\x27arb_controller\x27\x20—\x20provide\x20'+'accounts.arb_controller\x20to\x20plan_execute.'}),c['push']({'op':'create','id':'contact','object':'contact','params':{'name':b+'_contact','ims':{'op':'set','im':[{'at':{'$late':{'by':'env_signer'}}}]}},'notes':'R8:\x20customer-service\x20channel;\x20mandatory\x20when\x20customer_required\x20is\x20set.\x20'+'required_info\x20is\x20SELF-ATTESTED\x20—\x20the\x20chain\x20stores\x20the\x20buyer\x27s\x20claim\x20verbatim\x20and\x20nothing\x20verifies\x20it\x20'+'(the\x20bind\x20path\x20only\x20proves\x20the\x20claim\x20came\x20from\x20this\x20order\x27s\x20owner).\x20A\x20genuine\x20credential\x20gate\x20requires\x20'+'a\x20Proof-backed\x20delivery\x20guard\x20(see\x20the\x20privacy-delivery\x20design;\x20not\x20wired\x20by\x20default).'}),{'steps':c,'needsArbitration':d};}const rewardRowIdentifiers=a=>{const b=new Set(),c=d=>{if(Array['isArray'](d)){for(const f of d)c(f);return;}if(typeof d!=='object'||d===null)return;const e=d;if(typeof e['type']==='string'&&e['type']['startsWith']('query_reward_record')){const g=e['object'];if(g!==undefined&&typeof g['identifier']==='number')b['add'](g['identifier']);}for(const h of Object['values'](e))c(h);};return c(a),b;};export function emitRewardClaimEarly({reviewMode:a,guardSpecs:b,resolvedGuards:c,rewardMark:d}){const e=[],f=a==='review_reward'?b['find'](g=>g['host']==='reward'):undefined;if(a==='review_reward'&&f?.['step_id']!==undefined){const g=c['get'](f['key']);if(g!==undefined){const h=rewardRowIdentifiers(g['root']);c['set'](f['key'],{...g,'table':g['table']['map'](i=>{const j=i;if(j['b_submission']===!![]||!h['has'](j['identifier']))return i;return{...j,'value':ref('reward_review')};})});}e['push']({'op':'create','id':'reward_review','object':'reward','params':P({'name':d,'description':'Review\x20incentive\x20pool\x20(sale-time\x20planned;\x20terms\x20disclosed\x20at\x20quote/buy):\x20claim\x20gated\x20by\x20guard\x20\x27'+f['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\x20plan\x20ref\x20{\x22$ref\x22:\x22reward_review\x22}]'});}return{'steps':e};}export function emitExperiencePoolEarly({experienceClaimKey:a,guardSpecs:b,resolvedGuards:c,poolMark:d}){const e=[];if(a===undefined)return{'steps':e};const f=b['find'](h=>h['key']===a);if(f===undefined||f['step_id']===undefined)return{'steps':e};const g=c['get'](f['key']);if(g!==undefined){const h=rewardRowIdentifiers(g['root']);c['set'](f['key'],{...g,'table':g['table']['map'](i=>{const j=i;if(j['b_submission']===!![]||!h['has'](j['identifier']))return i;return{...j,'value':ref('reward_experience')};})});}return e['push']({'op':'create','id':'reward_experience','object':'reward','params':P({'name':d,'description':'Experience-compensation\x20pool\x20(K3\x20C-11;\x20terms\x20disclosed\x20at\x20quote/buy):\x20the\x20merchant\x20pre-funds\x20this\x20goodwill\x20pool\x20and\x20buyers\x20claim\x20PROACTIVELY\x20per\x20guard\x20\x27'+f['key']+'\x27.\x20NOT\x20escrow\x20—\x20it\x20never\x20touches\x20the\x20order\x27s\x20own\x20settlement\x20(a\x20claim\x20blocks\x20nothing;\x20nothing\x20is\x20ever\x20deducted\x20from\x20the\x20merchant).\x20The\x20balance\x20is\x20finite:\x20a\x20claim\x20above\x20the\x20remaining\x20balance\x20aborts,\x20and\x20the\x20merchant\x20may\x20withdraw\x20the\x20unclaimed\x20remainder\x20once\x20the\x20claim\x20window\x20lapses.'}),'notes':'EXPERIENCE-COMPENSATION\x20(K3\x20C-11):\x20the\x20goodwill\x20pool\x20must\x20be\x20perceivable\x20by\x20the\x20buyer\x20BEFORE\x20ordering\x20—\x20the\x20four\x20disclosure\x20duties\x20ride\x20the\x20quote/buy\x20surface\x20(pool\x20≠\x20escrow\x20/\x20finite\x20+\x20withdrawable\x20/\x20proactive\x20in-window\x20claim\x20/\x20Fixed-tier\x20amount).\x20'+'[ZR-08:\x20created\x20BEFORE\x20its\x20claim\x20guard\x20—\x20the\x20guard\x27s\x20Reward-address\x20row\x20freezes\x20at\x20creation\x20and\x20binds\x20this\x20pool\x20by\x20plan\x20ref\x20{\x22$ref\x22:\x22reward_experience\x22}]'}),{'steps':e};}export function checkDaysUnitSlots({resolvedGuards:a}){const b=[];{const c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=f['table'],i=h['filter'](m=>typeof m?.['name']==='string'&&/day/i['test'](m['name'])),j=i['find'](m=>/ms[_\s]?per[_\s]?day/i['test'](m['name']));if(j===undefined)continue;const k=d(j);if(k===undefined||k===c)continue;const l=i['some'](m=>m!==j&&(d(m)??0x0)>0xe42);if(!l)continue;b['push']({'code':'DAYS_SLOT_UNIT_MISMATCH','detail':'guard\x20\x27'+e+'\x27:\x20a\x20day-denominated\x20slot\x20is\x20stuffed\x20with\x20MILLISECONDS\x20while\x20its\x20ms_per_day\x20row\x20reads\x20'+k+'\x20'+'(tbpr7\x20F-V3-04:\x20DAYS\x20slots\x20carrying\x20173000/864000\x20beside\x20ms_per_day\x20=\x201).\x20Guards\x20are\x20immutable\x20—\x20a\x20wrong\x20'+'unit\x20is\x20PERMANENT:\x20the\x20window\x20runs\x20~6\x20orders\x20of\x20magnitude\x20long\x20(or\x20short)\x20and\x20no\x20keeper\x20call\x20can\x20fix\x20it.\x20'+'Day\x20slots\x20carry\x20DAY\x20COUNTS\x20(twin\x20templates\x20scale\x20by\x2086400000\x20at\x20compile;\x20on-chain\x20day\x20twins\x20keep\x20the\x20'+'ms_per_day\x20=\x2086400000\x20row):\x20set\x20ms_per_day\x20back\x20to\x2086400000\x20and\x20re-derive\x20the\x20day\x20slots\x20via\x20fee-param\x20bindings.'});}}return{'blockers':b};}export function checkWindowTruncation({resolvedGuards:a}){const b=[],c=0x5265c00,d=e=>{const f=e['value'],h=typeof f==='number'?f:typeof f==='string'?Number(f):NaN;return Number['isFinite'](h)?h:undefined;};for(const [e,f]of a){const h=new Map();for(const m of f['table']){if(!m||typeof m!=='object'||Array['isArray'](m))continue;const n=m;typeof n['identifier']==='number'&&n['b_submission']!==!![]&&h['set'](n['identifier'],n);}const i=o=>typeof o==='number'?h['get'](o):undefined,j=o=>{const p=[];for(const q of['nodes','and','or','left','right']){const s=o[q];if(Array['isArray'](s))p['push'](...s);else{if(s!==undefined)p['push'](s);}}return p;},k=o=>{if(!o||typeof o!=='object'||Array['isArray'](o))return{'multiplies':0x0,'total':0x0};const p=o,q=typeof p['type']==='string'?p['type']:'';if(q==='calc_number_multiply'&&Array['isArray'](p['nodes'])&&p['nodes']['length']===0x2){const [u,w]=p['nodes'],x=u!==null&&typeof u==='object'&&u['type']==='identifier'?i(u['identifier']):undefined,y=w!==null&&typeof w==='object'&&w['type']==='identifier'?i(w['identifier']):undefined;if(x===undefined||y===undefined)return undefined;const z=d(x)===c?x:d(y)===c?y:undefined;if(z===undefined)return undefined;const A=z===x?y:x;if(A['value_type']!=='U64'||z['value_type']!=='U64')return undefined;const B=d(A);if(B===undefined)return undefined;return{'multiplies':0x1,'total':B};}let s=0x0,t=0x0;for(const C of j(p)){const D=k(C);if(D===undefined)return undefined;s+=D['multiplies'],t+=D['total'];}return{'multiplies':s,'total':t};},l=(o,p)=>{if(!o||typeof o!=='object'||Array['isArray'](o))return;const q=o,s=typeof q['type']==='string'?q['type']:'',t=s['includes']('lesser')?!![]:s['includes']('greater')?![]:p;if(s['includes']('lesser')){const u=q['nodes'],v=Array['isArray'](u)?u[0x1]:undefined,w=v!==undefined?k(v):{'multiplies':0x0,'total':0x0};w!==undefined&&w['multiplies']>0x0&&w['total']<0x1&&b['push']({'code':'WINDOW_TRUNCATION_ZERO','detail':'guard\x20\x27'+e+'\x27:\x20a\x20CLOSING\x20window\x27s\x20day\x20slots\x20total\x20'+String(w['total'])+'\x20day(s)\x20—\x20a\x20zero\x20(or\x20'+'sub-1\x20fraction,\x20which\x20the\x20U64\x20slot\x20truncates\x20to\x200\x20at\x20BCS\x20encode)\x20makes\x20the\x20leg\x20compute\x20'+'anchor\x20+\x200\x20×\x2086400000\x20on-chain,\x20so\x20the\x20`<=`\x20window\x20welds\x20shut\x20the\x20instant\x20its\x20anchor\x20entry\x20'+'lands\x20and\x20never\x20reopens\x20(Guards\x20are\x20immutable;\x20the\x20live\x20run\x20compiled\x20a\x200.002-day\x20test\x20window\x20'+'into\x20exactly\x20this\x20shape).\x20Pass\x20whole\x20days,\x20or\x20answer\x20the\x20window\x27s\x20PARALLEL\x20`*_ms`\x20knob\x20'+'(e.g.\x20review_window_ms:\x20600000\x20=\x20a\x2010-minute\x20window;\x20nnd4\x20F-04)\x20—\x20the\x20compiler\x20then\x20emits\x20'+'the\x20millisecond-denominated\x20slot\x20pair\x20(duration_ms\x20beside\x20a\x20day-factor\x20of\x201).'});}for(const x of j(q))l(x,t);};l(f['root'],![]);}return{'blockers':b};}export function emitServiceDraft({template:a,base:b,inputs:c}){const d=[],e=[],f=typeof c['currency']==='string'?c['currency']['trim']():'',g=f===''?CANONICAL_CURRENCY:normalizeCurrency(f);g===undefined&&e['push']({'code':'CURRENCY_UNRESOLVED','detail':'inputs.currency\x20\x27'+String(c['currency'])+'\x27\x20is\x20not\x20a\x20resolvable\x20token\x20type.\x20Pass\x20the\x20'+'fully-qualified\x20form\x20\x270x2::wow::WOW\x27\x20or\x20the\x20bare\x20symbol\x20\x27WOW\x27\x20(aliased\x20here).\x20The\x20plan\x20carries\x20the\x20'+'canonical\x20default\x20so\x20the\x20shape\x20stays\x20inspectable,\x20but\x20the\x20verdict\x20is\x20blocked:\x20an\x20unqualified\x20symbol\x20'+'aborts\x20at\x20the\x20service\x20create\x20(type_parameter\x20validation)\x20AFTER\x20earlier\x20steps\x20already\x20ran\x20—\x20plan_execute\x20'+'is\x20not\x20transactional\x20(algr9\x20F-03:\x204\x20orphan\x20objects\x20behind\x20the\x20failed\x20step).'});const h=g??CANONICAL_CURRENCY;return d['push']({'op':'create','id':'service','object':'service','params':P({'name':b+'_service','type_parameter':h,'permission':ref('permission'),'um':ref('contact'),'description':a['id']+'\x20—\x20compiled\x20by\x20the\x20composition\x20compiler',...Array['isArray'](c['customer_required'])?{'customer_required':c['customer_required']}:{}}),'notes':'Draft\x20first\x20(F-01):\x20registers\x20the\x20LocalMark\x20name\x20every\x20guard\x20resolves\x20at\x20runtime.\x20'+'machine/repositories/buy_guard\x20attach\x20in\x20configure\x20steps\x20after\x20machine_publish\x20'+'(schema-sanctioned\x20phased\x20build;\x20machine/order_allocators\x20remain\x20publish-frozen).'}),{'steps':d,'currency':h,'blockers':e};}function runtimeWriteReceipt({policy:a,idFrom:b,valueType:c,writeGuard:d,submissionNote:e}){const f=b==='signer'||b==='clock',g=d['length']>0x0?'write_guard\x20'+JSON['stringify'](d)+'\x20MUST\x20ride\x20the\x20call'+e:'the\x20policy\x20ships\x20no\x20write_guard\x20(legal\x20only\x20for\x20signer/clock\x20rows)';return{'repository':ref('repository'),'policy':a,'id_from':f?b:'none','shape':f?'single_value':'items','call':{'data_add':f?{'name':a,'data':'<writer\x20payload\x20(value_type\x20'+c+')>',...d['length']>0x0?{'write_guard':d}:{}}:{'name':a,'items':[{'id':'<caller-chosen\x20row\x20key\x20(value_type\x20'+c+')>','data':'<row\x20payload>'}],...d['length']>0x0?{'write_guard':d}:{}}},'notes':f?'F-19\x20(dspt-mn-261104):\x20id_from='+b+'\x20rows\x20write\x20ONLY\x20this\x20single-value\x20data_add\x20form\x20—\x20the\x20items\x20shape\x20routes\x20to\x20'+('the\x20on-chain\x20batch-row\x20import\x20path\x20(multi-row\x20writes),\x20which\x20requires\x20id_from==ID_FROM_NONE\x20and\x20aborts\x20a\x20'+b+'-keyed\x20policy\x20')+('with\x20E_POLICY_ID_FROM_NONE=21;\x20the\x20row\x20id\x20auto-derives\x20from\x20the\x20writing\x20'+b+'.\x20'+g+'.\x20')+'The\x20write\x20is\x20a\x20RUNTIME\x20chain\x20op\x20(executed\x20by\x20each\x20writer\x20at\x20order\x20time)\x20—\x20this\x20receipt\x20documents\x20the\x20shape,\x20never\x20a\x20Plan\x20step.':'F-19\x20(dspt-mn-261104):\x20id_from=none\x20rows\x20write\x20ONLY\x20the\x20items\x20data_add\x20form\x20(the\x20batch-row\x20import\x20path\x20—\x20every\x20item\x20'+('carries\x20its\x20own\x20caller-chosen\x20row\x20id\x20of\x20value_type\x20'+c+');\x20a\x20single-value\x20form\x20would\x20auto-derive\x20the\x20id\x20from\x20')+('the\x20writer\x20and\x20abort\x20(E_POLICY_ID_FROM_NONE=21\x20family).\x20'+g+'.\x20')+'The\x20write\x20is\x20a\x20RUNTIME\x20chain\x20op\x20—\x20this\x20receipt\x20documents\x20the\x20shape,\x20never\x20a\x20Plan\x20step.'};}export function emitEvidenceRepository({needsRepository:a,base:b,inputs:c,guardSpecs:d,resolvedGuards:e}){const f=[],g=[],h=[],i=[],j=[];if(a){const k=Array['isArray'](c['repository_policies'])?c['repository_policies']['filter'](o=>typeof o==='object'&&o!==null):[],l=k['map'](o=>Array['isArray'](o['write_guard'])?o:{'write_guard':[],...o}),m=[];for(const o of l){const p=o['description'];if(typeof p!=='string')continue;const [q,r]=capUtf8(p,MAX_POLICY_DESCRIPTION_LEN);r&&(o['description']=q,m['push'](proseTruncatedAdvisory('caller-supplied\x20repository_policies\x20entry\x20\x27'+String(o['name']??'(unnamed)')+'\x27\x20description',Buffer['byteLength'](p,'utf8'),MAX_POLICY_DESCRIPTION_LEN,'on-chain\x20repository\x20policy\x20description\x20length\x20cap')));}for(const s of k){const t=typeof s['id_from']==='string'?s['id_from']['toLowerCase']():'none',u=Array['isArray'](s['write_guard'])?s['write_guard']['length']:0x0;t==='none'&&u===0x0&&g['push']({'code':'REPO_POLICY_WRITE_GUARD_REQUIRED','detail':'repository_policies\x20entry\x20\x27'+String(s['name']??'(unnamed)')+'\x27\x20declares\x20id_from\x20'+'\x27none\x27\x20(caller-supplied\x20row\x20key)\x20with\x20NO\x20write_guard\x20—\x20the\x20chain\x20aborts\x20policy\x20'+'creation\x20with\x20E_POLICY_WRITE_GUARD_REQUIRED\x20=\x2022\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'policy\x20add\x20(the\x20id\x20is\x20caller-chosen,\x20so\x20an\x20ungated\x20rule\x20'+'would\x20let\x20anyone\x20write\x20the\x20row).\x20Attach\x20a\x20write_guard:[{guard:...}]\x20leg,\x20or\x20switch\x20'+'the\x20policy\x20to\x20id_from\x20\x22signer\x22/\x22clock\x22\x20if\x20the\x20row\x20key\x20may\x20be\x20derived\x20from\x20the\x20writer.'});}const n=new Set(k['map'](v=>v['name']));for(const v of l){const w=typeof v['name']==='string'?v['name']:undefined;if(w===undefined)continue;j['push'](runtimeWriteReceipt({'policy':w,'idFrom':typeof v['id_from']==='string'?v['id_from']['toLowerCase']():'none','valueType':typeof v['value_type']==='string'?v['value_type']:'String','writeGuard':Array['isArray'](v['write_guard'])?v['write_guard']:[],'submissionNote':';\x20the\x20passport\x20must\x20submit\x20the\x20write_guard\x27s\x20b_submission\x20rows'}));}for(const x of d){if(x['host']!=='repository'||x['step_id']===undefined)continue;const y='host:\x22repository\x22\x20guard\x20\x27'+x['key']+'\x27\x20(step\x20\x27'+x['step_id']+'\x27)';if(x['policy']===undefined){g['push']({'code':'REPO_GUARD_POLICY_MISSING','detail':y+'\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;}const z=x['policy']['name']??x['key'],A=(x['policy']['id_from']??'none')['toLowerCase'](),B=x['policy']['id_from_submission'],C=x['policy']['data_from_submission'];B!==undefined&&(A==='signer'||A==='clock')&&g['push']({'code':'REPO_GUARD_SUBMISSION_ID_FORBIDDEN','detail':y+'\x20declares\x20id_from_submission\x20'+B+'\x20while\x20its\x20policy\x20id_from\x20is\x20'+('\x27'+A+'\x27\x20—\x20the\x20row\x20id\x20is\x20AUTO-generated\x20from\x20the\x20'+A+'\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\x20—\x20at\x20the\x20create\x20step\x20or\x20at\x20any\x20later\x20'+'permission-102\x20policy\x20add\x20—\x20so\x20this\x20must\x20be\x20fixed,\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 I=e['get'](x['key']),J=[['id_from_submission',B],['data_from_submission',C]];for(const [K,L]of J){if(L===undefined)continue;const M=I?.['table']['find'](N=>N['identifier']===L);(I===undefined||M===undefined||M['b_submission']!==!![])&&g['push']({'code':'REPO_GUARD_SUBMISSION_SLOT_UNKNOWN','detail':y+'\x20declares\x20'+K+'\x20'+L+',\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'+L+'\x20on\x20the\x20guard,\x20or\x20point\x20')+(K+'\x20at\x20an\x20existing\x20submission\x20slot.')});}}if(n['has'](z))continue;const D=x['policy']['description']??x['purpose'],[E,F]=capUtf8(D,MAX_POLICY_DESCRIPTION_LEN);F&&(x['purpose']=x['purpose']+'\x20'+proseTruncatedAdvisory('repository\x20policy\x20\x27'+z+'\x27\x20description',Buffer['byteLength'](D,'utf8'),MAX_POLICY_DESCRIPTION_LEN,'on-chain\x20repository\x20policy\x20description\x20length\x20cap'));const G={'name':z,'description':E,'id_from':x['policy']['id_from']??'none','value_type':x['policy']['value_type']??'String','write_once':x['policy']['write_once']??![]},H=[{'guard':ref(x['step_id']),...B!==undefined?{'id_from_submission':B}:{},...C!==undefined?{'data_from_submission':C}:{}}];h['push']({...G,'write_guard':H}),i['push'](x['step_id']),j['push'](runtimeWriteReceipt({'policy':z,'idFrom':A,'valueType':x['policy']['value_type']??'String','writeGuard':H,'submissionNote':';\x20the\x20passport\x20must\x20submit\x20the\x20write_guard\x27s\x20b_submission\x20rows'}));}f['push']({'op':'create','id':'repository','object':'repository','params':P({'name':b+'_evidence',...l['length']>0x0?{'policies':l}:{}}),'notes':'Evidence\x20rows\x20(tracking\x20hash,\x20receipts,\x20WTS\x20proofs).\x20Created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20the\x20guards\x27\x20table\x20rows\x20reach\x20this\x20repository\x20by\x20plan\x20ref.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20create\x20ships\x20ONLY\x20caller-supplied\x20policies\x20that\x20are\x20legal\x20at\x20construction\x20—\x20every\x20guard-derived\x20policy\x20lands\x20at\x20the\x20repository_write_guards\x20configure\x20step\x20right\x20after\x20the\x20wave,\x20in\x20its\x20credential-bound\x20(write_guard-attached)\x20form,\x20the\x20ONLY\x20legal\x20shape\x20for\x20id_from=none.]'+(m['length']>0x0?'\x20'+m['join']('\x20'):'')});}return{'steps':f,'repoBoundPolicies':h,'repoBoundStepIds':i,'runtimeWrites':j,'blockers':g};}export function emitReviewRepositoryEarly({reviewMode:a,base:b,inputs:c}){const d=[],e=[];return a!=='none'&&(c['buyer_review_enabled']===!![]&&e['push'](runtimeWriteReceipt({'policy':'buyer_review','idFrom':'signer','valueType':'String','writeGuard':[],'submissionNote':''})),d['push']({'op':'create','id':'repository_review','object':'repository','params':P({'name':b+'_review','description':'Structured\x20buyer\x20reputation\x20rows\x20(AR-1:\x20emitted\x20by\x20the\x20build\x20plan\x20—\x20no\x20manual\x20setup).',...c['buyer_review_enabled']===!![]?{'policies':[{'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':!![],'write_guard':[]}]}:{}}),'notes':'REVIEW-COMPONENT\x20AR-1\x20(F-05\x20early\x20form):\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).\x20The\x20\x27rating\x27\x20row\x20is\x20what\x20a\x20reward\x20good-review\x20leg\x20reads\x20(F-62).\x20Buyers\x20resolve\x20this\x20object\x20by\x20name\x20(workspace/onchain_objects)\x20—\x20never\x20guess\x20an\x20address.\x20[F-BS5-03\x20(bst5-mn-261101):\x20the\x20\x27review\x27/\x27rating\x27\x20policies\x20(id_from=none,\x20order-keyed)\x20ship\x20ONLY\x20on\x20the\x20repository_review_write_guards\x20configure\x20step\x20in\x20their\x20credential-bound\x20form\x20—\x20an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain\x20(the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20BOTH\x20the\x20create\x20path\x20and\x20every\x20later\x20policy\x20add).\x20buyer_review\x20(id_from=signer)\x20is\x20the\x20one\x20create-legal\x20policy.]'})),{'steps':d,'runtimeWrites':e};}export function rewritePlanRefs({base:a,resolvedGuards:b}){{const c=new Map([[a+'_service','service'],[a+'_evidence','repository'],[a+'_review','repository_review'],[a+'_arbitration','arbitration']]);for(const [,d]of b){for(const e of d['table']){const f=e,h=typeof f['value']==='string'?c['get'](f['value']):undefined;if(h!==undefined)f['value']=ref(h);}}}}export function dropEmptyVecGuards({resolvedGuards:a,guardSpecs:b,steps:c}){const d=[],e=[];{const f=new Map();for(const [i,j]of a){const k=new Set();for(const l of j['table']){const m=l;m['b_submission']===![]&&Array['isArray'](m['value'])&&m['value']['length']===0x0&&typeof m['identifier']==='number'&&k['add'](m['identifier']);}if(k['size']>0x0)f['set'](i,k);}const h=(n,o)=>{if(n===null||typeof n!=='object')return![];const p=n;if(p['type']!=='vec_contains_address'||!Array['isArray'](p['nodes']))return![];const q=p['nodes']['find'](s=>s['type']==='identifier');return q!==undefined&&typeof q['identifier']==='number'&&o['has'](q['identifier']);};for(const [n,o]of f){const p=a['get'](n),q=p['root'],s=b['find'](v=>v['key']===n),t=q['type']==='logic_not'&&h(q['node'],o);if(t&&s?.['host']==='service'&&n==='buy'){a['delete'](n),s['step_id']=undefined,e['push'](n);continue;}const u=[...o]['map'](String);d['push']({'code':'GUARD_EMPTY_VEC_ROW','detail':'guard\x20\x27'+n+'\x27\x20declares\x20static\x20vec\x20row(s)\x20'+u['join'](',\x20')+'\x20with\x20an\x20EMPTY\x20array\x20—\x20'+'the\x20executor\x20refuses\x20empty\x20static\x20vec\x20slots\x20(LE-10:\x20the\x20chain\x27s\x20table\x20builder\x20silently\x20DROPS\x20empty\x20'+'vectors,\x20so\x20the\x20created\x20Guard\x20would\x20diverge\x20from\x20the\x20reviewed\x20spec\x20—\x20mainnet\x207\x20submitted\x20->\x206\x20stored).\x20'+'Two\x20legal\x20exits:\x20(a)\x20arm\x20the\x20list\x20with\x20at\x20least\x20one\x20address\x20(the\x20blocklist\x20twin\x27s\x20intended\x20armed\x20form:\x20'+'list\x20the\x20provider-side\x20account(s)\x20to\x20ban\x20self-purchase);\x20or\x20(b)\x20if\x20the\x20empty\x20list\x20IS\x20the\x20intended\x20open\x20'+('polarity,\x20omit\x20the\x20guard:\x20guard_resolutions\x20{\x22'+n+'\x22:\x20{\x22kind\x22:\x20\x22omit\x22}}\x20—\x20the\x20compile\x20honors\x20omission\x20')+'and\x20the\x20attached\x20rail\x20ships\x20un-gated\x20(there\x20is\x20no\x20constant-true\x20Guard\x20object\x20to\x20fabricate).'});}}if(e['length']>0x0){const v=c['find'](w=>w['op']==='create'&&w['id']==='service');v!==undefined&&(v['notes']=(v['notes']??'')+'\x20[F-04\x20open-store\x20drop:\x20the\x20blocklist\x20buy\x20guard\x20('+e['join'](',\x20')+')\x20resolved\x20to\x20an\x20EMPTY\x20blocklist\x20—\x20NOT(vec_contains(empty))\x20is\x20constant\x20true,\x20a\x20no-op\x20gate,\x20and\x20the\x20executor\x20refuses\x20empty\x20vec\x20rows\x20(LE-10)\x20—\x20so\x20the\x20guard\x20and\x20its\x20buy\x20mount\x20are\x20OMITTED:\x20this\x20store\x20ships\x20OPEN.\x20To\x20arm\x20the\x20self-purchase\x20ban,\x20fill\x20the\x20blocklist\x20at\x20generation.]');}return{'blockers':d};}export function emitArbitrationHoist({needsArbitration:a,template:b,base:c,currency:d}){const e=[];return a&&e['push']({'op':'create','id':'arbitration','object':'arbitration',...b['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{},'params':P({'name':c+'_arbitration','permission':ref('permission_arb'),'type_parameter':d,'pause':![]}),'notes':'Independent\x20venue\x20(R2);\x20activates\x20atomically\x20(create+unpause\x20same\x20PTB).\x20[W5-05:\x20created\x20BEFORE\x20the\x20guard\x20wave\x20so\x20arb-ruling\x20guard\x20tables\x20bind\x20it\x20by\x20plan\x20ref]'}),{'steps':e};}export function emitGuardWave({resolvedGuards:a,specByKey:b,slot254Injected:c,repoBoundPolicies:d,repoBoundStepIds:e}){const f=[],g=h=>{const i=a['get'](h),j=b['get'](h)?.['purpose'];return{'op':'create','id':i['stepId'],'object':'guard','params':P({'description':i['description'],'table':i['table'],'root':i['root']}),'notes':c['has'](h)?(j??'Guard')+'\x20[kernel:\x20protocol\x20slot\x20254\x20(task\x20binding)\x20auto-declared]':j};};for(const [h]of a)f['push'](g(h));return d['length']>0x0&&f['push']({'op':'configure','id':'repository_write_guards','target':ref('repository'),'method':'policies','params':P({'op':'add','policy':d}),'requires':['repository',...e],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20ONLY\x20landing\x20place\x20for\x20the\x20evidence\x20repository\x27s\x20guard-derived\x20policies\x20—\x20the\x20create\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20the\x20credential-bound\x20forms\x20(write_guard\x20attached)\x20are\x20added\x20to\x20the\x20live\x20repository\x20here,\x20now\x20that\x20the\x20guards\x20exist\x20(the\x20plan-ref\x20rewrite\x20closed\x20the\x20double-object\x20cycle).'}),{'steps':f};}export function emitMachine({template:a,base:b,shape:c,resolvedGuards:d,specByKey:e,injectedOrderHolderKeys:f,merchantIndex:h}){const i=[],j=[],k=new Set(c['map'](r=>r['name'])),l=new Set((a['allocator']?.['rows']??[])['filter'](s=>s['track']==='settlement')['map'](s=>s['guard_key'])['filter'](r=>typeof r==='string'&&r['trim']()!=='')),n=[],p=new Set(),q=new Map();for(const r of c){if(r['from']===undefined||r['from']['length']===0x0){j['push']({'code':'MACHINE_EDGES_MISSING','detail':'machine_shape\x20node\x20\x27'+r['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 s=[],t=new Map(),u=new Map();for(const w of r['from']){const x=typeof w==='string'?{'prev':w}:w;if(x['prev']!==''&&!k['has'](x['prev'])){j['push']({'code':'EDGE_UNKNOWN_PREV','detail':'node\x20\x27'+r['name']+'\x27\x20edge\x20prev\x20\x27'+x['prev']+'\x27\x20is\x20not\x20a\x20machine_shape\x20node'});continue;}const y=x['operator']??r['operator']??(x['prev']===''?'order_payer':'merchant'),z=x['named_operator']??r['named_operator'],A=x['forward']??(x['prev']===''?'enter_'+r['name']:x['prev']+'_to_'+r['name']);x['permission_index']!==undefined&&y==='order_payer'&&j['push']({'code':'PERMISSION_INDEX_DROPPED','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20declares\x20permission_index\x20'+x['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'+x['permission_index']+'\x20only')});z!==undefined&&x['permission_index']!==undefined&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20declares\x20named_operator\x20\x27'+z+'\x27\x20AND\x20permission_index\x20'+x['permission_index']+'.\x20'+'namedOperator\x20and\x20permissionIndex\x20are\x20OR-options\x20in\x20the\x20on-chain\x20pre-check\x20(namedOperator\x20first),\x20so\x20both\x20rails\x20on\x20one\x20forward\x20'+'is\x20a\x20widening\x20ambiguity\x20—\x20the\x20forward\x20stays\x20open\x20to\x20whichever\x20rail\x20matches\x20and\x20neither\x20the\x20roster-only\x20nor\x20the\x20entity-only\x20intent\x20binds.\x20'+'Pick\x20ONE\x20rail:\x20drop\x20permission_index\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20permission\x20entity\x20rail'});z!==undefined&&(x['operator']==='order_payer'||r['operator']==='order_payer')&&j['push']({'code':'NAMED_OPERATOR_RAIL_CONFLICT','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20declares\x20named_operator\x20\x27'+z+'\x27\x20on\x20an\x20EXPLICIT\x20operator:\x27order_payer\x27.\x20'+'Both\x20ride\x20the\x20namedOperator\x20rail\x20with\x20different\x20payloads\x20—\x20the\x20buyer\x20self-advance\x20(\x27\x27\x20resolves\x20to\x20the\x20order\x20payer)\x20and\x20the\x20'+('third-party\x20namespace\x20(\x27'+z+'\x27\x20resolves\x20to\x20the\x20per-order\x20roster)\x20cannot\x20share\x20one\x20forward;\x20one\x20of\x20them\x20would\x20silently\x20lose.\x20')+'Pick\x20ONE\x20rail:\x20drop\x20the\x20operator\x20declaration\x20to\x20keep\x20the\x20named\x20roster\x20rail,\x20or\x20drop\x20named_operator\x20to\x20keep\x20the\x20buyer\x20self-advance'});const B=x['guard_key']!==undefined&&x['guard_key']['trim']()!==''&&l['has'](x['guard_key'])||/settle|release|payout/i['test'](A);{B&&x['permission_index']===undefined&&z===undefined&&y!=='order_payer'&&j['push']({'code':'RELEASE_EDGE_PERMISSIONLESS','detail':'settlement\x20edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20(forward\x20\x27'+A+'\x27,\x20guard\x20\x27'+(x['guard_key']??'none')+'\x27)\x20binds\x20NO\x20permission_index\x20and\x20NO\x20named_operator\x20rail\x20—\x20it\x20compiles\x20PERMISSIONLESS:\x20the\x20on-chain\x20permission\x20layer\x20checks\x20namedOperator\x20then\x20permissionIndex,\x20and\x20with\x20neither\x20present\x20ANYONE\x20with\x20a\x20valid\x20order\x20passport\x20can\x20advance\x20the\x20release\x20and\x20move\x20the\x20escrow\x20(5R-07①\x20F-56,\x20tbp\x20T17\x20live:\x20an\x20unrelated\x20buyer\x27s\x20wallet\x20executed\x20the\x20payout).\x20Bind\x20ONE\x20rail:\x20permission_index\x201002\x20(the\x20keeper\x20or\x20merchant\x20release\x20slot\x20—\x20recommended\x20default\x20C:\x20the\x20time-lock\x20guard\x20+\x20keeper\x20duty\x20+\x20bounty\x20schedule\x20the\x20release)\x20or\x20a\x20stricter\x20merchant-approval\x20rail\x20for\x20high-ticket\x20builds\x20(default\x20A:\x20the\x20merchant\x27s\x20own\x20approval\x20BEFORE\x20the\x20escrow\x20moves).\x20Pair\x20the\x20rail\x20with\x20the\x20guard\x27s\x20identity\x20leg\x20(Signer\x20binding)\x20as\x20defense\x20in\x20depth\x20—\x20declared\x20in\x20the\x20guard\x20table,\x20verified\x20by\x20the\x20audit\x20face'});}const C={'name':A,'weight':0x1,...z!==undefined?{'namedOperator':z}:y==='order_payer'?{'namedOperator':''}:{'permissionIndex':x['permission_index']??h}};{const G=C['permissionIndex'];if(typeof G==='number'){const H=q['get'](G);if(H!==undefined)H['push'](A);else q['set'](G,[A]);}}if(x['guard_key']!==undefined){const I=e['get'](x['guard_key']);if(I===undefined)j['push']({'code':'GUARD_KEY_UNKNOWN','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20binds\x20unknown\x20guard_key\x20\x27'+x['guard_key']+'\x27'});else{for(const K of I['purpose']['matchAll'](/progress\.current\s*==\s*([a-z0-9_]+)/g)){const L=K[0x1];k['has'](L)&&L!==x['prev']&&j['push']({'code':'FORWARD_GUARD_PINNED_TO_NON_PREV','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20guard\x20\x27'+I['key']+'\x27\x20pins\x20progress.current\x20==\x20\x27'+L+'\x27,\x20but\x20a\x20'+('forward\x20guard\x20evaluates\x20BEFORE\x20the\x20advance\x20(progress.current\x20==\x20prev\x20\x27'+x['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.'});}const J=I['template_id']==='pattern.identity_check_order_holder'||I['template_id']==='tpl_forward_order_holder'||I['template_id']==='tpl_forward_order_holder_or_time'||I['template_id']==='tpl_time_window_upper_order_holder'||I['template_id']==='tpl_time_window_band_abs_order_holder'||I['template_id']==='tpl_forward_order_holder_time_lock_absolute';if(J&&z!==undefined)j['push']({'code':'FORWARD_GUARD_IDENTITY_NAMED_CONFLICT','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20guard\x20\x27'+I['key']+'\x27\x20is\x20an\x20order-holder\x20(buyer)\x20identity\x20'+('check\x20but\x20the\x20forward\x20rides\x20a\x20named_operator\x20rail\x20(\x27'+z+'\x27\x20—\x20a\x20third\x20party\x20that\x20is\x20')+'neither\x20the\x20merchant\x20entity\x20nor\x20the\x20buyer).\x20The\x20identity\x20layer\x20runs\x20BEFORE\x20the\x20guard\x20and\x20the\x20'+'roster\x20signer\x20is\x20never\x20the\x20order\x20owner\x20—\x20nobody\x20can\x20pass\x20both.\x20Move\x20the\x20buyer-identity\x20leg\x20'+'off\x20this\x20forward\x20(the\x20roster\x20forward\x20may\x20carry\x20only\x20evidence/time\x20guards),\x20or\x20split\x20the\x20hop.'});else J&&y!=='order_payer'&&j['push']({'code':'FORWARD_GUARD_IDENTITY_PERM_CONFLICT','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20guard\x20\x27'+I['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 M=d['get'](I['key']);if(M!==undefined){const N=M['table']['some'](Q=>Q['identifier']===TASK_BINDING_SLOT),O=offTaskSlotIdentityLegs(M['root'])['filter'](Q=>{if(!N)return![];const R=M['table']['find'](S=>S['identifier']===Q['identifier']);return R!==undefined&&R['b_submission']===!![];});for(const Q of O){j['push']({'code':'GUARD_IDENTITY_SLOT_NOT_TASKBOUND','detail':'edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20guard\x20\x27'+I['key']+'\x27\x20reads\x20'+Q['query']+'\x20off\x20free\x20'+('submission\x20slot\x20'+Q['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,\x20so\x20this\x20'+('guard\x20is\x20the\x20only\x20identity\x20leg.\x20Anchor\x20the\x20'+Q['query']+'\x20query\x20on\x20identifier\x20')+(TASK_BINDING_SLOT+'\x20(the\x20task-binding\x20order\x20anchor\x20—\x20the\x20order\x20the\x20forward\x20actually\x20mutates).')});}}}if(I['step_id']!==undefined){C['guard']=ref(I['step_id']);if(B&&y==='order_payer'&&z===undefined){const R=d['get'](I['key']);R!==undefined&&!guardTemplateHasIdentityLeg(R['root'])&&j['push']({'code':'RELEASE_EDGE_NO_IDENTITY','detail':'settlement\x20edge\x20\x27'+x['prev']+'\x27->\x27'+r['name']+'\x27\x20(forward\x20\x27'+A+'\x27,\x20guard\x20'+('\x27'+I['key']+'\x27,\x20design\x20\x27'+I['template_id']+'\x27)\x20rides\x20the\x20buyer\x20rail\x20(operator\x20')+'\x27order_payer\x27\x20→\x20namedOperator\x20\x22\x22\x20with\x20NO\x20permissionIndex)\x20and\x20its\x20guard\x20carries\x20NO\x20'+'order-holder\x20identity\x20leg\x20—\x20on\x20a\x20guard-bound\x20forward\x20the\x20chain\x20skips\x20the\x20'+'permission\x20assert,\x20so\x20ANY\x20signer\x20holding\x20a\x20passport\x20for\x20this\x20guard\x20can\x20drive\x20the\x20'+'settlement\x20(gfm35-tn-261029\x20F02\x20live:\x20an\x20outsider\x20force-released\x20and\x20settled\x20order).\x20'+'Bind\x20a\x20guard\x20whose\x20root\x20carries\x20the\x20owner/agent\x20identity\x20legs\x20over\x20slot\x20254\x20—\x20e.g.\x20'+'tpl_forward_order_holder_time_lock_absolute\x20for\x20a\x20deadline\x20self-heal\x20(split\x20guard\x20'+'key:\x20keep\x20the\x20pure\x20time\x20lock\x20on\x20the\x20keeper/merchant\x20edge),\x20'+'tpl_time_window_upper_absolute_ms\x20for\x20a\x20closing\x20window.\x20The\x20STATE_AUTHORIZING\x20'+'exemption\x20covers\x20keeper/merchant\x20rails\x20only,\x20never\x20the\x20buyer\x20release\x20rail'});}}}}if(C['guard']===undefined&&y==='order_payer'&&z===undefined){const S=f['get'](A);if(S!==undefined){const T=e['get'](S);T?.['step_id']!==undefined&&(C['guard']=ref(T['step_id']));}}const D=t['get'](x['prev']);D!==undefined?D['push'](C):t['set'](x['prev'],[C]);const E=u['get'](x['prev']),F=z!==undefined?'namedOperator:'+z:y==='order_payer'?'namedOperator:':'permissionIndex:'+(x['permission_index']??h);z!==undefined&&p['add'](z),E!==undefined?E['add'](F):u['set'](x['prev'],new Set([F]));}const v=r['threshold']??0x0;for(const [U,V]of t){v>V['length']&&j['push']({'code':'PAIR_THRESHOLD_UNREACHABLE','detail':'node\x20\x27'+r['name']+'\x27\x20pair\x20from\x20\x27'+(U===''?'(entry)':U)+'\x27\x20declares\x20threshold\x20'+v+'\x20'+('but\x20the\x20pair\x20merges\x20only\x20'+V['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(v>=0x2){const W=u['get'](U)?.['size']??0x0;W<0x2&&j['push']({'code':'PAIR_THRESHOLD_SINGLE_OPERATOR','detail':'node\x20\x27'+r['name']+'\x27\x20pair\x20from\x20\x27'+(U===''?'(entry)':U)+'\x27\x20declares\x20threshold\x20'+v+'\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).'});}s['push']({'prev_node':U,'threshold':v,'forwards':V});}n['push']({'name':r['name'],...r['semantic_role']!==undefined?{'role':r['semantic_role']}:{},...r['optional']===!![]?{'optional':!![]}:{},'pairs':s});}if(p['size']>0x0){const X=/(named[-_ ]?operator|operator roster|\broster\b|dispatch|permission.{0,12}221)/i,Y=(a['build_notes']??[])['some'](Z=>X['test'](Z));!Y&&j['push']({'code':'NAMED_OPERATOR_ROSTER_UNDISCLOSED','detail':'machine_shape\x20binds\x20a\x20named\x20third-party\x20operator\x20namespace\x20('+[...p]['map'](Z=>'\x27'+Z+'\x27')['join'](',\x20')+')\x20'+'but\x20no\x20build_note\x20discloses\x20the\x20roster\x20management.\x20The\x20per-order\x20NamedOperator\x20roster\x20(max\x2060\x20rosters\x20/\x2080\x20addresses)\x20is\x20written\x20at\x20'+'runtime\x20by\x20the\x20account\x20holding\x20permission\x20index\x20221\x20—\x20without\x20a\x20disclosed\x20dispatch\x20duty\x20the\x20forward\x20compiles\x20but\x20nobody\x20can\x20ever\x20'+'pass\x20it\x20(silent\x20brick).\x20Add\x20a\x20build_note\x20stating\x20WHO\x20writes\x20the\x20roster,\x20WHEN\x20(per\x20order?\x20per\x20shift?),\x20and\x20what\x20happens\x20on\x20a\x20miss\x20'+'(e.g.\x20\x22namedOperator\x20\x27delivery_team\x27\x20roster\x20is\x20written\x20per\x20order\x20by\x20the\x20dispatch\x20keeper\x20via\x20permission\x20221;\x20an\x20unassigned\x20order\x20'+'waits\x20until\x20the\x20keeper\x20assigns\x20a\x20courier\x22).\x20K-4\x20stance:\x20dispatch\x20assignment\x20is\x20an\x20OFF-CHAIN\x20keeper\x20optimization,\x20never\x20a\x20chain\x20scheduler'});}for(const Z of[...q['keys']()]['sort']((a0,a1)=>a0-a1)){if(Z<0x3e8)continue;const a0=q['get'](Z);i['push']({'op':'configure','id':'permission_grant_'+Z,'target':ref('permission'),'method':'table','params':P({'op':'add\x20perm\x20by\x20index','index':Z,'entity':[{'$late':{'by':'env_signer'}}]}),'notes':'F-19\x20(amz-k7q2,\x202026-11-04):\x20grant\x20permission\x20index\x20'+Z+'\x20to\x20the\x20deploy\x20signer\x20'+('({$late\x20env_signer})\x20—\x20forward(s)\x20'+a0['map'](a1=>'\x27'+a1+'\x27')['join'](',\x20')+'\x20ride\x20this\x20rail\x20on\x20the\x20')+'machine\x27s\x20Permission\x20(the\x20shared\x20Service\x20permission,\x20F-CSTC-05);\x20without\x20this\x20grant\x20each\x20of\x20them\x20'+'aborts\x20E_PERMISSION_DENIED\x20on\x20a\x20fresh\x20store.\x20Adjust\x20or\x20extend\x20the\x20entity\x20roster\x20on-chain\x20'+'post-deploy\x20as\x20staff/keeper\x20roles\x20change.'});}return i['push']({'op':'create','id':'machine','object':'machine','params':P({'name':b+'_machine','permission':ref('permission'),'nodes':n})}),i['push']({'op':'publish','id':'machine_publish','target':ref('machine'),'preflight':[{'check':'machine_publish','status':'pending'},{'check':'TASKBIND-01','status':'pending'}]}),{'steps':i,'blockers':j};}export function emitServiceConfigure({guardSpecs:a,needsRepository:b}){const c=[],d=a['find'](e=>e['host']==='service'&&e['key']==='buy');return c['push']({'op':'configure','id':'service_machine','target':ref('service'),'method':'machine','params':ref('machine'),'requires':['machine_publish']}),b&&c['push']({'op':'configure','id':'service_repository','target':ref('service'),'method':'repositories','params':P({'op':'add','objects':[ref('repository')]}),'requires':['service','repository']}),d?.['step_id']!==undefined&&c['push']({'op':'configure','id':'service_buy_guard','target':ref('service'),'method':'buy_guard','params':ref(d['step_id']),'requires':['service',d['step_id']]}),{'steps':c};}export function emitAllocators({template:a,base:b,inputs:c,rowsWithAttachments:d,resolvedGuards:e,specByKey:f}){const h=[],i=d['length']>0x0?d:[{'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}],j=[],k=new Map();for(const n of i){if(n['guard_key']!==undefined){let o=k['get'](n['guard_key']);o===undefined&&(o={'key':n['guard_key'],'rows':[]},k['set'](n['guard_key'],o),j['push'](o)),o['rows']['push'](n);}else j['push']({'rows':[n]});}const l=[],m=new Set();for(const p of j){const q=[];let r;for(const w of p['rows']){let x=w['value'];x===undefined&&w['value_from']!==undefined&&(x=c[w['value_from']]??a['fee_params'][w['value_from']]);if(x===undefined&&w['value_from_complement']!==undefined){const A=w['value_from_complement'],B=c[A]??a['fee_params'][A],C=typeof B==='number'?B:typeof B==='string'&&/^\d+(?:\.\d+)?$/['test'](B['trim']())?Number(B):undefined;if(w['mode']!=='rate'){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20declares\x20value_from_complement\x20\x27'+A+'\x27\x20but\x20'+('mode\x20\x27'+w['mode']+'\x27\x20—\x20the\x20complement\x20is\x20RATE-domain\x20only\x20(10000\x20-\x20bps).\x20Use\x20value/value_from\x20for\x20Amount\x20rows.')});continue;}if(C===undefined||!Number['isFinite'](C)||C<0x0||C>0x2710){h['push']({'code':'ALLOCATOR_COMPLEMENT_INVALID','detail':'allocator\x20row\x20('+w['track']+'/'+(w['recipient_key']??w['recipient'])+')\x20value_from_complement\x20\x27'+A+'\x27\x20resolves\x20to\x20'+('\x27'+String(B)+'\x27\x20—\x20not\x20a\x20bps\x20value\x20in\x20[0,\x2010000];\x20the\x20complement\x20leg\x20cannot\x20be\x20computed.')});continue;}x=0x2710-C;}if(x===undefined&&w['mode']!=='surplus'){h['push']({'code':'ALLOCATOR_VALUE_MISSING','detail':'allocator\x20row\x20('+w['track']+'/'+w['recipient']+')\x20has\x20neither\x20value\x20nor\x20a\x20resolvable\x20value_from'});continue;}(w['fix']!==undefined||w['fix_from']!==undefined)&&h['push']({'code':'ALLOCATOR_FIX_UNSUPPORTED','detail':'allocator\x20row\x20('+w['track']+'/'+w['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'+'in\x20full\x20at\x20release,\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.'});r??=w['note'];let y;if(w['recipient']==='entity'){const D=w['recipient_key']??'merchant';m['add'](D),y={'Entity':{'name_or_address':{'$late':{'by':'local_name','mark':D}}}};}else{if(w['recipient']==='guard_identifier'){const E=Number(w['recipient_key']??0x0);y={'GuardIdentifier':E};const F=p['key']!==undefined?e['get'](p['key']):undefined;if(F!==undefined){const G=F['table']['find'](H=>H['identifier']===E);(G===undefined||G['b_submission']!==!![]||G['value_type']!=='Address')&&h['push']({'code':'GUARD_SLOT_UNKNOWN','detail':'allocator\x20leg\x20{GuardIdentifier:\x20'+E+'}\x20on\x20guard\x20\x27'+p['key']+'\x27\x20of\x20\x27'+b+'\x27:\x20the\x20bound\x20'+('Guard\x20table\x20has\x20no\x20slot\x20'+E+'\x20Address\x20submission\x20row\x20(b_submission:\x20true).\x20On\x20chain\x20the\x20leg\x20')+('reads\x20slot\x20'+E+'\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)\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'+E+',\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 y={'Signer':'signer'};}const z=typeof x==='number'?x===0x0:typeof x==='string'&&/^\s*0+(?:\.0+)?\s*$/['test'](x);q['push']({'who':y,'sharing':String(x??'0'),'mode':MODE_MAP[w['mode']],'zeroEntityRate':w['recipient']==='entity'&&w['mode']==='rate'&&z});}const s=q['filter'](H=>H['zeroEntityRate']),t=s['length']>0x0&&s['length']<q['length']?q['filter'](H=>!H['zeroEntityRate']):q,u=t['map'](H=>({'who':H['who'],'sharing':H['sharing'],'mode':H['mode']}));if(u['length']===0x0)continue;if(t['length']>0x0&&t['every'](H=>H['mode']==='Rate')){const H=t['map'](I=>/^\d+$/['test'](I['sharing']['trim']())?Number(I['sharing']):Number['NaN']);if(H['every'](I=>Number['isFinite'](I))){const I=H['reduce']((J,K)=>J+K,0x0);if(I!==0x2710){const J=K=>{if(typeof K==='string')return K;const L=K;if(L['GuardIdentifier']!==undefined)return'GuardIdentifier('+String(L['GuardIdentifier'])+')';if('Signer'in L)return'Signer';const M=L['Entity']?.['name_or_address']?.['$late']?.['mark'];return M!==undefined?'Entity('+M+')':JSON['stringify'](K);};h['push']({'code':'RATE_SUM_INVALID','detail':'Rate\x20group\x20\x27'+(p['key']??p['rows'][0x0]['track']+'/signer')+'\x27\x20sums\x20to\x20'+I+'\x20bps,\x20not\x2010000\x20'+('('+t['map'](K=>J(K['who'])+'='+K['sharing'])['join']('\x20+\x20')+').\x20The\x20chain\x20aborts\x20the\x20')+'allocator\x20with\x20ERATE_NOT_10000\x20at\x20apply\x20time,\x20when\x20the\x20plan\x20is\x20already\x20publish-frozen\x20—\x20fix\x20'+'the\x20split\x20now:\x20the\x20legs\x20of\x20one\x20guard_key\x20must\x20add\x20up\x20to\x20the\x20whole\x20pool\x20(a\x20two-party\x20split\x20'+'leaves\x20the\x20remainder\x20to\x20value_from_complement,\x20never\x20to\x20a\x20guessed\x20literal).'});}}}const v=p['key']!==undefined?f['get'](p['key'])?.['step_id']:undefined;p['key']!==undefined&&!f['has'](p['key'])&&h['push']({'code':'GUARD_KEY_UNKNOWN','detail':'allocator\x20row\x20('+p['rows'][0x0]['track']+')\x20binds\x20unknown\x20guard_key\x20\x27'+p['key']+'\x27'}),l['push']({...v!==undefined?{'guard':ref(v)}:{},...p['key']!==undefined?{'guard_key':p['key']}:{},'track':p['rows'][0x0]['track'],'sharing':u,...r!==undefined?{'note':r}:{}});}return{'rows':i,'rowGroups':j,'allocatorRows':l,'externalMarks':m,'blockers':h};}export function checkAllocatorRails({rowGroups:a,resolvedGuards:b,shape:c,recoverTwinRails:d,declares:e}){const g=[],h=a['map'](j=>{if(j['key']===undefined)return undefined;const k=b['get'](j['key']);return{'key':j['key'],'track':j['rows'][0x0]['track'],'table':k?.['table']??[],'root':k?.['root'],'recoverTwin':d['has'](j['key']),'recipient':typeof j['rows'][0x0]?.['recipient']==='string'?j['rows'][0x0]['recipient']:undefined};})['filter'](j=>j!==undefined),i=[];if(h['length']>0x0){const j=verifyAllocatorRails(h,c['map'](m=>({'name':m['name'],'semanticRole':m['semantic_role'],'fromNodes':(m['from']??[])['map'](o=>typeof o==='string'?o:o['prev'])['filter'](o=>typeof o==='string'&&o!=='')})),{'declaredKeys':new Set(e['keys']())}),k=a['map'](m=>m['key'])['filter'](m=>m!==undefined&&!b['has'](m)),l=k['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'+k['join'](',\x20')+'.':'';for(const m of j){if(m['level']==='info'&&m['railKey']!==undefined&&e['has'](m['railKey'])){i['push']('merchant-declared\x20exemption:\x20rail\x20\x27'+m['railKey']+'\x27\x20ships\x20without\x20a\x20caller\x20identity\x20leg\x20—\x20'+e['get'](m['railKey']));continue;}m['level']==='critical'&&g['push']({'code':m['code'],'detail':m['detail']+l});}}return{'blockers':g,'disclosures':i};}export function emitServiceAllocators({template:a,inputs:b,allocatorRows:c}){const d=[],e=a['allocator']['description'];let f,g=![];e!==undefined&&([f,g]=capUtf8(e,MAX_DESCRIPTION_CONTENT_BYTES));const h=g?proseTruncatedAdvisory('service_allocators\x20description',Buffer['byteLength'](e,'utf8'),MAX_DESCRIPTION_CONTENT_BYTES,'DescriptionSchema\x20(MAX_DESCRIPTION_LENGTH\x204000,\x20ULEB128-prefixed)'):undefined;return d['push']({'op':'configure','id':'service_allocators','target':ref('service'),'method':'order_allocators',...h!==undefined?{'notes':h}:{},'params':P({'description':f,'threshold':Number(b['threshold']??b['monthly_rent_amount']??a['fee_params']['threshold']??a['fee_params']['monthly_rent_amount']??0x0)||0x0,'allocators':c}),'requires':['machine_publish']}),{'steps':d};}export function checkEmittedStepShapes({steps:a}){const b=[],c=e=>{if(e===null)return'null';if(typeof e==='string')return'\x22'+e['slice'](0x0,0x18)+'\x22'+(e['length']>0x18?'…':'');if(Array['isArray'](e))return'array';if(typeof e==='object')return'{'+Object['keys'](e)['join'](',\x20')+'}';return typeof e;},d=e=>{if(e===null||typeof e!=='object'||Array['isArray'](e))return'not\x20a\x20tagged\x20recipient\x20object\x20(found\x20'+c(e)+')\x20—\x20the\x20schema\x20union\x20accepts\x20only\x20'+'{GuardIdentifier:\x20u8}\x20|\x20{Entity:\x20mark|object}\x20|\x20{Signer:\x20\x22signer\x22}';const f=Object['keys'](e);if(f['length']!==0x1)return'expected\x20exactly\x20ONE\x20recipient\x20tag,\x20found\x20['+f['join'](',\x20')+']';const g=f[0x0],h=e[g];if(g==='Signer'){if(h!=='signer')return'{Signer:\x20'+JSON['stringify'](h)+'}\x20—\x20the\x20literal\x20is\x20lowercase\x20\x22signer\x22';}else{if(g==='GuardIdentifier'){if(typeof h!=='number'||!Number['isInteger'](h)||h<0x0)return'{GuardIdentifier:\x20'+c(h)+'}\x20—\x20the\x20slot\x20is\x20a\x20u8\x20table\x20index';}else{if(g==='Entity'){if(typeof h!=='string'&&(h===null||typeof h!=='object'))return'{Entity:\x20'+c(h)+'}\x20—\x20a\x20mark\x20string\x20or\x20a\x20{name_or_address}\x20object';}else return'\x27'+g+'\x27\x20is\x20not\x20a\x20RecipientSchema\x20tag\x20(GuardIdentifier\x20|\x20Entity\x20|\x20Signer)';}}return undefined;};for(const e of a){if(e['op']==='configure'&&e['method']==='order_allocators'){const f=e['params']['allocators'];if(!Array['isArray'](f))continue;f['forEach']((g,h)=>{const i=g?.['sharing'];if(!Array['isArray'](i))return;i['forEach']((j,k)=>{const l=j?.['who'],m=d(l);m!==undefined&&b['push']({'code':'EMITTED_STEP_SHAPE_INVALID','detail':'step\x20\x27'+e['id']+'\x27\x20allocator['+h+']\x20sharing['+k+'].who\x20is\x20'+c(l)+':\x20'+m+'.\x20'+'The\x20call\x20layer\x27s\x20RecipientSchema\x20rejects\x20the\x20step\x20at\x20EXECUTION\x20with\x20schema_mismatch\x20'+'(nnd4\x20F-06:\x20the\x20bare\x20string\x20\x22Signer\x22\x20killed\x20the\x20service_allocators\x20configure\x20at\x20'+'step\x2035/44\x20and\x20blocked\x20the\x20remaining\x209\x20steps)\x20—\x20fix\x20the\x20EMITTER,\x20not\x20the\x20plan:\x20'+'this\x20gate\x20exists\x20so\x20a\x20shape\x20drift\x20fails\x20the\x20compile,\x20never\x20the\x20deploy.'});});});}if(e['op']==='create'&&e['object']==='guard'){const g=e['params']['root'],h=g===null||typeof g!=='object'?[{'path':'/root','message':'expected\x20a\x20Guard\x20node\x20object,\x20found\x20'+c(g)}]:validateGuardTreeShape(g);for(const i of h){b['push']({'code':'EMITTED_STEP_SHAPE_INVALID','detail':'step\x20\x27'+e['id']+'\x27\x20(guard\x20create)\x20root\x20at\x20'+i['path']+'\x20is\x20not\x20a\x20structured\x20Guard\x20node\x20tree:\x20'+(i['message']+'.\x20A\x20prose/logic-string\x20root\x20passes\x20emission\x20silently\x20and\x20dies\x20at\x20the\x20Guard\x20')+'create\x20(the\x20SDK\x20evaluator\x20walks\x20nodes,\x20never\x20prose)\x20—\x20the\x20root\x20must\x20be\x20the\x20structured\x20'+'node\x20vocabulary\x20({type:\x20logic_*|context|query|identifier|…})\x20the\x20guard\x20templates\x20fill.'});}}}return{'blockers':b};}const OWNER_CLASS_QUERY_RE=/^(order\.(owner|agent)|permission\.(owner|admin)|service\.permission)\b/i;function signerReachableArmPresent(a){let b=![];const c=(e,f)=>{if(b||e===null||typeof e!=='object')return;if(Array['isArray'](e)){for(const h of e)c(h,f);return;}const g=e;if(typeof g['type']==='string'&&/keys_where$/i['test'](g['type']))b=!![];if(g['kind']==='addressEq')b=!![];if(b)return;if(g['type']==='context'&&g['context']==='Signer'&&!f)b=!![];if(b)return;if(typeof g['query']==='string'&&OWNER_CLASS_QUERY_RE['test'](g['query'])){for(const i of Object['values'](g))c(i,!![]);return;}if(g['type']==='logic_equal'){const j=Array['isArray'](g['nodes'])?g['nodes']:g['left']!==undefined||g['right']!==undefined?[g['left'],g['right']]:[];j['forEach']((k,l)=>{const m=j['find']((o,p)=>p!==l);c(k,f||d(m));});return;}for(const k of Object['values'](g))c(k,f);},d=e=>e!==null&&typeof e==='object'&&!Array['isArray'](e)&&typeof e['query']==='string'&&OWNER_CLASS_QUERY_RE['test'](e['query']);return c(a,![]),b;}export function checkFundRailReachability({steps:a,resolvedGuards:b}){const c=[],d=new Set();for(const e of a){if(e['op']!=='configure'||e['method']!=='order_allocators')continue;const f=e['params']['allocators'];if(!Array['isArray'](f))continue;f['forEach']((h,i)=>{const j=h,k=j?.['sharing'];if(!Array['isArray'](k))return;const l=k['some'](q=>{if(q===null||typeof q!=='object'||Array['isArray'](q))return![];const r=q['who'];return r!==null&&typeof r==='object'&&!Array['isArray'](r)&&'Signer'in r;});if(!l)return;const m=j?.['guard_key'];if(typeof m!=='string'||d['has'](m))return;d['add'](m);const n=b['get'](m);if(n===undefined||n['root']===null||typeof n['root']!=='object')return;if(signerReachableArmPresent(n['root']))return;const o=typeof j?.['track']==='string'?j['track']:'?',p=typeof j?.['recipient_key']==='string'?j['recipient_key']:'signer';c['push']({'code':'FUND_RAIL_UNREACHABLE','detail':'allocator\x20row\x20['+i+']\x20('+o+'/'+p+')\x20on\x20guard\x20\x27'+m+'\x27\x20pays\x20the\x20DYNAMIC\x20'+'Recipient::Signer\x20(the\x20allocation\x20tx\x20sender),\x20but\x20the\x20resolved\x20guard\x20root\x20carries\x20NO\x20'+'caller-satisfiable\x20identity-binding\x20arm:\x20every\x20caller-authorization\x20comparison\x20pins\x20'+'context(Signer)\x20to\x20a\x20FIXED\x20order/permission\x20owner-class\x20identity\x20'+'(order.owner\x20/\x20order.agent\x20/\x20permission.owner\x20/\x20permission.admin\x20/\x20service.permission)\x20—\x20'+'the\x20intended\x20third-party\x20payee\x20(whatever\x20runtime\x20identity\x20the\x20rail\x20is\x20FOR,\x20e.g.\x20the\x20'+'judge-recorded\x20winner)\x20is\x20STRUCTURALLY\x20unable\x20to\x20fire\x20this\x20rail.\x20nnd4\x20F-01\x20(99designs\x20'+'design-contest\x20mainnet\x20261103):\x20the\x20signer\x20prize\x20rail\x20reused\x20the\x20owner/admin\x20caller\x20'+'template,\x20the\x20winner\x20was\x20neither,\x20and\x2013.8\x20WOW\x20stranded\x20—\x20discovered\x20only\x20after\x20real\x20'+'funds\x20were\x20on\x20chain,\x20because\x20guards\x20and\x20order_allocators\x20FREEZE\x20at\x20publish\x20(IMMUT-001).\x20'+'Cure\x20—\x20add\x20ONE\x20of\x20the\x20missing\x20arm\x20types:\x20(a)\x20the\x20SIGNER-BINDING\x20placement\x20leg\x20'+'logic_equal[context(Signer),\x20<self-submitted\x20probe>]\x20paired\x20with\x20a\x20keys_where/addressEq\x20'+'row-value\x20binding\x20(tpl_allocator_prize_settle_once\x20ships\x20the\x20third\x20arm\x20verbatim),\x20or\x20'+'(b)\x20a\x20fixed\x20payee\x20—\x20share\x20to\x20{Entity:\x20<mark>}\x20instead\x20of\x20the\x20dynamic\x20Signer\x20when\x20the\x20'+'payee\x20is\x20a\x20build-known\x20identity.'});});}return{'blockers':c};}export function checkWindowTopology({template:a}){const b=[],c=a['guards']??[],d=[];for(const h of c){const i=h['params'];if(i===undefined)continue;for(const [j,k]of Object['entries'](i)){typeof k==='string'&&k['length']>0x0&&/_(days|ms)$/['test'](j)&&d['push']({'guardKey':h['key'],'windowName':k});}}if(d['length']===0x0)return{'warnings':b};const e=new Map(c['map'](l=>[l['key'],l]));for(const l of a['machine_shape']??[]){const m=Array['isArray'](l['from'])?l['from']:[];for(const n of m){if(n===null||typeof n!=='object')continue;const o=n;for(const q of d){if(!l['role']['includes'](q['windowName']))continue;if(o['guard_key']===q['guardKey'])continue;const r=o['guard_key']!==undefined?e['get'](o['guard_key']):undefined;if(r!==undefined){const s=r['params'];if(s!==undefined&&typeof s['closing_window_days']==='string')continue;if(r['purpose']['includes'](q['windowName']))continue;}b['push']('WINDOW_CLOSING_NOT_MOUNTED:\x20edge\x20\x27'+(o['forward']??'?')+'\x27\x20->\x20node\x20\x27'+l['name']+'\x27\x20'+('(guard\x20'+(o['guard_key']??'UNBOUND')+')\x20purpose\x20names\x20window\x20\x27'+q['windowName']+'\x27,\x20but\x20the\x20edge\x27s\x20')+'guard\x20ships\x20neither\x20the\x20closing\x20window\x20leg\x20(params\x20closing_window_days/window_anchor_node,\x20'+'guard-fill\x20andClosingWindowLeg)\x20nor\x20is\x20it\x20the\x20window\x20guard\x20itself\x20—\x20the\x20window\x20semantics\x20ride\x20'+'keeper\x20discipline\x20alone\x20(nnd4\x20F-02:\x20the\x20contest\x20appeal\x20edge\x20stayed\x20reachable\x2066s\x20past\x20expiry\x20'+'while\x20the\x20finalize\x20lock\x20waited\x20on\x20the\x20keeper).\x20Mount\x20the\x20closing\x20leg\x20on\x20guard\x20'+('\x27'+(o['guard_key']??'<key>')+'\x27\x20(declare\x20params\x20{closing_window_days:\x20\x27'+q['windowName']+'\x27,\x20')+'window_anchor_node:\x20<anchor\x20node>})\x20or\x20bind\x20the\x20window\x20guard\x20to\x20this\x20edge.');}}}return{'warnings':b};}export function emitSales({inputs:a}){const b=[],c=[];if(Array['isArray'](a['sales'])&&a['sales']['length']>0x0){for(const d of a['sales']){const e=d;if(e===null||typeof e!=='object')continue;const f=Object['keys'](e)['filter'](g=>!SERVICE_SALE_FIELDS['has'](g));f['length']>0x0&&c['push']({'code':'SALE_INPUT_UNKNOWN_FIELD','detail':'sales\x20SKU\x20\x27'+String(e['name']??'?')+'\x27\x20carries\x20field(s)\x20outside\x20the\x20executor\x27s\x20'+('ServiceSaleSchema\x20vocabulary:\x20'+f['map'](g=>'\x27'+g+'\x27')['join'](',\x20')+'.\x20Allowed:\x20name,\x20price,\x20')+'stock\x20(or\x20the\x20generator\x20alias\x20\x27quantity\x27),\x20suspension,\x20wip,\x20wip_hash.\x20Unknown\x20fields\x20pass\x20emission\x20'+'verbatim\x20and\x20abort\x20the\x20sales\x20configure\x20at\x20execution\x20with\x20schema_mismatch\x20—\x20fix\x20the\x20inputs.sales\x20'+'entries\x20(cour-mn-261102-z5t8\x20E2:\x20generation-time\x20refusal\x20instead\x20of\x20a\x20guaranteed\x20execution\x20failure).'});}for(const g of a['sales']){const h=numericAmount(g?.['price']);h===0x0&&c['push']({'code':'SALE_ZERO_PRICE','detail':'sales\x20SKU\x20\x27'+String(g?.['name']??'?')+'\x27\x20lists\x20price\x20\x220\x22\x20—\x20a\x20zero-priced\x20'+'LISTING\x20is\x20refused\x20(E_ZERO_TOTAL_ORDER=42:\x20a\x20zero-total\x20order\x20carries\x20an\x20empty\x20'+'escrow\x20and\x20nothing\x20to\x20settle).\x20The\x20sanctioned\x20free\x20tier:\x20price\x20the\x20SKU\x20at\x201\x20smallest\x20unit\x20'+'(the\x20minimum\x20buyable\x20price),\x20or\x20deliver\x20it\x20outside\x20the\x20sales\x20rails.'});}b['push']({'op':'configure','id':'service_sales','target':ref('service'),'method':'sales','params':{'op':'add','sales':a['sales']}});}return{'steps':b,'blockers':c};}export function emitReviewComponent({template:a,inputs:b,reviewMode:c,experienceClaimKey:d,shape:f,guardSpecs:g,resolvedGuards:h,specByKey:i}){const j=[],k=[],l=[],m=a['payment_model']==='subscription';if(c!=='none'){const o=f['some'](x=>/review/i['test'](x['name']));c==='review'&&!o&&l['push']({'code':'REVIEW_NODE_MISSING','detail':'review_mode\x20\x27'+c+'\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 p=g['find'](x=>x['host']==='reward'),q=x=>{const y=new Set(),z=x!==undefined?h['get'](x):undefined;if(z===undefined)return y;const A=new Map();for(const C of z['table']){typeof C['identifier']==='number'&&typeof C['value']==='string'&&A['set'](C['identifier'],C['value']);}const B=D=>{if(Array['isArray'](D)){for(const F of D)B(F);return;}if(D===null||typeof D!=='object')return;const E=D;if(Array['isArray'](E['nodes'])){const [G,H]=E['nodes'];if(G?.['query']==='progress.current'&&typeof H?.['identifier']==='number'){const I=A['get'](H['identifier']);if(I!==undefined)y['add'](I);}B(E['nodes']);}};return B(z['root']),y;},s=f['find'](x=>/review/i['test'](x['name']))?.['name'];let t,u,v=[];if(s!==undefined){const x=[];for(const G of f){for(const H of G['from']??[]){const I=typeof H==='string'?{'prev':H,'guard_key':undefined}:H;x['push']({'prev':I['prev'],'guard_key':I['guard_key'],'target':G['name']});}}const y=x['filter'](J=>J['target']===s&&J['prev']!=='');v=[...new Set(y['map'](J=>J['prev']))];const z=[...new Set(y['flatMap'](J=>J['guard_key']!==undefined?[J['guard_key']]:[]))],A=z['length']===0x1?z[0x0]:z['length']===0x0?x['find'](J=>J['prev']===s&&J['guard_key']!==undefined)?.['guard_key']:undefined,B=q(A),C=B['size']===0x0||B['size']===0x1&&v['length']===0x1&&v[0x0]===[...B][0x0],D=C?A:undefined,E=D!==undefined?i['get'](D):undefined,F=E?.['template_id']==='tpl_review_submit_content_gate';t=F?undefined:E?.['step_id'],u=F?undefined:D;}if(t===undefined){const J=[...new Set([...f['filter'](R=>/review/i['test'](R['name'])||R['semantic_role']==='final')['map'](R=>R['name']),...v])],K={'type':'logic_or','nodes':[{'type':'logic_equal','nodes':[{'type':'query','query':'order.owner','object':{'identifier':0x0},'parameters':[]},{'type':'context','context':'Signer'}]},{'type':'query','query':'order.agent\x20has','object':{'identifier':0x0},'parameters':[{'type':'context','context':'Signer'}]}]},L={'type':'logic_equal','nodes':[{'type':'query','query':'order.service','object':{'identifier':0x0},'parameters':[]},{'type':'identifier','identifier':0x1}]},M=J['map']((R,S)=>({'type':'logic_equal','nodes':[{'type':'query','query':'progress.current','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'parameters':[]},{'type':'identifier','identifier':0x2+S}]})),N=M['length']===0x1?M[0x0]:M['length']>0x1?{'type':'logic_or','nodes':M}:undefined,O=f['find'](R=>R['semantic_role']==='delivered'&&!/review/i['test'](R['name']))?.['name'],Q=O===undefined?undefined:{'type':'logic_as_u256_greater_or_equal','nodes':[{'type':'query_progress_history_find','object':{'identifier':0x0,'convert_witness':'OrderProgress'},'where':{'nextNode':O},'find':'last'},{'type':'identifier','identifier':0x2+J['length']}]};j['push']({'op':'create','id':'guard_review_write','object':'guard','params':P({'description':'Review\x20write\x20credential\x20(AR-3,\x20kernel-emitted):\x20the\x20signer\x20owns\x20or\x20administers\x20an\x20order\x20of\x20THIS\x20service'+(N!==undefined?',\x20anchored\x20on\x20the\x20order\x20having\x20reached\x20'+J['join']('\x20/\x20'):'')+(Q!==undefined?',\x20and\x20the\x20order\x20must\x20have\x20ENTERED\x20the\x20\x27'+O+'\x27\x20node\x20at\x20least\x20once\x20(history\x20probe\x20—\x20a\x20never-delivered\x20order\x20cannot\x20write\x20the\x20rating\x20row,\x20ksk4\x20F-04).\x20':'.\x20')+'Gates\x20the\x20\x27review\x27\x20and\x20\x27rating\x27\x20policies\x20of\x20the\x20plan-created\x20review\x20repository\x20—\x20reads\x20nothing\x20from\x20that\x20repository,\x20so\x20the\x20write\x20path\x20is\x20satisfiable\x20by\x20construction\x20(no\x20credential\x20cycle).','table':[{'identifier':0x0,'b_submission':!![],'value_type':'Address','name':'order_being_reviewed'},{'identifier':0x1,'b_submission':![],'value_type':'Address','value':ref('service'),'name':'this_service'},...J['map']((R,S)=>({'identifier':0x2+S,'b_submission':![],'value_type':'String','value':R})),...Q!==undefined?[{'identifier':0x2+J['length'],'b_submission':![],'value_type':'U64','value':'0'}]:[]],'root':{'type':'logic_and','nodes':[...N!==undefined?[N]:[],...Q!==undefined?[Q]:[],K,L]}}),'notes':'AR-3\x20review\x20write\x20credential\x20(service\x20pinned\x20by\x20plan\x20ref\x20—\x20survives\x20permission\x20rotation).\x20The\x20buyer\x20writes\x20both\x20rows\x20at\x20review\x20time:\x20repository.data_add\x20{name:\x27review\x27|\x27rating\x27,\x20items:[{write_guard:\x27<this\x20guard>\x27,\x20data:[{id:<order\x20address>,\x20data:<stars/text>}]}]}\x20with\x20a\x20passport\x20submission\x20carrying\x20the\x20order.\x20Ordering\x20(F-05):\x20repository_review\x27s\x20create\x20is\x20EARLY\x20(pre-wave,\x20unguarded);\x20THIS\x20credential\x20exists\x20before\x20the\x20repository_review_write_guards\x20configure\x20step\x20that\x20freezes\x20the\x20credential\x20ref\x20(HOST-GRAPH-01).'}),t='guard_review_write',u='review_write';}const w=b['review_decision_enabled']===!![]&&c==='review_reward'&&p?.['step_id']!==undefined&&t!==undefined;w&&j['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(t!==undefined){const R=[{'guard':ref(t)}];j['push']({'op':'configure','id':'repository_review_write_guards','target':ref('repository_review'),'method':'policies','params':P({'op':'add','policy':[{'name':'review','description':m?'Re-writable\x20rating\x20+\x20comment\x20row\x20per\x20ORDER,\x20re-written\x20at\x20each\x20renewal\x20period\x20(renewal\x20exception,\x20W5-13:\x20write_once\x20on\x20a\x20renewal-subscription\x20review\x20policy\x20bricks\x20period-2+\x20reviews\x20—\x20O-F13;\x20the\x20order\x20address\x20row\x20key\x20never\x20changes\x20across\x20renewals).\x20Writes\x20require\x20the\x20review\x20credential\x20(guard\x20key\x20\x27'+u+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.':'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'+u+'\x27).\x20Payload:\x20JSON\x20text\x20{rating,\x20tags?,\x20orderRef?}.','write_guard':R,'id_from':'none','value_type':'String','write_once':!m},{'name':'rating','description':m?'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),\x20re-written\x20at\x20each\x20renewal\x20period\x20(renewal\x20exception,\x20W5-13\x20—\x20O-F13:\x20write_once\x20would\x20brick\x20period-2+\x20ratings).\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.':'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':R,'id_from':'none','value_type':'U64','write_once':!m},...w?[{'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'}]:[]]}),'requires':['repository_review',t,...w?['guard_review_decision']:[]],'notes':'F-BS5-03\x20(bst5-mn-261101):\x20the\x20credential-bound\x20and\x20ONLY\x20forms\x20of\x20the\x20review\x20repository\x27s\x20\x27review\x27/\x27rating\x27\x20policies\x20—\x20the\x20early\x20create\x20(pre-wave)\x20cannot\x20carry\x20them\x20(an\x20id_from=none\x20policy\x20without\x20a\x20write_guard\x20aborts\x20the\x20create\x20on-chain:\x20the\x20chain\x20requires\x20a\x20non-empty\x20write_guard\x20on\x20the\x20create\x20path\x20too),\x20so\x20they\x20land\x20here\x20now\x20that\x20the\x20credential\x20guards\x20exist.\x20The\x20buyer\x20writes\x20BOTH\x20rows\x20at\x20review\x20time\x20(repository.data_add\x20{name:\x27rating\x27,\x20items:[{data:[{id:<order\x20address>,\x20data:<stars>}]}]}\x20with\x20the\x20same\x20passport\x20as\x20the\x20forward);\x20a\x20good-review\x20bounty\x20claim\x20guard\x20must\x20query\x20the\x20order-keyed\x20U64\x20\x27rating\x27\x20row,\x20never\x20the\x20text\x20row.'+(w?'\x20[review_decision\x27s\x20write\x20credential\x20frozen\x20AFTER\x20guard_review_decision\x20—\x20HOST-GRAPH-01\x20discipline.]':'')}),j['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(c==='review_reward'){const S=p;if(S===undefined||S['step_id']===undefined)l['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 T=b['reward_funding'],U=S['params']?.['reward_claim_amount'];let V=U!==undefined&&U!==null?U:b['reward_claim_amount'],W='';if(V===undefined){const a2=b['review_reward_per_claim'];a2!==undefined&&a2!==null&&Number(a2)>0x0&&(V=a2,W='input\x20review_reward_per_claim');}if(V===undefined){const a3=a['fee_params']?.['review_reward_per_claim'];typeof a3==='number'&&a3>0x0&&(V=a3,W='template\x20fee_param\x20review_reward_per_claim\x20(override\x20with\x20the\x20reward_claim_amount\x20input)');}if(V===undefined){const a4=lowestSalePrice(b['sales']);a4!==undefined&&(V=String(Math['max'](Math['floor'](a4*0.02),0x1)),W='derived:\x202%\x20of\x20the\x20cheapest\x20SKU\x20('+a4+'\x20smallest\x20units),\x20floored\x20at\x201\x20(T-02)');}let X='';if(V!==undefined){const a5=numericAmount(String(V)),a6=lowestSalePrice(b['sales']);if(a5!==undefined&&a6!==undefined&&a6>0x0&&a5>0.5*a6){const a7=numericAmount(String(b['reward_funding']??'')),a8=a7!==undefined&&a5>0x0?'\x20the\x20reward_funding\x20pool\x20covers\x20~'+Math['floor'](a7/a5)+'\x20claim(s)':'';X='\x20⚠\x20T-02\x20SCALE:\x20the\x20per-claim\x20bounty\x20('+a5+')\x20exceeds\x20half\x20the\x20cheapest\x20SKU\x20price\x20('+a6+')\x20—\x20'+('each\x20claimed\x20order\x20pays\x20out\x20more\x20than\x20the\x20sale\x20earns;\x20a\x20low-price\x20SKU\x20makes\x20the\x20rail\x20a\x20bounty-farm\x20target.'+a8);}}if(V!==undefined&&!W['startsWith']('derived:')){const a9=0x5b8d80,aa=numericAmount(String(V));aa!==undefined&&aa<a9&&l['push']({'code':'REWARD_BELOW_CLAIM_GAS','detail':'The\x20per-claim\x20bounty\x20('+V+'\x20smallest\x20units)\x20is\x20below\x20the\x20claim\x20GAS\x20FLOOR\x20'+('('+a9+'\x20smallest\x20units\x20=\x200.006\x20WOW):\x20a\x20claim\x20transaction\x20costs\x20≈0.0026\x20WOW\x20on\x20mainnet\x20')+'(cour\x20BOUNTY-BELOW-GAS,\x20etsm\x20measured),\x20so\x20claiming\x20at\x20this\x20bounty\x20LOSES\x20money\x20and\x20no\x20rational\x20user\x20ever\x20'+'claims\x20—\x20the\x20funded\x20pool\x20is\x20a\x20dead\x20incentive\x20(and\x20whatever\x20the\x20pool\x20holds\x20is\x20stranded\x20until\x20the\x20guard\x20is\x20'+('reworked).\x20Source:\x20'+(W||'spec.params\x20reward_claim_amount')+'.\x20Fix:\x20pin\x20')+'reward_claim_amount\x20/\x20review_reward_per_claim\x20>=\x200.006\x20WOW\x20(6_000_000\x20smallest\x20units)\x20per\x20claim,\x20or\x20drop\x20the\x20'+'review_reward\x20track\x20(review_mode\x20without\x20a\x20payable\x20bounty\x20is\x20the\x20honest\x20shape).'});}if(V!==undefined&&!W['startsWith']('derived:')){const ab=numericAmount(String(V)),ac=lowestSalePrice(b['sales']);ab!==undefined&&ac!==undefined&&ac>0x0&&ab>BOUNTY_TO_MIN_SKU_ADVISORY_RATIO*ac&&(S['purpose']=S['purpose']+'\x20REWARD_BOUNTY_OVER_GOODS_VALUE\x20(P-021,\x20ADVISORY\x20—\x20not\x20a\x20blocker):\x20the\x20explicitly\x20'+('chosen\x20per-claim\x20bounty\x20('+ab+'\x20smallest\x20units)\x20is\x20'+(ab/ac)['toFixed'](0x1)+'x\x20the\x20')+('cheapest\x20positive\x20SKU\x20price\x20('+ac+'\x20smallest\x20units).\x20Anti-farm\x20review:\x20a\x20bounty\x20far\x20above\x20the\x20')+'goods\x20value\x20is\x20usually\x20a\x20misconfiguration\x20or\x20a\x20deliberate\x20farm\x20target\x20—\x20confirm\x20the\x20ratio\x20is\x20'+('intended\x20before\x20funding\x20the\x20pool.\x20Source:\x20'+(W||'spec.params\x20reward_claim_amount')+'.'));}const Y=h['get'](S['key']);Y!==undefined&&!rootHasRewardRecordGate(Y['root'])&&l['push']({'code':'REVIEW_REWARD_UNARMED','detail':'review_reward\x20claim\x20guard\x20\x27'+S['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 Z;if(Y!==undefined&&rootHasRewardRecordGate(Y['root']))for(const ad of Y['table']){const ae=ad;if(ae['b_submission']===!![]&&String(ae['value_type']??'')['toLowerCase']()==='address'&&(String(ae['object_type']??'')==='Order'||/order/i['test'](String(ae['name']??'')))){Z=ae['identifier'];break;}}const a0=S['params']?.['evidence']??b['review_claim_evidence'];let a1;if(a0!==undefined&&a0!==null&&typeof a0==='object'){const af=a0,ag=toByteVector(af['key']),ah=toByteVector(af['predicate']);ag!==undefined&&ah!==undefined&&(Z===undefined?l['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—\x20the\x20claim-time\x20'+'evidence\x20binding\x20aborts\x20with\x20E_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.'}):a1={'repo':ref('repository_review'),'key':ag,'predicate':ah});}V===undefined&&l['push']({'code':'REVIEW_REWARD_AMOUNT_MISSING','detail':'review_mode\x20\x27review_reward\x27\x20resolved\x20a\x20claim\x20guard\x20but\x20no\x20per-claim\x20bounty\x20was\x20provided\x20or\x20derivable.\x20'+'The\x20reward\x20guard_add\x20mount\x20REQUIRES\x20an\x20amount\x20(schema-required)\x20—\x20a\x20plan\x20step\x20emitted\x20without\x20'+'it\x20fails\x20mid-execution.\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),\x20set\x20it\x20in\x20the\x20guard\x20'+'spec\x27s\x20params,\x20or\x20include\x20a\x20parseable\x20sales\x20catalog\x20(inputs.sales\x20with\x20numeric\x20prices)\x20so\x20the\x20'+'T-02\x20default\x20applies\x20(2%\x20of\x20the\x20cheapest\x20SKU,\x20floored\x20at\x201\x20smallest\x20unit).'}),j['push']({'op':'configure','id':'reward_review_guard_add','target':ref('reward_review'),'method':'guard_add','params':P({'guard':ref(S['step_id']),'recipient':{'Signer':'signer'},...V!==undefined?{'amount':{'type':'Fixed','value':String(V)}}:{},...Z!==undefined?{'store_from_id':Z}:{},...a1!==undefined?{'evidence':a1}:{}}),'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.'+(V!==undefined?'\x20AMOUNT\x20(BK15-F09):\x20per-claim\x20bounty\x20pinned\x20at\x20plan\x20time\x20('+String(V)+')'+(W?'\x20—\x20'+W+';\x20override\x20with\x20the\x20reward_claim_amount\x20input':'')+'\x20—\x20no\x20execution-time\x20fill\x20needed.'+X:'')+(Z!==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).':'')+(a1!==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.'+'\x20PACKAGE\x20AVAILABILITY\x20(ksr-tn-261026\x20Q8-F04):\x20the\x20native\x20evidence-pinning\x20entry\x20is\x20'+'UNAVAILABLE\x20on\x20the\x20currently\x20deployed\x20package\x20—\x20batch\x20guard_add\x20submissions\x20silently\x20'+'DROP\x20the\x20pin\x20and\x20the\x20direct\x20face\x20hard-fails\x20with\x20a\x20missing-entry\x20error\x20(classified\x20'+'capability_unavailable,\x20non-retryable).\x20The\x20reward\x20guard_add\x20read-back\x20contract\x20'+'reports\x20EVIDENCE\x20BINDING\x20VERIFIED\x20/\x20NOT\x20ON\x20CHAIN\x20after\x20the\x20landed\x20call\x20—\x20treat\x20NOT\x20ON\x20'+'CHAIN\x20as\x20the\x20truth:\x20fall\x20back\x20to\x20the\x20repository-floor\x20guard\x20leg\x20and\x20disclose\x20that\x20it\x20'+'proves\x20only\x20\x27a\x20qualifying\x20row\x20exists\x20for\x20this\x20order\x27,\x20not\x20who\x20wrote\x20it.\x20Do\x20not\x20'+'re-send\x20guard_add\x20to\x20\x27fix\x27\x20a\x20dropped\x20pin.':'')}),j['push']({'op':'configure','id':'service_rewards','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_review')]}),'requires':['service']}),typeof T==='string'||typeof T==='number'?k['push']({'op':'configure','id':'reward_review_coin_add','target':ref('reward_review'),'method':'coin_add','params':{'balance':typeof T==='number'?T:String(T)},'requires':['reward_review']}):l['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(d!==undefined){const ai=g['find'](aj=>aj['key']===d);if(ai===undefined||ai['step_id']===undefined)l['push']({'code':'EXPERIENCE_COMPENSATION_GUARD_MISSING','detail':'experience_compensation_mode\x20\x27reward\x27\x20armed\x20the\x20goodwill\x20track,\x20but\x20the\x20injected\x20claim\x20guard\x20'+('\x27'+d+'\x27\x20never\x20resolved\x20to\x20a\x20guard\x20step\x20(no\x20delivery-class\x20node\x20and\x20no\x20final\x20')+'terminal\x20in\x20machine_shape\x20to\x20anchor\x20the\x20claim\x20on).\x20Mount\x20a\x20claim-able\x20shape,\x20or\x20set\x20'+'inputs.experience_compensation_mode=\x22none\x22.'});else{const aj=h['get'](ai['key']);aj!==undefined&&!rootHasRewardRecordGate(aj['root'])&&l['push']({'code':'EXPERIENCE_COMPENSATION_UNARMED','detail':'experience-compensation\x20claim\x20guard\x20\x27'+ai['key']+'\x27\x20carries\x20no\x20record-gate:\x20Reward.claim\x20has\x20no\x20'+'order\x20binding\x20of\x20its\x20own\x20(OFN-C1),\x20so\x20a\x20funded\x20pool\x20behind\x20this\x20guard\x20is\x20a\x20replay-drain\x20target.\x20'+'SV2_UNARMED_PRESCRIPTION\x20applies\x20—\x20keep\x20the\x20template\x27s\x20record-gate\x20leg\x20(per-order\x20once)\x20'+('wrapped\x20in\x20logic_and\x20with\x20the\x20identity\x20leg,\x20or\x20resolve\x20\x27'+ai['key']+'\x27\x20to\x20a\x20named\x20design\x20')+'that\x20carries\x20one.\x20Until\x20armed,\x20do\x20not\x20fund\x20the\x20pool.'});const ak=b['experience_claim_amount'],al=a['fee_params']['experience_claim_amount'],am=typeof ak==='string'&&ak['trim']()!==''||typeof ak==='number'?ak:typeof al==='string'||typeof al==='number'?al:undefined,an=am===undefined?NaN:Number(String(am)['replace'](/^[^0-9]*/,''));if(am===undefined||!(an>0x0))l['push']({'code':'EXPERIENCE_COMPENSATION_AMOUNT_MISSING','detail':'experience_compensation_mode\x20\x27reward\x27\x20resolved\x20a\x20claim\x20guard\x20but\x20no\x20per-claim\x20goodwill\x20tier\x20was\x20provided.\x20'+'The\x20reward\x20guard_add\x20mount\x20REQUIRES\x20an\x20amount\x20(schema-required)\x20—\x20a\x20plan\x20step\x20emitted\x20without\x20it\x20'+'fails\x20mid-execution.\x20Pass\x20\x27experience_claim_amount\x27\x20(a\x20display\x20string\x20with\x20the\x20token\x20symbol\x20like\x20'+'\x270.2WOW\x27,\x20or\x20a\x20smallest-unit\x20integer\x20like\x20\x27200000000\x27)\x20or\x20declare\x20fee_param\x20'+'experience_claim_amount\x20on\x20the\x20template.'});else an<0x5b8d80&&l['push']({'code':'EXPERIENCE_COMPENSATION_BELOW_CLAIM_GAS','detail':'experience-compensation\x20tier\x20'+an+'\x20is\x20below\x20the\x20claim-gas\x20floor\x20'+0x5b8d80+':\x20'+'a\x20buyer\x20who\x20claims\x20would\x20pay\x20more\x20gas\x20than\x20the\x20goodwill\x20pays\x20out\x20—\x20the\x20rail\x20is\x20dead\x20on\x20arrival\x20'+'(same\x20arithmetic\x20as\x20REWARD_BELOW_CLAIM_GAS).\x20Raise\x20fee_param\x20experience_claim_amount.'});let ao;if(aj!==undefined&&rootHasRewardRecordGate(aj['root']))for(const aq of aj['table']){const ar=aq;if(ar['b_submission']===!![]&&String(ar['value_type']??'')['toLowerCase']()==='address'&&(String(ar['object_type']??'')==='Order'||/order/i['test'](String(ar['name']??'')))){ao=ar['identifier'];break;}}j['push']({'op':'configure','id':'reward_experience_guard_add','target':ref('reward_experience'),'method':'guard_add','params':P({'guard':ref(ai['step_id']),'recipient':{'Signer':'signer'},...am!==undefined&&an>0x0?{'amount':{'type':'Fixed','value':String(am)}}:{},...ao!==undefined?{'store_from_id':ao}:{}}),'requires':['reward_experience'],'notes':'EXPERIENCE-COMPENSATION\x20(K3\x20C-11):\x20the\x20goodwill\x20claim\x20mount.\x20recipient\x20pinned\x20to\x20{Signer:\x27signer\x27}\x20—\x20'+'the\x20payout\x20lands\x20on\x20the\x20CLAIMER\x27s\x20own\x20account\x20(E_CLAIM_RECIPIENT_NOT_SIGNER\x20otherwise),\x20per-order\x20once\x20'+('(template\x20record-gate'+(ao!==undefined?',\x20store_from_id\x20'+ao+'\x20=\x20the\x20submitted\x20Order\x20stamp':'')+').')+(am!==undefined&&an>0x0?'\x20AMOUNT:\x20Fixed\x20tier\x20pinned\x20at\x20plan\x20time\x20('+String(am)+')\x20—\x20knowable\x20up\x20front,\x20no\x20execution-time\x20fill.':'')+'\x20The\x20pool\x20is\x20NOT\x20escrow:\x20a\x20claim\x20blocks\x20nothing\x20in\x20the\x20order\x27s\x20own\x20settlement,\x20and\x20nothing\x20is\x20ever\x20'+'deducted\x20from\x20the\x20merchant\x20(the\x20chain\x20has\x20no\x20debit/clawback\x20primitive).'}),j['push']({'op':'configure','id':'service_rewards_experience','target':ref('service'),'method':'rewards','params':P({'op':'add','objects':[ref('reward_experience')]}),'requires':['service']});const ap=b['experience_pool_funding'];typeof ap==='string'||typeof ap==='number'?k['push']({'op':'configure','id':'reward_experience_coin_add','target':ref('reward_experience'),'method':'coin_add','params':{'balance':typeof ap==='number'?ap:String(ap)},'requires':['reward_experience']}):l['push']({'code':'EXPERIENCE_COMPENSATION_UNFUNDED','detail':'experience_compensation_mode\x20\x27reward\x27\x20without\x20an\x20\x27experience_pool_funding\x27\x20input\x20(INV-4\x20family,\x20'+'fail-closed):\x20an\x20unfunded\x20goodwill\x20promise\x20must\x20not\x20publish.\x20Plan\x20the\x20pool\x20as\x20~expected\x20'+'experience\x20failures\x20x\x20the\x20per-claim\x20tier\x20(fee_param\x20experience_claim_amount),\x20pass\x20'+'experience_pool_funding\x20(smallest-unit\x20string)\x20to\x20fund\x20the\x20Reward\x20object,\x20or\x20set\x20'+'inputs.experience_compensation_mode=\x22none\x22\x20to\x20drop\x20the\x20track.'});}}return{'steps':j,'fundingSteps':k,'blockers':l};}export function emitArbitrationBindings({template:a,inputs:b,needsArbitration:c,shape:d,guardSpecs:e,specByKey:f}){const g=[],h=[],i=[],j=e['some'](l=>l['template_id']==='tpl_forward_arb_ruling_won'),k=[];j&&(k['push']('ARB\x20AWARD\x20SEQUENCING\x20(N1,\x20K4R-261103):\x20this\x20build\x20mounts\x20an\x20arb-ruling-won\x20edge\x20whose\x20claimed_by\x20leg\x20is\x20a\x20SEQUENCING\x20SEAL,\x20not\x20a\x20funding\x20gate\x20—\x20the\x20ruling\x20edge\x20advances\x20only\x20after\x20the\x20award\x20is\x20claimed\x20or\x20the\x20case\x20is\x20concluded.\x20The\x20award\x20CLAIM\x20requires\x20the\x20service\x20compensation\x20pool\x20to\x20cover\x20the\x20indemnity\x20(an\x20empty\x20pool\x20aborts\x20the\x20claim\x20with\x20code\x2027,\x20E_COMPENSATION_NOT_MATCH);\x20a\x20keeper\x20CONCLUDE\x20stamps\x20claimed_by\x20WITHOUT\x20any\x20fund\x20(BF-14)\x20and\x20is\x20the\x20zero-fund\x20escape\x20—\x20orchestrate\x20it\x20in\x20the\x20keeper\x20runbook\x20either\x20way.'),k['push']('ARB\x20DUAL-TRACK\x20NETTING\x20(decision\x2011,\x20disclosed\x20at\x20publish):\x20the\x20arbitration\x20award\x20pays\x20from\x20the\x20service\x20compensation\x20fund\x20as\x20an\x20INDEPENDENT\x20commercial\x20track\x20—\x20it\x20never\x20moves\x20the\x20order\x20escrow.\x20A\x20buyer\x20may\x20collect\x20BOTH\x20the\x20award\x20and\x20an\x20escrow\x20refund\x20on\x20the\x20same\x20order;\x20the\x20dual-payout\x20confirmation\x20gate\x20(and\x20the\x20store\x27s\x20standing\x20netting\x20policy)\x20governs\x20that\x20combination,\x20not\x20the\x20chain.'));if(c){g['push']({'op':'configure','id':'service_arbitrations','target':ref('service'),'method':'arbitrations','params':P({'op':'add','objects':[ref('arbitration')]})});const l=e['find'](o=>o['template_id']==='tpl_voting_guard_open_vote'&&o['step_id']!==undefined);l?.['step_id']!==undefined&&g['push']({'op':'configure','id':'arbitration_voting_guard','target':ref('arbitration'),'method':'voting_guard','params':P({'op':'set','guards':[{'guard':ref(l['step_id']),'vote_weight':{'FixedValue':0x1}}]}),...a['arbitration_mode']==='third_party'?{'account':'arb_controller'}:{}});const m=d['some'](o=>{if(o['semantic_role']!=='final')return![];for(const p of o['from']??[]){if(typeof p==='string')continue;const q=p['guard_key']===undefined?undefined:f['get'](p['guard_key']);if(q?.['template_id']==='tpl_forward_arb_ruling_won')return!![];}return![];}),n=b['compensation_fund'];if(typeof n==='string'||typeof n==='number'){const o=numericAmount(n);(m||j)&&o!==undefined&&o<=0x0?i['push']({'code':'ARB_REFUND_WITHOUT_FUND','detail':'This\x20build\x20declares\x20inputs.compensation_fund\x20=\x20'+JSON['stringify'](n)+'\x20on\x20an\x20arb-ruling-won\x20mount\x20'+'(the\x20claimed_by\x20sequencing\x20seal\x20makes\x20the\x20award\x20CLAIM\x20the\x20enforcement\x20step).\x20On\x20a\x20POST-settlement\x20'+'re-route\x20the\x20escrow\x20is\x20already\x20drained\x20when\x20the\x20ruling\x20lands,\x20so\x20the\x20fund\x20is\x20the\x20buyer\x27s\x20only\x20remedy\x20—\x20'+'and\x20a\x20zero/negative\x20fund\x20promise\x20is\x20an\x20UNFUNDED\x20remedy\x20(etsm-mn-261102-z5r8\x20F-02:\x20the\x20funding\x20step\x20would\x20'+'ship\x20balance\x20\x220\x22\x20and\x20the\x20COMPENSATION_FUND_REQUIRED\x20gate\x20would\x20never\x20see\x20it).\x20Pass\x20a\x20non-zero\x20'+'inputs.compensation_fund\x20(>=\x20the\x20largest\x20single-order\x20exposure),\x20or\x20rebuild\x20on\x20a\x20template\x20without\x20the\x20arb\x20re-route.'}):h['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':String(n)}});}else{if(j&&!m){const p=b['sales']??a['sales']??[],q=p['map'](t=>numericAmount(t['price']))['filter'](s=>s!==undefined&&s>0x0),r=q['length']>0x0?Math['max'](...q):undefined;if(r!==undefined){const s=BigInt(Math['round'](r))*0x3n;h['push']({'op':'configure','id':'service_compensation','target':ref('service'),'method':'compensation_fund_add','params':{'balance':s['toString']()},'notes':'N1\x20AUTO-SIZED\x20arbitration\x20pool:\x203x\x20the\x20largest\x20SKU\x20price\x20('+s['toString']()+'\x20=\x203\x20x\x20'+Math['round'](r)+')\x20—\x20the\x20award\x20ceiling\x20(MAX_INDEMNITY_MULTIPLE)\x20sizing.\x20Override\x20with\x20inputs.compensation_fund\x20before\x20materialize;\x20fund\x20at\x20the\x20post-deploy\x20top-up\x20step.'}),k['push']('ARB\x20POOL\x20AUTO-SIZED\x20(N1,\x20K4R-261103):\x20this\x20build\x27s\x20compensation\x20pool\x20is\x20auto-funded\x20at\x203x\x20the\x20largest\x20SKU\x20price\x20because\x20it\x20mounts\x20an\x20arb-ruling-won\x20edge\x20whose\x20claimed_by\x20seal\x20requires\x20an\x20enforceable\x20award.\x20Size\x20it\x20deliberately\x20—\x20pass\x20inputs.compensation_fund\x20(>=\x20the\x20largest\x20single-order\x20exposure)\x20if\x20your\x20dispute\x20volume\x20or\x20price\x20basis\x20differs.');}else k['push']('ARB\x20POOL\x20LEG\x20OMITTED\x20(N1,\x20K4R-261103):\x20this\x20build\x20mounts\x20an\x20arb-ruling-won\x20edge\x20whose\x20claimed_by\x20seal\x20requires\x20an\x20enforceable\x20award,\x20but\x20no\x20sellable\x20price\x20basis\x20exists\x20to\x20auto-size\x20the\x20compensation\x20pool\x20from.\x20Fund\x20the\x20pool\x20at\x20the\x20post-deploy\x20top-up\x20step\x20(>=\x20the\x20largest\x20single-order\x20exposure)\x20BEFORE\x20any\x20dispute\x20lands\x20—\x20an\x20empty\x20pool\x20aborts\x20the\x20award\x20claim\x20with\x20code\x2027.');}else m&&i['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.'});}}return{'steps':g,'fundingSteps':h,'blockers':i,'disclosures':k};}export function emitServicePublish(){const a=[];return a['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'}]}),{'steps':a};}export function computeMoneyRailKeys({rowsWithAttachments:a,guardSpecs:b}){const c=new Set(a['map'](f=>f['guard_key'])['filter'](f=>typeof f==='string')),d=new Set(b['filter'](f=>f['host']==='reward'&&f['step_id']!==undefined)['map'](f=>f['key'])),e=new Set([...c,...d]);return{'allocatorBoundKeys':c,'moneyRailKeys':e};}export function checkForeignServicePins({resolvedGuards:a,edgeBoundKeys:b,moneyRailKeys:c}){const d=[],e=/^0x[0-9a-fA-F]{20,64}$/,f=h=>{const i=a['get'](h);if(i===undefined)return[];const j=new Set(),k=m=>{if(Array['isArray'](m)){for(const o of m)k(o);return;}if(m===null||typeof m!=='object')return;const n=m;if(n['type']==='logic_equal'){const p=Array['isArray'](n['nodes'])?n['nodes']:n['left']!==undefined||n['right']!==undefined?[n['left'],n['right']]:[],s=p['find'](u=>u!==null&&typeof u==='object'&&typeof u['query']==='string'&&u['query']['startsWith']('order.service')),t=p['find'](u=>u!==s);s!==undefined&&t!==undefined&&t!==null&&typeof t==='object'&&t['type']==='identifier'&&j['add'](String(t['identifier']));}for(const u of Object['values'](n))k(u);};k(i['root']);const l=[];for(const m of i['table']){const n=m;if(n['b_submission']===!![]||n['value_type']!=='Address')continue;const o=n['value'];if(typeof o!=='string'||!e['test'](o))continue;if(!j['has'](String(n['identifier']??'?')))continue;l['push'](String(n['identifier']??'?'));}return l;};for(const g of a['keys']()){if(!b['has'](g)&&!c['has'](g))continue;for(const h of f(g)){d['push']({'code':'GUARD_FOREIGN_SERVICE','detail':'guard\x20\x27'+g+'\x27\x20pins\x20the\x20Service\x20by\x20on-chain\x20address\x20literal\x20(table\x20slot\x20'+h+'\x20on\x20an\x20'+'order.service\x20comparison\x20leg)\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.\x20'+'(A\x200x\x20literal\x20in\x20a\x20NON-service\x20slot\x20—\x20e.g.\x20a\x20judge\x20account\x20pin,\x20R-C4-04\x20—\x20is\x20a\x20legal\x20business\x20pin\x20and\x20not\x20flagged.)'});}}return{'blockers':d};}export function auditRepoIntegrityAndCallerLegs({steps:a,resolvedGuards:b,moneyRailKeys:c,recoverTwinRails:d}){const e=[],f=new Map(),h=new Map(),i=(v,w)=>{for(const x of w){const y=typeof x['name']==='string'?x['name']:undefined;if(y!==undefined)v['keys']['add'](y);const z=Array['isArray'](x['write_guard'])?x['write_guard']:[];for(const A of z){const B=A['guard'],C=typeof B==='string'?B:B!==null&&typeof B==='object'&&typeof B['$ref']==='string'?B['$ref']:undefined;if(C===undefined||y===undefined)continue;const D=v['writeGuards']['get'](y)??new Set();D['add'](C),v['writeGuards']['set'](y,D);}}};for(const v of a){if(v['op']!=='create'||v['object']!=='repository')continue;const w=v['params'],x={'keys':new Set(),'writeGuards':new Map()};i(x,Array['isArray'](w['policies'])?w['policies']:[]),f['set'](v['id'],x);if(typeof w['name']==='string')h['set'](w['name'],x);}for(const y of a){if(y['op']!=='configure'||y['method']!=='policies')continue;const z=y['target'],A=z!==null&&typeof z==='object'&&typeof z['$ref']==='string'?z['$ref']:undefined,B=A!==undefined?f['get'](A):undefined;if(B===undefined)continue;const C=y['params']['policy'];i(B,Array['isArray'](C)?C:[]);}const j=(D,E)=>E===undefined?undefined:D['find'](F=>F['identifier']===E),k=(D,E)=>{const F=j(D,E)?.['value'];if(F!==null&&typeof F==='object'&&typeof F['$ref']==='string')return f['get'](F['$ref']);return typeof F==='string'?h['get'](F):undefined;},l=(D,E)=>{const F=j(D,E)?.['value'];return typeof F==='string'?F:undefined;},m=new Map([['vec_contains_string',![]],['vec_indexof_string',![]],['vec_contains_string_nocase',!![]],['vec_indexof_string_nocase',!![]]]),n=new Set(['query_repository_data_keys_where','query_repository_policies_keys']),o=(D,E)=>{const F=[],G=I=>{const J=I?.['identifier'];return typeof J==='number'?J:undefined;},H=I=>{if(I===null||typeof I!=='object')return;if(Array['isArray'](I)){for(const L of I)H(L);return;}const J=I;if(J['type']==='query_repository_data_find_where'||J['type']==='query_repository_data_count_where'||J['type']==='query_repository_data_sum_where'||J['type']==='query_repository_data_sum_where_bound'||J['type']==='query_repository_data_sum_where_bound_all'){const M=k(D,G(J['object'])),N=l(D,G(J['key']));if(M!==undefined&&N!==undefined)F['push']({'repo':M,'key':N,'nocase':![]});}if(J['type']==='query'&&typeof J['query']==='string'&&/^repository\.data\b/i['test'](J['query'])){const O=k(D,G(J['object'])),Q=Array['isArray'](J['parameters'])?J['parameters']:[],R=l(D,G(Q[0x0]));if(O!==undefined&&R!==undefined)F['push']({'repo':O,'key':R,'nocase':![]});}if(J['type']==='query_repository_data'||J['type']==='query_repository_data_has'){const S=k(D,G(J['object'])),T=typeof J['key']==='string'?J['key']:undefined;if(S!==undefined&&T!==undefined)F['push']({'repo':S,'key':T,'nocase':![]});}const K=typeof J['type']==='string'?m['get'](J['type']):undefined;if(K!==undefined){const U=Array['isArray'](J['nodes'])?J['nodes']:[J['nodeLeft'],J['nodeRight']],V=U[0x0];if(V!==null&&typeof V==='object'&&typeof V['type']==='string'&&n['has'](V['type'])){const W=k(D,G(V['object']));if(W!==undefined)for(const X of U['slice'](0x1)){const Y=l(D,G(X));if(Y!==undefined)F['push']({'repo':W,'key':Y,'nocase':K});}}}for(const Z of Object['keys'](J))H(J[Z]);};return H(E),F;},p=(D,E,F)=>F?[...D['keys']]['some'](G=>G['toLowerCase']()===E['toLowerCase']()):D['keys']['has'](E),q=(D,E,F)=>F?[...D['writeGuards']]['find'](([G])=>G['toLowerCase']()===E['toLowerCase']())?.[0x1]:D['writeGuards']['get'](E);for(const [D,E]of b){if(E['stepId']===undefined)continue;for(const F of o(E['table'],E['root'])){!p(F['repo'],F['key'],F['nocase'])&&e['push']({'code':'POLICY_KEY_UNRESOLVED','detail':'guard\x20\x27'+D+'\x27\x20reads\x20repository\x20policy\x20key\x20\x27'+F['key']+'\x27,\x20but\x20NO\x20repository\x20create\x20step\x20in\x20this\x20'+'plan\x20defines\x20that\x20policy\x20—\x20as\x20built\x20the\x20read\x20'+'is\x20identically\x20ZERO\x20or\x20an\x20empty\x20key\x20list\x20(REPO-GATE-KEY-01):\x20the\x20gated\x20forward\x20never\x20opens\x20and\x20every\x20order\x20freezes\x20mid-rail\x20(bsx\x20BSX-F01:\x20'+'the\x20delivery\x20gate\x20read\x20\x27license_grant\x27\x20while\x20the\x20repository\x20stored\x20\x27grant\x27).\x20Policies\x20are\x20NOT\x20chain-frozen\x20—\x20'+'the\x20repository\x27s\x20policy-management\x20permission\x20(index\x20102)\x20can\x20add\x20the\x20missing\x20key\x20post-publish\x20—\x20but\x20do\x20not\x20ship\x20the\x20dead\x20rail:\x20'+'align\x20the\x20guard\x27s\x20row\x20'+'key\x20with\x20a\x20policy\x20name\x20this\x20plan\x20actually\x20creates.'}),q(F['repo'],F['key'],F['nocase'])?.['has'](E['stepId'])&&e['push']({'code':'CREDENTIAL_CYCLE','detail':'guard\x20\x27'+D+'\x27\x20is\x20a\x20write\x20credential\x20of\x20a\x20repository\x20policy\x20it\x20also\x20READS\x20(\x27'+F['key']+'\x27)\x20—\x20to\x20write\x20'+'the\x20row\x20you\x20must\x20first\x20pass\x20a\x20guard\x20requiring\x20the\x20row.\x20Unsatisfiable\x20by\x20construction\x20(bsn7\x20T-01\x20/\x20'+'bsx\x20BSX-F02:\x20the\x20review\x20write\x20credential\x20fell\x20back\x20to\x20the\x20reward-claim\x20guard,\x20which\x20requires\x20the\x20'+'rating\x20row\x20it\x20gates).\x20The\x20write\x20credential\x20must\x20be\x20an\x20identity/progress\x20credential\x20that\x20reads\x20'+'nothing\x20from\x20that\x20repository.'});}}const r=(G,H)=>{let I=![];const J=K=>{if(I||K===null||typeof K!=='object')return;if(Array['isArray'](K)){for(const M of K)J(M);return;}const L=K;if(L['type']==='context'&&L['context']===H)I=!![];for(const N of Object['keys'](L))J(L[N]);};return J(G),I;},u=G=>{let H=![];const I=J=>{if(H||J===null||typeof J!=='object')return;if(Array['isArray'](J)){for(const L of J)I(L);return;}const K=J;K['type']==='query'&&typeof K['query']==='string'&&/named_operator|permission|arb\./i['test'](K['query'])&&(H=!![]);for(const M of Object['keys'](K))I(K[M]);};return I(G),H;};for(const G of b['keys']()){if(!c['has'](G))continue;if(d['has'](G)||/recover/i['test'](G))continue;const H=b['get'](G);if(r(H['root'],'Signer'))continue;if(u(H['root']))continue;if(r(H['root'],'Clock'))continue;e['push']({'code':'MONEY_RAIL_CALLER_LEG_MISSING','detail':'money\x20rail\x20\x27'+G+'\x27\x20(allocator\x20row\x20or\x20reward\x20claim)\x20has\x20NO\x20caller-authorization\x20leg:\x20'+'alloc_by_guard\x20and\x20Reward\x20claims\x20are\x20NOT\x20forwards\x20—\x20'+'the\x20chain\x20injects\x20the\x20order-holder\x20rail\x20on\x20forward\x20ops\x20only\x20and\x20neither\x20op\x20has\x20a\x20'+'chain-side\x20caller\x20check,\x20so\x20this\x20rail\x20is\x20driveable\x20by\x20ANY\x20passport\x20holder\x20(gf30\x20A2\x20'+'settle_BY_OUTSIDER_v2\x20drained\x20o4;\x20rex5\x20T-27\x20rex-buy2\x20drained\x20a\x20third\x20party\x27s\x20escrow).\x20Bind\x20one:\x20'+'order.owner\x20==\x20Signer\x20OR\x20order.agent\x20has\x20Signer\x20(buyer),\x20or\x20the\x20dynamic-permission\x20leg\x20—\x20'+'service.permission\x20==\x20a\x20submitted\x20Permission\x20slot,\x20then\x20permission.owner\x20==\x20Signer\x20OR\x20'+'permission.admin\x20has\x20Signer\x20(merchant\x20or\x20keeper,\x20survives\x20rotation;\x20K-4).\x20State-determined\x20'+'exception\x20stays\x20open:\x20context\x20Clock\x20(time\x20gates).\x20Decision\x2011:\x20order.claimed_by\x20is\x20NEVER\x20an\x20'+'authorization\x20on\x20a\x20fund\x20rail\x20—\x20a\x20claimed_by\x20leg\x20there\x20is\x20the\x20RAIL_CLAIMED_BY_LEG\x20critical,\x20'+'blocked\x20by\x20the\x20rail\x20verifier\x20regardless\x20of\x20caller\x20identity.'});}return{'blockers':e};}export function emitSupplyChain({supplyChain:a,steps:b,derivedParams:c}){const d=[],e=[];let f;if(a!==undefined&&a['length']>0x0){const g=b['find'](n=>n['op']==='create'&&n['object']==='service'),h=g!==undefined&&g['op']==='create'&&typeof g['params']['name']==='string'?g['params']['name']:'',i=new Set(b['map'](n=>n['id'])),j=new Set(),k=new Set(),l=((()=>{for(let n=b['length']-0x1;n>=0x0;n-=0x1){const o=b[n];if(o['op']==='publish'&&o['target']['$ref']==='service')return n;}return b['length'];})());let m=0x0;a['forEach']((n,o)=>{const p=n['id_prefix']??(o===0x0?'sc':'sc'+String(o+0x1)),q='supply-chain\x20promise\x20#'+String(o+0x1)+'\x20(\x27'+(n['sub_service']||'unset\x20provider')+'\x27,\x20'+String(n['axis'])+')';if(n['service_step_id']!==undefined&&n['service_step_id']!=='service'){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20service_step_id\x20\x27'+n['service_step_id']+'\x27\x20names\x20no\x20step\x20in\x20this\x20plan.\x20Compile\x20'+'attaches\x20a\x20promise\x20to\x20its\x20own\x20Service\x20create,\x20whose\x20id\x20is\x20always\x20\x27service\x27\x20—\x20drop\x20the\x20field\x20'+'or\x20pass\x20\x27service\x27.'});return;}let r=n['repository_name'];if(r!==undefined&&j['has'](r)){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20repository_name\x20\x27'+r+'\x27\x20is\x20already\x20created\x20by\x20an\x20earlier\x20promise\x20—\x20one\x20'+('Repository\x20cannot\x20be\x20created\x20twice.\x20Pass\x20\x27repository:\x20'+r+'\x27\x20on\x20this\x20promise\x20to\x20')+'REUSE\x20the\x20shared\x20ledger\x20instead\x20of\x20creating\x20it.'});return;}if(n['repository']===undefined&&r===undefined){const u=(n['service_name']||h||'service')+'_supply_chain';if(j['has'](u))r=u+'_'+p;}const s=emitSupplyChainPromise({...n,'service_name':n['service_name']||h,'service_step_id':'service','id_prefix':p,...r!==undefined?{'repository_name':r}:{}});for(const v of s['blockers'])d['push']({'code':v['code'],'detail':q+':\x20'+v['detail']});const t=s['steps']['find'](w=>i['has'](w['id']));if(t!==undefined){d['push']({'code':'SUPPLY_CHAIN_ID_CONFLICT','detail':q+':\x20emitted\x20step\x20id\x20\x27'+t['id']+'\x27\x20already\x20exists\x20in\x20the\x20plan.\x20Each\x20promise\x20names\x20its\x20'+'objects\x20\x27<prefix>_gate\x27\x20/\x20\x27_write\x27\x20/\x20\x27_ack\x27\x20/\x20\x27_rendezvous\x27\x20/\x20\x27_bind_repository\x27\x20/\x20\x27_alloc\x27,\x20'+'so\x20give\x20this\x20promise\x20a\x20distinct\x20id_prefix.'});return;}for(const w of s['steps']){i['add'](w['id']),w['op']==='create'&&w['object']==='repository'&&typeof w['params']['name']==='string'&&j['add'](w['params']['name']);}b['splice'](l+m,0x0,...s['steps']),m+=s['steps']['length'],c['push'](...s['derived_params']??[]);if(s['steps']['length']===0x0)return;e['push'](s),k['add'](n['axis']);});if(k['size']>0x0){const n=[...k];f=n['length']===0x1?n[0x0]:'mixed';}}return{'supplyChainEmissions':e,'fulfillmentAxis':f,'blockers':d};}