@wowok/agent-mcp 3.3.1 → 3.3.2

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 (160) 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 +4 -2
  11. package/dist/composition/compile.js +1 -1
  12. package/dist/composition/inflight.d.ts +8 -4
  13. package/dist/composition/inflight.js +1 -1
  14. package/dist/customer/industry-risks.js +1 -1
  15. package/dist/customer/user-preferences.js +1 -1
  16. package/dist/extensions/business-modules.d.ts +7 -2
  17. package/dist/extensions/business-modules.js +1 -1
  18. package/dist/extensions/industry-audit.spec.js +1 -1
  19. package/dist/extensions/industry-pack.d.ts +3 -2
  20. package/dist/extensions/industry-pack.js +1 -1
  21. package/dist/extensions/modes.js +1 -1
  22. package/dist/graph/onchain/project-relationship.js +1 -1
  23. package/dist/knowledge/acquisition-flywheel.js +1 -1
  24. package/dist/knowledge/allocation-ledger.d.ts +4 -1
  25. package/dist/knowledge/allocation-ledger.js +1 -1
  26. package/dist/knowledge/allocation-puzzle.d.ts +1 -0
  27. package/dist/knowledge/allocation-puzzle.js +1 -1
  28. package/dist/knowledge/allocation-risk.d.ts +1 -1
  29. package/dist/knowledge/allocation-risk.js +1 -1
  30. package/dist/knowledge/arb-fund-facts.d.ts +5 -0
  31. package/dist/knowledge/arb-fund-facts.js +1 -1
  32. package/dist/knowledge/audit-rules.d.ts +4 -3
  33. package/dist/knowledge/audit-rules.js +1 -1
  34. package/dist/knowledge/baselines/rules/plan.json +48 -2
  35. package/dist/knowledge/baselines/rules/reward.json +1 -1
  36. package/dist/knowledge/builtin-templates.d.ts +9 -1
  37. package/dist/knowledge/builtin-templates.js +1 -1
  38. package/dist/knowledge/discount-threshold.js +1 -1
  39. package/dist/knowledge/guard-bindings.js +1 -1
  40. package/dist/knowledge/guard-design-patterns.js +1 -1
  41. package/dist/knowledge/guard-field-cognition.js +1 -1
  42. package/dist/knowledge/guard-lint.js +1 -1
  43. package/dist/knowledge/guard-submission-brief.d.ts +5 -0
  44. package/dist/knowledge/guard-submission-brief.js +1 -1
  45. package/dist/knowledge/guard-submission-prompt.d.ts +2 -1
  46. package/dist/knowledge/guard-submission-prompt.js +1 -1
  47. package/dist/knowledge/guard-templates.d.ts +1 -1
  48. package/dist/knowledge/guard-templates.js +1 -1
  49. package/dist/knowledge/industry-generalizer.js +1 -1
  50. package/dist/knowledge/industry-registry.js +1 -1
  51. package/dist/knowledge/industry-strategy.js +1 -1
  52. package/dist/knowledge/reward-ledger.js +1 -1
  53. package/dist/knowledge/reward-puzzle.d.ts +1 -1
  54. package/dist/knowledge/reward-risk.d.ts +1 -1
  55. package/dist/knowledge/scenario-modes.d.ts +2 -2
  56. package/dist/knowledge/scenario-modes.js +1 -1
  57. package/dist/knowledge/scenario-topology.js +1 -1
  58. package/dist/knowledge/strategy-manuals.js +1 -1
  59. package/dist/knowledge/template-index.d.ts +19 -0
  60. package/dist/knowledge/template-index.js +1 -0
  61. package/dist/knowledge/template-loader.d.ts +36 -0
  62. package/dist/knowledge/template-loader.js +1 -1
  63. package/dist/knowledge/template-registry.js +1 -1
  64. package/dist/knowledge/template-scanner.d.ts +7 -0
  65. package/dist/knowledge/template-scanner.js +1 -1
  66. package/dist/knowledge/tool-constraints.js +1 -1
  67. package/dist/knowledge/workflow-guidance.js +1 -1
  68. package/dist/monitor/MonitorLoop.js +1 -1
  69. package/dist/participation/radar-core.d.ts +1 -0
  70. package/dist/participation/radar-core.js +1 -1
  71. package/dist/persona/defaults.js +1 -1
  72. package/dist/persona/topology-focus.js +1 -1
  73. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  74. package/dist/playbooks/service-build/game-theory.d.ts +4 -1
  75. package/dist/playbooks/service-build/game-theory.js +1 -1
  76. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  77. package/dist/playbooks/service-build/merchant-guide.d.ts +25 -1
  78. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  79. package/dist/playbooks/service-build/migration-planner.js +1 -1
  80. package/dist/playbooks/service-build/object-panorama.js +1 -1
  81. package/dist/playbooks/service-build/participation-radar.js +1 -1
  82. package/dist/playbooks/service-build/pipeline-actions.d.ts +4 -1
  83. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  84. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  85. package/dist/playbooks/service-build/service-panorama.d.ts +4 -0
  86. package/dist/playbooks/service-build/service-panorama.js +1 -1
  87. package/dist/playbooks/service-build/service-quote.js +1 -1
  88. package/dist/relationship/derivation.d.ts +1 -1
  89. package/dist/review/index.js +1 -1
  90. package/dist/safety/confirm-gate.js +1 -1
  91. package/dist/schema/benchmark-migration/index.d.ts +35 -0
  92. package/dist/schema/benchmark-migration/index.js +1 -1
  93. package/dist/schema/call/allocation.d.ts +46 -3
  94. package/dist/schema/call/allocation.js +1 -1
  95. package/dist/schema/call/contact.js +1 -1
  96. package/dist/schema/call/guard.js +1 -1
  97. package/dist/schema/call/handler.js +1 -1
  98. package/dist/schema/call/order.js +1 -1
  99. package/dist/schema/call/progress.d.ts +6 -3
  100. package/dist/schema/call/progress.js +1 -1
  101. package/dist/schema/call/repository.js +1 -1
  102. package/dist/schema/call/reward.d.ts +2 -2
  103. package/dist/schema/call/reward.js +1 -1
  104. package/dist/schema/call/semantic.js +1 -1
  105. package/dist/schema/call/service.d.ts +8 -4
  106. package/dist/schema/call/service.js +1 -1
  107. package/dist/schema/common/index.js +1 -1
  108. package/dist/schema/goal/index.d.ts +54 -0
  109. package/dist/schema/goal/planning.d.ts +86 -0
  110. package/dist/schema/goal/planning.js +1 -1
  111. package/dist/schema/local/index.d.ts +39 -0
  112. package/dist/schema/local/index.js +1 -1
  113. package/dist/schema/operations.d.ts +20 -5
  114. package/dist/schema/operations.js +1 -1
  115. package/dist/schema/query/bi.d.ts +2 -0
  116. package/dist/schema/query/bi.js +1 -1
  117. package/dist/schema/query/index.d.ts +24 -12
  118. package/dist/schema/query/index.js +1 -1
  119. package/dist/schema/schema-version.d.ts +1 -1
  120. package/dist/schema/schema-version.js +1 -1
  121. package/dist/schema-query-impl/index.js +1 -1
  122. package/dist/schemas/account_operation.output.json +28 -3
  123. package/dist/schemas/benchmark_migration_operation.schema.json +87 -0
  124. package/dist/schemas/goal_operation.schema.json +94 -0
  125. package/dist/schemas/index.json +1 -1
  126. package/dist/schemas/onchain_operations.output.json +1 -1
  127. package/dist/schemas/onchain_operations.schema.json +409 -119
  128. package/dist/schemas/onchain_operations_allocation.schema.json +290 -6
  129. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -2
  130. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  131. package/dist/schemas/onchain_operations_demand.schema.json +3 -3
  132. package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
  133. package/dist/schemas/onchain_operations_guard.schema.json +63 -63
  134. package/dist/schemas/onchain_operations_machine.schema.json +1 -1
  135. package/dist/schemas/onchain_operations_order.schema.json +2 -2
  136. package/dist/schemas/onchain_operations_progress.schema.json +7 -3
  137. package/dist/schemas/onchain_operations_proof.schema.json +1 -1
  138. package/dist/schemas/onchain_operations_repository.schema.json +2 -2
  139. package/dist/schemas/onchain_operations_reward.schema.json +8 -8
  140. package/dist/schemas/onchain_operations_service.schema.json +20 -18
  141. package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
  142. package/dist/schemas/query_toolkit.output.json +67 -53
  143. package/dist/schemas/workflow_operation.schema.json +1 -1
  144. package/dist/tools/handlers/benchmark-migration.js +1 -1
  145. package/dist/tools/handlers/config.js +1 -1
  146. package/dist/tools/handlers/file-export.js +1 -1
  147. package/dist/tools/handlers/industry-pack.d.ts +1 -0
  148. package/dist/tools/handlers/industry-pack.js +1 -1
  149. package/dist/tools/handlers/local.js +1 -1
  150. package/dist/tools/handlers/onchain.d.ts +24 -0
  151. package/dist/tools/handlers/onchain.js +1 -1
  152. package/dist/tools/handlers/query.js +1 -1
  153. package/dist/tools/handlers/review-chain.d.ts +1 -1
  154. package/dist/tools/handlers/review-chain.js +1 -1
  155. package/dist/tools/handlers/schema-query.js +1 -1
  156. package/dist/tools/handlers/workflow.js +1 -1
  157. package/dist/tools/registry/agent.js +1 -1
  158. package/dist/tools/wip-deploy-assist.js +1 -1
  159. package/dist/tools/wrap.js +1 -1
  160. package/package.json +2 -2
@@ -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,8 @@ 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_DISABLED: 23;
49
+ readonly EFORMULA_SPEC_INVALID: 24;
47
50
  };
48
51
  export declare const ORDER_ALLOCATION_ALREADY_SPECIFIED = "E_ALLOCATION_ALREADY_SPECIFIED";
