@wowok/agent-mcp 3.3.1 → 3.3.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 (277) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/freeze-map.js +1 -1
  3. package/dist/chain-semantics/fund-flow.js +1 -1
  4. package/dist/chain-semantics/guard-verbs.js +1 -1
  5. package/dist/chain-semantics/object-graph.js +1 -1
  6. package/dist/composition/audit.d.ts +5 -0
  7. package/dist/composition/audit.js +1 -1
  8. package/dist/composition/blueprint-view.d.ts +0 -1
  9. package/dist/composition/blueprint-view.js +1 -1
  10. package/dist/composition/compile.d.ts +5 -3
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/inflight.d.ts +32 -4
  13. package/dist/composition/inflight.js +1 -1
  14. package/dist/config/judgment.d.ts +111 -1
  15. package/dist/config/judgment.js +1 -1
  16. package/dist/customer/industry-risks.js +1 -1
  17. package/dist/customer/user-preferences.js +1 -1
  18. package/dist/evaluation/arbitration-game.d.ts +4 -0
  19. package/dist/evaluation/arbitration-game.js +1 -1
  20. package/dist/evaluation/builtins/graph-service.js +1 -1
  21. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  22. package/dist/evaluation/game-strategy.d.ts +6 -0
  23. package/dist/evaluation/game-strategy.js +1 -1
  24. package/dist/evaluation/node-game.d.ts +4 -0
  25. package/dist/evaluation/node-game.js +1 -1
  26. package/dist/evaluation/value-risk.d.ts +8 -0
  27. package/dist/evaluation/value-risk.js +1 -0
  28. package/dist/experience/realtime-feedback.js +1 -1
  29. package/dist/extensions/business-modules.d.ts +7 -2
  30. package/dist/extensions/business-modules.js +1 -1
  31. package/dist/extensions/industry-audit.spec.js +1 -1
  32. package/dist/extensions/industry-pack.d.ts +3 -2
  33. package/dist/extensions/industry-pack.js +1 -1
  34. package/dist/extensions/modes.js +1 -1
  35. package/dist/graph/onchain/analyze.js +1 -1
  36. package/dist/graph/onchain/analyze.spec.js +1 -1
  37. package/dist/graph/onchain/expand.js +1 -1
  38. package/dist/graph/onchain/exposure.js +1 -1
  39. package/dist/graph/onchain/facet-projection.js +1 -1
  40. package/dist/graph/onchain/facet-projection.spec.js +1 -1
  41. package/dist/graph/onchain/facts.d.ts +20 -0
  42. package/dist/graph/onchain/facts.js +1 -1
  43. package/dist/graph/onchain/facts.spec.js +1 -1
  44. package/dist/graph/onchain/object-held-receipts.d.ts +20 -0
  45. package/dist/graph/onchain/object-held-receipts.js +1 -0
  46. package/dist/graph/onchain/object-held-receipts.spec.d.ts +1 -0
  47. package/dist/graph/onchain/object-held-receipts.spec.js +1 -0
  48. package/dist/graph/onchain/project-relationship.js +1 -1
  49. package/dist/graph/onchain/sdk-batch.d.ts +1 -0
  50. package/dist/graph/onchain/sdk-batch.js +1 -1
  51. package/dist/harness/index.d.ts +1 -0
  52. package/dist/harness/recover.d.ts +2 -1
  53. package/dist/harness/recover.js +1 -1
  54. package/dist/knowledge/acquisition-flywheel.js +1 -1
  55. package/dist/knowledge/allocation-ledger.d.ts +3 -1
  56. package/dist/knowledge/allocation-ledger.js +1 -1
  57. package/dist/knowledge/allocation-puzzle.d.ts +1 -0
  58. package/dist/knowledge/allocation-puzzle.js +1 -1
  59. package/dist/knowledge/allocation-risk.d.ts +1 -1
  60. package/dist/knowledge/allocation-risk.js +1 -1
  61. package/dist/knowledge/arb-fund-facts.d.ts +12 -0
  62. package/dist/knowledge/arb-fund-facts.js +1 -1
  63. package/dist/knowledge/audit-rules.d.ts +4 -3
  64. package/dist/knowledge/audit-rules.js +1 -1
  65. package/dist/knowledge/baselines/judgment-baselines.json +502 -81
  66. package/dist/knowledge/baselines/rules/allocation.json +0 -14
  67. package/dist/knowledge/baselines/rules/graph.json +4 -4
  68. package/dist/knowledge/baselines/rules/plan.json +81 -5
  69. package/dist/knowledge/baselines/rules/reward.json +1 -1
  70. package/dist/knowledge/builtin-templates.d.ts +9 -1
  71. package/dist/knowledge/builtin-templates.js +1 -1
  72. package/dist/knowledge/discount-threshold.js +1 -1
  73. package/dist/knowledge/event-semantics.js +1 -1
  74. package/dist/knowledge/game-scenarios.d.ts +21 -0
  75. package/dist/knowledge/game-scenarios.js +1 -0
  76. package/dist/knowledge/getting-started.js +1 -1
  77. package/dist/knowledge/guard-bindings.js +1 -1
  78. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  79. package/dist/knowledge/guard-design-patterns.js +1 -1
  80. package/dist/knowledge/guard-field-cognition.js +1 -1
  81. package/dist/knowledge/guard-leg-map.d.ts +5 -0
  82. package/dist/knowledge/guard-leg-map.js +1 -0
  83. package/dist/knowledge/guard-lint.js +1 -1
  84. package/dist/knowledge/guard-puzzle.js +1 -1
  85. package/dist/knowledge/guard-render.js +1 -1
  86. package/dist/knowledge/guard-risk.js +1 -1
  87. package/dist/knowledge/guard-submission-brief.d.ts +5 -0
  88. package/dist/knowledge/guard-submission-brief.js +1 -1
  89. package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
  90. package/dist/knowledge/guard-submission-prompt.js +1 -1
  91. package/dist/knowledge/guard-templates.d.ts +1 -1
  92. package/dist/knowledge/guard-templates.js +1 -1
  93. package/dist/knowledge/guard-translation.js +1 -1
  94. package/dist/knowledge/index.js +1 -1
  95. package/dist/knowledge/industry-generalizer.js +1 -1
  96. package/dist/knowledge/industry-registry.js +1 -1
  97. package/dist/knowledge/industry-strategy.js +1 -1
  98. package/dist/knowledge/jsonrpc-enum.js +1 -1
  99. package/dist/knowledge/onchain-constants.d.ts +4 -2
  100. package/dist/knowledge/onchain-constants.js +1 -1
  101. package/dist/knowledge/order-ledger.d.ts +1 -1
  102. package/dist/knowledge/order-ledger.js +1 -1
  103. package/dist/knowledge/order-puzzle.d.ts +3 -0
  104. package/dist/knowledge/order-risk.d.ts +1 -1
  105. package/dist/knowledge/passport-ledger.d.ts +12 -0
  106. package/dist/knowledge/passport-ledger.js +1 -1
  107. package/dist/knowledge/payment-tracker.js +1 -1
  108. package/dist/knowledge/protocol-facts.d.ts +1 -0
  109. package/dist/knowledge/protocol-facts.js +1 -1
  110. package/dist/knowledge/repository-write-semantics.d.ts +1 -1
  111. package/dist/knowledge/repository-write-semantics.js +1 -1
  112. package/dist/knowledge/reward-ledger.js +1 -1
  113. package/dist/knowledge/reward-puzzle.d.ts +1 -1
  114. package/dist/knowledge/reward-risk.d.ts +1 -1
  115. package/dist/knowledge/scenario-modes.d.ts +2 -2
  116. package/dist/knowledge/scenario-modes.js +1 -1
  117. package/dist/knowledge/scenario-topology.js +1 -1
  118. package/dist/knowledge/service-ledger.d.ts +14 -0
  119. package/dist/knowledge/service-ledger.js +1 -1
  120. package/dist/knowledge/strategy-manuals.js +1 -1
  121. package/dist/knowledge/template-index.d.ts +19 -0
  122. package/dist/knowledge/template-index.js +1 -0
  123. package/dist/knowledge/template-loader.d.ts +36 -0
  124. package/dist/knowledge/template-loader.js +1 -1
  125. package/dist/knowledge/template-registry.js +1 -1
  126. package/dist/knowledge/template-scanner.d.ts +11 -0
  127. package/dist/knowledge/template-scanner.js +1 -1
  128. package/dist/knowledge/tool-constraints.js +1 -1
  129. package/dist/knowledge/workflow-guidance.d.ts +2 -0
  130. package/dist/knowledge/workflow-guidance.js +1 -1
  131. package/dist/monitor/MonitorLoop.js +1 -1
  132. package/dist/participation/allocation-advice.d.ts +8 -1
  133. package/dist/participation/allocation-advice.js +1 -1
  134. package/dist/participation/game-context.d.ts +25 -0
  135. package/dist/participation/game-context.js +1 -0
  136. package/dist/participation/node-action-advisor.d.ts +64 -0
  137. package/dist/participation/node-action-advisor.js +1 -0
  138. package/dist/participation/radar-core.d.ts +1 -0
  139. package/dist/participation/radar-core.js +1 -1
  140. package/dist/persona/defaults.js +1 -1
  141. package/dist/persona/topology-focus.js +1 -1
  142. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  143. package/dist/playbooks/service-build/game-theory.d.ts +4 -1
  144. package/dist/playbooks/service-build/game-theory.js +1 -1
  145. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  146. package/dist/playbooks/service-build/merchant-guide.d.ts +26 -1
  147. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  148. package/dist/playbooks/service-build/migration-planner.d.ts +2 -2
  149. package/dist/playbooks/service-build/migration-planner.js +1 -1
  150. package/dist/playbooks/service-build/object-panorama.d.ts +13 -1
  151. package/dist/playbooks/service-build/object-panorama.js +1 -1
  152. package/dist/playbooks/service-build/participation-radar.js +1 -1
  153. package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -1
  154. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  155. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  156. package/dist/playbooks/service-build/service-panorama.d.ts +12 -0
  157. package/dist/playbooks/service-build/service-panorama.js +1 -1
  158. package/dist/playbooks/service-build/service-quote.js +1 -1
  159. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  160. package/dist/relationship/derivation.d.ts +1 -1
  161. package/dist/review/index.js +1 -1
  162. package/dist/review/repository.js +1 -1
  163. package/dist/role/intent.d.ts +23 -0
  164. package/dist/role/intent.js +1 -0
  165. package/dist/safety/confirm-gate.js +1 -1
  166. package/dist/schema/benchmark-migration/index.d.ts +39 -0
  167. package/dist/schema/benchmark-migration/index.js +1 -1
  168. package/dist/schema/call/allocation.d.ts +49 -3
  169. package/dist/schema/call/allocation.js +1 -1
  170. package/dist/schema/call/arbitration.js +1 -1
  171. package/dist/schema/call/base.d.ts +52 -0
  172. package/dist/schema/call/base.js +1 -1
  173. package/dist/schema/call/bridge.d.ts +3 -0
  174. package/dist/schema/call/contact.js +1 -1
  175. package/dist/schema/call/error-codes.d.ts +1 -1
  176. package/dist/schema/call/error-codes.js +1 -1
  177. package/dist/schema/call/guard.js +1 -1
  178. package/dist/schema/call/handler.js +1 -1
  179. package/dist/schema/call/machine.d.ts +10 -0
  180. package/dist/schema/call/machine.js +1 -1
  181. package/dist/schema/call/order.d.ts +2 -0
  182. package/dist/schema/call/order.js +1 -1
  183. package/dist/schema/call/progress.d.ts +6 -3
  184. package/dist/schema/call/progress.js +1 -1
  185. package/dist/schema/call/repository.d.ts +4 -0
  186. package/dist/schema/call/repository.js +1 -1
  187. package/dist/schema/call/reward.d.ts +2 -2
  188. package/dist/schema/call/reward.js +1 -1
  189. package/dist/schema/call/semantic.d.ts +6 -0
  190. package/dist/schema/call/semantic.js +1 -1
  191. package/dist/schema/call/service.d.ts +42 -4
  192. package/dist/schema/call/service.js +1 -1
  193. package/dist/schema/common/index.js +1 -1
  194. package/dist/schema/goal/index.d.ts +54 -0
  195. package/dist/schema/goal/planning.d.ts +86 -0
  196. package/dist/schema/goal/planning.js +1 -1
  197. package/dist/schema/keeper/index.d.ts +2 -0
  198. package/dist/schema/local/index.d.ts +72 -0
  199. package/dist/schema/local/index.js +1 -1
  200. package/dist/schema/messenger/index.d.ts +2 -0
  201. package/dist/schema/operations.d.ts +46 -5
  202. package/dist/schema/operations.js +1 -1
  203. package/dist/schema/persona/index.d.ts +484 -0
  204. package/dist/schema/query/bi.d.ts +4 -0
  205. package/dist/schema/query/bi.js +1 -1
  206. package/dist/schema/query/index.d.ts +84 -60
  207. package/dist/schema/query/index.js +1 -1
  208. package/dist/schema/schema-version.d.ts +1 -1
  209. package/dist/schema/schema-version.js +1 -1
  210. package/dist/schema-query-impl/index.js +1 -1
  211. package/dist/schemas/account_operation.output.json +41 -10
  212. package/dist/schemas/account_operation.schema.json +1 -1
  213. package/dist/schemas/benchmark_migration_operation.output.json +8 -5
  214. package/dist/schemas/benchmark_migration_operation.schema.json +91 -3
  215. package/dist/schemas/bridge_operation.output.json +13 -7
  216. package/dist/schemas/goal_operation.schema.json +94 -0
  217. package/dist/schemas/index.json +1 -1
  218. package/dist/schemas/keeper_operation.output.json +12 -7
  219. package/dist/schemas/local_cache_operation.output.json +34 -7
  220. package/dist/schemas/local_cache_operation.schema.json +16 -1
  221. package/dist/schemas/local_history_operation.output.json +13 -7
  222. package/dist/schemas/local_info_operation.output.json +13 -7
  223. package/dist/schemas/local_info_operation.schema.json +5 -1
  224. package/dist/schemas/local_mark_operation.output.json +13 -7
  225. package/dist/schemas/messenger_operation.output.json +12 -7
  226. package/dist/schemas/monitor_events.output.json +12 -7
  227. package/dist/schemas/monitor_subscription.output.json +12 -7
  228. package/dist/schemas/onchain_events.output.json +67 -18
  229. package/dist/schemas/onchain_events.schema.json +4 -0
  230. package/dist/schemas/onchain_operations.output.json +81 -24
  231. package/dist/schemas/onchain_operations.schema.json +531 -126
  232. package/dist/schemas/onchain_operations_allocation.schema.json +294 -6
  233. package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
  234. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  235. package/dist/schemas/onchain_operations_demand.schema.json +3 -3
  236. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  237. package/dist/schemas/onchain_operations_guard.schema.json +99 -63
  238. package/dist/schemas/onchain_operations_machine.schema.json +10 -1
  239. package/dist/schemas/onchain_operations_order.schema.json +8 -4
  240. package/dist/schemas/onchain_operations_progress.schema.json +8 -4
  241. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  242. package/dist/schemas/onchain_operations_repository.schema.json +6 -2
  243. package/dist/schemas/onchain_operations_reward.schema.json +8 -8
  244. package/dist/schemas/onchain_operations_service.schema.json +81 -21
  245. package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
  246. package/dist/schemas/onchain_table_data.output.json +16 -7
  247. package/dist/schemas/persona_operation.output.json +1387 -0
  248. package/dist/schemas/persona_operation.schema.json +219 -0
  249. package/dist/schemas/query_toolkit.output.json +115 -64
  250. package/dist/schemas/query_toolkit.schema.json +8 -0
  251. package/dist/schemas/workflow_operation.schema.json +1 -1
  252. package/dist/tools/handlers/benchmark-migration.js +1 -1
  253. package/dist/tools/handlers/bridge.js +1 -1
  254. package/dist/tools/handlers/config.js +1 -1
  255. package/dist/tools/handlers/dispatch-expectations.js +1 -1
  256. package/dist/tools/handlers/file-export.js +1 -1
  257. package/dist/tools/handlers/industry-pack.d.ts +1 -0
  258. package/dist/tools/handlers/industry-pack.js +1 -1
  259. package/dist/tools/handlers/local.js +1 -1
  260. package/dist/tools/handlers/messenger.js +1 -1
  261. package/dist/tools/handlers/onchain-name-registration.d.ts +11 -0
  262. package/dist/tools/handlers/onchain-name-registration.js +1 -1
  263. package/dist/tools/handlers/onchain.d.ts +28 -0
  264. package/dist/tools/handlers/onchain.js +1 -1
  265. package/dist/tools/handlers/query.js +1 -1
  266. package/dist/tools/handlers/review-chain.d.ts +1 -1
  267. package/dist/tools/handlers/review-chain.js +1 -1
  268. package/dist/tools/handlers/schema-query.js +1 -1
  269. package/dist/tools/handlers/workflow.js +1 -1
  270. package/dist/tools/move-fn-index.gen.js +1 -1
  271. package/dist/tools/registry/agent.js +1 -1
  272. package/dist/tools/registry/local.js +1 -1
  273. package/dist/tools/registry/onchain.js +1 -1
  274. package/dist/tools/registry/query.js +1 -1
  275. package/dist/tools/wip-deploy-assist.js +1 -1
  276. package/dist/tools/wrap.js +1 -1
  277. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ import{query_transaction}from'@wowok/wowok';import{batchQueryObjectsByIds}from'./sdk-batch.js';import{extractCoinType}from'./extract.js';const MAX_SCANNED_PAYMENTS=0x5,WRAPPER_TYPE_MARK='::payment::CoinWrapper<';function pickData(a){return a?.['data']??a??undefined;}function addrOf(a){return String(a?.['object']??a?.['data']?.['object']??'')['toLowerCase']();}function isOwnedByObject(a,b){if(!a||typeof a!=='object')return![];const c=a['ObjectOwner']??(a['$kind']==='ObjectOwner'?a['ObjectOwner']:undefined);return String(c??'')['toLowerCase']()===b;}function amountOf(a){const b=a?.['balance']?.['fields']?.['value']??a?.['content_raw']?.['fields']?.['balance']?.['fields']?.['value']??a?.['balance']?.['value']??a?.['content_raw']?.['fields']?.['balance'];return b==null?'0':String(b);}function paymentOf(a){const b=a?.['payment']??a?.['content_raw']?.['fields']?.['payment']??a?.['content_raw']?.['payment'];return String(b??'')['toLowerCase']();}function typeRawOf(a){return typeof a?.['type_raw']==='string'?a['type_raw']:typeof a?.['content_raw']?.['type']==='string'?a['content_raw']['type']:undefined;}export async function recoverObjectHeldReceipts(a,b){const c=String(a??'')['toLowerCase']();if(!c)return undefined;try{const d=await batchQueryObjectsByIds([c],b['network'],b['no_cache']),e=d['find'](s=>addrOf(s)===c)??d[0x0];if(!e)return undefined;const f=addrOf(e);if(!f)return undefined;const g=String(pickData(e)?.['allocation']??'')['toLowerCase']();if(!g)return undefined;const h=await batchQueryObjectsByIds([g],b['network'],b['no_cache']),i=h['find'](s=>addrOf(s)===g)??h[0x0],j=pickData(i)?.['payment'],k=Array['isArray'](j)?[...new Set(j['map'](s=>String(s??'')['toLowerCase']())['filter'](Boolean))]['slice'](-MAX_SCANNED_PAYMENTS):[];if(k['length']===0x0)return{'holder':f,'allocation':g,'payments_scanned':0x0,'receipts':[],'token_type':''};const l=await batchQueryObjectsByIds(k,b['network'],b['no_cache']),m=new Set(k),n=new Map();let o=0x0;for(const s of l){const t=String(s?.['previousTransaction']??'')['trim']();if(!t)continue;o++;try{const u=await query_transaction({'digest':t,'network':b['network'],'no_cache':b['no_cache']});for(const v of u?.['object_changes']??[]){if(v['type']!=='created')continue;const w=String(v['object_type']??'');if(!w['includes'](WRAPPER_TYPE_MARK))continue;const x=String(v['id']??'')['toLowerCase']();if(!x)continue;n['set'](x,{'version':v['version']!=null?String(v['version']):undefined,'digest':v['digest']!=null?String(v['digest']):undefined,'object_type':w});}}catch{}}if(n['size']===0x0)return{'holder':f,'allocation':g,'payments_scanned':o,'receipts':[],'token_type':''};const p=await batchQueryObjectsByIds([...n['keys']()],b['network'],b['no_cache']),q=[];let r='';for(const y of p){const z=addrOf(y);if(!z)continue;const A=n['get'](z);if(!A)continue;const B=typeRawOf(y)??A['object_type'];if(!B||!B['includes'](WRAPPER_TYPE_MARK))continue;const C=paymentOf(y);if(!m['has'](C))continue;if(!isOwnedByObject(y?.['owner'],f))continue;const D=String(y?.['version']??'');if(D&&A['version']&&D!==A['version'])continue;q['push']({'id':z,'payment':C,'amount':amountOf(y),'version':A['version']??(D||undefined),'digest':A['digest'],'type':B});if(!r)r=extractCoinType(B)??'';}return{'holder':f,'allocation':g,'payments_scanned':o,'receipts':q,'token_type':r};}catch{return undefined;}}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{describe,it,expect,vi,beforeEach}from'vitest';const {queryTransactionMock}=vi['hoisted'](()=>({'queryTransactionMock':vi['fn']()}));vi['mock']('./sdk-batch.js',()=>({'batchQueryObjectsByIds':vi['fn']()})),vi['mock']('@wowok/wowok',async a=>{const b=await a();return{...b,'query_transaction':queryTransactionMock};});import{batchQueryObjectsByIds}from'./sdk-batch.js';import{recoverObjectHeldReceipts}from'./object-held-receipts.js';const mockObjects=vi['mocked'](batchQueryObjectsByIds),ORDER='0xorder',ALLOC='0xalloc',PAY='0xpay',PAY_OTHER='0xpayother',WRAPPER='0xwrapper',WRAPPER_USER='0xwrapperuser',TX='0xtxd',WRAPPER_TYPE='0xpk::payment::CoinWrapper<0x2::wow::WOW>';function orderObj(){return{'object':ORDER,'type':'Order','allocation':ALLOC};}function allocObj(a=[PAY]){return{'object':ALLOC,'type':'Allocation','payment':a};}function payObj(a,b){return{'object':a,'type':'Payment','previousTransaction':b};}function wrapperObj(a,b={}){return{'object':a,'type_raw':WRAPPER_TYPE,'owner':{'ObjectOwner':ORDER},'version':'3','payment':PAY,'balance':{'type':'0x2::balance::Balance<0x2::wow::WOW>','fields':{'value':'500'}},...b};}function routeObjects(a){mockObjects['mockImplementation'](async b=>b['map'](c=>a[c])['filter'](c=>c!==undefined));}beforeEach(()=>{mockObjects['mockReset'](),queryTransactionMock['mockReset']();}),describe('recoverObjectHeldReceipts',()=>{it('recovers\x20the\x20wrapper\x20triples\x20from\x20the\x20allocation\x20transaction\x20effects',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX),[WRAPPER]:wrapperObj(WRAPPER)}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'DIGEST3'},{'id':'0xprogress','type':'created','object_type':'0xpk::order::Progress'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{'network':'testnet'});expect(a)['toBeDefined'](),expect(a['holder'])['toBe'](ORDER),expect(a['allocation'])['toBe'](ALLOC),expect(a['payments_scanned'])['toBe'](0x1),expect(a['token_type'])['toBe']('0x2::wow::WOW'),expect(a['receipts'])['toEqual']([{'id':WRAPPER,'payment':PAY,'amount':'500','version':'3','digest':'DIGEST3','type':WRAPPER_TYPE}]);}),it('drops\x20wrappers\x20owned\x20by\x20a\x20user\x20or\x20pointing\x20at\x20another\x20Payment',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj([PAY,PAY_OTHER]),[PAY]:payObj(PAY,TX),[PAY_OTHER]:payObj(PAY_OTHER,TX),[WRAPPER]:wrapperObj(WRAPPER),[WRAPPER_USER]:wrapperObj(WRAPPER_USER,{'owner':{'AddressOwner':'0xuser'}}),'0xwrapperother':wrapperObj('0xwrapperother',{'payment':'0xstranger'})}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D1'},{'id':WRAPPER_USER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D2'},{'id':'0xwrapperother','type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D3'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a['receipts']['map'](b=>b['id']))['toEqual']([WRAPPER]);}),it('excludes\x20a\x20wrapper\x20that\x20was\x20already\x20collected\x20(no\x20longer\x20resolves)',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX)}),queryTransactionMock['mockResolvedValue']({'digest':TX,'status':'success','object_changes':[{'id':WRAPPER,'type':'created','object_type':WRAPPER_TYPE,'version':'3','digest':'D1'}],'balance_changes':[],'event_count':0x0,'events':[]});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['receipts'])['toEqual']([]);}),it('returns\x20undefined\x20when\x20the\x20holder\x20is\x20not\x20an\x20escrow\x20object',async()=>{routeObjects({'0xuser':{'object':'0xuser','type':'Order'}});const a=await recoverObjectHeldReceipts('0xuser',{});expect(a)['toBeUndefined']();}),it('skips\x20a\x20Payment\x20with\x20no\x20previousTransaction\x20and\x20reports\x20zero\x20scanned',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,undefined)});const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['payments_scanned'])['toBe'](0x0),expect(a['receipts'])['toEqual']([]),expect(queryTransactionMock)['not']['toHaveBeenCalled']();}),it('fails\x20soft\x20when\x20the\x20transaction\x20read\x20throws',async()=>{routeObjects({[ORDER]:orderObj(),[ALLOC]:allocObj(),[PAY]:payObj(PAY,TX)}),queryTransactionMock['mockRejectedValue'](new Error('index\x20window\x20miss'));const a=await recoverObjectHeldReceipts(ORDER,{});expect(a)['toBeDefined'](),expect(a['payments_scanned'])['toBe'](0x1),expect(a['receipts'])['toEqual']([]);});});