49
52
  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_DISABLED':0x17,'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',0x17:'Formula\x20pricing\x20mode\x20(4)\x20used\x20while\x20the\x20protocol\x20feature\x20flag\x20enable_allocator_formula_pricing\x20is\x20off',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 {
@@ -1 +1 @@
1
- import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![],'F_A_16_rate_gross_sum_le_10000':!![],'F_A_17_no_mixed_rate_bases':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const r of f['sharing']){!['Amount','Rate','Surplus','RateGross']['includes'](r['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+r['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](t=>t['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](t=>t['mode']==='Amount')['reduce']((t,u)=>t+Number(u['sharing']),0x0),i=f['sharing']['some'](t=>t['mode']==='RateGross'),j=f['sharing']['some'](t=>t['mode']==='Rate'),k=i&&h===0x0&&j,l=f['sharing']['filter'](t=>t['mode']==='Rate'||k&&t['mode']==='RateGross')['reduce']((t,u)=>t+Number(u['sharing']),0x0),n=g>0x0;!(j&&i&&h>0x0)&&(!n&&l>0x0&&l!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+l+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':l,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'}),n&&l>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+l+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':l,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'}));const o=Number(c['threshold']);h>0x0&&h<o&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+h+'\x20<\x20threshold\x20'+o,'current_value':h,'limit':o,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&h>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+h+'\x20>\x20max\x20'+Number(f['max']),'current_value':h,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const p=f['sharing']['filter'](t=>t['mode']==='RateGross')['reduce']((t,u)=>t+Number(u['sharing']),0x0);if(i&&!j){if(p>RATE_TOTAL_FULL)b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+p+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':p,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});else{if(f['max']!=null){const t=Number(f['max']);h*RATE_TOTAL_FULL+p*t>t*RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20plan\x20overdraws\x20max:\x20fix\x20'+h+'×10000\x20+\x20rateSum\x20'+p+'×'+t+'\x20>\x20'+t+'×10000','related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}else h>0x0&&p>=RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+p+'\x20with\x20fixed\x20total\x20'+h+'\x20and\x20no\x20max\x20must\x20be\x20<\x20'+RATE_TOTAL_FULL,'current_value':p,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}}j&&i&&h>0x0&&b['push']({'constraint_id':'F-A-17','severity':'high','message':'Allocator\x20'+f['guard']+'\x20mixes\x20NET\x20Rate\x20and\x20RateGross\x20with\x20a\x20fixed\x20Amount\x20total\x20('+h+')\x20—\x20abort\x20EMIXED_RATE_BASES','related_move_error':'EMIXED_RATE_BASES\x20(17)'});const q=f['sharing']['find'](u=>typeof u['who']==='object'&&'GuardIdentifier'in u['who']);if(q){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'NET\x20Rate:\x20total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix;\x20RateGross:\x20total_rates\x20=\x20max\x20(if\x20max)\x20else\x20balance\x20(fix\x20NOT\x20removed)'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/RateGross/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'sweep\x20the\x20remainder\x20to\x20surplus_recipient\x20(if\x20any)\x20—\x20uncapped:\x20the\x20whole\x20remaining\x20pool;\x20max-capped:\x20topped\x20up\x20to\x20the\x20cap'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
1
+ import{MAX_ALLOCATOR_COUNT,ALLOCATION_MAX_SHARING_COUNT,RATE_TOTAL_FULL}from'./allocation-ledger.js';export function initPuzzleFromIntent(a){const b={};return(a['action']||a['distribution_goal']||a['trigger_condition'])&&(b['intent']={'action':a['action']??'create','host_context':a['host_context']??'service_order_allocators','trigger_condition':a['trigger_condition']??'','distribution_goal':a['distribution_goal']??'','failure_conditions':a['failure_conditions']??[]}),b['constraints']={'F_A_01_allocator_count_le_100':!![],'F_A_02_sharing_count_le_100':!![],'F_A_03_sharing_mode_valid':!![],'F_A_04_at_most_1_surplus_per_allocator':!![],'F_A_05_pure_rate_sum_eq_10000':!![],'F_A_06_rate_plus_surplus_sum_le_10000':!![],'F_A_07_amount_sum_ge_threshold':!![],'F_A_08_amount_sum_le_max':!![],'F_A_09_balance_ge_threshold_at_alloc':!![],'F_A_10_payment_info_present':!![],'F_A_11_allocators_not_empty':!![],'F_A_12_order_at_most_1_allocation':!![],'F_A_13_guard_identifier_is_address':!![],'F_A_14_guard_addresses_unique':!![],'F_A_15_order_allocators_immutable_after_publish':!![],'F_A_16_rate_gross_sum_le_10000':!![],'F_A_17_no_mixed_rate_bases':!![],'F_A_18_formula_coefficient_le_10000':!![]},b;}export function checkPuzzleCompleteness(a){const b=[],c=[];if(!a['intent'])b['push']('A'),c['push']({'dimension':'A','reason':'Intent\x20not\x20specified\x20(action\x20+\x20distribution_goal)'});else{if(!a['intent']['distribution_goal'])b['push']('A'),c['push']({'dimension':'A','reason':'distribution_goal\x20is\x20empty'});else!a['intent']['host_context']&&(b['push']('A'),c['push']({'dimension':'A','reason':'host_context\x20(trigger\x20source)\x20must\x20be\x20specified'}));}if(!a['binding'])b['push']('B'),c['push']({'dimension':'B','reason':'Binding\x20not\x20specified\x20(coin_type\x20+\x20guard_objects)'});else{if(!a['binding']['coin_type'])b['push']('B'),c['push']({'dimension':'B','reason':'coin_type\x20is\x20missing'});else a['binding']['guard_objects']['length']===0x0&&(b['push']('B'),c['push']({'dimension':'B','reason':'guard_objects\x20list\x20is\x20empty\x20—\x20at\x20least\x201\x20Guard\x20required'}));}if(!a['data_source']&&a['intent']?.['action']==='create')b['push']('C'),c['push']({'dimension':'C','reason':'Data\x20source\x20not\x20specified\x20(allocators_config\x20+\x20payment_info)'});else a['data_source']&&a['data_source']['allocators_config']['allocators']['length']===0x0&&(b['push']('C'),c['push']({'dimension':'C','reason':'allocators_config.allocators\x20is\x20empty'}));return!a['operations']&&(b['push']('D'),c['push']({'dimension':'D','reason':'Operations\x20not\x20enumerated'})),!a['logic']&&(b['push']('E'),c['push']({'dimension':'E','reason':'Logic\x20flow\x20(7-step\x20alloc)\x20not\x20defined'})),!a['constraints']&&(b['push']('F'),c['push']({'dimension':'F','reason':'Constraints\x20not\x20checked'})),{'dimensions':['A','B','C','D','E','F'],'missing':b,'missing_details':c,'complete':b['length']===0x0,'next_step':b['length']===0x0?'Puzzle\x20complete\x20—\x20ready\x20for\x20confirmation\x20text\x20generation':'Next:\x20complete\x20dimension\x20'+b[0x0]+'\x20—\x20'+c[0x0]['reason']};}export function validateConstraints(a){const b=[];if(!a['data_source'])return b;const c=a['data_source']['allocators_config'];c['allocators']['length']>MAX_ALLOCATOR_COUNT&&b['push']({'constraint_id':'F-A-01','severity':'critical','message':'Allocator\x20count\x20'+c['allocators']['length']+'\x20exceeds\x20MAX_ALLOCATOR_COUNT\x20'+MAX_ALLOCATOR_COUNT,'current_value':c['allocators']['length'],'limit':MAX_ALLOCATOR_COUNT,'related_move_error':'EALLOCATOR_COUNT_EXCEEDED\x20(2)'});c['allocators']['length']===0x0&&b['push']({'constraint_id':'F-A-11','severity':'critical','message':'allocators.allocators\x20is\x20empty\x20—\x20at\x20least\x201\x20Allocator\x20required','related_move_error':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)'});const d=c['allocators']['map'](f=>f['guard']),e=new Set(d);e['size']!==d['length']&&b['push']({'constraint_id':'F-A-14','severity':'medium','message':'Duplicate\x20Guard\x20addresses\x20in\x20allocators\x20('+d['length']+'\x20entries,\x20'+e['size']+'\x20unique)\x20—\x20alloc_by_guard\x20address\x20match\x20only\x20hits\x20the\x20first,\x20subsequent\x20duplicate\x20Allocators\x20are\x20never\x20reachable'});for(const f of c['allocators']){f['sharing']['length']>ALLOCATION_MAX_SHARING_COUNT&&b['push']({'constraint_id':'F-A-02','severity':'critical','message':'Allocator\x20'+f['guard']+'\x20has\x20'+f['sharing']['length']+'\x20sharing\x20entries,\x20exceeds\x20MAX_SHARING_COUNT\x20'+ALLOCATION_MAX_SHARING_COUNT,'current_value':f['sharing']['length'],'limit':ALLOCATION_MAX_SHARING_COUNT,'related_move_error':'ESHARING_COUNT_EXCEEDED\x20(10)'});for(const t of f['sharing']){!['Amount','Rate','Surplus','RateGross','Formula']['includes'](t['mode'])&&b['push']({'constraint_id':'F-A-03','severity':'critical','message':'Invalid\x20sharing\x20mode:\x20'+t['mode'],'related_move_error':'ESHARING_MODE_INVALID\x20(11)'});}const g=f['sharing']['filter'](u=>u['mode']==='Surplus')['length'];g>0x1&&b['push']({'constraint_id':'F-A-04','severity':'high','message':'Allocator\x20'+f['guard']+'\x20has\x20'+g+'\x20Surplus\x20sharing\x20—\x20at\x20most\x201\x20allowed','current_value':g,'limit':0x1,'related_move_error':'EMULTIPLE_SURPLUS\x20(5)'});const h=f['sharing']['filter'](u=>u['mode']==='Amount')['reduce']((u,v)=>u+Number(v['sharing']),0x0),i=f['sharing']['some'](u=>u['mode']==='RateGross'),j=f['sharing']['some'](u=>u['mode']==='Rate'),k=f['sharing']['some'](u=>u['mode']==='Formula'),l=i&&h===0x0&&j,n=f['sharing']['filter'](u=>u['mode']==='Rate'||l&&u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0),o=g>0x0;!(j&&i&&h>0x0)&&(!o&&n>0x0&&n!==RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-05','severity':'high','message':'Pure\x20Rate\x20mode\x20(no\x20Surplus)\x20sum\x20'+n+'\x20!=\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_NOT_10000\x20(4)'}),o&&n>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-06','severity':'high','message':'Rate\x20+\x20Surplus\x20mode\x20sum\x20'+n+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':n,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'}));const p=Number(c['threshold']);!k&&h>0x0&&h<p&&b['push']({'constraint_id':'F-A-07','severity':'high','message':'Amount\x20sum\x20'+h+'\x20<\x20threshold\x20'+p,'current_value':h,'limit':p,'related_move_error':'EAMOUNT_BELOW_THRESHOLD\x20(12)'});f['max']!=null&&h>Number(f['max'])&&b['push']({'constraint_id':'F-A-08','severity':'medium','message':'Amount\x20sum\x20'+h+'\x20>\x20max\x20'+Number(f['max']),'current_value':h,'limit':Number(f['max']),'related_move_error':'EAMOUNT_EXCEEDS_MAX\x20(13)'});const q=f['sharing']['filter'](u=>u['mode']==='RateGross')['reduce']((u,v)=>u+Number(v['sharing']),0x0);if(i&&!j){if(q>RATE_TOTAL_FULL)b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20>\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});else{if(f['max']!=null){const u=Number(f['max']);h*RATE_TOTAL_FULL+q*u>u*RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20plan\x20overdraws\x20max:\x20fix\x20'+h+'×10000\x20+\x20rateSum\x20'+q+'×'+u+'\x20>\x20'+u+'×10000','related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}else h>0x0&&q>=RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-16','severity':'high','message':'RateGross\x20sum\x20'+q+'\x20with\x20fixed\x20total\x20'+h+'\x20and\x20no\x20max\x20must\x20be\x20<\x20'+RATE_TOTAL_FULL,'current_value':q,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}}j&&i&&h>0x0&&b['push']({'constraint_id':'F-A-17','severity':'high','message':'Allocator\x20'+f['guard']+'\x20mixes\x20NET\x20Rate\x20and\x20RateGross\x20with\x20a\x20fixed\x20Amount\x20total\x20('+h+')\x20—\x20abort\x20EMIXED_RATE_BASES','related_move_error':'EMIXED_RATE_BASES\x20(17)'});for(const v of f['sharing']['filter'](w=>w['mode']==='Formula')){const w=Number(v['sharing']);Number['isFinite'](w)&&w>RATE_TOTAL_FULL&&b['push']({'constraint_id':'F-A-18','severity':'high','message':'Allocator\x20'+f['guard']+'\x20Formula\x20coefficient\x20'+w+'\x20>\x20'+RATE_TOTAL_FULL+'\x20(basis-point\x20ceiling,\x20ERATE_EXCEEDS_10000)','current_value':w,'limit':RATE_TOTAL_FULL,'related_move_error':'ERATE_EXCEEDS_10000\x20(6)'});}const r=f['sharing']['find'](x=>typeof x['who']==='object'&&'GuardIdentifier'in x['who']);if(r){}}return b;}export function generateConfirmationText(a){const b=[];b['push']('═══\x20Allocation\x20Confirmation\x20═══'),b['push']('');if(a['intent']){b['push']('Action:\x20'+a['intent']['action']),b['push']('Host\x20context:\x20'+a['intent']['host_context']),b['push']('Trigger:\x20'+a['intent']['trigger_condition']),b['push']('Distribution\x20goal:\x20'+a['intent']['distribution_goal']);if(a['intent']['failure_conditions']['length']>0x0){b['push']('Failure\x20conditions:');for(const d of a['intent']['failure_conditions'])b['push']('\x20\x20-\x20'+d);}b['push']('');}if(a['binding']){b['push']('─\x20Binding\x20──────────────'),b['push']('Coin\x20type:\x20'+a['binding']['coin_type']);if(a['binding']['host_service'])b['push']('Host\x20Service:\x20'+a['binding']['host_service']);if(a['binding']['host_arbitration'])b['push']('Host\x20Arbitration:\x20'+a['binding']['host_arbitration']);if(a['binding']['bound_order'])b['push']('Bound\x20Order:\x20'+a['binding']['bound_order']);if(a['binding']['trigger_node'])b['push']('Trigger\x20node:\x20'+a['binding']['trigger_node']);b['push']('Guard\x20objects\x20('+a['binding']['guard_objects']['length']+'):\x20'+a['binding']['guard_objects']['join'](',\x20')),b['push']('Payment\x20info\x20source:\x20'+a['binding']['payment_info_source']),b['push']('');}if(a['data_source']){const e=a['data_source']['allocators_config'];b['push']('─\x20Data\x20Source\x20──────────────'),b['push']('Description:\x20'+e['description']),b['push']('Threshold:\x20'+e['threshold']),b['push']('Allocators:\x20'+e['allocators']['length']),e['allocators']['forEach']((f,g)=>{b['push']('\x20\x20['+g+']\x20guard='+f['guard']+',\x20sharing='+f['sharing']['length']+'\x20items,\x20fix='+(f['fix']??'0')+',\x20max='+(f['max']??'null')),f['sharing']['forEach']((h,k)=>{b['push']('\x20\x20\x20\x20\x20\x20('+k+')\x20who='+JSON['stringify'](h['who'])+',\x20sharing='+h['sharing']+',\x20mode='+h['mode']);});}),b['push']('Payment\x20info\x20for_object:\x20'+a['data_source']['payment_info']['for_object']+(a['data_source']['payment_info']['for_object']?'\x20(ENFORCED\x20at\x20alloc:\x20GuardIdentifier\x20submissions\x20must\x20equal\x20this\x20address,\x20abort\x2015\x20on\x20mismatch)':'\x20(no\x20anchor:\x20nothing\x20enforced\x20on-chain,\x20recipient\x20routing\x20is\x20the\x20creator\x27s\x20business)')),b['push']('Coin\x20source:\x20'+a['data_source']['coin_source']),b['push']('');}if(a['logic']){b['push']('─\x20Logic\x20──────────────'),b['push']('Guard\x20matching:\x20'+a['logic']['guard_matching_strategy']),b['push']('alloc()\x20flow\x20('+a['logic']['alloc_flow']['length']+'\x20steps):');for(const f of a['logic']['alloc_flow']){b['push']('\x20\x20'+f['step']+'.\x20'+f['action']+':\x20'+f['description']);}b['push']('');}const c=validateConstraints(a);if(c['length']>0x0){b['push']('─\x20Constraint\x20Violations\x20──────────────');for(const g of c){b['push']('\x20\x20['+g['severity']+']\x20'+g['constraint_id']+':\x20'+g['message']);}b['push']('');}return b['join']('\x0a');}export function buildDefaultAllocFlow(){return[{'step':0x1,'action':'pre_check','description':'assert\x20balance\x20>=\x20threshold,\x20payment_info.is_some(),\x20allocators\x20not\x20empty'},{'step':0x2,'action':'guard_lookup','description':'iterate\x20allocators[],\x20locate\x20alloc.guard\x20==\x20alloc_by_guard\x20address;\x20on\x20hit\x20run\x20the\x20Passport\x20guard-result\x20hard\x20verification\x20(failure\x20aborts\x20E_VERIFY_FAILED)'},{'step':0x3,'action':'rate_base_calc','description':'NET\x20Rate:\x20total_rates\x20=\x20max\x20-\x20fix\x20(if\x20max)\x20else\x20balance\x20-\x20fix;\x20RateGross:\x20total_rates\x20=\x20max\x20(if\x20max)\x20else\x20balance\x20(fix\x20NOT\x20removed)'},{'step':0x4,'action':'sharing_distribution','description':'iterate\x20sharing[],\x20split\x20by\x20mode\x20(Amount/Rate/RateGross/Surplus\x20placeholder)'},{'step':0x5,'action':'surplus_distribution','description':'sweep\x20the\x20remainder\x20to\x20surplus_recipient\x20(if\x20any)\x20—\x20uncapped:\x20the\x20whole\x20remaining\x20pool;\x20max-capped:\x20topped\x20up\x20to\x20the\x20cap'},{'step':0x6,'action':'recipient_resolution','description':'resolve\x20address\x20from\x20GuardIdentifier(passport)\x20/\x20Entity(static)\x20/\x20Signer(tx\x20sender);\x20GuardIdentifier\x20submissions\x20are\x20additionally\x20checked\x20against\x20payment_info.for_object\x20when\x20it\x20is\x20Some\x20(mismatch\x20aborts\x20ERECIPIENT_NOT_FOR_OBJECT\x2015;\x20None\x20=\x20no\x20anchor,\x20nothing\x20enforced)'},{'step':0x7,'action':'payment_creation','description':'create\x20Payment\x20object,\x20push\x20to\x20self.payment\x20vector'}];}export function buildDefaultRecipientRules(){return[{'recipient_type':'GuardIdentifier','resolution_source':'passport_table','safety_level':'safe'},{'recipient_type':'Entity','resolution_source':'static_address','safety_level':'safe'},{'recipient_type':'Signer','resolution_source':'tx_sender','safety_level':'dangerous'}];}export function buildDefaultLogicPuzzle(){return{'alloc_flow':buildDefaultAllocFlow(),'guard_matching_strategy':'caller_specified_guard','recipient_resolution_rules':buildDefaultRecipientRules()};}export const ALLOCATION_PUZZLE_VERSION='1.0.0';
@@ -40,7 +40,7 @@ export interface AllocationRiskCheckContext {
40
40
  Signer: "signer";
41
41
  };