@@ -1 +1 @@
1
- import{rootOf}from'./extract.js';const MAX_MANAGED_TOTAL=0x3c,MAX_ORDERS=0x28,MAX_DEMANDS=0x14,MAX_ALLOCATIONS=0x28,MAX_CONTACTS=0x14,MAX_MACHINES=0xa,MAX_ARB_SERVICES=0xf;function fld(a,b){if(!a?.['raw'])return undefined;const c=rootOf(a['raw']);return c[b];}function addrList(a,b){const c=fld(a,b);return(Array['isArray'](c)?c:[])['filter'](d=>typeof d==='string');}function outEdges(a,b,c){return(a['out']['get'](b['toLowerCase']())??[])['filter'](d=>d['schema']===c);}function rawOf(a,b){return b?a['nodes']['get'](b['toLowerCase']()):undefined;}function managedTargets(a,b){const c=new Set();for(const d of[...outEdges(a,b,'permission.core_binding'),...outEdges(a,b,'permission.tx_binding')]){c['add'](d['to']);}return[...c]['map'](f=>a['nodes']['get'](f))['filter'](f=>!!f&&f['kind']==='object');}function mapMode(a){if(a===0x1||a==='Rate')return'Rate';if(a===0x2||a==='Surplus')return'Surplus';if(a===0x3||a==='RateGross')return'RateGross';return'Amount';}export function projectRelationshipFacts(b,c){const f=c['toLowerCase'](),g=outEdges(b,f,'eoa.permission'),h=[],i=new Map();for(const C of g){const D=b['nodes']['get'](C['to']);if(!D)continue;const E=outEdges(b,D['id'],'permission.entity')['map'](H=>({'address':H['to'],'perm_indices':H['payload']?.['permIndices']??[]})),F=managedTargets(b,D['id']),G=F['filter'](H=>!!H['objectType'])['map'](H=>({'object_type':H['objectType'],'address':H['id']}));for(const H of G){if(i['size']>=MAX_MANAGED_TOTAL)break;i['set'](H['address']['toLowerCase'](),H);}h['push']({'address':D['id'],'owner':fld(D,'owner')??'','admins':addrList(D,'admin'),'entities':E,'anchor_role_bits':C['payload']?.['roleBits'],'managed_objects':G});}const j=I=>[...i['values']()]['filter'](J=>J['object_type']===I)['map'](J=>J['address']),k=j('Service'),l=j('Machine')['slice'](0x0,MAX_MACHINES),n=j('Demand')['slice'](0x0,MAX_DEMANDS),p=j('Contact')['slice'](0x0,MAX_CONTACTS),q=j('Arbitration'),r=new Map();for(const I of outEdges(b,f,'eoa.order'))r['set'](I['to'],'buyer');for(const J of k){for(const K of outEdges(b,J,'service.order'))r['set'](K['to'],'merchant');}const t=[],u={};for(const L of[...r['keys']()]['slice'](0x0,MAX_ORDERS)){const M=rawOf(b,L);if(!M||M['objectType']!=='Order')continue;const N=fld(M,'service')??'';t['push']({'address':M['id'],'owner':fld(M,'owner')??fld(M,'builder')??'','agents':addrList(M,'agent'),'service':N,'amount':fld(M,'amount'),'allocation':fld(M,'allocation'),'dispute_arbitrations':addrList(M,'dispute'),'claimed_by':fld(M,'claimed_by')??null});if(N){const O=rawOf(b,N),P=outEdges(b,N,'service.permission')[0x0]?.['to'],Q=rawOf(b,P),R=fld(Q,'owner');if(R)u[O?.['id']??N['toLowerCase']()]=R;}}const v=n['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'demand.permission')[0x0]?.['to'],V=fld(rawOf(b,U),'owner')??'',W=outEdges(b,S,'demand.presenter')['map'](Y=>({'address':Y['to'],'service':typeof Y['payload']?.['service']==='string'?Y['payload']['service']:undefined,'acceptance_score':typeof Y['payload']?.['score']==='number'?Y['payload']['score']:undefined,'scoredAt':typeof Y['payload']?.['feedbackTime']==='number'&&Y['payload']['feedbackTime']>0x0?Y['payload']['feedbackTime']:typeof Y['payload']?.['time']==='number'&&Y['payload']['time']>0x0?Y['payload']['time']:undefined})),X=(fld(T,'guards')??[])['map'](Y=>typeof Y==='string'?Y:Y?.['guard'])['filter'](Y=>typeof Y==='string');return{'address':T['id'],'owner':V,'presenters':W,'rewards':addrList(T,'rewards'),'guards':X};}),w=[...new Set(t['map'](S=>S['allocation'])['filter'](S=>!!S))]['slice'](0x0,MAX_ALLOCATIONS),x=w['map'](S=>{const T=rawOf(b,S),U=fld(T,'allocators')??rootOf(T['raw']),V=Array['isArray'](U)?U:Array['isArray'](U?.['allocators'])?U['allocators']:[],W=V['flatMap'](X=>(Array['isArray'](X?.['sharing'])?X['sharing']:[])['map'](Y=>({'who':Y?.['who']??Y,'mode':mapMode(Y?.['mode']),'sharing':Y?.['sharing']!=null?String(Y['sharing']):undefined,'guard':typeof X?.['guard']==='string'?X['guard']:undefined})));return{'address':T['id'],'owner':fld(T,'owner'),'sharing':W};}),y=p['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'contact.permission')[0x0]?.['to'],V=fld(rawOf(b,U),'owner')??'',W=(fld(T,'ims')??[])['map'](X=>typeof X==='string'?X:X?.['at'])['filter'](X=>typeof X==='string');return{'address':T['id'],'ims':W,'owner':V};}),z=l['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'machine.permission')[0x0]?.['to'],V=S['toLowerCase']()+'::node::',W=b['edges']['filter'](X=>X['schema']==='wf.transition'&&X['from']['startsWith'](V))['map'](X=>({'node':X['payload']?.['prevNode']??'','next_node':X['payload']?.['node']??'','forward_name':X['payload']?.['forward']??'','named_operator':X['payload']?.['namedOperator']??null,'permission_index':X['payload']?.['permissionIndex']??null,'guard':X['payload']?.['guard']??null}));return{'address':T['id'],'permission_address':U,'forwards':W};}),A=new Map();for(const S of t){const T=r['get'](S['address']['toLowerCase']())??'buyer';for(const U of S['dispute_arbitrations']??[])A['set'](U['toLowerCase'](),T);}const B=[];for(const [V,W]of A){const X=rawOf(b,V);if(!X)continue;const Y=(fld(X,'voted')??[])['map'](Z=>({'address':typeof Z?.['voter']==='string'?Z['voter']:'','weight':typeof Z?.['weight']==='number'?Z['weight']:undefined}))['filter'](Z=>Z['address']['length']>0x0);B['push']({'address':X['id'],'object_kind':'case','voters':Y,'order':fld(X,'order'),'arbitration':fld(X,'arbitration'),'anchor_side':W,'bound_services':[]});}for(const Z of q['slice'](0x0,MAX_ARB_SERVICES)){if(A['has'](Z['toLowerCase']()))continue;B['push']({'address':Z,'object_kind':'service','voters':[],'bound_services':[]});}return{'anchor':f,'permissions':h,'machines':z,'orders':t,'demands':v,'allocations':x,'contacts':y,'arbitrations':B,'service_owners':u};}
1
+ import{rootOf}from'./extract.js';const MAX_MANAGED_TOTAL=0x3c,MAX_ORDERS=0x28,MAX_DEMANDS=0x14,MAX_ALLOCATIONS=0x28,MAX_CONTACTS=0x14,MAX_MACHINES=0xa,MAX_ARB_SERVICES=0xf;function fld(a,b){if(!a?.['raw'])return undefined;const c=rootOf(a['raw']);return c[b];}function addrList(a,b){const c=fld(a,b);return(Array['isArray'](c)?c:[])['filter'](d=>typeof d==='string');}function outEdges(a,b,c){return(a['out']['get'](b['toLowerCase']())??[])['filter'](d=>d['schema']===c);}function rawOf(a,b){return b?a['nodes']['get'](b['toLowerCase']()):undefined;}function managedTargets(a,b){const c=new Set();for(const d of[...outEdges(a,b,'permission.core_binding'),...outEdges(a,b,'permission.tx_binding')]){c['add'](d['to']);}return[...c]['map'](f=>a['nodes']['get'](f))['filter'](f=>!!f&&f['kind']==='object');}function mapMode(a){if(a===0x1||a==='Rate')return'Rate';if(a===0x2||a==='Surplus')return'Surplus';if(a===0x3||a==='RateGross')return'RateGross';if(a===0x4||a==='Formula')return'Formula';return'Amount';}export function projectRelationshipFacts(b,c){const f=c['toLowerCase'](),g=outEdges(b,f,'eoa.permission'),h=[],i=new Map();for(const C of g){const D=b['nodes']['get'](C['to']);if(!D)continue;const E=outEdges(b,D['id'],'permission.entity')['map'](H=>({'address':H['to'],'perm_indices':H['payload']?.['permIndices']??[]})),F=managedTargets(b,D['id']),G=F['filter'](H=>!!H['objectType'])['map'](H=>({'object_type':H['objectType'],'address':H['id']}));for(const H of G){if(i['size']>=MAX_MANAGED_TOTAL)break;i['set'](H['address']['toLowerCase'](),H);}h['push']({'address':D['id'],'owner':fld(D,'owner')??'','admins':addrList(D,'admin'),'entities':E,'anchor_role_bits':C['payload']?.['roleBits'],'managed_objects':G});}const j=I=>[...i['values']()]['filter'](J=>J['object_type']===I)['map'](J=>J['address']),k=j('Service'),l=j('Machine')['slice'](0x0,MAX_MACHINES),n=j('Demand')['slice'](0x0,MAX_DEMANDS),p=j('Contact')['slice'](0x0,MAX_CONTACTS),q=j('Arbitration'),r=new Map();for(const I of outEdges(b,f,'eoa.order'))r['set'](I['to'],'buyer');for(const J of k){for(const K of outEdges(b,J,'service.order'))r['set'](K['to'],'merchant');}const t=[],u={};for(const L of[...r['keys']()]['slice'](0x0,MAX_ORDERS)){const M=rawOf(b,L);if(!M||M['objectType']!=='Order')continue;const N=fld(M,'service')??'';t['push']({'address':M['id'],'owner':fld(M,'owner')??fld(M,'builder')??'','agents':addrList(M,'agent'),'service':N,'amount':fld(M,'amount'),'allocation':fld(M,'allocation'),'dispute_arbitrations':addrList(M,'dispute'),'claimed_by':fld(M,'claimed_by')??null});if(N){const O=rawOf(b,N),P=outEdges(b,N,'service.permission')[0x0]?.['to'],Q=rawOf(b,P),R=fld(Q,'owner');if(R)u[O?.['id']??N['toLowerCase']()]=R;}}const v=n['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'demand.permission')[0x0]?.['to'],V=fld(rawOf(b,U),'owner')??'',W=outEdges(b,S,'demand.presenter')['map'](Y=>({'address':Y['to'],'service':typeof Y['payload']?.['service']==='string'?Y['payload']['service']:undefined,'acceptance_score':typeof Y['payload']?.['score']==='number'?Y['payload']['score']:undefined,'scoredAt':typeof Y['payload']?.['feedbackTime']==='number'&&Y['payload']['feedbackTime']>0x0?Y['payload']['feedbackTime']:typeof Y['payload']?.['time']==='number'&&Y['payload']['time']>0x0?Y['payload']['time']:undefined})),X=(fld(T,'guards')??[])['map'](Y=>typeof Y==='string'?Y:Y?.['guard'])['filter'](Y=>typeof Y==='string');return{'address':T['id'],'owner':V,'presenters':W,'rewards':addrList(T,'rewards'),'guards':X};}),w=[...new Set(t['map'](S=>S['allocation'])['filter'](S=>!!S))]['slice'](0x0,MAX_ALLOCATIONS),x=w['map'](S=>{const T=rawOf(b,S),U=fld(T,'allocators')??rootOf(T['raw']),V=Array['isArray'](U)?U:Array['isArray'](U?.['allocators'])?U['allocators']:[],W=V['flatMap'](X=>(Array['isArray'](X?.['sharing'])?X['sharing']:[])['map'](Y=>({'who':Y?.['who']??Y,'mode':mapMode(Y?.['mode']),'sharing':Y?.['sharing']!=null?String(Y['sharing']):undefined,'guard':typeof X?.['guard']==='string'?X['guard']:undefined})));return{'address':T['id'],'owner':fld(T,'owner'),'sharing':W};}),y=p['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'contact.permission')[0x0]?.['to'],V=fld(rawOf(b,U),'owner')??'',W=(fld(T,'ims')??[])['map'](X=>typeof X==='string'?X:X?.['at'])['filter'](X=>typeof X==='string');return{'address':T['id'],'ims':W,'owner':V};}),z=l['map'](S=>{const T=rawOf(b,S),U=outEdges(b,S,'machine.permission')[0x0]?.['to'],V=S['toLowerCase']()+'::node::',W=b['edges']['filter'](X=>X['schema']==='wf.transition'&&X['from']['startsWith'](V))['map'](X=>({'node':X['payload']?.['prevNode']??'','next_node':X['payload']?.['node']??'','forward_name':X['payload']?.['forward']??'','named_operator':X['payload']?.['namedOperator']??null,'permission_index':X['payload']?.['permissionIndex']??null,'guard':X['payload']?.['guard']??null}));return{'address':T['id'],'permission_address':U,'forwards':W};}),A=new Map();for(const S of t){const T=r['get'](S['address']['toLowerCase']())??'buyer';for(const U of S['dispute_arbitrations']??[])A['set'](U['toLowerCase'](),T);}const B=[];for(const [V,W]of A){const X=rawOf(b,V);if(!X)continue;const Y=(fld(X,'voted')??[])['map'](Z=>({'address':typeof Z?.['voter']==='string'?Z['voter']:'','weight':typeof Z?.['weight']==='number'?Z['weight']:undefined}))['filter'](Z=>Z['address']['length']>0x0);B['push']({'address':X['id'],'object_kind':'case','voters':Y,'order':fld(X,'order'),'arbitration':fld(X,'arbitration'),'anchor_side':W,'bound_services':[]});}for(const Z of q['slice'](0x0,MAX_ARB_SERVICES)){if(A['has'](Z['toLowerCase']()))continue;B['push']({'address':Z,'object_kind':'service','voters':[],'bound_services':[]});}return{'anchor':f,'permissions':h,'machines':z,'orders':t,'demands':v,'allocations':x,'contacts':y,'arbitrations':B,'service_owners':u};}
@@ -17,6 +17,7 @@ export interface ParsedMachineNode {
17
17
  export declare const QUERY_OBJECTS_BATCH = 50;
18
18
  export declare function lastUnresolvedInputs(network?: string, noCache?: boolean): string[];
19
19
  export declare function batchQueryObjectsByIds(ids: string[], network?: string, noCache?: boolean): Promise<any[]>;
20
+ export declare function batchQueryObjectsByRef(ids: string[], network?: string, noCache?: boolean): Promise<Map<string, any>>;
20
21
  export interface TableFieldEntry {
21
22
  key: string;
22
23
  objectId: string;
@@ -1 +1 @@
1
- import{ObjectType,objectTypeFromAddress}from'@wowok/wowok';import{MAX_OBJECTS_PER_QUERY}from'./dataplane.js';import{SdkDataPlane}from'./sdk-dataplane.js';export const QUERY_OBJECTS_BATCH=MAX_OBJECTS_PER_QUERY;const planes=new Map();function batchPlane(a,b){const c=(a??'')+'|'+(b?0x1:0x0);let d=planes['get'](c);return!d&&(d=new SdkDataPlane(a??undefined,{'noCache':b}),planes['set'](c,d)),d;}export function lastUnresolvedInputs(a,b){return batchPlane(a,b)['unresolvedInputs'];}function parentToken(a){return String(a)['toLowerCase']();}export async function batchQueryObjectsByIds(a,b,c){const d=await batchPlane(b,c)['getObjects'](a);return[...d['values']()];}export async function fetchTableEntries(a,b){const {items:c,truncated:d}=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit'],'fetchValues':![]});return{'entries':c['map'](f=>({'key':f['key'],'objectId':f['objectId']})),'truncated':d};}export async function fetchAllFieldObjectIds(a,b,c){const {entries:d}=await fetchTableEntries(a,{'network':b,'noCache':c});return d['map'](f=>f['objectId']);}export async function batchQueryTableItems(a,b){const c=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit']});return{'items':c['items'],'truncated':c['truncated']};}export async function fetchMachineNodes(a,b,c){const d=await batchQueryObjectsByIds([a],b,c),e=d[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const {items:g}=await batchQueryTableItems(f,{'network':b,'noCache':c});return g['map'](h=>h['object'])['filter'](h=>h?.['type']==='TableItem_MachineNode')['map'](h=>{const i=h?.['data']??h,j=typeof i?.['name']==='string'?i['name']:'',k=Array['isArray'](i?.['value'])?i['value']:Array['isArray'](i?.['pairs'])?i['pairs']:[];if(!j)return null;return{'name':j,'pairs':k['map'](l=>({'prev_node':String(l?.['prev_node']??''),'threshold':Number(l?.['threshold']??0x0),'forwards':Array['isArray'](l?.['forwards'])?l['forwards']['map'](m=>{const n=typeof m?.['guard']==='object'&&m?.['guard']!==null?m['guard']['guard']??undefined:typeof m?.['guard']==='string'?m['guard']:undefined;return{'name':String(m?.['name']??''),'weight':Number(m?.['weight']??0x0),'namedOperator':m?.['namedOperator']!==undefined&&m?.['namedOperator']!==null?String(m['namedOperator']):undefined,'permissionIndex':m?.['permissionIndex']!==undefined&&m?.['permissionIndex']!==null?Number(m['permissionIndex']):undefined,'guard':n};}):[]}))};})['filter'](h=>h!==null);}export async function batchReadAddressKeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e);}export async function batchReadKeyedItems(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'strict':!![]});}export async function batchReadU64KeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f))['filter'](f=>f!==''&&Number['isFinite'](Number(f))))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'keyType':'u64'});}export const ENTITY_REGISTRAR_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aab';export const ENTITY_LINKER_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aaa';export async function batchFetchEntityRegistrar(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_REGISTRAR_OBJECT_ID,a,b,c);}catch{return new Map();}}export async function batchFetchEntityLinker(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_LINKER_OBJECT_ID,a,b,c);}catch{return new Map();}}export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_PERMISSION_ROLES={'OWNER':0x1,'ADMIN':0x2,'ENTITY':0x4};export async function batchFetchEntityPermission(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_PERMISSION_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byPermission':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['permission']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'permission':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byPermission':m});}return f;}export async function fetchEntityPermission(a,b,c){try{const d=await batchFetchEntityPermission([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export async function batchFetchEntityContact(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_CONTACT_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byContact':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=String(n?.['contact']??'')['toLowerCase'](),p=Number(n?.['time']??0x0);o&&(l['push']({'contact':o,'time':p}),m['set'](o,(m['get'](o)??0x0)||p));}f['set'](i,{'items':l,'byContact':m});}return f;}export async function fetchEntityContact(a,b,c){try{const d=await batchFetchEntityContact([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_ORDER_OBJECT_ID='0xaa8';export const ENTITY_ORDER_ROLES={'OWNER':0x1,'AGENT':0x2};export async function batchFetchEntityOrder(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_ORDER_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byOrder':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['order']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'order':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byOrder':m});}return f;}export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';export const LINKER_RING_LIMIT=0x1450;export function ringWindowSaturated(a){return a>=LINKER_RING_LIMIT;}export async function batchFetchObjectLinker(b,c,e,f){const g=new Map(),h=await batchReadKeyedItems(b,c,e,f);for(const i of new Set((c??[])['map'](j=>String(j)['toLowerCase']()))){g['set'](i,{'items':[],'byWho':new Map()});}for(const [j,k]of h){const l=k,m=[],n=new Map();for(const o of Array['isArray'](l?.['items'])?l['items']:[]){const p=String(o?.['who']??'')['toLowerCase'](),q=Number(o?.['time']??0x0);p&&(m['push']({'who':p,'time':q}),n['set'](p,q));}g['set'](j,{'items':m,'byWho':n});}return g;}export function batchFetchObjectLinkerCore(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function batchFetchObjectLinkerTx(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}async function fetchObjectLinker(a,b,c,d){try{const e=await batchFetchObjectLinker(a,[b],c,d);return e['get'](String(b)['toLowerCase']());}catch{return undefined;}}export function fetchObjectLinkerCore(a,b,c){return fetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function fetchObjectLinkerTx(a,b,c){return fetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}export async function fetchServiceOrders(a,b,c){const d=await fetchObjectLinkerTx(a,b,c);if(!d)return undefined;const e=ringWindowSaturated(d['items']['length']),f=d['items']['filter'](g=>objectTypeFromAddress(g['who'])===ObjectType['Order']);return{'items':f,'byWho':new Map(f['map'](g=>[g['who'],g['time']])),'ring_saturated':e};}export async function fetchPermissionContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0],g=f?.['data']??f,h=new Set((g?.['admin']??[])['map'](k=>String(k)['toLowerCase']())),i=new Map(),{items:j}=await batchQueryTableItems(a,{'network':b,'noCache':c});for(const k of j){const l=k['object'],m=l?.['data']??l;m?.['address']!=null&&Array['isArray'](m['perm'])&&i['set'](String(m['address'])['toLowerCase'](),new Set(m['perm']['map'](n=>Number(n))));}return{'admin':h,'table':i};}catch{return undefined;}}export async function fetchOrderContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0];if(f?.['type']!=='Order'&&f?.['data']?.['type']!=='Order')return undefined;const g=f?.['data']??f;return{'builder':String(g['builder']??g['owner']??''),'agent':new Set((g['agent']??[])['map'](h=>String(h)['toLowerCase']()))};}catch{return undefined;}}
1
+ import{ObjectType,objectTypeFromAddress,LocalMark}from'@wowok/wowok';import{MAX_OBJECTS_PER_QUERY}from'./dataplane.js';import{SdkDataPlane}from'./sdk-dataplane.js';export const QUERY_OBJECTS_BATCH=MAX_OBJECTS_PER_QUERY;const planes=new Map();function batchPlane(a,b){const c=(a??'')+'|'+(b?0x1:0x0);let d=planes['get'](c);return!d&&(d=new SdkDataPlane(a??undefined,{'noCache':b}),planes['set'](c,d)),d;}export function lastUnresolvedInputs(a,b){return batchPlane(a,b)['unresolvedInputs'];}function parentToken(a){return String(a)['toLowerCase']();}export async function batchQueryObjectsByIds(a,b,c){const d=await batchPlane(b,c)['getObjects'](a);return[...d['values']()];}export async function batchQueryObjectsByRef(a,b,c){const d=a['map'](h=>String(h)['toLowerCase']());let e=d['map'](()=>null);try{e=await LocalMark['Instance']()['get_many_address'](d);}catch{}const f=await batchQueryObjectsByIds(d,b,c),g=new Map();for(const h of f){const j=String(h?.['object']??'')['toLowerCase']();if(j==='')continue;for(let k=0x0;k<d['length'];k++){if(g['has'](d[k]))continue;const l=e[k]?String(e[k])['toLowerCase']():'';if(d[k]===j||l===j)g['set'](d[k],h);}}return g;}export async function fetchTableEntries(a,b){const {items:c,truncated:d}=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit'],'fetchValues':![]});return{'entries':c['map'](f=>({'key':f['key'],'objectId':f['objectId']})),'truncated':d};}export async function fetchAllFieldObjectIds(a,b,c){const {entries:d}=await fetchTableEntries(a,{'network':b,'noCache':c});return d['map'](f=>f['objectId']);}export async function batchQueryTableItems(a,b){const c=await batchPlane(b?.['network'],b?.['noCache'])['getTable'](a,{'maxItems':b?.['maxItems'],'pageLimit':b?.['limit']});return{'items':c['items'],'truncated':c['truncated']};}export async function fetchMachineNodes(a,b,c){const d=await batchQueryObjectsByIds([a],b,c),e=d[0x0],f=e?.['object']??(typeof a==='string'&&a['startsWith']('0x')?a:undefined);if(!f)return[];const {items:g}=await batchQueryTableItems(f,{'network':b,'noCache':c});return g['map'](h=>h['object'])['filter'](h=>h?.['type']==='TableItem_MachineNode')['map'](h=>{const i=h?.['data']??h,j=typeof i?.['name']==='string'?i['name']:'',k=Array['isArray'](i?.['value'])?i['value']:Array['isArray'](i?.['pairs'])?i['pairs']:[];if(!j)return null;return{'name':j,'pairs':k['map'](l=>({'prev_node':String(l?.['prev_node']??''),'threshold':Number(l?.['threshold']??0x0),'forwards':Array['isArray'](l?.['forwards'])?l['forwards']['map'](m=>{const n=typeof m?.['guard']==='object'&&m?.['guard']!==null?m['guard']['guard']??undefined:typeof m?.['guard']==='string'?m['guard']:undefined;return{'name':String(m?.['name']??''),'weight':Number(m?.['weight']??0x0),'namedOperator':m?.['namedOperator']!==undefined&&m?.['namedOperator']!==null?String(m['namedOperator']):undefined,'permissionIndex':m?.['permissionIndex']!==undefined&&m?.['permissionIndex']!==null?Number(m['permissionIndex']):undefined,'guard':n};}):[]}))};})['filter'](h=>h!==null);}export async function batchReadAddressKeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e);}export async function batchReadKeyedItems(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f)['toLowerCase']())['filter'](f=>f['startsWith']('0x')))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'strict':!![]});}export async function batchReadU64KeyedFields(a,b,c,d){const e=[...new Set((b??[])['map'](f=>String(f))['filter'](f=>f!==''&&Number['isFinite'](Number(f))))];return batchPlane(c,d)['getKeyedFields'](parentToken(a),e,{'keyType':'u64'});}export const ENTITY_REGISTRAR_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aab';export const ENTITY_LINKER_OBJECT_ID='0x0000000000000000000000000000000000000000000000000000000000000aaa';export async function batchFetchEntityRegistrar(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_REGISTRAR_OBJECT_ID,a,b,c);}catch{return new Map();}}export async function batchFetchEntityLinker(a,b,c){try{return await batchReadAddressKeyedFields(ENTITY_LINKER_OBJECT_ID,a,b,c);}catch{return new Map();}}export const ENTITY_PERMISSION_OBJECT_ID='0xaad';export const ENTITY_PERMISSION_ROLES={'OWNER':0x1,'ADMIN':0x2,'ENTITY':0x4};export async function batchFetchEntityPermission(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_PERMISSION_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byPermission':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['permission']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'permission':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byPermission':m});}return f;}export async function fetchEntityPermission(a,b,c){try{const d=await batchFetchEntityPermission([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_CONTACT_OBJECT_ID='0xaa9';export async function batchFetchEntityContact(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_CONTACT_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byContact':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=String(n?.['contact']??'')['toLowerCase'](),p=Number(n?.['time']??0x0);o&&(l['push']({'contact':o,'time':p}),m['set'](o,(m['get'](o)??0x0)||p));}f['set'](i,{'items':l,'byContact':m});}return f;}export async function fetchEntityContact(a,b,c){try{const d=await batchFetchEntityContact([a],b,c);return d['get'](String(a)['toLowerCase']());}catch{return undefined;}}export const ENTITY_ORDER_OBJECT_ID='0xaa8';export const ENTITY_ORDER_ROLES={'OWNER':0x1,'AGENT':0x2};export async function batchFetchEntityOrder(b,c,e){const f=new Map(),g=await batchReadKeyedItems(ENTITY_ORDER_OBJECT_ID,b,c,e);for(const h of new Set((b??[])['map'](i=>String(i)['toLowerCase']()))){f['set'](h,{'items':[],'byOrder':new Map()});}for(const [i,j]of g){const k=j,l=[],m=new Map();for(const n of Array['isArray'](k?.['items'])?k['items']:[]){const o=Number(n?.['role']??0x0),p=String(n?.['order']??'')['toLowerCase'](),q=Number(n?.['time']??0x0);p&&(l['push']({'role':o,'order':p,'time':q}),m['set'](p,(m['get'](p)??0x0)|o));}f['set'](i,{'items':l,'byOrder':m});}return f;}export const OBJECT_LINKER_CORE_OBJECT_ID='0xaae';export const OBJECT_LINKER_TX_OBJECT_ID='0xaaf';export const LINKER_RING_LIMIT=0x1450;export function ringWindowSaturated(a){return a>=LINKER_RING_LIMIT;}export async function batchFetchObjectLinker(b,c,e,f){const g=new Map(),h=await batchReadKeyedItems(b,c,e,f);for(const i of new Set((c??[])['map'](j=>String(j)['toLowerCase']()))){g['set'](i,{'items':[],'byWho':new Map()});}for(const [j,k]of h){const l=k,m=[],n=new Map();for(const o of Array['isArray'](l?.['items'])?l['items']:[]){const p=String(o?.['who']??'')['toLowerCase'](),q=Number(o?.['time']??0x0);p&&(m['push']({'who':p,'time':q}),n['set'](p,q));}g['set'](j,{'items':m,'byWho':n});}return g;}export function batchFetchObjectLinkerCore(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function batchFetchObjectLinkerTx(a,b,c){return batchFetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}async function fetchObjectLinker(a,b,c,d){try{const e=await batchFetchObjectLinker(a,[b],c,d);return e['get'](String(b)['toLowerCase']());}catch{return undefined;}}export function fetchObjectLinkerCore(a,b,c){return fetchObjectLinker(OBJECT_LINKER_CORE_OBJECT_ID,a,b,c);}export function fetchObjectLinkerTx(a,b,c){return fetchObjectLinker(OBJECT_LINKER_TX_OBJECT_ID,a,b,c);}export async function fetchServiceOrders(a,b,c){const d=await fetchObjectLinkerTx(a,b,c);if(!d)return undefined;const e=ringWindowSaturated(d['items']['length']),f=d['items']['filter'](g=>objectTypeFromAddress(g['who'])===ObjectType['Order']);return{'items':f,'byWho':new Map(f['map'](g=>[g['who'],g['time']])),'ring_saturated':e};}export async function fetchPermissionContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0],g=f?.['data']??f,h=new Set((g?.['admin']??[])['map'](k=>String(k)['toLowerCase']())),i=new Map(),{items:j}=await batchQueryTableItems(a,{'network':b,'noCache':c});for(const k of j){const l=k['object'],m=l?.['data']??l;m?.['address']!=null&&Array['isArray'](m['perm'])&&i['set'](String(m['address'])['toLowerCase'](),new Set(m['perm']['map'](n=>Number(n))));}return{'admin':h,'table':i};}catch{return undefined;}}export async function fetchOrderContext(a,b,c){try{const e=await batchQueryObjectsByIds([a],b,c),f=e[0x0];if(f?.['type']!=='Order'&&f?.['data']?.['type']!=='Order')return undefined;const g=f?.['data']??f;return{'builder':String(g['builder']??g['owner']??''),'agent':new Set((g['agent']??[])['map'](h=>String(h)['toLowerCase']()))};}catch{return undefined;}}
@@ -9,6 +9,7 @@ export declare class Harness {
9
9
  recover(errorCode: string, operationId: string, context?: {
10
10
  operation_type?: string;
11
11
  data?: Record<string, unknown>;
12
+ retryable?: boolean;
12
13
  }): RecoveryAction;
13
14
  resetRecovery(operationId: string): void;
14
15
  getBackoffDelay(attempt: number): number;
@@ -10,8 +10,9 @@ export interface RecoveryRule {
10
10
  }
11
11
  export declare const RECOVERY_RULES: Record<string, RecoveryRule>;
12
12
  export declare function resetAttempts(operationId: string): void;
13
- export declare function recover(errorCode: string, operationId: string, _context?: {
13
+ export declare function recover(errorCode: string, operationId: string, context?: {
14
14
  operation_type?: string;
15
15
  data?: Record<string, unknown>;
16
+ retryable?: boolean;
16
17
  }): RecoveryAction;
17
18
  export declare function getBackoffDelay(attempt: number): number;
@@ -1 +1 @@
1
- export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'insufficient_gas':{'error_code':'insufficient_gas','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Gas\x20exhausted\x20—\x20the\x20transaction\x20failed\x20deterministically\x20and\x20did\x20NOT\x20commit\x20on-chain\x20(no\x20state\x20changed;\x20commit-state\x20verification\x20is\x20NOT\x20needed).\x201.\x20Raise\x20the\x20gas_budget\x20parameter\x20above\x20the\x20failed\x20transaction\x27s\x20gas_used\x202.\x20If\x20the\x20account\x20balance\x20cannot\x20cover\x20any\x20budget,\x20fund\x20the\x20signing\x20account\x20with\x20gas\x20tokens\x20first\x203.\x20Resubmit\x20as\x20a\x20FRESH\x20call\x20—\x20do\x20NOT\x20replay\x20the\x20same\x20transaction','user_prompt':'The\x20transaction\x20ran\x20out\x20of\x20gas\x20and\x20did\x20not\x20commit\x20on-chain.\x20Increase\x20the\x20gas\x20budget\x20(or\x20fund\x20the\x20account\x20with\x20gas)\x20and\x20submit\x20a\x20fresh\x20transaction\x20—\x20retrying\x20unchanged\x20will\x20fail\x20the\x20same\x20way.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'wip_storage_rejected':{'error_code':'wip_storage_rejected','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx\x20—\x20deterministic\x20client-side\x20fault,\x20retrying\x20unchanged\x20fails\x20identically).\x20400:\x20malformed\x20body\x20or\x20failed\x20WIP\x20validation\x20—\x20re-generate\x20via\x20wip_file\x20type=\x27generate\x27\x20401:\x20re-sign\x20with\x20a\x20fresh\x20nonce\x20inside\x20the\x20timestamp\x20window\x20403:\x20check\x20storage\x20service\x20configuration\x20404:\x20file\x20does\x20not\x20exist\x20—\x20re-upload\x20409:\x20quota\x20—\x20delete\x20old\x20files\x20via\x20wip_file\x20type=\x27list\x27\x20then\x20delete\x20413:\x20compress\x20images\x20(each\x20<=\x202MB,\x20total\x20<=\x2010MB)\x20and\x20regenerate','user_prompt':'The\x20WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx).\x20Fix\x20the\x20specific\x20fault\x20(re-generate/re-sign/re-upload\x20per\x20the\x20status\x20code)\x20and\x20retry\x20—\x20do\x20not\x20retry\x20unchanged.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once\x20—\x20for\x20a\x20FIRST-EVER\x20transaction\x20on\x20a\x20fresh\x20account\x20make\x20that\x20resubmission\x20with\x20env.no_auto_register=true\x20and\x20SAY\x20SO\x20(the\x20SDK\x20silently\x20appends\x20an\x20entity\x20registration\x20to\x20a\x20first\x20business\x20call;\x20if\x20that\x20appended\x20leg\x20was\x20the\x20failing\x20leg\x20the\x20skip\x20lets\x20the\x20call\x20through\x20—\x20ziroom-mn-261013\x20live\x20case;\x20if\x20the\x20resubmission\x20aborts,\x20the\x20envelope\x20now\x20names\x20the\x20abort\x20—\x20re-enable\x20auto\x20registration\x20and\x20retry).\x204.\x20If\x20the\x20reported\x20digest\x20does\x20not\x20resolve\x20or\x20the\x20failure\x20repeats,\x20STOP\x20looping\x20on\x20digest\x20checks\x20and\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20—\x20the\x20simulation\x20surfaces\x20the\x20real\x20failure\x20(exact\x20Move\x20abort)\x20without\x20gas\x20or\x20duplicate\x20risk.\x205.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x206.\x20M-K2\x20replay\x20discipline:\x20a\x20FAILED\x20receipt\x20is\x20final\x20—\x20its\x20digest\x20is\x20consumed\x20and\x20replaying\x20the\x20same\x20bytes\x20returns\x20the\x20same\x20failure\x20forever;\x20fix\x20the\x20cause\x20(usually\x20funding)\x20and\x20build\x20a\x20FRESH\x20transaction.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first\x205.\x20A\x20TIME-window\x20rejection\x20may\x20simply\x20be\x20EARLY:\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20to\x20probe\x20the\x20window\x20for\x20free\x20(guard\x20rejections\x20do\x20NOT\x20consume\x20the\x20total\x20retry\x20budget;\x20only\x20the\x20per-code\x20cap\x20of\x202\x20applies)','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.\x20A\x20time-window\x20rejection\x20may\x20simply\x20be\x20early:\x20probe\x20the\x20window\x20with\x20env.dry_run=true\x20(free\x20—\x20guard\x20rejections\x20do\x20not\x20consume\x20the\x20total\x20retry\x20budget).'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'move_abort_unmapped':{'error_code':'move_abort_unmapped','strategy':'stop','max_attempts':0x1,'automation':'manual','detail':'The\x20chain\x27s\x20business\x20logic\x20aborted\x20and\x20the\x20(module,\x20abort\x20code)\x20pair\x20has\x20no\x20local\x20mapping.\x20Read\x20the\x20module\x20and\x20abort\x20code\x20from\x20move_abort_info\x20/\x20the\x20message\x20(rendered\x20as\x20\x27abort\x20(N)\x27),\x20resolve\x20their\x20meaning\x20from\x20the\x20module\x27s\x20documentation\x20or\x20the\x20wowok-tools\x20Skill,\x20fix\x20the\x20business\x20cause,\x20and\x20issue\x20a\x20NEW\x20call.\x20Do\x20NOT\x20restart\x20the\x20server\x20and\x20do\x20NOT\x20retry\x20the\x20identical\x20call\x20—\x20it\x20aborts\x20deterministically.','user_prompt':'The\x20operation\x20was\x20rejected\x20by\x20the\x20chain\x27s\x20business\x20logic\x20and\x20its\x20abort\x20code\x20is\x20not\x20mapped\x20locally.\x20The\x20module\x20name\x20and\x20abort\x20code\x20in\x20the\x20error\x20are\x20authoritative\x20—\x20review\x20them\x20(and\x20the\x20object\x20state\x20via\x20query_toolkit)\x20before\x20adjusting\x20anything.'},'missing_data':{'error_code':'missing_data','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'A\x20guard\x20rule\x20read\x20a\x20keyed\x20table\x20row\x20that\x20does\x20NOT\x20exist\x20(repository.data\x20/\x20oracle\x20entry)\x20and\x20the\x20verifier\x20surfaced\x20it\x20as\x20a\x20location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20no\x20abort\x20code,\x20because\x20the\x20framework\x20cannot\x20express\x20\x27row\x20absent\x27\x20as\x20an\x20abort.\x20This\x20is\x20a\x20DATA\x20problem:\x201.\x20Identify\x20the\x20repository\x20and\x20key\x20the\x20guard\x20rule\x20reads\x20(guard2file\x20/\x20analyze_guard_semantics\x20on\x20the\x20guard\x20source)\x202.\x20Have\x20the\x20row\x27s\x20producer\x20write\x20it\x20(e.g.\x20an\x20oracle\x20timestamp\x20like\x20checkin_ts),\x20or\x20add\x20it\x20with\x20repository\x20data_add\x20(data_add.name\x20must\x20match\x20a\x20policy\x20rule\x20name)\x203.\x20Retry\x20the\x20SAME\x20call\x20unchanged\x20—\x20a\x20dry_run\x20that\x20turns\x20clean\x20after\x20the\x20row\x20exists\x20confirms\x20the\x20diagnosis','user_prompt':'A\x20guard\x20rule\x20references\x20a\x20data\x20row\x20that\x20has\x20not\x20been\x20written\x20yet\x20(location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20NOT\x20a\x20network\x20problem).\x20Identify\x20the\x20repository\x20row\x20the\x20guard\x20expects\x20(guard2file\x20/\x20analyze_guard_semantics),\x20write\x20it\x20with\x20repository\x20data_add\x20(or\x20let\x20its\x20producer\x20write\x20it),\x20then\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}const BUDGET_EXEMPT_CODES=new Set(['guard_rejected']);function getBudgetAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const [d,e]of b){if(!BUDGET_EXEMPT_CODES['has'](d))c+=e;}return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getBudgetAttempts(b),g=getAttemptCount(b,a);if(d['max_attempts']<=0x1||d['strategy']==='stop')return{'strategy':d['strategy'],'should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.\x20Attempts\x20recorded\x20for\x20this\x20operation\x20id:\x20'+([...(operationAttempts['get'](b)??new Map())['entries']()]['map'](([i,j])=>i+':'+j)['join'](',\x20')||'none')+'.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a);return{'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
1
+ export const RECOVERY_RULES={'insufficient_balance':{'error_code':'insufficient_balance','strategy':'claim_faucet','max_attempts':0x3,'automation':'semi','detail':'1.\x20Testnet:\x20claim\x20WOW\x20from\x20the\x20faucet\x202.\x20Mainnet:\x20transfer\x20ETH/USDT/USDC/WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge\x20(query\x20active\x20EVM\x20account\x20→\x20top\x20up\x20from\x20external\x20wallet\x20→\x20confirm\x20→\x20cross-chain)\x203.\x20Point\x20the\x20user\x20to\x20the\x20live\x20airdrop\x20page\x20(https://wowok.net/airdrop.html)\x20for\x20the\x20current\x20round\x204.\x20Retry\x20original\x20operation.\x20NOTE:\x20this\x20rule\x20is\x20for\x20the\x20SIGNING\x20ACCOUNT\x27s\x20wallet/gas\x20only\x20—\x20an\x20on-chain\x20POOL\x20shortage\x20(reward/allocation)\x20classifies\x20as\x20pool_shortage,\x20never\x20here','user_prompt':'Insufficient\x20balance\x20for\x20gas\x20or\x20operation.\x20How\x20to\x20obtain\x20WOW\x20tokens:\x20(1)\x20Testnet\x20—\x20claim\x20WOW\x20from\x20the\x20faucet\x20(https://faucet.testnet.wowok.net);\x20all\x20merchant\x20and\x20order\x20testing\x20can\x20use\x20WOW\x20as\x20the\x20payment\x20token.\x20(2)\x20Mainnet\x20—\x20transfer\x20ETH\x20/\x20USDT\x20/\x20USDC\x20/\x20WBTC\x20via\x20the\x20ETH\x20mainnet\x20cross-chain\x20bridge:\x20first\x20query\x20the\x20active\x20EVM\x20account\x20(bridge_operation\x20query_active_evm_account,\x20auto-generated\x20on\x20first\x20use),\x20then\x20transfer\x20from\x20an\x20external\x20wallet\x20(e.g.\x20MetaMask)\x20to\x20that\x20address,\x20confirm\x20the\x20balance\x20arrived,\x20and\x20cross-chain\x20to\x20WOW\x20mainnet\x20(bridge_operation\x20cross_chain_evm_to_wow).\x20(3)\x20WOW\x20airdrop:\x20current\x20round\x20status,\x20pool\x20and\x20eligibility\x20are\x20published\x20live\x20at\x20https://wowok.net/airdrop.html\x20(referral:\x20https://wowok.net/refer.html)\x20—\x20open\x20that\x20page\x20rather\x20than\x20assuming\x20a\x20round\x20is\x20live\x20or\x20closed.\x20Query\x20wowok_buildin_info\x20with\x20info=\x27funding\x20guidance\x27\x20for\x20the\x20canonical\x20funding\x20guidance.'},'pool_shortage':{'error_code':'pool_shortage','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'An\x20on-chain\x20POOL\x20cannot\x20cover\x20the\x20operation\x20(reward.move:243\x20abort\x206\x20/\x20'+'allocation.move:509\x20abort\x207)\x20—\x20a\x20pool\x20funding\x20problem,\x20NOT\x20the\x20caller\x27s\x20wallet;\x20a\x20faucet\x20claim\x20will\x20NOT\x20help\x20and\x20re-sending\x20the\x20rail\x20unchanged\x20changes\x20nothing.\x201.\x20Reward\x20pool:\x20the\x20reward\x20ISSUER\x20tops\x20it\x20up\x20with\x20reward\x20coin_add\x20(permission\x20153)\x20—\x20the\x20claim\x20key\x20slot\x20is\x20written\x20BEFORE\x20the\x20balance\x20assert\x20and\x20the\x20abort\x20rolls\x20it\x20back,\x20so\x20NOTHING\x20was\x20consumed;\x20the\x20identical\x20claim\x20succeeds\x20after\x20the\x20top-up\x20(mainnet-proven,\x20T14).\x202.\x20Allocation\x20pool:\x20the\x20payer\x20side\x20funds\x20the\x20order/allocation\x20first\x20(order\x20renew,\x20payment\x20create\x20into\x20the\x20allocation),\x20then\x20re-runs\x20the\x20rail;\x20if\x20the\x20pool\x20is\x20drained\x20because\x20the\x20rail\x20ALREADY\x20paid\x20(balance\x200,\x20once-slot\x20consumed),\x20verify\x20via\x20the\x20Payment\x20record\x20instead\x20of\x20retrying.\x203.\x20As\x20the\x20BUYER:\x20report\x20the\x20shortage\x20to\x20the\x20merchant\x20—\x20never\x20fund\x20a\x20pool\x20you\x20do\x20not\x20own','user_prompt':'The\x20on-chain\x20pool\x20backing\x20this\x20operation\x20is\x20short\x20of\x20funds.\x20The\x20pool\x27s\x20owner\x20must\x20top\x20it\x20up\x20(reward\x20coin_add\x20/\x20allocation\x20funding)\x20—\x20a\x20faucet\x20claim\x20will\x20not\x20help.\x20As\x20the\x20buyer,\x20ask\x20the\x20merchant\x20to\x20fund\x20the\x20pool.'},'stock_exhausted':{'error_code':'stock_exhausted','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Merchant-side\x20inventory\x20shortfall\x20(Move\x20service:16\x20E_STOCK_NOT_ENOUGH)\x20—\x20NOT\x20a\x20buyer\x20balance\x20problem,\x20so\x20a\x20faucet\x20claim\x20will\x20NOT\x20help.\x201.\x20Reduce\x20the\x20purchase\x20quantity\x20to\x20the\x20item\x27s\x20remaining\x20stock\x202.\x20Pick\x20another\x20sale\x20item\x203.\x20Ask\x20the\x20merchant\x20to\x20restock,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x27s\x20stock\x20is\x20exhausted\x20for\x20the\x20requested\x20quantity.\x20Reduce\x20the\x20quantity,\x20choose\x20another\x20item,\x20or\x20ask\x20the\x20merchant\x20to\x20restock.'},'sale_suspended':{'error_code':'sale_suspended','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20merchant\x20suspended\x20this\x20sale\x20item\x20(Move\x20service:34\x20E_SALE_SUSPENDED).\x201.\x20Pick\x20another\x20(non-suspended)\x20item\x202.\x20Contact\x20the\x20merchant\x20to\x20resume\x20the\x20sale,\x20then\x20retry','user_prompt':'The\x20sale\x20item\x20is\x20suspended\x20by\x20the\x20merchant.\x20Please\x20choose\x20another\x20item\x20or\x20contact\x20the\x20merchant.'},'discount_invalid':{'error_code':'discount_invalid','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'The\x20discount\x20is\x20outside\x20its\x20[time_start,\x20time_end]\x20validity\x20window\x20(Move\x20service:35\x20E_DISCOUNT_TIME_INVALID).\x201.\x20Retry\x20without\x20the\x20discount\x202.\x20Ask\x20the\x20merchant\x20for\x20a\x20fresh\x20discount,\x20then\x20retry','user_prompt':'The\x20discount\x20is\x20not\x20valid\x20at\x20the\x20current\x20time\x20(outside\x20its\x20validity\x20window).\x20Buy\x20without\x20the\x20discount\x20or\x20ask\x20the\x20merchant\x20for\x20a\x20new\x20one.'},'rate_limit':{'error_code':'rate_limit','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Rate\x20limit\x20hit\x20(HTTP\x20429).\x20Exponential\x20backoff\x20retry:\x202s\x20/\x204s\x20/\x208s\x20/\x2016s\x20/\x2032s.\x20Avoid\x20parallel\x20calls\x20while\x20the\x20limit\x20window\x20is\x20active.'},'gas_exceeded':{'error_code':'gas_exceeded','strategy':'adjust_params','max_attempts':0x3,'automation':'semi','detail':'Gas\x20budget\x20exceeded.\x201.\x20Increase\x20the\x20gas_budget\x20parameter\x202.\x20Reduce\x20the\x20operation\x20size\x20(fewer\x20objects\x20per\x20transaction)\x203.\x20Retry\x20the\x20original\x20operation','user_prompt':'Gas\x20budget\x20exceeded.\x20Increase\x20the\x20gas\x20budget\x20or\x20reduce\x20the\x20operation\x20size,\x20then\x20retry.'},'insufficient_gas':{'error_code':'insufficient_gas','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'Gas\x20exhausted\x20—\x20the\x20transaction\x20failed\x20deterministically\x20and\x20did\x20NOT\x20commit\x20on-chain\x20(no\x20state\x20changed;\x20commit-state\x20verification\x20is\x20NOT\x20needed).\x201.\x20Raise\x20the\x20gas_budget\x20parameter\x20above\x20the\x20failed\x20transaction\x27s\x20gas_used\x202.\x20If\x20the\x20account\x20balance\x20cannot\x20cover\x20any\x20budget,\x20fund\x20the\x20signing\x20account\x20with\x20gas\x20tokens\x20first\x203.\x20Resubmit\x20as\x20a\x20FRESH\x20call\x20—\x20do\x20NOT\x20replay\x20the\x20same\x20transaction','user_prompt':'The\x20transaction\x20ran\x20out\x20of\x20gas\x20and\x20did\x20not\x20commit\x20on-chain.\x20Increase\x20the\x20gas\x20budget\x20(or\x20fund\x20the\x20account\x20with\x20gas)\x20and\x20submit\x20a\x20fresh\x20transaction\x20—\x20retrying\x20unchanged\x20will\x20fail\x20the\x20same\x20way.'},'bcs_error':{'error_code':'bcs_error','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'BCS\x20serialization/deserialization\x20error\x20—\x20a\x20parameter\x20does\x20not\x20match\x20the\x20expected\x20type/structure.\x201.\x20Query\x20the\x20operation\x20schema\x20(schema_query)\x202.\x20Fix\x20the\x20offending\x20parameter\x20type\x20(e.g.\x20BigInt\x20vs\x20number,\x20vector\x20element\x20type)\x203.\x20Retry','user_prompt':'A\x20parameter\x20failed\x20serialization.\x20Check\x20the\x20parameter\x20types\x20against\x20the\x20schema\x20and\x20retry.'},'signature_error':{'error_code':'signature_error','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'Signature\x20verification\x20failed.\x201.\x20Verify\x20the\x20account\x20is\x20not\x20suspended\x202.\x20Check\x20the\x20network\x20matches\x20the\x20account\x27s\x203.\x20Switch\x20to\x20a\x20healthy\x20account\x20and\x20retry','user_prompt':'Signature\x20verification\x20failed.\x20The\x20account\x20may\x20be\x20suspended\x20or\x20misconfigured.\x20Switch\x20accounts\x20or\x20check\x20the\x20configuration\x20and\x20retry.'},'config_error':{'error_code':'config_error','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'Local\x20configuration\x20error\x20(network\x20not\x20specified,\x20persistent\x20storage\x20not\x20set).\x201.\x20Show\x20the\x20user\x20which\x20configuration\x20is\x20missing\x202.\x20Guide\x20the\x20user\x20through\x20the\x20account_operation/config\x20setup\x203.\x20Retry\x20after\x20the\x20user\x20fixes\x20it','user_prompt':'Local\x20configuration\x20is\x20incomplete.\x20Please\x20finish\x20the\x20account/network\x20setup\x20and\x20retry.'},'wip_verification_failed':{'error_code':'wip_verification_failed','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'WIP\x20file\x20not\x20publicly\x20reachable\x20/\x20hash\x20mismatch.\x201.\x20Upload\x20via\x20the\x20wip\x20storage\x20service\x20(wip_file\x20type=\x27upload\x27\x20—\x20official\x20free\x20store\x20or\x20storage=\x27custom\x27)\x202.\x20Or\x20deploy\x20to\x20a\x20public\x20URL\x20(GitHub\x20Pages\x20/\x20IPFS\x20/\x20own\x20site)\x203.\x20Update\x20the\x20sale\x27s\x20wip\x20URL\x204.\x20Re-run\x20the\x20operation','user_prompt':'The\x20WIP\x20file\x20could\x20not\x20be\x20verified\x20from\x20a\x20public\x20URL.\x20Upload\x20it\x20with\x20wip_file\x20type=\x27upload\x27\x20(official\x20free\x20store\x20or\x20your\x20own\x20service)\x20or\x20deploy\x20it\x20(GitHub\x20Pages\x20/\x20IPFS),\x20update\x20the\x20sale\x27s\x20WIP\x20URL,\x20and\x20retry.'},'wip_storage_unavailable':{'error_code':'wip_storage_unavailable','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'Transient\x20wip\x20storage\x20transport\x20failure.\x201.\x20Retry\x20the\x20same\x20request\x20with\x20bounded\x20backoff\x202.\x20Large\x20WIP\x20files\x20are\x20network-sensitive:\x20compress\x20images\x20before\x20generate\x20(each\x20image\x20<=\x202MB,\x20total\x20<=\x2010MB)\x203.\x20Check\x20connectivity\x20to\x20the\x20storage\x20base\x20URL\x20if\x20retries\x20keep\x20failing','user_prompt':'The\x20wip\x20storage\x20request\x20failed\x20due\x20to\x20a\x20network\x20problem.\x20Retry\x20the\x20upload;\x20if\x20it\x20keeps\x20failing,\x20reduce\x20the\x20file\x20size\x20or\x20check\x20connectivity.'},'wip_storage_rejected':{'error_code':'wip_storage_rejected','strategy':'adjust_params','max_attempts':0x1,'automation':'semi','detail':'WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx\x20—\x20deterministic\x20client-side\x20fault,\x20retrying\x20unchanged\x20fails\x20identically).\x20400:\x20malformed\x20body\x20or\x20failed\x20WIP\x20validation\x20—\x20re-generate\x20via\x20wip_file\x20type=\x27generate\x27\x20401:\x20re-sign\x20with\x20a\x20fresh\x20nonce\x20inside\x20the\x20timestamp\x20window\x20403:\x20check\x20storage\x20service\x20configuration\x20404:\x20file\x20does\x20not\x20exist\x20—\x20re-upload\x20409:\x20quota\x20—\x20delete\x20old\x20files\x20via\x20wip_file\x20type=\x27list\x27\x20then\x20delete\x20413:\x20compress\x20images\x20(each\x20<=\x202MB,\x20total\x20<=\x2010MB)\x20and\x20regenerate','user_prompt':'The\x20WIP\x20storage\x20service\x20rejected\x20the\x20request\x20(HTTP\x204xx).\x20Fix\x20the\x20specific\x20fault\x20(re-generate/re-sign/re-upload\x20per\x20the\x20status\x20code)\x20and\x20retry\x20—\x20do\x20not\x20retry\x20unchanged.'},'network_error':{'error_code':'network_error','strategy':'retry','max_attempts':0x5,'automation':'full','detail':'Transport\x20failure\x20(timeout\x20/\x20connection\x20reset\x20/\x20RPC\x20unreachable\x20/\x20HTTP\x205xx\x20gateway\x20error).\x20Exponential\x20backoff\x20retry:\x201s\x20/\x202s\x20/\x204s\x20/\x208s\x20/\x2016s.\x20Switch\x20RPC\x20node\x20if\x20available.\x20READS:\x20a\x20plain\x20retry\x20is\x20safe.\x20FUND-MOVING\x20WRITES:\x20before\x20any\x20resubmission,\x20verify\x20whether\x20the\x20previous\x20attempt\x20landed\x20(query\x20the\x20reported\x20digest\x20directly,\x20or\x20the\x20expected\x20object\x20via\x20the\x20sender\x27s\x20recent\x20on-chain\x20objects\x20/\x20onchain_events)\x20—\x20if\x20it\x20landed,\x20ADOPT\x20it\x20and\x20stop;\x20a\x20blind\x20backoff\x20retry\x20of\x20a\x20landed\x20write\x20moves\x20the\x20funds\x20a\x20second\x20time.'},'submission_unknown':{'error_code':'submission_unknown','strategy':'query_and_retry','max_attempts':0x2,'automation':'semi','detail':'Transport-level\x20failure\x20after\x20the\x20request\x20left\x20the\x20client\x20—\x20the\x20submission\x20state\x20is\x20UNKNOWN\x20and\x20the\x20transaction\x20may\x20already\x20be\x20committed.\x20NEVER\x20auto-retry\x20a\x20write\x20here.\x201.\x20Verify\x20commit\x20state\x20on-chain:\x20query_toolkit\x20for\x20the\x20object\x20this\x20call\x20would\x20create/modify\x20(resolve\x20the\x20reference\x20from\x20the\x20call\x27s\x20own\x20arguments),\x20or\x20onchain_events\x20for\x20the\x20sender\x27s\x20recent\x20transactions.\x202.\x20If\x20the\x20expected\x20object\x20EXISTS,\x20adopt\x20it\x20and\x20continue\x20the\x20workflow\x20(the\x20operation\x20succeeded\x20despite\x20the\x20transport\x20error).\x203.\x20If\x20confirmed\x20ABSENT,\x20resubmit\x20the\x20SAME\x20call\x20once\x20—\x20for\x20a\x20FIRST-EVER\x20transaction\x20on\x20a\x20fresh\x20account\x20make\x20that\x20resubmission\x20with\x20env.no_auto_register=true\x20and\x20SAY\x20SO\x20(the\x20SDK\x20silently\x20appends\x20an\x20entity\x20registration\x20to\x20a\x20first\x20business\x20call;\x20if\x20that\x20appended\x20leg\x20was\x20the\x20failing\x20leg\x20the\x20skip\x20lets\x20the\x20call\x20through\x20—\x20ziroom-mn-261013\x20live\x20case;\x20if\x20the\x20resubmission\x20aborts,\x20the\x20envelope\x20now\x20names\x20the\x20abort\x20—\x20re-enable\x20auto\x20registration\x20and\x20retry).\x204.\x20If\x20the\x20reported\x20digest\x20does\x20not\x20resolve\x20or\x20the\x20failure\x20repeats,\x20STOP\x20looping\x20on\x20digest\x20checks\x20and\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20—\x20the\x20simulation\x20surfaces\x20the\x20real\x20failure\x20(exact\x20Move\x20abort)\x20without\x20gas\x20or\x20duplicate\x20risk.\x205.\x20Reads\x20are\x20idempotent\x20—\x20retry\x20immediately.\x206.\x20M-K2\x20replay\x20discipline:\x20a\x20FAILED\x20receipt\x20is\x20final\x20—\x20its\x20digest\x20is\x20consumed\x20and\x20replaying\x20the\x20same\x20bytes\x20returns\x20the\x20same\x20failure\x20forever;\x20fix\x20the\x20cause\x20(usually\x20funding)\x20and\x20build\x20a\x20FRESH\x20transaction.\x20Live\x20mainnet\x20incident\x20behind\x20this\x20rule:\x20an\x20order_new\x20-32603\x20\x27did\x20not\x20complete\x27\x20had\x20committed;\x20the\x20blind\x20retry\x20created\x20a\x20second\x20order\x20with\x20a\x20second\x20full\x20escrow\x20and\x20a\x20second\x20stock\x20decrement','user_prompt':'The\x20request\x20failed\x20at\x20transport\x20level\x20but\x20may\x20have\x20already\x20been\x20committed\x20on-chain.\x20Verify\x20whether\x20the\x20expected\x20object\x20exists\x20(query\x20it)\x20before\x20any\x20retry\x20—\x20a\x20blind\x20retry\x20can\x20duplicate\x20the\x20operation\x20(double\x20escrow).\x20For\x20read\x20operations,\x20a\x20plain\x20retry\x20is\x20safe.'},'transaction_expired':{'error_code':'transaction_expired','strategy':'retry','max_attempts':0x3,'automation':'full','detail':'The\x20transaction\x20expired\x20before\x20execution\x20(epoch\x20boundary\x20or\x20validator/gateway\x20outage)\x20—\x20it\x20did\x20NOT\x20land\x20and\x20nothing\x20was\x20committed.\x20Bounded\x20backoff\x20retry:\x2010s\x20/\x2030s\x20/\x2060s,\x20resubmit\x20the\x20SAME\x20call\x20unchanged.\x20If\x20a\x20dry_run\x20passes\x20while\x20the\x20real\x20call\x20keeps\x20failing,\x20the\x20fault\x20is\x20chain-side\x20—\x20wait\x20it\x20out.\x20Verify\x20with\x20onchain_events\x20if\x20unsure.'},'guard_rejected':{'error_code':'guard_rejected','strategy':'fill_submission','max_attempts':0x2,'automation':'semi','detail':'1.\x20Parse\x20Guard\x20table\x20structure\x202.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20them\x20and\x20resubmit\x20with\x20call_with_submission\x203.\x20If\x20it\x20defines\x20none,\x20the\x20rule\x20evaluated\x20false\x20—\x20typical\x20causes:\x20a\x20TIME\x20WINDOW\x20(Clock\x20deadline/opening\x20comparison\x20—\x20this\x20call\x20may\x20sit\x20outside\x20the\x20window,\x20and\x20a\x20mis-oriented\x20comparison\x20inverts\x20it:\x20everything\x20inside\x20rejected,\x20everything\x20after\x20admitted)\x20or\x20an\x20IDENTITY\x20condition\x20(signer/state\x20checks\x20—\x20the\x20caller\x20may\x20not\x20be\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20the\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20(docs#40)\x204.\x20When\x20the\x20failure\x20is\x20passport\x20E_VERIFY_FAILED\x20and\x20a\x20submission\x20was\x20supplied,\x20the\x20response\x20appends\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line\x20naming\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20fix\x20that\x20guard\x20first\x205.\x20A\x20TIME-window\x20rejection\x20may\x20simply\x20be\x20EARLY:\x20re-run\x20the\x20SAME\x20call\x20with\x20env.dry_run=true\x20to\x20probe\x20the\x20window\x20for\x20free\x20(guard\x20rejections\x20do\x20NOT\x20consume\x20the\x20total\x20retry\x20budget;\x20only\x20the\x20per-code\x20cap\x20of\x202\x20applies)','user_prompt':'Guard\x20verification\x20rejected.\x20If\x20the\x20Guard\x20defines\x20submission\x20items,\x20fill\x20in\x20the\x20required\x20submission\x20data\x20and\x20resubmit;\x20if\x20it\x20defines\x20none,\x20the\x20Guard\x20rule\x20evaluated\x20false\x20—\x20the\x20usual\x20causes\x20are\x20a\x20time\x20window\x20(this\x20call\x20may\x20be\x20outside\x20the\x20Clock\x20deadline/opening\x20window)\x20or\x20an\x20identity\x20condition\x20(the\x20caller\x20is\x20not\x20the\x20address\x20the\x20rule\x20expects);\x20adjust\x20this\x20call\x27s\x20parameters\x20or\x20change\x20the\x20Guard\x20rule.\x20When\x20the\x20response\x20includes\x20a\x20\x27Guard\x20diagnosis\x20(dry-run)\x27\x20line,\x20it\x20names\x20the\x20first\x20failing\x20impact\x20guard\x20—\x20address\x20that\x20guard\x20first.\x20A\x20time-window\x20rejection\x20may\x20simply\x20be\x20early:\x20probe\x20the\x20window\x20with\x20env.dry_run=true\x20(free\x20—\x20guard\x20rejections\x20do\x20not\x20consume\x20the\x20total\x20retry\x20budget).'},'time_lock_not_elapsed':{'error_code':'time_lock_not_elapsed','strategy':'wait_and_retry','max_attempts':0x1,'automation':'semi','detail':'1.\x20Verify\x20Service\x20is\x20paused\x20(bPaused=true).\x20If\x20not,\x20submit\x20pause=true\x20first.\x202.\x20Wait\x20until\x20paused_time\x20+\x20setting_lock_duration\x20<=\x20current\x20clock.\x203.\x20Retry\x20the\x20original\x20operation.\x20Do\x20NOT\x20recreate\x20the\x20object.','user_prompt':'Service\x20setting_lock_duration\x20has\x20not\x20elapsed\x20since\x20the\x20Service\x20was\x20paused.\x20Please\x20pause\x20the\x20Service\x20if\x20it\x20is\x20not\x20already\x20paused,\x20wait\x20for\x20the\x20lock\x20duration\x20to\x20elapse,\x20then\x20retry.'},'immutable_violation':{'error_code':'immutable_violation','strategy':'recreate','max_attempts':0x1,'automation':'semi','detail':'1.\x20Stop\x20modification\x20attempt\x202.\x20Evaluate\x20creating\x20a\x20new\x20object\x20as\x20replacement\x203.\x20Re-plan\x20affected\x20phases','user_prompt':'Cannot\x20modify\x20an\x20immutable\x20object.\x20A\x20new\x20object\x20must\x20be\x20created\x20as\x20a\x20replacement.\x20Confirm\x20to\x20proceed\x20with\x20recreation.'},'permission_denied':{'error_code':'permission_denied','strategy':'switch_account','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20object\x27s\x20permission_guard\x202.\x20List\x20accounts\x20with\x20permission\x203.\x20Switch\x20account\x20or\x20prompt\x20user\x20to\x20add\x20permission','user_prompt':'Current\x20account\x20lacks\x20permission\x20for\x20this\x20operation.\x20Switch\x20to\x20an\x20authorized\x20account\x20or\x20update\x20the\x20Permission\x20object.'},'object_not_found':{'error_code':'object_not_found','strategy':'query_and_retry','max_attempts':0x3,'automation':'semi','detail':'1.\x20Verify\x20the\x20referenced\x20name/ID\x20spelling\x20(local_mark_list)\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network\x202.\x20If\x20recently\x20created,\x20re-query\x20the\x20object\x20(may\x20be\x20sync\x20delay)\x203.\x20If\x20truly\x20absent,\x20search\x20for\x20similar\x20objects\x204.\x20Prompt\x20user\x20to\x20reselect','user_prompt':'Referenced\x20object\x20not\x20found.\x20First\x20verify\x20the\x20name/ID\x20spelling\x20and\x20that\x20the\x20object\x20exists\x20on\x20the\x20current\x20network;\x20if\x20it\x20was\x20created\x20recently,\x20this\x20may\x20be\x20a\x20synchronization\x20delay\x20—\x20retry.\x20If\x20the\x20issue\x20persists,\x20please\x20select\x20a\x20valid\x20object.'},'state_conflict':{'error_code':'state_conflict','strategy':'adjust_params','max_attempts':0x2,'automation':'full','detail':'1.\x20Query\x20object\x27s\x20current\x20true\x20state\x202.\x20Update\x20ODG\x20status\x20annotations\x203.\x20Adjust\x20subsequent\x20operations\x20(e.g.,\x20skip\x20completed\x20steps)'},'invalid_parameter':{'error_code':'invalid_parameter','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'1.\x20Query\x20the\x20relevant\x20schema\x202.\x20Auto-fix\x20obvious\x20errors\x20(e.g.,\x20BigInt\x20vs\x20string)\x203.\x20If\x20unfixable,\x20prompt\x20user','user_prompt':'Parameter\x20validation\x20failed.\x20Please\x20check\x20the\x20parameter\x20types\x20and\x20values\x20against\x20the\x20schema\x20and\x20retry.'},'move_abort_unmapped':{'error_code':'move_abort_unmapped','strategy':'stop','max_attempts':0x1,'automation':'manual','detail':'The\x20chain\x27s\x20business\x20logic\x20aborted\x20and\x20the\x20(module,\x20abort\x20code)\x20pair\x20has\x20no\x20local\x20mapping.\x20Read\x20the\x20module\x20and\x20abort\x20code\x20from\x20move_abort_info\x20/\x20the\x20message\x20(rendered\x20as\x20\x27abort\x20(N)\x27),\x20resolve\x20their\x20meaning\x20from\x20the\x20module\x27s\x20documentation\x20or\x20the\x20wowok-tools\x20Skill,\x20fix\x20the\x20business\x20cause,\x20and\x20issue\x20a\x20NEW\x20call.\x20Do\x20NOT\x20restart\x20the\x20server\x20and\x20do\x20NOT\x20retry\x20the\x20identical\x20call\x20—\x20it\x20aborts\x20deterministically.','user_prompt':'The\x20operation\x20was\x20rejected\x20by\x20the\x20chain\x27s\x20business\x20logic\x20and\x20its\x20abort\x20code\x20is\x20not\x20mapped\x20locally.\x20The\x20module\x20name\x20and\x20abort\x20code\x20in\x20the\x20error\x20are\x20authoritative\x20—\x20review\x20them\x20(and\x20the\x20object\x20state\x20via\x20query_toolkit)\x20before\x20adjusting\x20anything.'},'missing_data':{'error_code':'missing_data','strategy':'adjust_params','max_attempts':0x2,'automation':'semi','detail':'A\x20guard\x20rule\x20read\x20a\x20keyed\x20table\x20row\x20that\x20does\x20NOT\x20exist\x20(repository.data\x20/\x20oracle\x20entry)\x20and\x20the\x20verifier\x20surfaced\x20it\x20as\x20a\x20location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20no\x20abort\x20code,\x20because\x20the\x20framework\x20cannot\x20express\x20\x27row\x20absent\x27\x20as\x20an\x20abort.\x20This\x20is\x20a\x20DATA\x20problem:\x201.\x20Identify\x20the\x20repository\x20and\x20key\x20the\x20guard\x20rule\x20reads\x20(guard2file\x20/\x20analyze_guard_semantics\x20on\x20the\x20guard\x20source)\x202.\x20Have\x20the\x20row\x27s\x20producer\x20write\x20it\x20(e.g.\x20an\x20oracle\x20timestamp\x20like\x20checkin_ts),\x20or\x20add\x20it\x20with\x20repository\x20data_add\x20(data_add.name\x20must\x20match\x20a\x20policy\x20rule\x20name)\x203.\x20Retry\x20the\x20SAME\x20call\x20unchanged\x20—\x20a\x20dry_run\x20that\x20turns\x20clean\x20after\x20the\x20row\x20exists\x20confirms\x20the\x20diagnosis','user_prompt':'A\x20guard\x20rule\x20references\x20a\x20data\x20row\x20that\x20has\x20not\x20been\x20written\x20yet\x20(location-only\x20fault\x20inside\x20the\x20passport\x20module\x20—\x20NOT\x20a\x20network\x20problem).\x20Identify\x20the\x20repository\x20row\x20the\x20guard\x20expects\x20(guard2file\x20/\x20analyze_guard_semantics),\x20write\x20it\x20with\x20repository\x20data_add\x20(or\x20let\x20its\x20producer\x20write\x20it),\x20then\x20retry.'},'unknown':{'error_code':'unknown','strategy':'escalate_human','max_attempts':0x1,'automation':'manual','detail':'1.\x20Report\x20full\x20error\x20context\x20to\x20the\x20user\x202.\x20Escalate\x20to\x20human\x20intervention\x203.\x20Flag\x20for\x20error-classification\x20rule\x20addition','user_prompt':'An\x20unclassified\x20error\x20occurred.\x20Please\x20review\x20the\x20error\x20details\x20and\x20contact\x20support\x20if\x20needed.'}};const operationAttempts=new Map();function getAttemptCount(a,b){const c=operationAttempts['get'](a);if(!c)return 0x0;return c['get'](b)??0x0;}function incrementAttempt(a,b){!operationAttempts['has'](a)&&operationAttempts['set'](a,new Map());const c=operationAttempts['get'](a),d=(c['get'](b)??0x0)+0x1;return c['set'](b,d),d;}const BUDGET_EXEMPT_CODES=new Set(['guard_rejected']);function getBudgetAttempts(a){const b=operationAttempts['get'](a);if(!b)return 0x0;let c=0x0;for(const [d,e]of b){if(!BUDGET_EXEMPT_CODES['has'](d))c+=e;}return c;}export function resetAttempts(a){operationAttempts['delete'](a);}export function recover(a,b,c){const d=RECOVERY_RULES[a]??RECOVERY_RULES['unknown'],e=0x5,f=getBudgetAttempts(b),g=getAttemptCount(b,a);if(d['max_attempts']<=0x1||d['strategy']==='stop')return{'strategy':d['strategy'],'should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};if(f>=e)return{'strategy':'stop','should_retry':![],'max_attempts':e,'current_attempt':f,'detail':'Total\x20retry\x20limit\x20('+e+')\x20reached\x20for\x20operation\x20'+b+'.\x20Escalating\x20to\x20human\x20intervention.\x20Attempts\x20recorded\x20for\x20this\x20operation\x20id:\x20'+([...(operationAttempts['get'](b)??new Map())['entries']()]['map'](([j,k])=>j+':'+k)['join'](',\x20')||'none')+'.','user_prompt':'Maximum\x20retry\x20attempts\x20reached.\x20Manual\x20intervention\x20required.'};if(g>=d['max_attempts'])return{'strategy':'escalate_human','should_retry':![],'max_attempts':d['max_attempts'],'current_attempt':g,'detail':'Per-error-code\x20retry\x20limit\x20('+d['max_attempts']+')\x20reached\x20for\x20'+a+'.\x20Escalating\x20to\x20human.','user_prompt':'Recovery\x20attempts\x20for\x20'+a+'\x20exhausted.\x20Manual\x20intervention\x20required.'};const h=incrementAttempt(b,a),i={'strategy':d['strategy'],'should_retry':d['automation']==='full'||h<d['max_attempts'],'max_attempts':d['max_attempts'],'current_attempt':h,'adjusted_params':d['adjusted_params'],'user_prompt':d['user_prompt'],'detail':d['detail']};return i['should_retry']&&c?.['retryable']===![]&&a!=='guard_rejected'&&d['strategy']!=='fill_submission'&&d['strategy']!=='query_and_retry'&&(i['should_retry']=![],i['detail']+='\x20NON-RETRYABLE\x20CLASSIFICATION:\x20retrying\x20the\x20IDENTICAL\x20call\x20fails\x20identically\x20—\x20apply\x20the\x20strategy\x20above\x20to\x20fix\x20the\x20cause,\x20then\x20submit\x20a\x20FRESH\x20call.'),i;}export function getBackoffDelay(a){return Math['pow'](0x2,a-0x1)*0x3e8;}
@@ -1 +1 @@
1
- export const ACQUISITION_FLYWHEEL_VERSION=0x1;export const INDUSTRY_FLYWHEELS=[{'industry':'freelance','trustSellingPoints':['Delivery\x20acceptance\x20+\x20fund\x20escrow\x20+\x20arbitration\x20guarantee','Transparent\x20process:\x20Machine\x20defines\x20clear\x20delivery\x20nodes','compensation_fund\x20secures\x20customer\x20rights'],'keyActions':[{'action':'Set\x20Reward\x20first-order\x20bonus','purpose':'Attract\x20new\x20customers\x20to\x20place\x20orders','mutableField':'rewards','metricToWatch':'New\x20customer\x20order\x20rate'},{'action':'Cumulative-spend\x20tiered\x20Reward','purpose':'Incentivize\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'},{'action':'Adjust\x20Machine\x20nodes','purpose':'Optimize\x20delivery\x20process\x20speed','mutableField':'description','metricToWatch':'Average\x20completion\x20time'},{'action':'Increase\x20compensation_fund','purpose':'Improve\x20trust\x20score','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'First-order\x20reward\x20+\x20cumulative-spend\x20tiered\x20reward\x20(e.g.\x20discount\x20after\x205\x20orders)','discountStrategy':'Monthly\x20discount\x20+\x20long-term\x20cooperation\x20discount','trustDescription':'Fund\x20escrow\x20+\x20delivery\x20acceptance\x20+\x20arbitration\x20guarantee'},{'industry':'rental','trustSellingPoints':['Deposit\x20escrow\x20+\x20damage\x20Guard\x20+\x20return\x20process','Guard\x20verifies\x20item\x20condition\x20to\x20prevent\x20disputes','compensation_fund\x20covers\x20damage\x20risk'],'keyActions':[{'action':'Set\x20Discount\x20long-term\x20rental\x20bonus','purpose':'Incentivize\x20long-term\x20rental','mutableField':'discount','metricToWatch':'Long-term\x20rental\x20ratio'},{'action':'Credit-accumulation\x20Reward','purpose':'Multi-rental\x20credit\x20accumulation','mutableField':'rewards','metricToWatch':'Re-rental\x20rate'},{'action':'Configure\x20damage\x20Guard','purpose':'Reduce\x20dispute\x20rate','mutableField':'buy_guard','metricToWatch':'Dispute\x20rate'},{'action':'Increase\x20compensation_fund','purpose':'Cover\x20damage\x20risk','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'Credit\x20accumulation\x20+\x20long-term\x20rental\x20discount\x20+\x20referral\x20cashback','discountStrategy':'Monthly\x2010%\x20off\x20+\x20quarterly\x2020%\x20off\x20+\x20annual\x2030%\x20off','trustDescription':'Deposit\x20escrow\x20+\x20Guard\x20verification\x20+\x20return\x20guarantee'},{'industry':'education','trustSellingPoints':['Transparent\x20course\x20progress\x20+\x20refund\x20Guard','Machine\x20defines\x20learning\x20stages\x20and\x20acceptance\x20nodes'],'keyActions':[{'action':'Set\x20milestone\x20Reward','purpose':'Incentivize\x20course\x20completion','mutableField':'rewards','metricToWatch':'Course\x20completion\x20rate'},{'action':'Referral\x20cashback\x20Reward','purpose':'Viral\x20acquisition','mutableField':'rewards','metricToWatch':'Referral\x20rate'}],'rewardStrategy':'Milestone\x20reward\x20+\x20referral\x20cashback\x20+\x20trial-class\x20discount','discountStrategy':'Early-bird\x20price\x20+\x20group-buy\x20price\x20+\x20student-aid\x20discount','trustDescription':'Transparent\x20progress\x20+\x20refund\x20guarantee\x20+\x20acceptance\x20nodes'},{'industry':'travel','trustSellingPoints':['Itinerary\x20escrow\x20+\x20cancellation\x20Guard\x20+\x20arbitration\x20guarantee','Guard\x20verifies\x20itinerary\x20change\x20conditions'],'keyActions':[{'action':'Limited-time\x20flash-sale\x20Reward','purpose':'Clearance\x20promotion','mutableField':'rewards','metricToWatch':'Conversion\x20rate'},{'action':'Spend\x20cashback\x20Reward','purpose':'Improve\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'}],'rewardStrategy':'Limited-time\x20flash\x20sale\x20+\x20spend\x20cashback\x20+\x20referral\x20commission','discountStrategy':'Early-bird\x20price\x20+\x20group-buy\x20price\x20+\x20member\x20price','trustDescription':'Itinerary\x20escrow\x20+\x20cancellation\x20guarantee\x20+\x20arbitration'},{'industry':'subscription','trustSellingPoints':['Transparent\x20subscription\x20+\x20auto-renewal\x20Guard\x20+\x20cancel\x20anytime','Machine\x20defines\x20billing\x20cycles\x20and\x20auto-debit'],'keyActions':[{'action':'Loyalty\x20Reward','purpose':'Long-term\x20retention','mutableField':'rewards','metricToWatch':'Renewal\x20rate'},{'action':'Referral\x20cashback\x20Reward','purpose':'Viral\x20acquisition','mutableField':'rewards','metricToWatch':'Referral\x20rate'}],'rewardStrategy':'Loyalty\x20reward\x20+\x20referral\x20cashback\x20+\x20first-month\x20discount','discountStrategy':'Annual\x20discount\x20+\x20team\x20discount\x20+\x20upgrade\x20discount','trustDescription':'Transparent\x20subscription\x20+\x20renewal\x20guarantee\x20+\x20cancel\x20anytime'},{'industry':'retail','trustSellingPoints':['Transaction\x20escrow\x20+\x20logistics\x20Guard\x20+\x20refund\x20guarantee','Guard\x20verifies\x20shipping\x20and\x20receipt'],'keyActions':[{'action':'First-order\x20discount','purpose':'Attract\x20new\x20customers','mutableField':'discount','metricToWatch':'New\x20customer\x20order\x20rate'},{'action':'Spend\x20cashback\x20Reward','purpose':'Improve\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'}],'rewardStrategy':'First-order\x20discount\x20+\x20spend\x20cashback\x20+\x20spend-threshold\x20discount','discountStrategy':'Spend-threshold\x20discount\x20+\x20limited-time\x20discount\x20+\x20member\x20price','trustDescription':'Transaction\x20escrow\x20+\x20logistics\x20Guard\x20+\x20refund\x20guarantee'}];let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getFlywheelForIndustry(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['flywheel'])return b['flywheel'];}return INDUSTRY_FLYWHEELS['find'](c=>c['industry']===a['toLowerCase']());}export function listIndustries(){return INDUSTRY_FLYWHEELS['map'](a=>a['industry']);}export function suggestAcquisitionActions(a){const b=getFlywheelForIndustry(a);return b?.['keyActions']??[];}export function generateTrustDescription(a){const b=[];if(a['industry']){const c=getFlywheelForIndustry(a['industry']);c&&b['push'](c['trustDescription']);}return a['orderCount']!==undefined&&a['orderCount']>0x0&&b['push']('Completed\x20'+a['orderCount']+'\x20orders'),a['completedRate']!==undefined&&b['push']('Completion\x20rate\x20'+Math['round'](a['completedRate']*0x64)+'%'),a['avgCompletionTime']!==undefined&&(a['avgCompletionTime']<0x1?b['push']('Average\x20completion\x20time\x20'+Math['round'](a['avgCompletionTime']*0x3c)+'\x20minutes'):b['push']('Average\x20completion\x20time\x20'+Math['round'](a['avgCompletionTime'])+'\x20hours')),a['hasCompensationFund']&&b['push']('Sufficient\x20compensation\x20fund'),a['hasArbitration']&&b['push']('Third-party\x20arbitration\x20guarantee'),a['reviewCount']!==undefined&&a['reviewCount']>0x0&&a['reviewLikeRate']!==undefined&&b['push']('Like\x20rate\x20'+Math['round'](a['reviewLikeRate']*0x64)+'%\x20('+a['reviewCount']+'\x20reviews)'),b['join'](';\x20')||'No\x20trust\x20data\x20available';}export function buildAcquisitionDashboard(a){const {orderCount:b,completedRate:c,avgCompletionTime:d,repeatCustomerRate:e,reviewLikeRate:f,reviewCount:g}=a;let h='cold_start';if(b>=0x32)h='optimization';else{if(b>=0x14)h='mature';else{if(b>=0x5)h='growing';}}const i=[];if(h==='cold_start')i['push']('Cold-start\x20stage:\x20set\x20first-order\x20Reward\x20to\x20attract\x20new\x20customers'),i['push']('Increase\x20compensation_fund\x20to\x20boost\x20initial\x20trust');else{if(h==='growing')i['push']('Growing\x20stage:\x20set\x20referral\x20cashback\x20Reward\x20for\x20viral\x20acquisition'),e!==undefined&&e<0.2&&i['push']('Repurchase\x20rate\x20is\x20low;\x20consider\x20setting\x20cumulative-spend\x20tiered\x20Reward');else h==='mature'?(f!==undefined&&f>0.8&&i['push']('High\x20like\x20rate;\x20you\x20can\x20highlight\x20trust\x20metrics\x20in\x20the\x20description'),e!==undefined&&e>0.3&&i['push']('High\x20repurchase\x20rate;\x20consider\x20setting\x20loyalty\x20Reward\x20to\x20incentivize\x20long-term\x20customers')):(i['push']('Optimization\x20stage:\x20fine-tune\x20pricing\x20and\x20Reward\x20strategies'),d!==undefined&&d>0x30&&i['push']('Completion\x20time\x20is\x20long;\x20consider\x20optimizing\x20the\x20Machine\x20process'));}return{'metrics':{'orderCount':b,'completedRate':c??0x0,'avgCompletionTime':d,'repeatCustomerRate':e,'reviewLikeRate':f,'reviewCount':g},'suggestions':i,'flywheelStage':h};}
1
+ export const ACQUISITION_FLYWHEEL_VERSION=0x1;export const INDUSTRY_FLYWHEELS=[{'industry':'freelance','trustSellingPoints':['Delivery\x20acceptance\x20+\x20fund\x20escrow\x20+\x20arbitration\x20guarantee','Transparent\x20process:\x20Machine\x20defines\x20clear\x20delivery\x20nodes','compensation_fund\x20secures\x20customer\x20rights'],'keyActions':[{'action':'Set\x20Reward\x20first-order\x20bonus','purpose':'Attract\x20new\x20customers\x20to\x20place\x20orders','mutableField':'rewards','metricToWatch':'New\x20customer\x20order\x20rate'},{'action':'Cumulative-spend\x20tiered\x20Reward','purpose':'Incentivize\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'},{'action':'Adjust\x20Machine\x20nodes','purpose':'Optimize\x20delivery\x20process\x20speed','mutableField':'description','metricToWatch':'Average\x20completion\x20time'},{'action':'Increase\x20compensation_fund','purpose':'Improve\x20trust\x20score','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'First-order\x20reward\x20+\x20cumulative-spend\x20tiered\x20reward\x20(e.g.\x20discount\x20after\x205\x20orders)','discountStrategy':'Monthly\x20discount\x20+\x20long-term\x20cooperation\x20discount','trustDescription':'Fund\x20escrow\x20+\x20delivery\x20acceptance\x20+\x20arbitration\x20guarantee'},{'industry':'rental','trustSellingPoints':['Deposit\x20escrow\x20+\x20damage\x20Guard\x20+\x20return\x20process','Guard\x20verifies\x20item\x20condition\x20to\x20prevent\x20disputes','compensation_fund\x20covers\x20damage\x20risk'],'keyActions':[{'action':'Set\x20Discount\x20long-term\x20rental\x20bonus','purpose':'Incentivize\x20long-term\x20rental','mutableField':'discount','metricToWatch':'Long-term\x20rental\x20ratio'},{'action':'Credit-accumulation\x20Reward','purpose':'Multi-rental\x20credit\x20accumulation','mutableField':'rewards','metricToWatch':'Re-rental\x20rate'},{'action':'Configure\x20damage\x20Guard','purpose':'Reduce\x20dispute\x20rate','mutableField':'buy_guard','metricToWatch':'Dispute\x20rate'},{'action':'Increase\x20compensation_fund','purpose':'Cover\x20damage\x20risk','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'Credit\x20accumulation\x20+\x20long-term\x20rental\x20discount\x20+\x20referral\x20cashback','discountStrategy':'Monthly\x2010%\x20off\x20+\x20quarterly\x2020%\x20off\x20+\x20annual\x2030%\x20off','trustDescription':'Deposit\x20escrow\x20+\x20Guard\x20verification\x20+\x20return\x20guarantee'},{'industry':'education','trustSellingPoints':['Transparent\x20course\x20progress\x20+\x20refund\x20Guard','Machine\x20defines\x20learning\x20stages\x20and\x20acceptance\x20nodes'],'keyActions':[{'action':'Set\x20milestone\x20Reward','purpose':'Incentivize\x20course\x20completion','mutableField':'rewards','metricToWatch':'Course\x20completion\x20rate'},{'action':'Referral\x20cashback\x20Reward','purpose':'Viral\x20acquisition','mutableField':'rewards','metricToWatch':'Referral\x20rate'}],'rewardStrategy':'Milestone\x20reward\x20+\x20referral\x20cashback\x20+\x20trial-class\x20discount','discountStrategy':'Early-bird\x20price\x20+\x20group-buy\x20price\x20+\x20student-aid\x20discount','trustDescription':'Transparent\x20progress\x20+\x20refund\x20guarantee\x20+\x20acceptance\x20nodes'},{'industry':'travel','trustSellingPoints':['Itinerary\x20escrow\x20+\x20cancellation\x20Guard\x20+\x20arbitration\x20guarantee','Guard\x20verifies\x20itinerary\x20change\x20conditions'],'keyActions':[{'action':'Limited-time\x20flash-sale\x20Reward','purpose':'Clearance\x20promotion','mutableField':'rewards','metricToWatch':'Conversion\x20rate'},{'action':'Spend\x20cashback\x20Reward','purpose':'Improve\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'}],'rewardStrategy':'Limited-time\x20flash\x20sale\x20+\x20spend\x20cashback\x20+\x20referral\x20commission','discountStrategy':'Early-bird\x20price\x20+\x20group-buy\x20price\x20+\x20member\x20price','trustDescription':'Itinerary\x20escrow\x20+\x20cancellation\x20guarantee\x20+\x20arbitration'},{'industry':'subscription','trustSellingPoints':['Transparent\x20subscription\x20+\x20auto-renewal\x20Guard\x20+\x20cancel\x20anytime','Machine\x20defines\x20billing\x20cycles\x20and\x20auto-debit'],'keyActions':[{'action':'Loyalty\x20Reward','purpose':'Long-term\x20retention','mutableField':'rewards','metricToWatch':'Renewal\x20rate'},{'action':'Referral\x20cashback\x20Reward','purpose':'Viral\x20acquisition','mutableField':'rewards','metricToWatch':'Referral\x20rate'}],'rewardStrategy':'Loyalty\x20reward\x20+\x20referral\x20cashback\x20+\x20first-month\x20discount','discountStrategy':'Annual\x20discount\x20+\x20team\x20discount\x20+\x20upgrade\x20discount','trustDescription':'Transparent\x20subscription\x20+\x20renewal\x20guarantee\x20+\x20cancel\x20anytime'},{'industry':'retail','trustSellingPoints':['Transaction\x20escrow\x20+\x20logistics\x20Guard\x20+\x20refund\x20guarantee','Guard\x20verifies\x20shipping\x20and\x20receipt'],'keyActions':[{'action':'First-order\x20discount','purpose':'Attract\x20new\x20customers','mutableField':'discount','metricToWatch':'New\x20customer\x20order\x20rate'},{'action':'Spend\x20cashback\x20Reward','purpose':'Improve\x20repurchase','mutableField':'rewards','metricToWatch':'Repurchase\x20rate'}],'rewardStrategy':'First-order\x20discount\x20+\x20spend\x20cashback\x20+\x20spend-threshold\x20discount','discountStrategy':'Spend-threshold\x20discount\x20+\x20limited-time\x20discount\x20+\x20member\x20price','trustDescription':'Transaction\x20escrow\x20+\x20logistics\x20Guard\x20+\x20refund\x20guarantee'},{'industry':'licensing','trustSellingPoints':['License\x20terms\x20hash-anchored\x20as\x20a\x20WIP\x20object\x20—\x20the\x20grant\x20is\x20provable,\x20not\x20prose','Royalty/purchase\x20proceeds\x20split\x20on-chain\x20via\x20Allocation\x20—\x20the\x20split\x20is\x20frozen\x20at\x20publish\x20and\x20auditable\x20by\x20every\x20rights-holder','Territory\x20+\x20term\x20enforced\x20by\x20Guard\x20(allowlist\x20/\x20time-lock);\x20escrow\x20+\x20inspection\x20window\x20before\x20the\x20grant\x20is\x20final'],'keyActions':[{'action':'Anchor\x20license\x20terms\x20as\x20WIP','purpose':'Make\x20the\x20granted\x20rights\x20provable\x20in\x20a\x20dispute','mutableField':'description','metricToWatch':'Dispute\x20rate'},{'action':'Publish\x20the\x20Allocation\x20split','purpose':'Show\x20rights-holders\x20their\x20share\x20is\x20frozen\x20and\x20auditable','mutableField':'allocator','metricToWatch':'Trust\x20score'},{'action':'Configure\x20an\x20inspection-window\x20time-lock\x20Guard','purpose':'Give\x20the\x20buyer\x20a\x20verify-then-release\x20window\x20before\x20the\x20grant\x20is\x20final','mutableField':'buy_guard','metricToWatch':'Refund/dispute\x20rate'},{'action':'Increase\x20compensation_fund','purpose':'Back\x20the\x20reporting-honesty\x20promise\x20the\x20buyer\x20is\x20trusting','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'Repeat-license\x20/\x20catalog-referral\x20reward;\x20early-access\x20reward\x20on\x20a\x20new\x20drop','discountStrategy':'Volume-license\x20discount\x20+\x20tiered\x20license\x20pricing\x20(basic/premium/unlimited/exclusive)','trustDescription':'Terms\x20hash-anchored\x20+\x20on-chain\x20royalty\x20split\x20+\x20territory/term\x20Guard\x20+\x20escrow\x20inspection\x20window'},{'industry':'crowdfunding','trustSellingPoints':['Each\x20contribution\x20is\x20escrowed\x20in\x20its\x20OWN\x20Allocation\x20(never\x20pooled)\x20—\x20a\x20funder\x27s\x20money\x20stays\x20attributable\x20to\x20their\x20order\x20and\x20is\x20refundable\x20to\x20them,\x20not\x20lost\x20in\x20a\x20merged\x20pot','The\x20funding\x20threshold\x20is\x20an\x20on-chain\x20aggregate\x20read\x20(a\x20shared\x20campaign\x20ledger\x20summed\x20at\x20settlement)\x20—\x20the\x20raise\x20is\x20provable,\x20and\x20the\x20deadline\x20release/refund\x20decision\x20is\x20enforced\x20by\x20Guard,\x20not\x20by\x20the\x20project\x27s\x20goodwill','Two-leg\x20escrow\x20exit:\x20on\x20deadline\x20the\x20funds\x20EITHER\x20release\x20to\x20the\x20project\x20(threshold\x20met)\x20XOR\x20refund\x20per\x20contributor\x20(threshold\x20missed)\x20—\x20never\x20both,\x20never\x20neither'],'keyActions':[{'action':'Publish\x20the\x20funding\x20threshold\x20+\x20deadline','purpose':'Make\x20the\x20all-or-nothing\x20gate\x20provable\x20so\x20funders\x20trust\x20the\x20raise\x20is\x20real','mutableField':'description','metricToWatch':'Funding\x20conversion\x20rate'},{'action':'Configure\x20the\x20two-leg\x20settlement\x20Guard\x20(release\x20XOR\x20refund)','purpose':'Guarantee\x20a\x20missed\x20campaign\x20refunds\x20every\x20contributor\x20automatically','mutableField':'allocator','metricToWatch':'Refund/dispute\x20rate'},{'action':'Set\x20an\x20early-backer\x20Reward','purpose':'Reward\x20funders\x20who\x20commit\x20before\x20the\x20deadline','mutableField':'rewards','metricToWatch':'Early-funding\x20velocity'},{'action':'Increase\x20compensation_fund','purpose':'Back\x20the\x20delivery\x20promise\x20funders\x20trust\x20after\x20a\x20successful\x20raise','mutableField':'compensation_fund','metricToWatch':'Trust\x20score'}],'rewardStrategy':'Early-backer\x20reward\x20+\x20referral\x20reward\x20(viral\x20campaign\x20sharing);\x20tiered\x20reward\x20by\x20contribution\x20level.\x20NOT\x20an\x20investment\x20return\x20—\x20never\x20promise\x20financial\x20yield\x20(L-01)','discountStrategy':'Early-bird\x20contribution\x20tier\x20+\x20group-backer\x20bundle;\x20no\x20discounting\x20that\x20implies\x20a\x20resale\x20return','trustDescription':'Per-contributor\x20escrow\x20(unpooled)\x20+\x20on-chain\x20aggregate\x20threshold\x20+\x20deadline\x20two-leg\x20release/refund\x20+\x20arbitration\x20guarantee'}];let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getFlywheelForIndustry(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['flywheel'])return b['flywheel'];}return INDUSTRY_FLYWHEELS['find'](c=>c['industry']===a['toLowerCase']());}export function listIndustries(){return INDUSTRY_FLYWHEELS['map'](a=>a['industry']);}export function suggestAcquisitionActions(a){const b=getFlywheelForIndustry(a);return b?.['keyActions']??[];}export function generateTrustDescription(a){const b=[];if(a['industry']){const c=getFlywheelForIndustry(a['industry']);c&&b['push'](c['trustDescription']);}return a['orderCount']!==undefined&&a['orderCount']>0x0&&b['push']('Completed\x20'+a['orderCount']+'\x20orders'),a['completedRate']!==undefined&&b['push']('Completion\x20rate\x20'+Math['round'](a['completedRate']*0x64)+'%'),a['avgCompletionTime']!==undefined&&(a['avgCompletionTime']<0x1?b['push']('Average\x20completion\x20time\x20'+Math['round'](a['avgCompletionTime']*0x3c)+'\x20minutes'):b['push']('Average\x20completion\x20time\x20'+Math['round'](a['avgCompletionTime'])+'\x20hours')),a['hasCompensationFund']&&b['push']('Sufficient\x20compensation\x20fund'),a['hasArbitration']&&b['push']('Third-party\x20arbitration\x20guarantee'),a['reviewCount']!==undefined&&a['reviewCount']>0x0&&a['reviewLikeRate']!==undefined&&b['push']('Like\x20rate\x20'+Math['round'](a['reviewLikeRate']*0x64)+'%\x20('+a['reviewCount']+'\x20reviews)'),b['join'](';\x20')||'No\x20trust\x20data\x20available';}export function buildAcquisitionDashboard(a){const {orderCount:b,completedRate:c,avgCompletionTime:d,repeatCustomerRate:e,reviewLikeRate:f,reviewCount:g}=a;let h='cold_start';if(b>=0x32)h='optimization';else{if(b>=0x14)h='mature';else{if(b>=0x5)h='growing';}}const i=[];if(h==='cold_start')i['push']('Cold-start\x20stage:\x20set\x20first-order\x20Reward\x20to\x20attract\x20new\x20customers'),i['push']('Increase\x20compensation_fund\x20to\x20boost\x20initial\x20trust');else{if(h==='growing')i['push']('Growing\x20stage:\x20set\x20referral\x20cashback\x20Reward\x20for\x20viral\x20acquisition'),e!==undefined&&e<0.2&&i['push']('Repurchase\x20rate\x20is\x20low;\x20consider\x20setting\x20cumulative-spend\x20tiered\x20Reward');else h==='mature'?(f!==undefined&&f>0.8&&i['push']('High\x20like\x20rate;\x20you\x20can\x20highlight\x20trust\x20metrics\x20in\x20the\x20description'),e!==undefined&&e>0.3&&i['push']('High\x20repurchase\x20rate;\x20consider\x20setting\x20loyalty\x20Reward\x20to\x20incentivize\x20long-term\x20customers')):(i['push']('Optimization\x20stage:\x20fine-tune\x20pricing\x20and\x20Reward\x20strategies'),d!==undefined&&d>0x30&&i['push']('Completion\x20time\x20is\x20long;\x20consider\x20optimizing\x20the\x20Machine\x20process'));}return{'metrics':{'orderCount':b,'completedRate':c??0x0,'avgCompletionTime':d,'repeatCustomerRate':e,'reviewLikeRate':f,'reviewCount':g},'suggestions':i,'flywheelStage':h};}
@@ -1,5 +1,5 @@
1
1
  import { MAX_ALLOCATOR_COUNT } from "@wowok/wowok";
2
- export type AllocationMode = "Amount" | "Rate" | "Surplus" | "RateGross";
2
+ export type AllocationMode = "Amount" | "Rate" | "Surplus" | "RateGross" | "Formula";
3
3
  export type RecipientType = "GuardIdentifier" | "Entity" | "Signer";
4
4
  export type TriggerSource = "service_order_allocators" | "arbitration_fees" | "standalone";
5
5
  export interface AllocationScene {
@@ -25,6 +25,7 @@ export declare const ALLOCATION_MODE_AMOUNT = 0;
25
25
  export declare const ALLOCATION_MODE_RATE = 1;
26
26
  export declare const ALLOCATION_MODE_SURPLUS = 2;
27
27
  export declare const ALLOCATION_MODE_RATE_GROSS = 3;
28
+ export declare const ALLOCATION_MODE_FORMULA = 4;
28
29
  export declare const RATE_TOTAL_FULL = 10000;
29
30
  export declare const ALLOCATION_ERROR_CODES: {
30
31
  readonly ERECIPIENT_IDENTIFIER_NOT_ADDRESS: 1;
@@ -44,6 +45,7 @@ export declare const ALLOCATION_ERROR_CODES: {
44
45
  readonly ERECIPIENT_NOT_FOR_OBJECT: 15;
45
46
  readonly E_ONCE_TRIGGERED: 16;
46
47
  readonly EMIXED_RATE_BASES: 17;
48
+ readonly EFORMULA_SPEC_INVALID: 24;
47
49
  };
48
50
  export declare const ORDER_ALLOCATION_ALREADY_SPECIFIED = "E_ALLOCATION_ALREADY_SPECIFIED";
49
51
  export declare const ALLOCATION_SCENES: AllocationScene[];
@@ -1 +1 @@
1
- import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'allocator\x20append\x20rejected:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding'};return b[a];}
1
+ import{MAX_SHARING_COUNT,MAX_ALLOCATOR_COUNT}from'@wowok/wowok';export{MAX_ALLOCATOR_COUNT};export const ALLOCATION_MAX_SHARING_COUNT=MAX_SHARING_COUNT;export const ALLOCATION_MODE_AMOUNT=0x0;export const ALLOCATION_MODE_RATE=0x1;export const ALLOCATION_MODE_SURPLUS=0x2;export const ALLOCATION_MODE_RATE_GROSS=0x3;export const ALLOCATION_MODE_FORMULA=0x4;export const RATE_TOTAL_FULL=0x2710;export const ALLOCATION_ERROR_CODES={'ERECIPIENT_IDENTIFIER_NOT_ADDRESS':0x1,'EALLOCATOR_COUNT_EXCEEDED':0x2,'ENO_ALLOCATOR':0x3,'ERATE_NOT_10000':0x4,'EMULTIPLE_SURPLUS':0x5,'ERATE_EXCEEDS_10000':0x6,'EINSUFFICIENT_BALANCE':0x7,'EALLOCATORS_EMPTY':0x8,'ENO_PAYMENT_INFO':0x9,'ESHARING_COUNT_EXCEEDED':0xa,'ESHARING_MODE_INVALID':0xb,'EAMOUNT_BELOW_THRESHOLD':0xc,'EAMOUNT_EXCEEDS_MAX':0xd,'EZERO_DISTRIBUTION':0xe,'ERECIPIENT_NOT_FOR_OBJECT':0xf,'E_ONCE_TRIGGERED':0x10,'EMIXED_RATE_BASES':0x11,'EFORMULA_SPEC_INVALID':0x18};export const ORDER_ALLOCATION_ALREADY_SPECIFIED='E_ALLOCATION_ALREADY_SPECIFIED';export const ALLOCATION_SCENES=[{'id':'allocation_standard_three_way_split','name':'Standard\x20three-way\x20split\x20(merchant\x20/\x20platform\x20/\x20logistics)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'All\x20three\x20Treasury\x20objects\x20must\x20use\x20the\x20same\x20Coin<T>\x20type\x20as\x20the\x20Allocation','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20Treasury\x20address','Guard\x20verifies\x20order.service\x20binding\x20(query\x201563)\x20to\x20prevent\x20cross-project\x20bypass','Guard\x20verifies\x20progress.current_node\x20===\x20\x27Complete\x27'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','order_allocators\x20immutable\x20after\x20Service\x20publish\x20(R-A-10)'],'recommended_templates':['T-A-02']},{'id':'allocation_merchant_full_payment','name':'Merchant\x20full\x20payment\x20(single\x20recipient,\x20100%)','trigger_source':'service_order_allocators','distribution_strategy':'pure_rate','coin_type_note':'Simplest\x20configuration\x20—\x20single\x20Treasury\x20or\x20personal\x20address','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'single_relaxed','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate\x20sharing\x20=\x2010000','Guard\x20only\x20verifies\x20order\x20status\x20(no\x20complex\x20conditions)','who=Entity\x20can\x20be\x20either\x20Treasury\x20or\x20personal\x20wallet'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['Simplest\x20allocation\x20configuration','No\x20multi-party\x20coordination\x20required'],'recommended_templates':['T-A-01']},{'id':'allocation_refund_first_surplus_to_merchant','name':'Refund\x20first\x20+\x20surplus\x20to\x20merchant\x20(Amount\x20+\x20Surplus\x20hybrid)','trigger_source':'service_order_allocators','distribution_strategy':'amount_plus_surplus','coin_type_note':'Refund\x20amount\x20must\x20match\x20Coin<T>\x20precision','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Surplus'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x202\x20sharing\x20items','sharing[0]:\x20Amount=refund_value,\x20who=Entity(customer_address)','sharing[1]:\x20Surplus,\x20who=Entity(merchant_treasury)','fix\x20=\x20refund_value\x20(cached\x20Amount\x20sum)','threshold\x20=\x20refund_value\x20(ensure\x20sufficient\x20balance\x20for\x20Amount)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator','F-A-07:\x20fix\x20>=\x20threshold\x20(Amount\x20sum\x20must\x20cover\x20threshold)','fix\x20must\x20precisely\x20match\x20the\x20refund\x20amount'],'recommended_templates':['T-A-03']},{'id':'allocation_treasury_personal_alternatives','name':'Treasury\x20+\x20Personal\x20alternative\x20strategies\x20(caller-specified\x20guard)','trigger_source':'service_order_allocators','distribution_strategy':'first_match_alternatives','coin_type_note':'Both\x20target\x20addresses\x20must\x20accept\x20the\x20same\x20Coin<T>','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators,\x20each\x20with\x201\x20Rate=10000\x20sharing','Allocator[0]:\x20guard=guard_treasury,\x20who=Entity(treasury_address)','Allocator[1]:\x20guard=guard_personal,\x20who=Entity(personal_address)','Two\x20Guard\x20objects\x20must\x20be\x20different\x20addresses\x20(R-A-11)','caller-specified\x20guard:\x20caller\x20selects\x20Treasury\x20or\x20Personal\x20path\x20via\x20alloc_by_guard;\x20the\x20Passport\x20hard-verifies\x20the\x20selected\x20Guard\x20(failure\x20aborts\x20with\x20E_VERIFY_FAILED;\x20caller\x20must\x20switch\x20guard\x20and\x20retry)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-14:\x20allocators[].guard\x20must\x20be\x20unique','Treasury\x20Permission\x20should\x20match\x20Service\x20Permission\x20(R-A-12)','Guard\x20A\x20and\x20Guard\x20B\x20may\x20share\x20root/table\x20but\x20must\x20differ\x20in\x20description'],'recommended_templates':['T-A-04']},{'id':'allocation_tiered_by_order_amount','name':'Tiered\x20split\x20by\x20order\x20amount\x20(multi-Allocator\x20amount-threshold\x20switch)','trigger_source':'service_order_allocators','distribution_strategy':'tiered_by_amount','coin_type_note':'Amount\x20threshold\x20uses\x20Coin<T>\x20smallest\x20unit\x20(e.g.\x20MIST\x20for\x20WOW)','typical_allocator_count':0x2,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['2\x20Allocators\x20triggered\x20by\x20mutually\x20exclusive\x20Guard\x20conditions','Allocator[0]:\x20guard\x20verifies\x20order.amount\x20<\x20threshold,\x20Rate=10000\x20to\x20merchant','Allocator[1]:\x20guard\x20verifies\x20order.amount\x20>=\x20threshold,\x20Rate=8000/2000\x20split','caller-specified\x20guard:\x20caller\x20selects\x20the\x20matching\x20Allocator\x20based\x20on\x20order\x20amount;\x20allocator\x20order\x20is\x20irrelevant','Guard\x20queries\x20order.amount\x20(query\x201561)'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20(R-A-4-02\x20design\x20clarity)','Caller\x20must\x20select\x20correct\x20guard\x20based\x20on\x20order.amount\x20(no\x20auto-fallback)'],'recommended_templates':['T-A-05']},{'id':'allocation_dynamic_recipient','name':'Multi-role\x20split\x20with\x20dynamic\x20recipient\x20(GuardIdentifier)','trigger_source':'service_order_allocators','distribution_strategy':'dynamic_recipient','coin_type_note':'Passport\x20table\x20must\x20contain\x20address-typed\x20entry\x20at\x20the\x20referenced\x20identifier','typical_allocator_count':0x1,'sharing_who_types':['Entity','GuardIdentifier'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x203\x20Rate\x20sharing\x20items','sharing[0]:\x20Rate=8000,\x20who=Entity(merchant_treasury)','sharing[1]:\x20Rate=1000,\x20who=Entity(platform_treasury)','sharing[2]:\x20Rate=1000,\x20who=GuardIdentifier(0)\x20—\x20resolves\x20from\x20Passport\x20table','Customer\x20submits\x20Passport\x20with\x20referrer\x20address\x20at\x20identifier=0'],'dependencies':['Service','Treasury','Guard','Passport','Order','Payment'],'key_constraints':['F-A-13:\x20Passport\x20table[identifier]\x20must\x20be\x20address\x20type\x20(else\x20ERECIPIENT_IDENTIFIER_NOT_ADDRESS)','Guard\x20must\x20verify\x20Passport\x20completeness','Customer\x20order\x20must\x20include\x20Passport\x20with\x20referrer\x20address'],'recommended_templates':['T-A-06']},{'id':'allocation_arbitration_fees','name':'Arbitration\x20fees\x20split\x20(arbitrator\x20/\x20platform)','trigger_source':'arbitration_fees','distribution_strategy':'pure_rate','coin_type_note':'Coin<T>\x20must\x20match\x20Arbitration\x27s\x20fee\x20Coin\x20type','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Triggered\x20by\x20the\x20Arbitration\x20fee-allocation\x20operation\x20(permission\x20365),\x20direct\x20or\x20Passport\x20path','Single\x20Allocator,\x202\x20Rate\x20sharing\x20items:\x208000\x20arbitrator\x20/\x202000\x20platform','payment_info\x20reuses\x20Arbitration\x27s\x20payment_info','Caller\x20must\x20hold\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'dependencies':['Arbitration','Treasury','Guard','Payment'],'key_constraints':['Independent\x20from\x20Service-order\x20Allocation','Requires\x20ARBITRATION_FEES_ALLOC=365\x20permission'],'recommended_templates':['T-A-08']},{'id':'allocation_refund_to_order','name':'Refund\x20Allocator\x20(100%\x20to\x20Order\x20object)','trigger_source':'service_order_allocators','distribution_strategy':'refund_to_order','coin_type_note':'who=Entity\x20must\x20be\x20the\x20Order\x20object\x20address\x20(NOT\x20a\x20personal\x20wallet)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x201\x20Rate=10000\x20sharing','who=Entity(order_address)\x20—\x20funds\x20flow\x20back\x20to\x20Order,\x20not\x20personal\x20wallet','Guard\x20verifies\x20customer\x20refund\x20request\x20and\x20eligibility','Customer-side\x20risk\x20assessment\x20adds\x208-point\x20weight\x20(onchain_topology\x20graph\x20evaluation)'],'dependencies':['Service','Guard','Order','Payment'],'key_constraints':['who=Entity\x20MUST\x20be\x20Order\x20object\x20address\x20(not\x20personal\x20address)','Customer\x20due-diligence\x20rewards\x20this\x20configuration\x20(8-point\x20weight)','Refund\x20funds\x20return\x20to\x20Order\x20for\x20downstream\x20handling'],'recommended_templates':['T-A-07']},{'id':'allocation_max_capped_retain','name':'Max-capped\x20allocation\x20(retain\x20residual\x20balance)','trigger_source':'service_order_allocators','distribution_strategy':'max_capped','coin_type_note':'max\x20field\x20uses\x20Coin<T>\x20smallest\x20unit','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate'],'guard_requirement':'required','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['Single\x20Allocator\x20with\x20max\x20field\x20set','max\x20triple\x20role:\x20Amount\x20cap\x20+\x20NET\x20Rate\x20base\x20+\x20Surplus\x20cap','Amount\x20sharing\x20consumes\x20fix;\x20NET\x20Rate\x20sharing\x20uses\x20(max\x20-\x20fix)\x20as\x20base\x20(RateGross\x20uses\x20max\x20itself)','Residual\x20balance\x20remains\x20in\x20Allocation\x20for\x20subsequent\x20alloc()\x20calls'],'dependencies':['Service','Treasury','Guard','Order','Payment'],'key_constraints':['F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','NET\x20Rate:\x20max\x20-\x20fix\x20becomes\x20the\x20base\x20(NOT\x20balance\x20-\x20fix);\x20RateGross:\x20the\x20base\x20is\x20max\x20(fix\x20not\x20removed)','Residual\x20balance\x20may\x20be\x20claimed\x20by\x20re-triggering\x20alloc()'],'recommended_templates':[]},{'id':'allocation_multi_node_trigger','name':'Multi-Machine-node\x20triggered\x20allocation\x20(Complete\x20/\x20Refund\x20/\x20Lost)','trigger_source':'service_order_allocators','distribution_strategy':'multi_node_trigger','coin_type_note':'All\x20Allocators\x20share\x20the\x20same\x20Allocation\x27s\x20Coin<T>','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'multiple_unique','non_zero_threshold':![],'uses_max':![],'common_patterns':['3\x20Allocators\x20mapped\x20to\x20Machine\x20terminal\x20nodes\x20(Complete/Refund/Lost)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20progress.current_node\x20==\x20<node_name>','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20terminal\x20node\x20active\x20at\x20a\x20time)','Machine.required_allocators[]\x20describes\x20each\x20trigger_node\x20mapping'],'dependencies':['Service','Treasury','Guard','Order','Progress','Machine','Payment'],'key_constraints':['Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive','Sequence-sensitive:\x20business-flow\x20order','Machine.required_allocators[trigger_node]\x20must\x20map\x20to\x20Allocator\x20indices'],'recommended_templates':[]},{'id':'allocation_standalone_periodic_split','name':'Standalone\x20periodic\x20split\x20(investment\x20dividends\x20/\x20shared\x20income)','trigger_source':'standalone','distribution_strategy':'periodic_split','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20asset\x20being\x20distributed\x20(e.g.\x20profit\x20token)','typical_allocator_count':0x1,'sharing_who_types':['Entity'],'modes_used':['Rate'],'guard_requirement':'required','non_zero_threshold':![],'uses_max':![],'common_patterns':['Single\x20Allocator,\x20N\x20Rate\x20sharing\x20items,\x20sum(rates)\x20===\x2010000','Each\x20sharing.who=Entity\x20points\x20to\x20a\x20beneficiary\x20wallet\x20(not\x20Treasury)','Guard\x20verifies\x20time-based\x20trigger\x20(e.g.\x20context(Clock).timestamp\x20>=\x20next_release)\x20or\x20signer\x20authorization','User\x20calls\x20receive()\x20to\x20deposit\x20funds,\x20then\x20alloc()\x20to\x20trigger\x20distribution','No\x20Service/Order/Progress/Machine\x20context\x20required'],'dependencies':['Treasury','Guard','Payment'],'key_constraints':['F-A-05:\x20sum(rates)\x20===\x2010000\x20(pure\x20Rate\x20mode)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20+\x20Passport\x20MUST\x20be\x20sufficient','Caller\x20is\x20fully\x20responsible\x20for\x20receive\x20→\x20alloc\x20lifecycle\x20(no\x20auto-trigger)','Guard\x20should\x20bind\x20Signer\x20to\x20prevent\x20unauthorized\x20alloc()\x20calls'],'recommended_templates':['T-A-09']},{'id':'allocation_standalone_vesting','name':'Standalone\x20vesting\x20release\x20(time-locked\x20multi-stage\x20unlock)','trigger_source':'standalone','distribution_strategy':'time_locked_vesting','coin_type_note':'Coin<T>\x20must\x20match\x20the\x20vested\x20asset\x20(e.g.\x20locked\x20team\x20tokens)','typical_allocator_count':0x3,'sharing_who_types':['Entity'],'modes_used':['Amount','Rate','Surplus'],'guard_requirement':'multiple_unique','non_zero_threshold':!![],'uses_max':!![],'common_patterns':['N\x20Allocators,\x20each\x20mapped\x20to\x20a\x20vesting\x20stage\x20(e.g.\x2025%\x20at\x20month\x2012,\x2025%\x20at\x20month\x2024,\x2050%\x20surplus\x20at\x20month\x2036)','Each\x20Allocator\x27s\x20Guard\x20verifies\x20context(Clock).timestamp\x20>=\x20stage_unlock_time','Amount\x20sharing\x20per\x20stage\x20with\x20max\x20field\x20capping\x20the\x20cumulative\x20release','Final\x20Allocator\x20uses\x20Surplus\x20to\x20drain\x20remaining\x20balance\x20after\x20last\x20vesting\x20stage','Mutually\x20exclusive\x20Guard\x20conditions\x20(only\x20one\x20stage\x20active\x20at\x20a\x20time,\x20based\x20on\x20timestamp)','User\x20calls\x20receive()\x20to\x20deposit\x20locked\x20tokens,\x20then\x20alloc()\x20at\x20each\x20vesting\x20milestone'],'dependencies':['Treasury','Guard','Passport','Payment'],'key_constraints':['F-A-04:\x20at\x20most\x201\x20Surplus\x20per\x20Allocator\x20(final\x20stage\x20uses\x20Surplus\x20to\x20drain\x20remainder)','F-A-08:\x20Amount\x20sum\x20<=\x20max\x20(EAMOUNT_EXCEEDS_MAX)','R-A-3-04:\x20standalone\x20mode\x20has\x20no\x20Service-layer\x20access\x20control\x20—\x20Guard\x20time-lock\x20MUST\x20be\x20enforced','Guard\x20conditions\x20must\x20be\x20mutually\x20exclusive\x20by\x20timestamp\x20(R-A-4-02)','Caller\x20must\x20wait\x20for\x20time-lock\x20expiry\x20before\x20alloc()\x20succeeds;\x20otherwise\x20alloc()\x20silently\x20returns\x20(R-A-4-01)'],'recommended_templates':['T-A-10']}];export const ALLOCATION_LEDGER_VERSION='1.0.0';export function getScenesByTriggerSource(a){return ALLOCATION_SCENES['filter'](b=>b['trigger_source']===a);}export function getScenesByMode(a){return ALLOCATION_SCENES['filter'](b=>b['modes_used']['includes'](a));}export function getScenesByStrategy(a){return ALLOCATION_SCENES['filter'](b=>b['distribution_strategy']===a);}export function findSceneById(a){return ALLOCATION_SCENES['find'](b=>b['id']===a);}export function inferSceneFromIntent(a){const b=a['toLowerCase']();if(b['includes']('arbitration')||b['includes']('fees\x20alloc'))return findSceneById('allocation_arbitration_fees');if(b['includes']('standalone')||b['includes']('periodic\x20split')||b['includes']('investment\x20dividend')||b['includes']('shared\x20income')||b['includes']('dividend'))return findSceneById('allocation_standalone_periodic_split');if(b['includes']('vesting')||b['includes']('time-lock')||b['includes']('unlock\x20period')||b['includes']('locked\x20release')||b['includes']('token\x20unlock'))return findSceneById('allocation_standalone_vesting');if(b['includes']('refund')){if(b['includes']('order')||b['includes']('100%'))return findSceneById('allocation_refund_to_order');if(b['includes']('surplus')||b['includes']('merchant'))return findSceneById('allocation_refund_first_surplus_to_merchant');}if(b['includes']('alternative')||b['includes']('priority')||b['includes']('treasury')&&b['includes']('personal'))return findSceneById('allocation_treasury_personal_alternatives');if(b['includes']('tiered')||b['includes']('threshold\x20switch'))return findSceneById('allocation_tiered_by_order_amount');if(b['includes']('dynamic\x20recipient')||b['includes']('referrer')||b['includes']('guardidentifier'))return findSceneById('allocation_dynamic_recipient');if(b['includes']('retain')||b['includes']('max'))return findSceneById('allocation_max_capped_retain');if(b['includes']('multi-node')||b['includes']('multi\x20machine')||b['includes']('multi_node'))return findSceneById('allocation_multi_node_trigger');const c=(a['match'](/%/g)||[])['length'];if(c<=0x1)return findSceneById('allocation_merchant_full_payment');if(c>=0x2)return findSceneById('allocation_standard_three_way_split');return undefined;}export function getAllScenes(){return[...ALLOCATION_SCENES];}export function getScenesCount(){return ALLOCATION_SCENES['length'];}export function allocationModeToNumber(a){switch(a){case'Amount':return ALLOCATION_MODE_AMOUNT;case'Rate':return ALLOCATION_MODE_RATE;case'Surplus':return ALLOCATION_MODE_SURPLUS;case'RateGross':return ALLOCATION_MODE_RATE_GROSS;case'Formula':return ALLOCATION_MODE_FORMULA;}}export function allocationModeFromNumber(a){switch(a){case ALLOCATION_MODE_AMOUNT:return'Amount';case ALLOCATION_MODE_RATE:return'Rate';case ALLOCATION_MODE_SURPLUS:return'Surplus';case ALLOCATION_MODE_RATE_GROSS:return'RateGross';case ALLOCATION_MODE_FORMULA:return'Formula';default:throw new Error('Invalid\x20AllocationMode\x20number:\x20'+a);}}export function getRecipientType(a){if('GuardIdentifier'in a)return'GuardIdentifier';if('Entity'in a)return'Entity';return'Signer';}export function isSignerRecipient(a){return'Signer'in a;}export function isEntityRecipient(a){return'Entity'in a;}export function isGuardIdentifierRecipient(a){return'GuardIdentifier'in a;}export function getErrorName(a){for(const [b,d]of Object['entries'](ALLOCATION_ERROR_CODES)){if(d===a)return b;}return undefined;}export function getErrorDescription(a){const b={0x1:'GuardIdentifier\x20resolved\x20value\x20is\x20not\x20an\x20address\x20type',0x2:'Allocator\x20count\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20(100)',0x3:'No\x20Allocator\x20in\x20the\x20allocators\x20vector',0x4:'Pure\x20Rate\x20mode\x20sum\x20!=\x2010000\x20(no\x20Surplus\x20to\x20absorb\x20remainder)',0x5:'Multiple\x20Surplus\x20sharing\x20in\x20a\x20single\x20Allocator',0x6:'Rate\x20+\x20Surplus\x20sum\x20>\x2010000',0x7:'balance\x20<\x20threshold\x20(insufficient\x20balance\x20to\x20trigger\x20alloc)',0x8:'allocators.allocators\x20is\x20empty',0x9:'payment_info\x20is\x20None\x20when\x20alloc()\x20is\x20called',0xa:'sharing\x20count\x20exceeds\x20MAX_SHARING_COUNT\x20(100)',0xb:'sharing\x20mode\x20is\x20not\x200\x20(Amount)\x20/\x201\x20(Rate)\x20/\x202\x20(Surplus)\x20/\x203\x20(RateGross)\x20/\x204\x20(Formula)',0xc:'Amount\x20sum\x20(fix)\x20<\x20threshold',0xd:'Amount\x20sum\x20(fix)\x20>\x20max',0xe:'distribution\x20computes\x20to\x20zero\x20while\x20the\x20pool\x20still\x20holds\x20funds\x20(or\x20balance\x20is\x200)',0xf:'GuardIdentifier\x20recipient\x20address\x20!=\x20payment_info.for_object\x20anchor\x20(abort\x20fires\x20only\x20when\x20a\x20for_object\x20binding\x20is\x20declared)',0x10:'once-trigger\x20key\x20already\x20consumed\x20—\x20the\x20guard\x20submitted\x20the\x20reserved\x20identifier\x20255\x20and\x20its\x20raw\x20submission\x20bytes\x20were\x20recorded\x20as\x20a\x20(guard,\x20allocator\x20index,\x20raw\x20bytes)\x20dynamic-field\x20key\x20on\x20this\x20Allocation',0x11:'mixed\x20rate\x20bases\x20—\x20one\x20allocator\x20carries\x20both\x20NET\x20Rate\x20and\x20RateGross\x20entries\x20while\x20a\x20fixed\x20Amount\x20total\x20is\x20present\x20(rejected\x20only\x20when\x20fix\x20>\x200;\x20with\x20fix\x20==\x200\x20the\x20two\x20bases\x20coincide\x20and\x20mixing\x20is\x20allowed)',0x12:'RateGross\x20+\x20fixed\x20Amount\x20without\x20a\x20max\x20cap\x20—\x20plan\x20payability\x20unprovable\x20at\x20declaration\x20time',0x13:'guard\x20not\x20bound\x20to\x20any\x20allocator\x20on\x20this\x20Allocation\x20(was\x20a\x20silent\x20no-op\x20success\x20before)',0x14:'allocator\x20append\x20rejected:\x20new\x20Allocators\x20is\x20not\x20a\x20pure\x20extension\x20(prefix/threshold\x20changed)',0x15:'once-for-object\x20slot\x20(identifier\x20254)\x20armed\x20but\x20payment_info\x20declares\x20no\x20for_object\x20binding',0x18:'FormulaSpec\x20rejected:\x20selector\x20is\x20not\x20COUNT(0)/SUM(1),\x20allocator/slot\x20index\x20out\x20of\x20range,\x20or\x20the\x20target\x20sharing\x20slot\x20is\x20not\x20a\x20Formula\x20(mode\x204)\x20leg'};return b[a];}
@@ -99,6 +99,7 @@ export interface AllocationConstraintChecklist {
99
99
  F_A_15_order_allocators_immutable_after_publish: boolean;
100
100
  F_A_16_rate_gross_sum_le_10000: boolean;
101
101
  F_A_17_no_mixed_rate_bases: boolean;
102
+ F_A_18_formula_coefficient_le_10000: boolean;
102
103
  }
103
104
  export type AllocationPuzzleDimension = "A" | "B" | "C" | "D" | "E" | "F";
104
105
  export interface AllocationPuzzle {