42
42
  sharing: string | number;
43
- mode: "Amount" | "Rate" | "Surplus" | "RateGross";
43
+ mode: "Amount" | "Rate" | "Surplus" | "RateGross" | "Formula";
44
44
  }[];
45
45
  fix?: string | number;
46
46
  max?: string | number | null;
@@ -1 +1 @@
1
- import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft}from'./recipient-constraint.js';import{checkEntityRecipientsSync}from'./entity-recipient-guard.js';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,evaluateCondition}from'../config/rule-engine.js';const AUTO_FIXABLE=new Set(['R-A-1-02#0','R-A-1-02#1','R-A-1-02#2','R-A-1-02#3','R-A-1-02#4','R-A-1-03#0','R-A-1-03#2','R-A-2-03#0','R-A-5-03#0']),RELATED_MOVE_ERROR={'R-A-1-01#0':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','R-A-1-01#1':'ENO_ALLOCATOR\x20(3)','R-A-1-02#0':'ERATE_NOT_10000\x20(4)','R-A-1-02#1':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#2':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#3':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#4':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#5':'EMIXED_RATE_BASES\x20(17)','R-A-1-03#0':'EMULTIPLE_SURPLUS\x20(5)','R-A-1-04#0':'NO\x20chain\x20rejection\x20—\x20allocation\x20pays\x20Rate\x20legs\x20then\x20the\x20Surplus\x20remainder\x20verbatim,\x20and\x20order_allocators\x20freezes\x20at\x20Service\x20publish\x20(E_ALREADY_PUBLISHED\x20=\x206),\x20so\x20the\x20misrouted\x20share\x20is\x20permanent','R-A-1-03#1':'EAMOUNT_BELOW_THRESHOLD\x20(12)','R-A-1-03#2':'EAMOUNT_EXCEEDS_MAX\x20(13)','R-A-2-02#0':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','R-A-2-04#0':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','R-A-2-04#1':'NO\x20chain\x20rejection\x20when\x20the\x20anchor\x20is\x20None\x20—\x20allocation.move:444-448\x20gates\x20the\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20assertion\x20on\x20option::is_some,\x20and\x20the\x20comment\x20at\x20allocation.move:434-443\x20hands\x20the\x20due-diligence\x20obligation\x20to\x20this\x20tooling\x20layer;\x20order/arbitration\x20flows\x20always\x20anchor\x20(service.move:394,\x20arbitration.move:342),\x20so\x20None\x20is\x20reachable\x20only\x20via\x20standalone/custom\x20PaymentInfo','R-A-5-01#0':'E_ALLOCATION_ALREADY_SPECIFIED','R-A-5-02#0':'ENO_PAYMENT_INFO\x20(9)','R-RECIPIENT-03#0':'NO\x20chain\x20rejection\x20for\x20an\x20Entity\x20recipient\x20of\x20any\x20address\x20—\x20the\x20SDK\x20substitutes\x20the\x20default\x20local\x20account\x20before\x20the\x20address\x20reaches\x20Move,\x20and\x20allocation.move:250-255\x20swallows\x20Recipient::Entity\x20in\x20a\x20(_)\x20catch-all\x20at\x20declaration\x20while\x20allocation.move:451-453\x20/\x20:514\x20forwards\x20the\x20raw\x20address\x20straight\x20to\x20the\x20payout\x20constructor\x20(retracted\x202026-10-06:\x20there\x20is\x20no\x20ERECIPIENT_ZERO_ENTITY\x20constant;\x20grep\x20returns\x200\x20.move\x20hits)'},RELATED_GUARD_RISK={'R-A-2-01#0':'R-C3-06','R-A-3-04#0':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','R-A-4-01#0':'R-X1-05','R-A-4-03#0':'reentrancy\x20low'};export function allocationRiskFacts(b){const c=b['allocators_config'],d=!!c,e=d?c['allocators']:[];let f,g;if(d&&e['length']>0x0)for(let a4=0x0;a4<e['length'];a4++){if(e[a4]['sharing']['length']===0x0){f=a4,g=e[a4]['guard'];break;}}let h,j,k,l=![],n=![];if(d)for(let a5=0x0;a5<e['length'];a5++){const a6=e[a5],a7=a6['sharing']['some'](af=>af['mode']==='RateGross'),a8=a6['sharing']['filter'](af=>af['mode']==='Amount')['reduce']((af,ag)=>af+Number(ag['sharing']),0x0);if(a7&&a8>0x0)continue;const a9=a7&&a8===0x0&&a6['sharing']['some'](af=>af['mode']==='Rate'),aa=a6['sharing']['filter'](af=>af['mode']==='Rate'||a9&&af['mode']==='RateGross');if(aa['length']===0x0)continue;const ab=aa['map'](af=>Number(af['sharing']));if(ab['some'](af=>!Number['isFinite'](af)))continue;const ad=ab['reduce']((af,ag)=>af+ag,0x0),ae=a6['sharing']['some'](af=>af['mode']==='Surplus');if(!ae&&ad!==RATE_TOTAL_FULL){h=a5,j=a6['guard'],k=ad,l=!![];break;}if(ae&&ad>RATE_TOTAL_FULL){h=a5,j=a6['guard'],k=ad,n=!![];break;}}let o,p,q,r,t,u,v=![],w,x;if(d)for(let af=0x0;af<e['length'];af++){const ag=e[af],ah=ag['sharing']['some'](am=>am['mode']==='Rate'),ai=ag['sharing']['filter'](am=>am['mode']==='RateGross');if(ai['length']===0x0)continue;const aj=ag['sharing']['filter'](am=>am['mode']==='Amount')['reduce']((am,an)=>am+Number(an['sharing']),0x0);if(ah){if(aj>0x0){v=!![],w=af,x=ag['guard'];break;}continue;}const ak=ai['map'](am=>Number(am['sharing']));if(ak['some'](am=>!Number['isFinite'](am))||!Number['isFinite'](aj))continue;const al=ak['reduce']((am,an)=>am+an,0x0);if(al>RATE_TOTAL_FULL){o='sum_exceeds_10000',p=af,q=ag['guard'],r=al,t=aj;break;}if(ag['max']!=null){const am=Number(ag['max']);if(Number['isFinite'](am)&&aj*RATE_TOTAL_FULL+al*am>am*RATE_TOTAL_FULL){o='cap_fit',p=af,q=ag['guard'],r=al,t=aj,u=am;break;}}else{if(aj>0x0&&al>=RATE_TOTAL_FULL){o='fixed_full',p=af,q=ag['guard'],r=al,t=aj;break;}}}let y,z,A,B,C,D,E;if(d){const an=Number(c['threshold']);for(let ao=0x0;ao<e['length'];ao++){const ap=e[ao],aq=ap['sharing']['filter'](at=>at['mode']==='Surplus')['length'];if(aq>0x1){y='multiple_surplus',z=ao,A=ap['guard'],B=aq;break;}const ar=ap['sharing']['filter'](at=>at['mode']==='Amount')['reduce']((at,au)=>at+Number(au['sharing']),0x0),as=ap['sharing']['some'](at=>at['mode']==='Rate'||at['mode']==='Surplus');if(!as&&ar>0x0&&ar<an){y='below_threshold',z=ao,A=ap['guard'],C=ar,D=an;break;}if(ap['max']!=null&&ar>Number(ap['max'])){y='exceeds_max',z=ao,A=ap['guard'],C=ar,E=Number(ap['max']);break;}}}let F=![],G,H,I;if(d)for(let at=0x0;at<e['length'];at++){const au=e[at],av=au['sharing']['some'](ax=>'Signer'in ax['who']),aw=b['guard_signer_bindings']?.[au['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':av,'caller_identity_constrained':aw})){F=!![],G=at,H=au['guard'],I=aw;break;}}let J,K,L;if(d&&b['passport_identifier_types'])for(let ax=0x0;ax<e['length'];ax++){const ay=e[ax],az=ay['sharing']['find'](aC=>'GuardIdentifier'in aC['who']);if(!az)continue;const aA=az['who']['GuardIdentifier'],aB=b['passport_identifier_types'][aA];if(aB!==undefined&&aB!=='address'){J=aA,K=aB,L=ax;break;}}let M=![],N,O,P,Q;if(d){const aC=e['map'](aE=>aE['guard']),aD=new Set(aC);if(aD['size']!==aC['length']){const aE=aC['filter']((aF,aG)=>aC['indexOf'](aF)!==aG);M=!![],N=aC['length'],O=aD['size'],P=aE['join'](',\x20'),Q=aE['join'](',');}}const R=b['payment_info_for_object']!==undefined,S=d&&e['some'](aF=>aF['sharing']['some'](aG=>'GuardIdentifier'in aG['who'])),T=!!b['payment_info_for_object'];let U=![],V,W;if(d&&b['referenced_treasuries_permissions']&&b['host_service_permission'])for(const aF of e){for(const aG of aF['sharing']){if(!(aG['who']!==null&&typeof aG['who']==='object'&&'Entity'in aG['who']))continue;const aH=aG['who']['Entity'],aI=b['referenced_treasuries_permissions'][aH];if(aI&&aI!==b['host_service_permission']){U=!![],V=aH,W=aI;break;}}if(U)break;}let X;if(b['trigger_source']==='standalone'&&d){const aJ=[];for(const aK of e){const aL=b['guard_signer_bindings']?.[aK['guard']]===!![],aM=b['guard_has_time_lock']?.[aK['guard']]===!![];if(!aL&&!aM)aJ['push'](aK['guard']);}X=aJ;}let Y;if(d)for(let aN=0x0;aN<e['length'];aN++){const aO=e[aN],aP=aO['sharing']['length']>0x0&&aO['sharing']['every'](aQ=>aQ['mode']==='Amount');if(aP){Y=aN;break;}}let Z,a0,a1;if(d){const aQ=aS=>{if(aS!==null&&typeof aS==='object'){if('Entity'in aS)return'entity:'+String(aS['Entity'])['trim']()['toLowerCase']();if('GuardIdentifier'in aS)return'guard_identifier:'+Number(aS['GuardIdentifier']);if('Signer'in aS)return'signer';}return undefined;},aR=aS=>{if(aS!==null&&typeof aS==='object'){if('Entity'in aS)return'Entity('+aS['Entity']+')';if('GuardIdentifier'in aS)return'GuardIdentifier('+aS['GuardIdentifier']+')';if('Signer'in aS)return'Signer';}return String(aS);};for(let aS=0x0;aS<e['length'];aS++){const aT=e[aS],aU=new Set(aT['sharing']['filter'](aW=>aW['mode']==='Rate'||aW['mode']==='RateGross')['map'](aW=>aQ(aW['who']))['filter'](aW=>aW!==undefined));if(aU['size']===0x0)continue;const aV=aT['sharing']['find'](aW=>{if(aW['mode']!=='Surplus')return![];const aX=aQ(aW['who']);return aX!==undefined&&aU['has'](aX);});if(aV){Z=aS,a0=aT['guard'],a1=aR(aV['who']);break;}}}const a2=d?checkEntityRecipientsSync(c,{'builderAddress':b['builder_address']}):[],a3=a2['map'](aW=>'Allocator['+aW['allocator_index']+'].sharing['+aW['sharing_index']+']\x20('+aW['reason']+')');return{'allocators_config_present':d,'allocators_count':d?e['length']:undefined,'allocators_empty':d&&e['length']===0x0,'empty_sharing_allocator_index':f,'empty_sharing_allocator_guard':g,'rate_rule_index':h,'rate_rule_guard':j,'rate_rule_sum':k,'rate_rule_pure':l,'rate_rule_exceed':n,'rate_total_full':RATE_TOTAL_FULL,'rate_gross_branch':o,'rate_gross_index':p,'rate_gross_guard':q,'rate_gross_sum':r,'rate_gross_fix':t,'rate_gross_max':u,'mixed_rate_bases_present':v,'mixed_rate_bases_index':w,'mixed_rate_bases_guard':x,'amount_rule_branch':y,'amount_rule_index':z,'amount_rule_guard':A,'amount_rule_surplus_count':B,'amount_rule_amount_sum':C,'amount_rule_threshold':D,'amount_rule_max':E,'surplus_dup_rate_index':Z,'surplus_dup_rate_guard':a0,'surplus_dup_rate_recipient':a1,'signer_theft_detected':F,'signer_theft_index':G,'signer_theft_guard':H,'signer_theft_guard_bound':I,'guard_id_bad_identifier':J,'guard_id_bad_type':K,'guard_id_bad_index':L,'entity_recipient_bad_count':a2['length'],'entity_recipient_bad_count_display':String(a2['length']),'entity_recipient_bad_rows_csv_sp':a3['length']>0x0?a3['join'](',\x20'):undefined,'entity_recipient_bad_rows_csv':a3['length']>0x0?a3['join'](','):undefined,'duplicate_guards_present':M,'allocators_total':N,'allocators_unique':O,'duplicate_guards_csv_sp':P,'duplicate_guards_csv':Q,'for_object_anchor_known':R,'guard_identifier_recipient_present':S,'for_object_anchor_set':T,'for_object_anchor':R&&T?b['payment_info_for_object']??undefined:undefined,'host_service_published':b['host_service_published'],'treasury_perm_mismatch':U,'treasury_perm_entity':V,'treasury_perm_treasury':W,'host_service_permission':b['host_service_permission'],'allocation_create_op':b['operation_type']==='create','allocation_standalone':b['trigger_source']==='standalone','trigger_source_display':b['trigger_source']??'unknown','standalone_weak_guards_count':X?.['length'],'standalone_weak_guards_csv_sp':X?.['join'](',\x20'),'standalone_weak_guards_csv':X?.['join'](','),'has_fallback_allocator':b['has_fallback_allocator'],'guard_conditions_mutually_exclusive':b['guard_conditions_mutually_exclusive'],'has_fallback_allocator_display':String(b['has_fallback_allocator']??![]),'mutually_exclusive_display':String(b['guard_conditions_mutually_exclusive']??![]),'pure_amount_index':Y,'order_already_has_allocation':b['order_already_has_allocation'],'bound_order_display':b['bound_order']??'unknown','bound_order_paren_display':b['bound_order']??'(unknown)','has_payment_info':b['has_payment_info'],'operation_type':b['operation_type'],'max_allocator_count':MAX_ALLOCATOR_COUNT};}function allocationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['allocation'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27allocation\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function firedCaseKey(a,b,c){const d=a['find'](e=>e['rule_id']===c);if(d)for(let e=0x0;e<d['cases']['length'];e++){if(evaluateCondition(d['cases'][e]['when'],b))return c+'#'+e;}return c+'#0';}function findingToAllocationRisk(a,b){const c=RELATED_MOVE_ERROR[b],d=RELATED_GUARD_RISK[b];return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...c!==undefined?{'related_move_error':c}:{},...d!==undefined?{'related_guard_risk':d}:{},'auto_fixable':AUTO_FIXABLE['has'](b),...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ALLOCATION_RISK_VERSION='1.2.0';export function getAllRiskRules(){const a=factoryRulePack('allocation');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const d=allocationRiskFacts(c),{findings:e}=evaluateRuleBook([b],d);return e['length']>0x0?findingToAllocationRisk(e[0x0],firedCaseKey([b],d,b['rule_id'])):null;}}));}export function assessAllocationRisks(a){const b=allocationRuleBook(),c=allocationRiskFacts(a),{findings:d}=evaluateRuleBook(b,c),e=d['map'](j=>findingToAllocationRisk(j,firedCaseKey(b,c,j['rule_id']))),f=e['length']===0x0?'low':e['some'](j=>j['level']==='critical')?'critical':e['some'](j=>j['level']==='high')?'high':e['some'](j=>j['level']==='medium')?'medium':'low',g={},h={};for(const j of e){g[j['category']]=(g[j['category']]??0x0)+0x1,h[j['level']]=(h[j['level']]??0x0)+0x1;}const i={};for(const k of e){for(const l of k['affected_stakeholders']){if(!i[l])i[l]=[];i[l]['push'](k['id']+':\x20'+k['mitigation']);}}return{'summary':'Assessed\x20'+e['length']+'\x20risk(s)\x20across\x20'+Object['keys'](g)['length']+'\x20categories','risks':e,'overall_risk':f,'risks_by_category':g,'risks_by_level':h,'stakeholder_advice':i,'needs_human_review':e['some'](m=>m['level']==='critical'||m['level']==='high'),'blocks_publish':e['some'](m=>m['level']==='critical')};}export{ALLOCATION_ERROR_CODES};
1
+ import{MAX_ALLOCATOR_COUNT,RATE_TOTAL_FULL,ALLOCATION_ERROR_CODES}from'./allocation-ledger.js';import{isUnboundSignerTheft}from'./recipient-constraint.js';import{checkEntityRecipientsSync}from'./entity-recipient-guard.js';import{getJudgmentDoc,factoryRulePack}from'../config/judgment.js';import{evaluateRuleBook,evaluateCondition}from'../config/rule-engine.js';const AUTO_FIXABLE=new Set(['R-A-1-02#0','R-A-1-02#1','R-A-1-02#2','R-A-1-02#3','R-A-1-02#4','R-A-1-03#0','R-A-1-03#2','R-A-2-03#0','R-A-5-03#0']),RELATED_MOVE_ERROR={'R-A-1-01#0':'EALLOCATORS_EMPTY\x20(8)\x20/\x20ENO_ALLOCATOR\x20(3)','R-A-1-01#1':'ENO_ALLOCATOR\x20(3)','R-A-1-02#0':'ERATE_NOT_10000\x20(4)','R-A-1-02#1':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#2':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#3':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#4':'ERATE_EXCEEDS_10000\x20(6)','R-A-1-02#5':'EMIXED_RATE_BASES\x20(17)','R-A-1-03#0':'EMULTIPLE_SURPLUS\x20(5)','R-A-1-04#0':'NO\x20chain\x20rejection\x20—\x20allocation\x20pays\x20Rate\x20legs\x20then\x20the\x20Surplus\x20remainder\x20verbatim,\x20and\x20order_allocators\x20freezes\x20at\x20Service\x20publish\x20(E_ALREADY_PUBLISHED\x20=\x206),\x20so\x20the\x20misrouted\x20share\x20is\x20permanent','R-A-1-03#1':'EAMOUNT_BELOW_THRESHOLD\x20(12)','R-A-1-03#2':'EAMOUNT_EXCEEDS_MAX\x20(13)','R-A-2-02#0':'ERECIPIENT_IDENTIFIER_NOT_ADDRESS\x20(1)','R-A-2-04#0':'ERECIPIENT_NOT_FOR_OBJECT\x20(15)','R-A-2-04#1':'NO\x20chain\x20rejection\x20when\x20the\x20anchor\x20is\x20None\x20—\x20allocation.move:444-448\x20gates\x20the\x20ERECIPIENT_NOT_FOR_OBJECT\x20(15)\x20assertion\x20on\x20option::is_some,\x20and\x20the\x20comment\x20at\x20allocation.move:434-443\x20hands\x20the\x20due-diligence\x20obligation\x20to\x20this\x20tooling\x20layer;\x20order/arbitration\x20flows\x20always\x20anchor\x20(service.move:394,\x20arbitration.move:342),\x20so\x20None\x20is\x20reachable\x20only\x20via\x20standalone/custom\x20PaymentInfo','R-A-5-01#0':'E_ALLOCATION_ALREADY_SPECIFIED','R-A-5-02#0':'ENO_PAYMENT_INFO\x20(9)','R-RECIPIENT-03#0':'NO\x20chain\x20rejection\x20for\x20an\x20Entity\x20recipient\x20of\x20any\x20address\x20—\x20the\x20SDK\x20substitutes\x20the\x20default\x20local\x20account\x20before\x20the\x20address\x20reaches\x20Move,\x20and\x20allocation.move:250-255\x20swallows\x20Recipient::Entity\x20in\x20a\x20(_)\x20catch-all\x20at\x20declaration\x20while\x20allocation.move:451-453\x20/\x20:514\x20forwards\x20the\x20raw\x20address\x20straight\x20to\x20the\x20payout\x20constructor\x20(retracted\x202026-10-06:\x20there\x20is\x20no\x20ERECIPIENT_ZERO_ENTITY\x20constant;\x20grep\x20returns\x200\x20.move\x20hits)'},RELATED_GUARD_RISK={'R-A-2-01#0':'R-C3-06','R-A-3-04#0':'R-C3-06\x20(Signer\x20binding)\x20/\x20time-lock\x20patterns','R-A-4-01#0':'R-X1-05','R-A-4-03#0':'reentrancy\x20low'};export function allocationRiskFacts(b){const c=b['allocators_config'],d=!!c,e=d?c['allocators']:[];let f,g;if(d&&e['length']>0x0)for(let a4=0x0;a4<e['length'];a4++){if(e[a4]['sharing']['length']===0x0){f=a4,g=e[a4]['guard'];break;}}let h,j,k,l=![],n=![];if(d)for(let a5=0x0;a5<e['length'];a5++){const a6=e[a5],a7=a6['sharing']['some'](af=>af['mode']==='RateGross'),a8=a6['sharing']['filter'](af=>af['mode']==='Amount')['reduce']((af,ag)=>af+Number(ag['sharing']),0x0);if(a7&&a8>0x0)continue;const a9=a7&&a8===0x0&&a6['sharing']['some'](af=>af['mode']==='Rate'),aa=a6['sharing']['filter'](af=>af['mode']==='Rate'||a9&&af['mode']==='RateGross');if(aa['length']===0x0)continue;const ab=aa['map'](af=>Number(af['sharing']));if(ab['some'](af=>!Number['isFinite'](af)))continue;const ad=ab['reduce']((af,ag)=>af+ag,0x0),ae=a6['sharing']['some'](af=>af['mode']==='Surplus');if(!ae&&ad!==RATE_TOTAL_FULL){h=a5,j=a6['guard'],k=ad,l=!![];break;}if(ae&&ad>RATE_TOTAL_FULL){h=a5,j=a6['guard'],k=ad,n=!![];break;}}let o,p,q,r,t,u,v=![],w,x;if(d)for(let af=0x0;af<e['length'];af++){const ag=e[af],ah=ag['sharing']['some'](am=>am['mode']==='Rate'),ai=ag['sharing']['filter'](am=>am['mode']==='RateGross');if(ai['length']===0x0)continue;const aj=ag['sharing']['filter'](am=>am['mode']==='Amount')['reduce']((am,an)=>am+Number(an['sharing']),0x0);if(ah){if(aj>0x0){v=!![],w=af,x=ag['guard'];break;}continue;}const ak=ai['map'](am=>Number(am['sharing']));if(ak['some'](am=>!Number['isFinite'](am))||!Number['isFinite'](aj))continue;const al=ak['reduce']((am,an)=>am+an,0x0);if(al>RATE_TOTAL_FULL){o='sum_exceeds_10000',p=af,q=ag['guard'],r=al,t=aj;break;}if(ag['max']!=null){const am=Number(ag['max']);if(Number['isFinite'](am)&&aj*RATE_TOTAL_FULL+al*am>am*RATE_TOTAL_FULL){o='cap_fit',p=af,q=ag['guard'],r=al,t=aj,u=am;break;}}else{if(aj>0x0&&al>=RATE_TOTAL_FULL){o='fixed_full',p=af,q=ag['guard'],r=al,t=aj;break;}}}let y,z,A,B,C,D,E;if(d){const an=Number(c['threshold']);for(let ao=0x0;ao<e['length'];ao++){const ap=e[ao],aq=ap['sharing']['filter'](at=>at['mode']==='Surplus')['length'];if(aq>0x1){y='multiple_surplus',z=ao,A=ap['guard'],B=aq;break;}const ar=ap['sharing']['filter'](at=>at['mode']==='Amount')['reduce']((at,au)=>at+Number(au['sharing']),0x0),as=ap['sharing']['some'](at=>at['mode']==='Rate'||at['mode']==='Surplus'||at['mode']==='Formula');if(!as&&ar>0x0&&ar<an){y='below_threshold',z=ao,A=ap['guard'],C=ar,D=an;break;}if(ap['max']!=null&&ar>Number(ap['max'])){y='exceeds_max',z=ao,A=ap['guard'],C=ar,E=Number(ap['max']);break;}}}let F=![],G,H,I;if(d)for(let at=0x0;at<e['length'];at++){const au=e[at],av=au['sharing']['some'](ax=>'Signer'in ax['who']),aw=b['guard_signer_bindings']?.[au['guard']]===!![];if(isUnboundSignerTheft({'recipient_is_signer':av,'caller_identity_constrained':aw})){F=!![],G=at,H=au['guard'],I=aw;break;}}let J,K,L;if(d&&b['passport_identifier_types'])for(let ax=0x0;ax<e['length'];ax++){const ay=e[ax],az=ay['sharing']['find'](aC=>'GuardIdentifier'in aC['who']);if(!az)continue;const aA=az['who']['GuardIdentifier'],aB=b['passport_identifier_types'][aA];if(aB!==undefined&&aB!=='address'){J=aA,K=aB,L=ax;break;}}let M=![],N,O,P,Q;if(d){const aC=e['map'](aE=>aE['guard']),aD=new Set(aC);if(aD['size']!==aC['length']){const aE=aC['filter']((aF,aG)=>aC['indexOf'](aF)!==aG);M=!![],N=aC['length'],O=aD['size'],P=aE['join'](',\x20'),Q=aE['join'](',');}}const R=b['payment_info_for_object']!==undefined,S=d&&e['some'](aF=>aF['sharing']['some'](aG=>'GuardIdentifier'in aG['who'])),T=!!b['payment_info_for_object'];let U=![],V,W;if(d&&b['referenced_treasuries_permissions']&&b['host_service_permission'])for(const aF of e){for(const aG of aF['sharing']){if(!(aG['who']!==null&&typeof aG['who']==='object'&&'Entity'in aG['who']))continue;const aH=aG['who']['Entity'],aI=b['referenced_treasuries_permissions'][aH];if(aI&&aI!==b['host_service_permission']){U=!![],V=aH,W=aI;break;}}if(U)break;}let X;if(b['trigger_source']==='standalone'&&d){const aJ=[];for(const aK of e){const aL=b['guard_signer_bindings']?.[aK['guard']]===!![],aM=b['guard_has_time_lock']?.[aK['guard']]===!![];if(!aL&&!aM)aJ['push'](aK['guard']);}X=aJ;}let Y;if(d)for(let aN=0x0;aN<e['length'];aN++){const aO=e[aN],aP=aO['sharing']['length']>0x0&&aO['sharing']['every'](aQ=>aQ['mode']==='Amount');if(aP){Y=aN;break;}}let Z,a0,a1;if(d){const aQ=aS=>{if(aS!==null&&typeof aS==='object'){if('Entity'in aS)return'entity:'+String(aS['Entity'])['trim']()['toLowerCase']();if('GuardIdentifier'in aS)return'guard_identifier:'+Number(aS['GuardIdentifier']);if('Signer'in aS)return'signer';}return undefined;},aR=aS=>{if(aS!==null&&typeof aS==='object'){if('Entity'in aS)return'Entity('+aS['Entity']+')';if('GuardIdentifier'in aS)return'GuardIdentifier('+aS['GuardIdentifier']+')';if('Signer'in aS)return'Signer';}return String(aS);};for(let aS=0x0;aS<e['length'];aS++){const aT=e[aS],aU=new Set(aT['sharing']['filter'](aW=>aW['mode']==='Rate'||aW['mode']==='RateGross')['map'](aW=>aQ(aW['who']))['filter'](aW=>aW!==undefined));if(aU['size']===0x0)continue;const aV=aT['sharing']['find'](aW=>{if(aW['mode']!=='Surplus')return![];const aX=aQ(aW['who']);return aX!==undefined&&aU['has'](aX);});if(aV){Z=aS,a0=aT['guard'],a1=aR(aV['who']);break;}}}const a2=d?checkEntityRecipientsSync(c,{'builderAddress':b['builder_address']}):[],a3=a2['map'](aW=>'Allocator['+aW['allocator_index']+'].sharing['+aW['sharing_index']+']\x20('+aW['reason']+')');return{'allocators_config_present':d,'allocators_count':d?e['length']:undefined,'allocators_empty':d&&e['length']===0x0,'empty_sharing_allocator_index':f,'empty_sharing_allocator_guard':g,'rate_rule_index':h,'rate_rule_guard':j,'rate_rule_sum':k,'rate_rule_pure':l,'rate_rule_exceed':n,'rate_total_full':RATE_TOTAL_FULL,'rate_gross_branch':o,'rate_gross_index':p,'rate_gross_guard':q,'rate_gross_sum':r,'rate_gross_fix':t,'rate_gross_max':u,'mixed_rate_bases_present':v,'mixed_rate_bases_index':w,'mixed_rate_bases_guard':x,'amount_rule_branch':y,'amount_rule_index':z,'amount_rule_guard':A,'amount_rule_surplus_count':B,'amount_rule_amount_sum':C,'amount_rule_threshold':D,'amount_rule_max':E,'surplus_dup_rate_index':Z,'surplus_dup_rate_guard':a0,'surplus_dup_rate_recipient':a1,'signer_theft_detected':F,'signer_theft_index':G,'signer_theft_guard':H,'signer_theft_guard_bound':I,'guard_id_bad_identifier':J,'guard_id_bad_type':K,'guard_id_bad_index':L,'entity_recipient_bad_count':a2['length'],'entity_recipient_bad_count_display':String(a2['length']),'entity_recipient_bad_rows_csv_sp':a3['length']>0x0?a3['join'](',\x20'):undefined,'entity_recipient_bad_rows_csv':a3['length']>0x0?a3['join'](','):undefined,'duplicate_guards_present':M,'allocators_total':N,'allocators_unique':O,'duplicate_guards_csv_sp':P,'duplicate_guards_csv':Q,'for_object_anchor_known':R,'guard_identifier_recipient_present':S,'for_object_anchor_set':T,'for_object_anchor':R&&T?b['payment_info_for_object']??undefined:undefined,'host_service_published':b['host_service_published'],'treasury_perm_mismatch':U,'treasury_perm_entity':V,'treasury_perm_treasury':W,'host_service_permission':b['host_service_permission'],'allocation_create_op':b['operation_type']==='create','allocation_standalone':b['trigger_source']==='standalone','trigger_source_display':b['trigger_source']??'unknown','standalone_weak_guards_count':X?.['length'],'standalone_weak_guards_csv_sp':X?.['join'](',\x20'),'standalone_weak_guards_csv':X?.['join'](','),'has_fallback_allocator':b['has_fallback_allocator'],'guard_conditions_mutually_exclusive':b['guard_conditions_mutually_exclusive'],'has_fallback_allocator_display':String(b['has_fallback_allocator']??![]),'mutually_exclusive_display':String(b['guard_conditions_mutually_exclusive']??![]),'pure_amount_index':Y,'order_already_has_allocation':b['order_already_has_allocation'],'bound_order_display':b['bound_order']??'unknown','bound_order_paren_display':b['bound_order']??'(unknown)','has_payment_info':b['has_payment_info'],'operation_type':b['operation_type'],'max_allocator_count':MAX_ALLOCATOR_COUNT};}function allocationRuleBook(){const a=getJudgmentDoc()['rules']['domains']['allocation'];if(!a)throw new Error('factory\x20rule\x20pack\x20\x27allocation\x27\x20missing\x20—\x20broken\x20installation');return a['rules'];}function firedCaseKey(a,b,c){const d=a['find'](e=>e['rule_id']===c);if(d)for(let e=0x0;e<d['cases']['length'];e++){if(evaluateCondition(d['cases'][e]['when'],b))return c+'#'+e;}return c+'#0';}function findingToAllocationRisk(a,b){const c=RELATED_MOVE_ERROR[b],d=RELATED_GUARD_RISK[b];return{'id':a['rule_id'],'level':a['level'],'category':a['dimension']??'structural','title':a['title'],'description':a['description'],'affected_stakeholders':a['stakeholders']??[],'scenario':a['scenario']??'','mitigation':a['mitigation']??'','evidence':a['evidence'],...c!==undefined?{'related_move_error':c}:{},...d!==undefined?{'related_guard_risk':d}:{},'auto_fixable':AUTO_FIXABLE['has'](b),...a['exposure']!=null?{'exposure':a['exposure']}:{}};}export const ALLOCATION_RISK_VERSION='1.2.0';export function getAllRiskRules(){const a=factoryRulePack('allocation');if(!a)return[];return a['rules']['map'](b=>({'id':b['rule_id'],'category':b['dimension']??'structural','trigger':b['trigger']??'','check':c=>{const d=allocationRiskFacts(c),{findings:e}=evaluateRuleBook([b],d);return e['length']>0x0?findingToAllocationRisk(e[0x0],firedCaseKey([b],d,b['rule_id'])):null;}}));}export function assessAllocationRisks(a){const b=allocationRuleBook(),c=allocationRiskFacts(a),{findings:d}=evaluateRuleBook(b,c),e=d['map'](j=>findingToAllocationRisk(j,firedCaseKey(b,c,j['rule_id']))),f=e['length']===0x0?'low':e['some'](j=>j['level']==='critical')?'critical':e['some'](j=>j['level']==='high')?'high':e['some'](j=>j['level']==='medium')?'medium':'low',g={},h={};for(const j of e){g[j['category']]=(g[j['category']]??0x0)+0x1,h[j['level']]=(h[j['level']]??0x0)+0x1;}const i={};for(const k of e){for(const l of k['affected_stakeholders']){if(!i[l])i[l]=[];i[l]['push'](k['id']+':\x20'+k['mitigation']);}}return{'summary':'Assessed\x20'+e['length']+'\x20risk(s)\x20across\x20'+Object['keys'](g)['length']+'\x20categories','risks':e,'overall_risk':f,'risks_by_category':g,'risks_by_level':h,'stakeholder_advice':i,'needs_human_review':e['some'](m=>m['level']==='critical'||m['level']==='high'),'blocks_publish':e['some'](m=>m['level']==='critical')};}export{ALLOCATION_ERROR_CODES};
@@ -21,6 +21,11 @@ export interface OrderFundFacts {
21
21
  time: string | number;
22
22
  remark?: string;
23
23
  }[];
24
+ escrow_payouts_after_case: {
25
+ payment: string;
26
+ amount: string;
27
+ time: string | number;
28
+ }[];
24
29
  order_time?: string | number;
25
30
  case_time?: string | number;
26
31
  }
@@ -1 +1 @@
1
- import{batchQueryObjectsByIds}from'../graph/onchain/sdk-batch.js';const PAYMENT_HISTORY_CAP=0x5;function asBigIntOrUndefined(a){try{if(typeof a==='bigint')return a;if(typeof a==='number'&&Number['isFinite'](a))return BigInt(Math['trunc'](a));if(typeof a==='string'&&a['trim']()!=='')return BigInt(a);}catch{}return undefined;}function pickData(a){return a?.['data']??a;}function pickAddr(a){return a?.['object']??a?.['data']?.['object']??a?.['id'];}export async function buildOrderFundFacts(b){const c=b['noCache']??!![];let d,e,f,g,h;if(b['arbRef']){const B=await batchQueryObjectsByIds([b['arbRef']],b['network'],c),C=B['find'](E=>pickData(E)?.['type']==='Arb'||pickData(E)?.['order']),D=pickData(C);D?.['order']&&typeof D['order']==='string'&&(d=D['order'],e=pickAddr(C),f=typeof D['status']==='number'?D['status']:undefined,g=D['indemnity']?.['amount']??null,h=D['time']);}if(!d&&b['orderRef'])d=b['orderRef'];if(!d)return undefined;const i=await batchQueryObjectsByIds([d],b['network'],c),j=pickData(i[0x0]);if(!j||j['amount']===undefined)return undefined;const k=[];if(typeof j['allocation']==='string'&&j['allocation'])k['push'](j['allocation']);if(typeof j['progress']==='string'&&j['progress'])k['push'](j['progress']);const l=k['length']>0x0?await batchQueryObjectsByIds(k,b['network'],c):[],m=new Map();for(const E of l){const F=pickAddr(E);if(F)m['set'](F['toLowerCase'](),E);}const n=j['allocation']?m['get'](String(j['allocation'])['toLowerCase']()):undefined,q=pickData(n),r=j['progress']?m['get'](String(j['progress'])['toLowerCase']()):undefined,s=pickData(r),t=[],u=Array['isArray'](q?.['payment'])?q['payment']['slice'](-PAYMENT_HISTORY_CAP):[];if(u['length']>0x0){const G=await batchQueryObjectsByIds(u,b['network'],c),H=new Map();for(const I of G){const J=pickAddr(I);if(J)H['set'](J['toLowerCase'](),I);}for(const K of u){const L=pickData(H['get'](String(K)['toLowerCase']()));if(!L)continue;t['push']({'payment':K,'amount':String(L['amount']??'0'),'time':L['time']??'',...L['info']?.['remark']?{'remark':String(L['info']['remark'])}:{}});}}const v=asBigIntOrUndefined(j['amount'])??0x0n,x=q?asBigIntOrUndefined(q['balance']):undefined,y=x!==undefined?v-x:undefined,z={...e?{'arb_case':e}:{},...f!==undefined?{'arb_status':f}:{},...g!==undefined?{'arb_indemnity':g}:{},'order':d,'order_amount':String(j['amount']),'claimed_by':typeof j['claimed_by']==='string'?j['claimed_by']:null,'progress_node':typeof s?.['current']==='string'&&s['current']!==''?s['current']:null,'allocation':typeof j['allocation']==='string'&&j['allocation']?j['allocation']:null,'allocation_balance':x!==undefined?String(x):null,'escrow_deficit':y!==undefined?String(y):null,'withdraw_history':t,...j['time']!==undefined?{'order_time':j['time']}:{},...h!==undefined?{'case_time':h}:{}},A=['ORDER\x20FUND\x20FACTS\x20(raw\x20units,\x20live\x20read):'];A['push']('-\x20order\x20'+d+':\x20amount='+z['order_amount']);z['allocation']?A['push']('-\x20escrow\x20allocation\x20'+z['allocation']+':\x20balance='+z['allocation_balance']+'\x20(deficit\x20vs\x20amount:\x20'+z['escrow_deficit']+')'):A['push']('-\x20escrow\x20allocation:\x20none\x20(zero-amount\x20order\x20carries\x20no\x20escrow)');A['push']('-\x20compensation\x20claimed_by:\x20'+(z['claimed_by']??'null\x20(unclaimed)')),A['push']('-\x20workflow\x20node:\x20'+(z['progress_node']??'(none)'));if(t['length']>0x0){A['push']('-\x20escrow\x20payouts\x20so\x20far\x20('+t['length']+(u['length']===PAYMENT_HISTORY_CAP?'+':'')+'):');for(const M of t){A['push']('\x20\x20*\x20'+M['amount']+'\x20at\x20'+M['time']+(M['remark']?'\x20—\x20'+M['remark']:'')+'\x20['+M['payment']+']');}}return y!==undefined&&y>0x0n&&A['push']('NET\x20GUIDANCE:\x20the\x20escrow\x20has\x20already\x20paid\x20out\x20'+y+'\x20raw\x20units\x20more\x20than\x20it\x20holds\x20—\x20'+'if\x20the\x20buyer\x20was\x20refunded\x20through\x20the\x20escrow\x20track\x20before\x20filing,\x20net\x20the\x20indemnity\x20against\x20the\x20refunded\x20principal;\x20'+'compensate\x20the\x20delta,\x20not\x20the\x20full\x20loss.'),z['claimed_by']&&A['push']('NOTE:\x20claimed_by\x20is\x20set\x20—\x20the\x20order\x20has\x20already\x20marked\x20a\x20compensation\x20claim;\x20a\x20further\x20ruling\x20pays\x20on\x20top\x20of\x20any\x20escrow\x20payout.'),{'structured':z,'text':A['join']('\x0a')};}
1
+ import{batchQueryObjectsByIds}from'../graph/onchain/sdk-batch.js';const PAYMENT_HISTORY_CAP=0x5;function asBigIntOrUndefined(a){try{if(typeof a==='bigint')return a;if(typeof a==='number'&&Number['isFinite'](a))return BigInt(Math['trunc'](a));if(typeof a==='string'&&a['trim']()!=='')return BigInt(a);}catch{}return undefined;}function asMsOrUndefined(a){if(typeof a==='number'&&Number['isFinite'](a))return a;if(typeof a==='string'&&/^\d+$/['test'](a['trim']()))return Number(a['trim']());return undefined;}function pickData(a){return a?.['data']??a;}function pickAddr(a){return a?.['object']??a?.['data']?.['object']??a?.['id'];}export async function buildOrderFundFacts(b){const c=b['noCache']??!![];let d,e,f,g,h;if(b['arbRef']){const E=await batchQueryObjectsByIds([b['arbRef']],b['network'],c),F=E['find'](H=>pickData(H)?.['type']==='Arb'||pickData(H)?.['order']),G=pickData(F);G?.['order']&&typeof G['order']==='string'&&(d=G['order'],e=pickAddr(F),f=typeof G['status']==='number'?G['status']:undefined,g=G['indemnity']?.['amount']??null,h=G['time']);}if(!d&&b['orderRef'])d=b['orderRef'];if(!d)return undefined;const i=await batchQueryObjectsByIds([d],b['network'],c),j=pickData(i[0x0]);if(!j||j['amount']===undefined)return undefined;const k=[];if(typeof j['allocation']==='string'&&j['allocation'])k['push'](j['allocation']);if(typeof j['progress']==='string'&&j['progress'])k['push'](j['progress']);const l=k['length']>0x0?await batchQueryObjectsByIds(k,b['network'],c):[],m=new Map();for(const H of l){const I=pickAddr(H);if(I)m['set'](I['toLowerCase'](),H);}const n=j['allocation']?m['get'](String(j['allocation'])['toLowerCase']()):undefined,q=pickData(n),r=j['progress']?m['get'](String(j['progress'])['toLowerCase']()):undefined,s=pickData(r),u=[],v=Array['isArray'](q?.['payment'])?q['payment']['slice'](-PAYMENT_HISTORY_CAP):[];if(v['length']>0x0){const J=await batchQueryObjectsByIds(v,b['network'],c),K=new Map();for(const L of J){const M=pickAddr(L);if(M)K['set'](M['toLowerCase'](),L);}for(const N of v){const O=pickData(K['get'](String(N)['toLowerCase']()));if(!O)continue;u['push']({'payment':N,'amount':String(O['amount']??'0'),'time':O['time']??'',...O['info']?.['remark']?{'remark':String(O['info']['remark'])}:{}});}}const x=asBigIntOrUndefined(j['amount'])??0x0n,y=q?asBigIntOrUndefined(q['balance']):undefined,z=y!==undefined?x-y:undefined,A=asMsOrUndefined(h),B=[];if(A!==undefined)for(const P of u){const Q=asMsOrUndefined(P['time']);Q!==undefined&&Q>A&&B['push']({'payment':P['payment'],'amount':P['amount'],'time':P['time']});}const C={...e?{'arb_case':e}:{},...f!==undefined?{'arb_status':f}:{},...g!==undefined?{'arb_indemnity':g}:{},'order':d,'order_amount':String(j['amount']),'claimed_by':typeof j['claimed_by']==='string'?j['claimed_by']:null,'progress_node':typeof s?.['current']==='string'&&s['current']!==''?s['current']:null,'allocation':typeof j['allocation']==='string'&&j['allocation']?j['allocation']:null,'allocation_balance':y!==undefined?String(y):null,'escrow_deficit':z!==undefined?String(z):null,'withdraw_history':u,'escrow_payouts_after_case':B,...j['time']!==undefined?{'order_time':j['time']}:{},...h!==undefined?{'case_time':h}:{}},D=['ORDER\x20FUND\x20FACTS\x20(raw\x20units,\x20live\x20read):'];D['push']('-\x20order\x20'+d+':\x20amount='+C['order_amount']);C['allocation']?D['push']('-\x20escrow\x20allocation\x20'+C['allocation']+':\x20balance='+C['allocation_balance']+'\x20(deficit\x20vs\x20amount:\x20'+C['escrow_deficit']+')'):D['push']('-\x20escrow\x20allocation:\x20none\x20(zero-amount\x20order\x20carries\x20no\x20escrow)');D['push']('-\x20compensation\x20claimed_by:\x20'+(C['claimed_by']??'null\x20(unclaimed)')),D['push']('-\x20workflow\x20node:\x20'+(C['progress_node']??'(none)'));if(u['length']>0x0){D['push']('-\x20escrow\x20payouts\x20so\x20far\x20('+u['length']+(v['length']===PAYMENT_HISTORY_CAP?'+':'')+'):');for(const R of u){D['push']('\x20\x20*\x20'+R['amount']+'\x20at\x20'+R['time']+(R['remark']?'\x20—\x20'+R['remark']:'')+'\x20['+R['payment']+']');}}return z!==undefined&&z>0x0n&&D['push']('NET\x20GUIDANCE:\x20the\x20escrow\x20has\x20already\x20paid\x20out\x20'+z+'\x20raw\x20units\x20more\x20than\x20it\x20holds\x20—\x20'+'if\x20the\x20buyer\x20was\x20refunded\x20through\x20the\x20escrow\x20track\x20before\x20filing,\x20net\x20the\x20indemnity\x20against\x20the\x20refunded\x20principal;\x20'+'compensate\x20the\x20delta,\x20not\x20the\x20full\x20loss.'),C['claimed_by']&&D['push']('NOTE:\x20claimed_by\x20is\x20set\x20—\x20the\x20order\x20has\x20already\x20marked\x20a\x20compensation\x20claim;\x20a\x20further\x20ruling\x20pays\x20on\x20top\x20of\x20any\x20escrow\x20payout.'),B['length']>0x0&&D['push']('ESCROW\x20MOVED\x20DURING\x20THE\x20CASE:\x20'+B['length']+'\x20payout(s)\x20landed\x20after\x20the\x20case\x20was\x20filed\x20'+('(first:\x20'+B[0x0]['amount']+'\x20raw\x20at\x20'+B[0x0]['time']+').\x20')+'Reconcile\x20each\x20with\x20the\x20ruling\x20direction\x20—\x20a\x20sweep\x20that\x20contradicts\x20the\x20award\x20(e.g.\x20a\x20merchant\x20recover\x20on\x20a\x20'+'buyer-favorable\x20ruling)\x20belongs\x20in\x20the\x20ruling\x20text\x20and\x20the\x20parties\x27\x20statements,\x20never\x20in\x20a\x20silent\x20pass.'),D['push']('DUAL-TRACK\x20REMINDER:\x20the\x20escrow\x20track\x20(refund\x20/\x20recover\x20allocators)\x20and\x20this\x20arbitration\x20are\x20INDEPENDENT\x20'+'commercial\x20routes\x20—\x20the\x20protocol\x20deliberately\x20does\x20not\x20couple\x20them,\x20and\x20neither\x20blocks\x20the\x20other.\x20Both\x20are\x20'+'observable\x20here:\x20re-read\x20these\x20facts\x20before\x20you\x20finalize\x20the\x20ruling\x20and\x20again\x20before\x20the\x20indemnity\x20is\x20claimed;\x20'+'an\x20escrow\x20movement\x20that\x20lands\x20after\x20the\x20award\x20is\x20visible\x20in\x20the\x20payout\x20history\x20above.'),{'structured':C,'text':D['join']('\x0a')};}
@@ -36,12 +36,13 @@ export declare const ANTI_PATTERN_NODE_REGEX: RegExp;
36
36
  export declare const REMEDY_FAMILY_NODE_REGEX: RegExp;
37
37
  export declare function isRemedyLoopEdge(fromNode: string, toNode: string): boolean;
38
38
  export type LoopTier = "renewal" | "remedy" | "charge";
39
- export declare function classifyLoopCycle(cycleNodes: string[]): LoopTier;
39
+ export type ReentryKind = "none" | "review-loop" | "paid-cycle";
40
+ export declare function classifyLoopCycle(cycleNodes: string[], declared?: ReentryKind): LoopTier;
40
41
  export interface MachineNodeAudit {
41
42
  critical: string[];
42
43
  warnings: string[];
43
44
  }
44
- export declare function auditMachineNodes(nodes: unknown[]): MachineNodeAudit;
45
+ export declare function auditMachineNodes(nodes: unknown[], declaredReentry?: ReentryKind): MachineNodeAudit;
45
46
  export declare function computeTerminalReachability(nodes: unknown[]): {
46
47
  terminals: string[];
47
48
  unreachable: string[];
@@ -69,4 +70,4 @@ export declare function hasBlockingErrors(findings: AuditFinding[]): boolean;
69
70
  export declare function getErrors(findings: AuditFinding[]): AuditFinding[];
70
71
  export declare function getWarnings(findings: AuditFinding[]): AuditFinding[];
71
72
  export declare function summarizeFindings(findings: AuditFinding[]): string;
72
- export declare const AUDIT_RULES_VERSION = 10;
73
+ export declare const AUDIT_RULES_VERSION = 11;