@wowok/agent-mcp 3.3.7 → 3.3.9

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 (173) hide show
  1. package/dist/chain-semantics/fund-flow.js +1 -1
  2. package/dist/chain-semantics/guard-verbs.js +1 -1
  3. package/dist/chain-semantics/object-graph.js +1 -1
  4. package/dist/communication/message-cursors.d.ts +35 -0
  5. package/dist/communication/message-cursors.js +1 -0
  6. package/dist/communication/wts-attestation.d.ts +5 -0
  7. package/dist/communication/wts-attestation.js +1 -1
  8. package/dist/composition/audit.js +1 -1
  9. package/dist/composition/compile.d.ts +2 -2
  10. package/dist/composition/compile.js +1 -1
  11. package/dist/composition/inflight.d.ts +7 -0
  12. package/dist/composition/inflight.js +1 -1
  13. package/dist/composition/materialize.d.ts +4 -1
  14. package/dist/composition/materialize.js +1 -1
  15. package/dist/config/index.d.ts +1 -0
  16. package/dist/config/index.js +1 -1
  17. package/dist/config/store-policy.d.ts +14 -0
  18. package/dist/config/store-policy.js +1 -0
  19. package/dist/config/store-policy.spec.d.ts +1 -0
  20. package/dist/config/store-policy.spec.js +1 -0
  21. package/dist/customer/industry-risks.js +1 -1
  22. package/dist/customer/user-preferences.js +1 -1
  23. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  24. package/dist/evaluation/engine.js +1 -1
  25. package/dist/experience/realtime-feedback.js +1 -1
  26. package/dist/extensions/business-modules.d.ts +1 -1
  27. package/dist/extensions/business-modules.js +1 -1
  28. package/dist/extensions/industry-pack.js +1 -1
  29. package/dist/extensions/modes.js +1 -1
  30. package/dist/graph/onchain/analyze.js +1 -1
  31. package/dist/graph/onchain/expand.js +1 -1
  32. package/dist/graph/onchain/exposure.js +1 -1
  33. package/dist/graph/onchain/facts.d.ts +1 -0
  34. package/dist/graph/onchain/facts.js +1 -1
  35. package/dist/graph/onchain/facts.spec.js +1 -1
  36. package/dist/harness/recover.js +1 -1
  37. package/dist/knowledge/acquisition-flywheel.js +1 -1
  38. package/dist/knowledge/allocation-ledger.d.ts +1 -0
  39. package/dist/knowledge/allocation-ledger.js +1 -1
  40. package/dist/knowledge/allocator-rail-verifier.d.ts +6 -2
  41. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  42. package/dist/knowledge/arbitration-ledger.js +1 -1
  43. package/dist/knowledge/audit-rules.d.ts +37 -0
  44. package/dist/knowledge/audit-rules.js +1 -1
  45. package/dist/knowledge/baselines/rules/plan.json +32 -2
  46. package/dist/knowledge/builtin-templates.d.ts +13 -1
  47. package/dist/knowledge/builtin-templates.js +1 -1
  48. package/dist/knowledge/commission-landing.d.ts +26 -0
  49. package/dist/knowledge/commission-landing.js +1 -0
  50. package/dist/knowledge/discount-threshold.js +1 -1
  51. package/dist/knowledge/fund-layer.d.ts +7 -0
  52. package/dist/knowledge/fund-layer.js +1 -1
  53. package/dist/knowledge/getting-started.js +1 -1
  54. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  55. package/dist/knowledge/guard-design-patterns.js +1 -1
  56. package/dist/knowledge/guard-puzzle.js +1 -1
  57. package/dist/knowledge/guard-render.d.ts +7 -0
  58. package/dist/knowledge/guard-render.js +1 -1
  59. package/dist/knowledge/guard-risk.js +1 -1
  60. package/dist/knowledge/guard-templates.d.ts +1 -1
  61. package/dist/knowledge/guard-templates.js +1 -1
  62. package/dist/knowledge/guard-translation.js +1 -1
  63. package/dist/knowledge/index.js +1 -1
  64. package/dist/knowledge/industry-generalizer.js +1 -1
  65. package/dist/knowledge/industry-registry.d.ts +1 -1
  66. package/dist/knowledge/industry-registry.js +1 -1
  67. package/dist/knowledge/industry-strategy.js +1 -1
  68. package/dist/knowledge/jsonrpc-enum.js +1 -1
  69. package/dist/knowledge/machine-fork-watch.d.ts +9 -0
  70. package/dist/knowledge/machine-fork-watch.js +1 -0
  71. package/dist/knowledge/migration-preflight.js +1 -1
  72. package/dist/knowledge/projection.spec.js +1 -1
  73. package/dist/knowledge/scenario-modes.d.ts +8 -2
  74. package/dist/knowledge/scenario-modes.js +1 -1
  75. package/dist/knowledge/semantic-ir.d.ts +24 -5
  76. package/dist/knowledge/semantic-ir.js +1 -1
  77. package/dist/knowledge/service-ledger.js +1 -1
  78. package/dist/knowledge/strategy-manuals.js +1 -1
  79. package/dist/knowledge/template-index.js +1 -1
  80. package/dist/knowledge/template-loader.d.ts +11 -0
  81. package/dist/knowledge/template-loader.js +1 -1
  82. package/dist/knowledge/template-registry.js +1 -1
  83. package/dist/knowledge/template-scanner.d.ts +4 -2
  84. package/dist/knowledge/template-scanner.js +1 -1
  85. package/dist/knowledge/template-validation.js +1 -1
  86. package/dist/knowledge/tools-reference.js +1 -1
  87. package/dist/monitor/MonitorLoop.js +1 -1
  88. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  89. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  90. package/dist/playbooks/service-build/merchant-guide.d.ts +12 -6
  91. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  92. package/dist/playbooks/service-build/migration-planner.d.ts +10 -2
  93. package/dist/playbooks/service-build/migration-planner.js +1 -1
  94. package/dist/playbooks/service-build/mode-actions.d.ts +1 -0
  95. package/dist/playbooks/service-build/mode-actions.js +1 -1
  96. package/dist/playbooks/service-build/object-panorama.js +1 -1
  97. package/dist/playbooks/service-build/participation-radar.js +1 -1
  98. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  99. package/dist/playbooks/service-build/service-panorama.js +1 -1
  100. package/dist/playbooks/service-build/service-quote.js +1 -1
  101. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  102. package/dist/review/index.js +1 -1
  103. package/dist/safety/confirm-gate.js +1 -1
  104. package/dist/schema/benchmark-migration/index.d.ts +72 -1
  105. package/dist/schema/benchmark-migration/index.js +1 -1
  106. package/dist/schema/call/allocation.d.ts +3 -0
  107. package/dist/schema/call/allocation.js +1 -1
  108. package/dist/schema/call/base.d.ts +24 -0
  109. package/dist/schema/call/bridge.d.ts +6 -0
  110. package/dist/schema/call/error-codes.d.ts +1 -1
  111. package/dist/schema/call/error-codes.js +1 -1
  112. package/dist/schema/call/order.js +1 -1
  113. package/dist/schema/call/semantic.js +1 -1
  114. package/dist/schema/call/service.js +1 -1
  115. package/dist/schema/common/index.js +1 -1
  116. package/dist/schema/config/index.d.ts +24 -0
  117. package/dist/schema/config/index.js +1 -1
  118. package/dist/schema/goal/index.d.ts +14 -0
  119. package/dist/schema/goal/planning.d.ts +26 -0
  120. package/dist/schema/goal/planning.js +1 -1
  121. package/dist/schema/industry-pack/index.d.ts +9 -1
  122. package/dist/schema/industry-pack/modes.d.ts +9 -1
  123. package/dist/schema/industry-pack/modes.js +1 -1
  124. package/dist/schema/local/index.d.ts +60 -0
  125. package/dist/schema/local/index.js +1 -1
  126. package/dist/schema/messenger/index.d.ts +278 -1
  127. package/dist/schema/messenger/index.js +1 -1
  128. package/dist/schema/operations.d.ts +1 -0
  129. package/dist/schema/query/bi.d.ts +38 -0
  130. package/dist/schema/query/bi.js +1 -1
  131. package/dist/schema/query/index.d.ts +3 -0
  132. package/dist/schema/query/index.js +1 -1
  133. package/dist/schema/schema-version.js +1 -1
  134. package/dist/schema/service-clone/index.d.ts +17 -0
  135. package/dist/schema/service-clone/index.js +1 -1
  136. package/dist/schema-query-impl/index.js +1 -1
  137. package/dist/schemas/account_operation.output.json +6 -0
  138. package/dist/schemas/benchmark_migration_operation.output.json +254 -2
  139. package/dist/schemas/benchmark_migration_operation.schema.json +87 -5
  140. package/dist/schemas/bridge_operation.output.json +6 -0
  141. package/dist/schemas/config_operation.output.json +95 -0
  142. package/dist/schemas/config_operation.schema.json +16 -1
  143. package/dist/schemas/goal_operation.schema.json +22 -0
  144. package/dist/schemas/index.json +1 -1
  145. package/dist/schemas/industry_pack_operation.output.json +4 -0
  146. package/dist/schemas/industry_pack_operation.schema.json +40 -3
  147. package/dist/schemas/local_cache_operation.output.json +6 -0
  148. package/dist/schemas/local_history_operation.output.json +6 -0
  149. package/dist/schemas/local_info_operation.output.json +6 -0
  150. package/dist/schemas/local_mark_operation.output.json +6 -0
  151. package/dist/schemas/messenger_operation.output.json +609 -1
  152. package/dist/schemas/messenger_operation.schema.json +96 -1
  153. package/dist/schemas/onchain_operations.output.json +6 -0
  154. package/dist/schemas/onchain_operations.schema.json +334 -7
  155. package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
  156. package/dist/schemas/onchain_operations_guard.schema.json +318 -0
  157. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  158. package/dist/schemas/onchain_operations_service.schema.json +5 -5
  159. package/dist/schemas/query_toolkit.output.json +271 -8
  160. package/dist/schemas/service_clone_operation.output.json +79 -0
  161. package/dist/tools/handlers/benchmark-migration.d.ts +14 -0
  162. package/dist/tools/handlers/benchmark-migration.js +1 -1
  163. package/dist/tools/handlers/config.js +1 -1
  164. package/dist/tools/handlers/messenger.js +1 -1
  165. package/dist/tools/handlers/onchain.d.ts +19 -1
  166. package/dist/tools/handlers/onchain.js +1 -1
  167. package/dist/tools/handlers/query.d.ts +1 -0
  168. package/dist/tools/handlers/query.js +1 -1
  169. package/dist/tools/handlers/service-clone.d.ts +18 -0
  170. package/dist/tools/handlers/service-clone.js +1 -1
  171. package/dist/tools/registry/business.js +1 -1
  172. package/dist/tools/wrap.js +1 -1
  173. package/package.json +2 -2
@@ -1 +1 @@
1
- import{getScenarioMode}from'../knowledge/scenario-modes.js';import{BUILTIN_TEMPLATES}from'../knowledge/builtin-templates.js';import{getIndustryTraits}from'../knowledge/industry-registry.js';import{getIndustryRiskChecks,getIndustryNeeds}from'../customer/index.js';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{getFlywheelForIndustry}from'../knowledge/acquisition-flywheel.js';const GENERAL_TRAITS={'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![],'regulatory_intensity':'low','trust_sensitivity':'medium','consumption_frequency':'occasional','avg_ticket_size':'medium'},GENERAL_FLYWHEEL={'industry':'general','trustSellingPoints':[],'keyActions':[],'rewardStrategy':'User-defined','discountStrategy':'User-defined','trustDescription':'User-defined\x20trust\x20mechanism'},GENERAL_MACHINE_SHAPE=[{'name':'paid','role':'Entry:\x20order\x20created\x20and\x20paid'},{'name':'delivering','role':'Service\x20delivery\x20in\x20progress'},{'name':'delivered','role':'Deliverable\x20available\x20for\x20review'},{'name':'completed','role':'Service\x20completed,\x20funds\x20released'},{'name':'cancelled','role':'Pre-delivery\x20cancellation\x20—\x20triggers\x20refund\x20Allocator','operator':'order_payer'}],GENERAL_ALLOCATOR={'recipient':'signer','count':0x1,'mode':'surplus','description':'Default:\x20surplus\x20to\x20service\x20owner\x20(general\x20fallback)'},RETAIL_D2C_MACHINE_SHAPE=[{'name':'ordered','role':'Entry:\x20order\x20created\x20(funds\x20escrowed\x20in\x20Allocation)'},{'name':'shipped','role':'Merchant\x20ships\x20goods'},{'name':'delivered','role':'Goods\x20delivered\x20to\x20buyer'},{'name':'completed','role':'Buyer\x20confirms\x20receipt\x20—\x20withdraw_guard\x20releases\x20funds','operator':'order_payer'},{'name':'cancelled','role':'Pre-ship\x20cancellation\x20—\x20refund_guard\x20refunds\x20buyer','operator':'order_payer'}],RETAIL_D2C_GUARDS=[{'template_id':'withdraw_guard_delivery','host':'service','purpose':'Release\x20funds\x20to\x20merchant\x20+\x20processor\x20on\x20order\x20completion\x20(delivery\x20confirmation)'},{'template_id':'refund_guard_cancellation','host':'service','purpose':'Refund\x20100%\x20to\x20buyer\x20on\x20order\x20cancellation'}],RETAIL_D2C_ALLOCATOR={'recipient':'entity','count':0x2,'mode':'rate','description':'Merchant\x2097%\x20+\x20Processor\x203%\x20(rate-based\x20split,\x20no\x20platform\x20commission)'},RETAIL_D2C_KEY_RISK='No\x20platform\x20arbitration\x20—\x20disputes\x20rely\x20on\x20optional\x20Arbitration\x20or\x20off-chain\x20chargeback',RETAIL_D2C_BUILD_NOTES=['Allocation\x20escrow\x20replaces\x20platform\x20custody\x20—\x20funds\x20locked\x20in\x20contract\x20until\x20Guard\x20releases','withdraw_guard\x20enforces\x20delivery\x20gate\x20—\x20merchant\x20must\x20reach\x20\x27completed\x27\x20state\x20to\x20receive\x20payment','refund_guard\x20ensures\x20100%\x20refund\x20on\x20cancellation\x20—\x20no\x20merchant\x20approval\x20needed','No\x20buy_guard\x20needed\x20—\x20D2C\x20doesn\x27t\x20gate\x20purchases\x20(open\x20storefront)','Arbitration\x20is\x20optional\x20—\x20add\x20when\x20dispute\x20volume\x20justifies\x20the\x20cost','Service\x20↔\x20Guard\x20circular\x20dependency:\x20create\x20Service\x20(unpublished)\x20→\x20create\x20Guards\x20→\x20update\x20Service\x20(publish)'],SUPPORTED_INDUSTRY_SET=new Set([...SUPPORTED_INDUSTRIES,'retail_d2c']);function fetchTemplate(a){const b=a==='retail_d2c'?'retail':a,c=getIndustryTraits(b)??GENERAL_TRAITS,d=SUPPORTED_INDUSTRY_SET['has'](a),e=a==='retail_d2c'?'retail':a,f=d?getIndustryRiskChecks(e):[],g=d?getIndustryNeeds(e):[],h=getFlywheelForIndustry(b)??GENERAL_FLYWHEEL;let i,j,k,l,m;if(a==='retail_d2c')i=RETAIL_D2C_MACHINE_SHAPE,j=RETAIL_D2C_GUARDS,k=RETAIL_D2C_ALLOCATOR,l=RETAIL_D2C_KEY_RISK,m=RETAIL_D2C_BUILD_NOTES;else{if(a==='general'){const n=getScenarioMode('general');i=GENERAL_MACHINE_SHAPE,j=[],k=GENERAL_ALLOCATOR,l=n?.['key_risk']??'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually',m=n?.['build_notes'];}else{const o=getScenarioMode(a);if(!o)throw new Error('[modes.ts]\x20No\x20scenario\x20mode\x20found\x20for\x20industry:\x20'+a);const p=BUILTIN_TEMPLATES['find'](q=>q['id']===o['default_template']);if(!p)throw new Error('[modes.ts]\x20Mode\x20\x27'+a+'\x27\x20default_template\x20\x27'+o['default_template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20template\x20catalog');i=p['machine_shape'],j=p['guards'],k=p['allocator'],l=o['key_risk'],m=o['build_notes'];}}return{'traits':c,'risk_checks':f,'needs':g,'flywheel':h,'machine_shape':i,'guards':j,'allocator':k,'key_risk':l,'build_notes':m};}export const BUILTIN_MODES=[{'name':'freelance','display_name':'Freelance','version':'v1','source':'builtin',...fetchTemplate('freelance'),'analyze':{'key_questions':['Are\x20WIP\x20hashes\x20bound\x20to\x20each\x20milestone,\x20so\x20delivery\x20evidence\x20cannot\x20be\x20substituted\x20after\x20acceptance?','Does\x20the\x20acceptance\x20gate\x20have\x20a\x20time-bounded\x20escape\x20(keeper-driven\x20auto-accept),\x20or\x20can\x20a\x20silent\x20buyer\x20hold\x20the\x20provider\x27s\x20funds\x20hostage\x20indefinitely?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'service':{'setting_lock_duration':'30d','engagement_type':'milestone'},'machine':{'wip_required':!![],'wip_hash_algorithm':'sha256','acceptance_gate':!![]}},'expected_benefits':[{'metric':'Dispute\x20rate\x20reduction','expected_value':'40%','evidence':'WIP\x20hash\x20+\x20milestone\x20allocation\x20enforces\x20delivery\x20evidence'},{'metric':'Delivery\x20confirmation\x20efficiency','expected_value':'+50%','evidence':'acceptance\x20gate\x20automates\x20acceptance\x20workflow'},{'metric':'Provider\x20payment\x20assurance','expected_value':'100%','evidence':'Funds\x20auto-release\x20to\x20provider\x20after\x20accepted\x20node'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':![],'require_wip_evidence':!![],'other_constraints':['setting_lock_duration\x20>=\x207d\x20to\x20lock\x20engagement-period\x20rules','Acceptance\x20timeout\x20=\x20the\x20template\x27s\x20escrow_release_days\x20(single\x20source:\x20fee_params,\x20override\x20via\x20fee_overrides).\x20Mechanism:\x20dual-branch\x20time-gated\x20forward\x20(pattern.time_lock_progress\x20anchored\x20on\x20the\x20delivered\x20entry);\x20a\x20keeper\x20advances\x20the\x20timeout\x20path.\x20adminUnhold\x20(224)\x20is\x20ONLY\x20the\x20hold-release\x20escape\x20hatch,\x20never\x20the\x20timeout\x20mechanism.']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Suitable\x20for\x20mid-to-long-term\x20project\x20delivery','Requires\x20milestone-based\x20phased\x20acceptance']},'similar_industries':['rental','education'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_compensation_fund']},{'name':'rental','display_name':'Rental','version':'v1','source':'builtin',...fetchTemplate('rental'),'analyze':{'key_questions':['Is\x20the\x20deposit\x20escrowed\x20on-chain\x20and\x20sized\x20against\x20the\x20item\x27s\x20full\x20replacement\x20value,\x20not\x20just\x20the\x20rental\x20fee?','Are\x20pre-handover\x20and\x20post-return\x20WIP\x20states\x20hash-recorded,\x20so\x20damage\x20attribution\x20is\x20provable\x20rather\x20than\x20asserted?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'treasury':{'deposit_escrow':!![],'deposit_deductible':!![]},'machine':{'wip_required':!![],'wip_stages':['handover_out','returned'],'inspection_gate':!![]}},'expected_benefits':[{'metric':'Deposit\x20dispute\x20rate','expected_value':'-60%','evidence':'pre-rental\x20WIP\x20mandatorily\x20records\x20item\x27s\x20original\x20state'},{'metric':'Damage\x20liability\x20accuracy','expected_value':'+70%','evidence':'pre/post\x20WIP\x20hash\x20comparison\x20eliminates\x20unfounded\x20deductions'},{'metric':'Trust\x20score','expected_value':'+25%','evidence':'compensation_fund\x20covers\x20damage\x20risk'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'max_single_transaction':0x2710,'compensation_fund_coverage_ratio':0xa,'other_constraints':['Deposit\x20must\x20be\x20escrowed\x20(no\x20direct\x20transfer)','lock_duration\x20>=\x207d\x20to\x20prevent\x20arbitrary\x20merchant\x20withdrawal']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Requires\x20physical\x20item\x20handover','Has\x20logistics\x20or\x20offline\x20delivery\x20leg']},'similar_industries':['retail','travel'],'novel_capabilities':[]},{'name':'education','display_name':'Education','version':'v1','source':'builtin',...fetchTemplate('education'),'analyze':{'key_questions':['Does\x20tuition\x20release\x20per\x20attended\x20session\x20(Progress\x20node),\x20so\x20undelivered\x20sessions\x20stay\x20refundable\x20if\x20the\x20institution\x20disappears?','Does\x20setting_lock_duration\x20span\x20the\x20full\x20term,\x20so\x20the\x20institution\x20cannot\x20tighten\x20refund\x20rules\x20mid-course?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x1,'mode':'amount','description':'1/N\x20of\x20tuition\x20released\x20per\x20session\x20attendance'},'session_threshold':!![]},'service':{'setting_lock_duration':'120d','anti_runaway':!![]}},'expected_benefits':[{'metric':'Refund\x20dispute\x20rate','expected_value':'-50%','evidence':'per-session\x20release\x20distributes\x20tuition\x20by\x20class'},{'metric':'Institution\x20runaway\x20risk','expected_value':'eliminated','evidence':'Funds\x20release\x20per\x20session;\x20undelivered\x20portion\x20is\x20refundable'},{'metric':'Attendance\x20traceability','expected_value':'100%','evidence':'attendance_guard\x20signs\x20each\x20session'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'other_constraints':['setting_lock_duration\x20covers\x20the\x20entire\x20term\x20(>=90d)','Long-cycle\x20projects\x20must\x20monitor\x20>90d\x20progress']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Long-cycle\x20delivery','Requires\x20per-session\x20acceptance','Regulatory\x20intensity:\x20medium']},'similar_industries':['freelance','subscription'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'travel','display_name':'Travel','version':'v1','source':'builtin',...fetchTemplate('travel'),'analyze':{'key_questions':['Does\x20each\x20itinerary\x20segment\x20have\x20its\x20own\x20guard\x20and\x20WIP\x20acceptance,\x20so\x20one\x20failed\x20leg\x20is\x20refundable\x20without\x20unwinding\x20the\x20whole\x20trip?','Is\x20the\x20multi-tier\x20allocation\x20waterfall\x20(agency\x20→\x20hotel/guide/driver)\x20visible\x20on-chain,\x20so\x20the\x20agency\x20cannot\x20silently\x20re-split\x20funds?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x3,'mode':'amount','description':'Deposit\x2020%\x20to\x20agency,\x20final\x2080%\x20to\x20agency,\x20then\x20agency-side\x20Allocation\x20splits\x20to\x20hotel/guide/driver\x20per\x20segment'},'multi_tier_waterfall':!![],'guard_chaining':!![]},'service':{'supply_chain_suborders':!![],'segment_guard_required':!![]}},'expected_benefits':[{'metric':'Fund\x20transparency','expected_value':'100%','evidence':'multi-tier\x20allocation\x20splits\x20per\x20segment\x20to\x20hotel/guide/driver'},{'metric':'Itinerary\x20change\x20disputes','expected_value':'-45%','evidence':'segment\x20WIP\x20accepts\x20each\x20leg'},{'metric':'Breach\x20compensation\x20assurance','expected_value':'+60%','evidence':'compensation_fund\x20covers\x20itinerary\x20breach'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['Multi-tier\x20allocation\x20requires\x20guard\x20chaining\x20validation','deposit\x2020%\x20+\x20final\x2080%\x20two-stage\x20payment']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Multi-segment\x20itinerary\x20combination','Requires\x20hotel/guide/driver\x20multi-party\x20allocation']},'similar_industries':['rental','education'],'novel_capabilities':[]},{'name':'subscription','display_name':'Subscription','version':'v1','source':'builtin',...fetchTemplate('subscription'),'analyze':{'key_questions':['Is\x20every\x20periodic\x20charge\x20gated\x20by\x20an\x20explicit\x20user\x20confirmation,\x20with\x20no\x20auto-renew\x20default?','Can\x20the\x20subscriber\x20cancel\x20anytime\x20effective\x20next\x20period,\x20without\x20a\x20dead-end\x20node\x20in\x20the\x20machine?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'no_auto_renew_trap':!![],'user_confirmed_charge':!![],'cancel_anytime':!![],'next_period_effective':!![]},'service':{'creator_data_subscription':!![],'periodic_billing':!![]}},'expected_benefits':[{'metric':'Renewal\x20rate','expected_value':'+25%','evidence':'loyalty\x20reward\x20+\x20transparent\x20subscription\x20mechanism'},{'metric':'Cancellation\x20disputes','expected_value':'eliminated','evidence':'cancel\x20anytime\x20+\x20no\x20auto-renew\x20trap'},{'metric':'Creator\x20retention','expected_value':'+30%','evidence':'deliver_guard_wip\x20prevents\x20content\x20dropout'}],'risk_appetite':'aggressive','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x3,'other_constraints':['Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in)','charge_guard\x20requires\x20user\x20confirmation\x20each\x20period']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x5,'other_conditions':['Pure-digital\x20delivery','Periodic\x20content\x20or\x20SaaS\x20service']},'similar_industries':['freelance','education'],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'retail','display_name':'Retail','version':'v1','source':'builtin',...fetchTemplate('retail'),'analyze':{'key_questions':['Is\x20the\x20logistics\x20tracking\x20number\x20recorded\x20as\x20WIP\x20before\x20the\x20confirm\x20gate,\x20so\x20receipt\x20disputes\x20have\x20carrier\x20evidence?','Is\x20the\x20refund\x20window\x20at\x20least\x207\x20days\x20with\x20an\x20on-chain\x20refund\x20path\x20that\x20does\x20not\x20rely\x20on\x20merchant\x20goodwill?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'wip_field':'tracking_number','confirm_gate':!![],'refund_requires_approval':!![]},'service':{'logistics_mode':'standard','first_order_discount':!![]}},'expected_benefits':[{'metric':'Return\x20dispute\x20rate','expected_value':'-35%','evidence':'logistics\x20WIP\x20+\x20refund\x20path\x20assurance'},{'metric':'Repurchase\x20rate','expected_value':'+20%','evidence':'spend\x20cashback\x20reward'},{'metric':'Product\x20authenticity\x20traceability','expected_value':'100%','evidence':'WIP\x20verifies\x20product/logistics\x20info'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x5,'other_constraints':['refund_window\x20>=\x207d','confirm_gate:\x20only\x20buyer\x20can\x20confirm\x20receipt']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0xa,'other_conditions':['Has\x20logistics\x20shipping\x20leg','High-frequency\x20small-ticket\x20transactions']},'similar_industries':['rental','subscription'],'novel_capabilities':[],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'retail_d2c','display_name':'Retail\x20D2C\x20(Direct-to-Consumer)','version':'v1','source':'builtin',...fetchTemplate('retail_d2c'),'analyze':{'key_questions':['Do\x20withdraw_guard\x20and\x20refund_guard\x20fully\x20enclose\x20the\x20Allocation\x20escrow,\x20so\x20neither\x20side\x20can\x20move\x20funds\x20outside\x20the\x20contract\x20path?','With\x20no\x20platform\x20arbitration,\x20what\x20off-chain\x20recourse\x20(if\x20any)\x20backs\x20a\x20delivery\x20failure\x20—\x20and\x20is\x20that\x20acceptable\x20for\x20the\x20ticket\x20size?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_withdraw','guard.validate_refund','machine.node_topology','allocation.distribute','service.publish','progress.advance','contact.im_create'],'config_overrides':{'machine':{'wip_required':![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'logistics_mode':'merchant_managed','multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Merchant\x20revenue\x20share','expected_value':'97%','evidence':'No\x20platform\x20commission\x20—\x20only\x203%\x20processing\x20fee'},{'metric':'Fund\x20safety','expected_value':'contract-grade','evidence':'Allocation\x20escrow\x20+\x20Guard\x20verification\x20replaces\x20platform\x20custody'},{'metric':'Delivery\x20reliability','expected_value':'high','evidence':'withdraw_guard\x20enforces\x20delivery\x20confirmation\x20before\x20payment'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'other_constraints':['Allocation\x20escrow\x20required\x20(withdraw_guard\x20+\x20refund_guard)','Service\x20↔\x20Guard\x20circular\x20dependency\x20requires\x203-step\x20creation\x20pattern']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Independent\x20storefront\x20(no\x20marketplace)','Merchant-managed\x20logistics','Allocation\x20escrow\x20model']},'similar_industries':['retail','subscription'],'novel_capabilities':['Allocation\x20escrow\x20as\x20platform-custody\x20alternative','Multi-recipient\x20allocation\x20(merchant\x20+\x20processor)'],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'licensing','display_name':'Licensing','version':'v1','source':'builtin',...fetchTemplate('licensing'),'analyze':{'key_questions':['Is\x20the\x20license\x20grant\x20(terms\x20+\x20asset/certificate\x20hash)\x20anchored\x20as\x20a\x20WIP\x20artifact\x20and\x20an\x20evidence\x20Repository\x20row\x20BEFORE\x20release,\x20so\x20a\x20misrepresentation\x20dispute\x20has\x20an\x20on-chain\x20artifact\x20to\x20read?','Does\x20the\x20release\x20split\x20sum\x20to\x20exactly\x2010000\x20bps\x20across\x20explicit\x20NON-EMPTY\x20rights-holder\x20Entities\x20(no\x20empty\x20Entity\x20routing\x20the\x20share\x20to\x20the\x20deployer,\x20no\x20Surplus\x20draining\x20the\x20pool)?','Are\x20the\x20chain\x20GAPs\x20disclosed\x20honestly\x20—\x20the\x20auction\x20resolved\x20OFF-chain\x20(no\x20bid\x20ledger)\x20and\x20usage\x20caps\x20enforced\x20as\x20attested-counter\x20arbitration\x20evidence\x20(no\x20metering\x20oracle),\x20never\x20as\x20chain-enforced\x20limits?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':!![]},'service':{'multi_recipient_allocation':!![],'logistics_mode':'none'}},'expected_benefits':[{'metric':'Royalty-split\x20transparency','expected_value':'100%','evidence':'every\x20rights-holder\x20share\x20is\x20an\x20on-chain\x20Rate\x20leg\x20the\x20buyer\x20can\x20audit\x20before\x20ordering'},{'metric':'Misrepresentation\x20dispute\x20rate','expected_value':'-40%','evidence':'inspection-window\x20escrow\x20+\x20grant-artifact\x20WIP\x20anchor\x20the\x20terms\x20before\x20release'},{'metric':'Settlement\x20latency','expected_value':'seconds','evidence':'release\x20fires\x20on\x20buyer\x20accept\x20/\x20time-lock,\x20not\x20a\x20calendar\x20freeze'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['release\x20split\x20Rate\x20legs\x20sum\x20exactly\x2010000\x20(ERATE_NOT_10000);\x20every\x20recipient\x20an\x20explicit\x20NON-EMPTY\x20Entity','inspection/delivery\x20window\x20>=\x203d\x20so\x20the\x20buyer\x20can\x20verify\x20the\x20grant\x20before\x20auto-accept','🔴\x20auction\x20resolved\x20OFF-chain\x20(no\x20bid\x20ledger)\x20and\x20usage\x20caps\x20attested\x20(no\x20oracle)\x20—\x20disclosed,\x20never\x20chain-enforced']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Pure-digital\x20grant\x20(no\x20logistics\x20leg)','Rights-holder\x20/\x20producer\x20/\x20publisher\x20owns\x20the\x20IP','Long-lived\x20value\x20(a\x20royalty\x20share\x20or\x20a\x20license\x20term)']},'similar_industries':['subscription','freelance'],'novel_capabilities':['Multi-recipient\x20royalty\x20split\x20(Allocation\x20Rate\x20plan)','Territory/qualification\x20allowlist\x20buy\x20gate','Inspection-window\x20escrow\x20before\x20release']},{'name':'crowdfunding','display_name':'Crowdfunding','version':'v1','source':'builtin',...fetchTemplate('crowdfunding'),'analyze':{'key_questions':['Is\x20each\x20contribution\x20escrowed\x20to\x20the\x20funder\x27s\x20OWN\x20Order\x20(for_object)\x20and\x20NEVER\x20pooled\x20via\x20balance::join,\x20so\x20per-backer\x20attribution\x20survives\x20settlement\x20or\x20refund?','Does\x20the\x20threshold\x20gate\x20read\x20a\x20WRITER-BOUND\x20Repository\x20numeric\x20row\x20(id_from\x20signer,\x20value\x20=\x20amount)\x20summed\x20via\x20the\x20sum-where\x20query,\x20ANDed\x20with\x20an\x20ABSOLUTE\x20shared\x20campaign\x20deadline\x20—\x20so\x20a\x20funder\x20cannot\x20inflate\x20the\x20total\x20and\x20every\x20backer\x20sees\x20the\x20same\x20cutoff?','Is\x20the\x20aggregate\x20total\x20disclosed\x20honestly\x20as\x20a\x20keeper-attested\x20Repository\x20sum\x20(arbitration\x20evidence,\x20NOT\x20a\x20chain-verified\x20money\x20oracle),\x20and\x20is\x20the\x20escrow-exit\x20two-leg\x20polarity\x20exact\x20(refund\x20claimed_by\x20some==false\x20XOR\x20recover_gate\x20claimed_by\x20some==true,\x20D-BUG-2)?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'multi_recipient_allocation':!![],'logistics_mode':'none'}},'expected_benefits':[{'metric':'Backer\x20attribution','expected_value':'100%','evidence':'each\x20contribution\x20is\x20a\x20for_object-bound\x20Allocation\x20on\x20the\x20funder\x27s\x20own\x20Order\x20—\x20never\x20pooled'},{'metric':'Unmet-threshold\x20refund','expected_value':'automatic','evidence':'the\x20sum-where\x20<\x20goal\x20leg\x20fires\x20the\x20refund\x20exit\x20with\x20no\x20merchant\x20approval\x20(D-BUG-2\x20polarity)'},{'metric':'Campaign\x20deadline\x20drift','expected_value':'0','evidence':'one\x20ABSOLUTE\x20Clock\x20timestamp\x20shared\x20by\x20every\x20funder,\x20not\x20per-order\x20entry+duration'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['per-contributor\x20Allocation\x20for_object\x20=\x20own\x20Order;\x20NEVER\x20balance::join\x20(attribution\x20survives)','threshold\x20gate\x20=\x20repository.data\x20sum-where\x20(1174)\x20over\x20WRITER-BOUND\x20rows\x20ANDed\x20with\x20an\x20ABSOLUTE\x20deadline','🔴\x20the\x20aggregate\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum\x20(arbitration\x20evidence),\x20NOT\x20a\x20chain-verified\x20money\x20oracle\x20—\x20disclosed','🔴\x20L-01\x20never\x20promises\x20investment\x20returns\x20or\x20promotes\x20coin\x20price;\x20L-05\x20KYC/AML\x20+\x20cross-border\x20caution\x20(HIGH\x20regulatory\x20intensity)']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Aggregate\x20funding\x20goal\x20with\x20a\x20fixed\x20campaign\x20deadline','Per-backer\x20reward\x20tiers\x20or\x20donation\x20(no\x20logistics\x20leg\x20required)','All-or-nothing\x20(refund\x20if\x20unmet)\x20or\x20keep-it-all\x20(no\x20refund)\x20campaign\x20shape']},'similar_industries':['retail','licensing'],'novel_capabilities':['Aggregate-goal\x20threshold\x20gate\x20via\x20writer-bound\x20Repository\x20sum-where','Per-contributor\x20for_object\x20escrow\x20(attribution-preserving,\x20never\x20pooled)','Absolute\x20shared\x20campaign\x20deadline\x20+\x20two-leg\x20escrow-exit\x20(release\x20XOR\x20refund)']},{'name':'general','display_name':'General','version':'v1','source':'builtin',...fetchTemplate('general'),'analyze':{'key_questions':['Which\x20trust\x20mechanisms\x20(arbitration,\x20compensation\x20fund,\x20WIP\x20evidence)\x20are\x20missing\x20here,\x20and\x20what\x20does\x20each\x20absence\x20cost\x20in\x20the\x20worst\x20case?','What\x20is\x20the\x20single\x20point\x20of\x20failure\x20—\x20who\x20can\x20unilaterally\x20take\x20funds\x20or\x20stall\x20the\x20workflow?']},'capabilities_used':['permission.index_create','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance'],'expected_benefits':[{'metric':'Flexibility','expected_value':'100%','evidence':'User\x20customizes\x20all\x20trust\x20mechanism\x20parameters'},{'metric':'Degraded\x20safety','expected_value':'usable','evidence':'Can\x20fall\x20back\x20to\x20general\x20at\x20any\x20time'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![]},'applicable_conditions':{'business_scale':'small','other_conditions':['Fallback\x20degraded\x20mode','Hybrid\x20scenarios\x20not\x20covered\x20by\x20other\x20industries']},'similar_industries':[],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']}];
1
+ import{getScenarioMode}from'../knowledge/scenario-modes.js';import{BUILTIN_TEMPLATES}from'../knowledge/builtin-templates.js';import{getIndustryTraits}from'../knowledge/industry-registry.js';import{getIndustryRiskChecks,getIndustryNeeds}from'../customer/index.js';import{SUPPORTED_INDUSTRIES}from'../customer/user-preferences.js';import{getFlywheelForIndustry}from'../knowledge/acquisition-flywheel.js';const GENERAL_TRAITS={'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![],'regulatory_intensity':'low','trust_sensitivity':'medium','consumption_frequency':'occasional','avg_ticket_size':'medium'},GENERAL_FLYWHEEL={'industry':'general','trustSellingPoints':[],'keyActions':[],'rewardStrategy':'User-defined','discountStrategy':'User-defined','trustDescription':'User-defined\x20trust\x20mechanism'},GENERAL_MACHINE_SHAPE=[{'name':'paid','role':'Entry:\x20order\x20created\x20and\x20paid'},{'name':'delivering','role':'Service\x20delivery\x20in\x20progress'},{'name':'delivered','role':'Deliverable\x20available\x20for\x20review'},{'name':'completed','role':'Service\x20completed,\x20funds\x20released'},{'name':'cancelled','role':'Pre-delivery\x20cancellation\x20—\x20triggers\x20refund\x20Allocator','operator':'order_payer'}],GENERAL_ALLOCATOR={'recipient':'signer','count':0x1,'mode':'surplus','description':'Default:\x20surplus\x20to\x20service\x20owner\x20(general\x20fallback)'},RETAIL_D2C_MACHINE_SHAPE=[{'name':'ordered','role':'Entry:\x20order\x20created\x20(funds\x20escrowed\x20in\x20Allocation)'},{'name':'shipped','role':'Merchant\x20ships\x20goods'},{'name':'delivered','role':'Goods\x20delivered\x20to\x20buyer'},{'name':'completed','role':'Buyer\x20confirms\x20receipt\x20—\x20withdraw_guard\x20releases\x20funds','operator':'order_payer'},{'name':'cancelled','role':'Pre-ship\x20cancellation\x20—\x20refund_guard\x20refunds\x20buyer','operator':'order_payer'}],RETAIL_D2C_GUARDS=[{'template_id':'withdraw_guard_delivery','host':'service','purpose':'Release\x20funds\x20to\x20merchant\x20+\x20processor\x20on\x20order\x20completion\x20(delivery\x20confirmation)'},{'template_id':'refund_guard_cancellation','host':'service','purpose':'Refund\x20100%\x20to\x20buyer\x20on\x20order\x20cancellation'}],RETAIL_D2C_ALLOCATOR={'recipient':'entity','count':0x2,'mode':'rate','description':'Merchant\x2097%\x20+\x20Processor\x203%\x20(rate-based\x20split,\x20no\x20platform\x20commission)'},RETAIL_D2C_KEY_RISK='No\x20platform\x20arbitration\x20—\x20disputes\x20rely\x20on\x20optional\x20Arbitration\x20or\x20off-chain\x20chargeback',RETAIL_D2C_BUILD_NOTES=['Allocation\x20escrow\x20replaces\x20platform\x20custody\x20—\x20funds\x20locked\x20in\x20contract\x20until\x20Guard\x20releases','withdraw_guard\x20enforces\x20delivery\x20gate\x20—\x20merchant\x20must\x20reach\x20\x27completed\x27\x20state\x20to\x20receive\x20payment','refund_guard\x20ensures\x20100%\x20refund\x20on\x20cancellation\x20—\x20no\x20merchant\x20approval\x20needed','No\x20buy_guard\x20needed\x20—\x20D2C\x20doesn\x27t\x20gate\x20purchases\x20(open\x20storefront)','Arbitration\x20is\x20optional\x20—\x20add\x20when\x20dispute\x20volume\x20justifies\x20the\x20cost','Service\x20↔\x20Guard\x20circular\x20dependency:\x20create\x20Service\x20(unpublished)\x20→\x20create\x20Guards\x20→\x20update\x20Service\x20(publish)'],SUPPORTED_INDUSTRY_SET=new Set([...SUPPORTED_INDUSTRIES,'retail_d2c']);function fetchTemplate(a){const b=a==='retail_d2c'?'retail':a,c=getIndustryTraits(b)??GENERAL_TRAITS,d=SUPPORTED_INDUSTRY_SET['has'](a),e=a==='retail_d2c'?'retail':a,f=d?getIndustryRiskChecks(e):[],g=d?getIndustryNeeds(e):[],h=getFlywheelForIndustry(b)??GENERAL_FLYWHEEL;let i,j,k,l,m;if(a==='retail_d2c')i=RETAIL_D2C_MACHINE_SHAPE,j=RETAIL_D2C_GUARDS,k=RETAIL_D2C_ALLOCATOR,l=RETAIL_D2C_KEY_RISK,m=RETAIL_D2C_BUILD_NOTES;else{if(a==='general'){const n=getScenarioMode('general');i=GENERAL_MACHINE_SHAPE,j=[],k=GENERAL_ALLOCATOR,l=n?.['key_risk']??'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually',m=n?.['build_notes'];}else{const o=getScenarioMode(a);if(!o)throw new Error('[modes.ts]\x20No\x20scenario\x20mode\x20found\x20for\x20industry:\x20'+a);const p=BUILTIN_TEMPLATES['find'](q=>q['id']===o['default_template']);if(!p)throw new Error('[modes.ts]\x20Mode\x20\x27'+a+'\x27\x20default_template\x20\x27'+o['default_template']+'\x27\x20is\x20not\x20in\x20the\x20builtin\x20template\x20catalog');i=p['machine_shape'],j=p['guards'],k=p['allocator'],l=o['key_risk'],m=o['build_notes'];}}return{'traits':c,'risk_checks':f,'needs':g,'flywheel':h,'machine_shape':i,'guards':j,'allocator':k,'key_risk':l,'build_notes':m};}export const BUILTIN_MODES=[{'name':'freelance','display_name':'Freelance','version':'v1','source':'builtin',...fetchTemplate('freelance'),'analyze':{'key_questions':['Are\x20WIP\x20hashes\x20bound\x20to\x20each\x20milestone,\x20so\x20delivery\x20evidence\x20cannot\x20be\x20substituted\x20after\x20acceptance?','Does\x20the\x20acceptance\x20gate\x20have\x20a\x20time-bounded\x20escape\x20(keeper-driven\x20auto-accept),\x20or\x20can\x20a\x20silent\x20buyer\x20hold\x20the\x20provider\x27s\x20funds\x20hostage\x20indefinitely?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'service':{'setting_lock_duration':'30d','engagement_type':'milestone'},'machine':{'wip_required':!![],'wip_hash_algorithm':'sha256','acceptance_gate':!![]}},'expected_benefits':[{'metric':'Dispute\x20rate\x20reduction','expected_value':'40%','evidence':'WIP\x20hash\x20+\x20milestone\x20allocation\x20enforces\x20delivery\x20evidence'},{'metric':'Delivery\x20confirmation\x20efficiency','expected_value':'+50%','evidence':'acceptance\x20gate\x20automates\x20acceptance\x20workflow'},{'metric':'Provider\x20payment\x20assurance','expected_value':'100%','evidence':'Funds\x20auto-release\x20to\x20provider\x20after\x20accepted\x20node'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':![],'require_wip_evidence':!![],'other_constraints':['setting_lock_duration\x20>=\x207d\x20to\x20lock\x20engagement-period\x20rules','Acceptance\x20timeout\x20=\x20the\x20template\x27s\x20escrow_release_days\x20(single\x20source:\x20fee_params,\x20override\x20via\x20fee_overrides).\x20Mechanism:\x20dual-branch\x20time-gated\x20forward\x20(pattern.time_lock_progress\x20anchored\x20on\x20the\x20delivered\x20entry);\x20a\x20keeper\x20advances\x20the\x20timeout\x20path.\x20adminUnhold\x20(224)\x20is\x20ONLY\x20the\x20hold-release\x20escape\x20hatch,\x20never\x20the\x20timeout\x20mechanism.']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Suitable\x20for\x20mid-to-long-term\x20project\x20delivery','Requires\x20milestone-based\x20phased\x20acceptance']},'similar_industries':['rental','education'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_compensation_fund']},{'name':'rental','display_name':'Rental','version':'v1','source':'builtin',...fetchTemplate('rental'),'analyze':{'key_questions':['Is\x20the\x20deposit\x20escrowed\x20on-chain\x20and\x20sized\x20against\x20the\x20item\x27s\x20full\x20replacement\x20value,\x20not\x20just\x20the\x20rental\x20fee?','Are\x20pre-handover\x20and\x20post-return\x20WIP\x20states\x20hash-recorded,\x20so\x20damage\x20attribution\x20is\x20provable\x20rather\x20than\x20asserted?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'treasury':{'deposit_escrow':!![],'deposit_deductible':!![]},'machine':{'wip_required':!![],'wip_stages':['handover_out','returned'],'inspection_gate':!![]}},'expected_benefits':[{'metric':'Deposit\x20dispute\x20rate','expected_value':'-60%','evidence':'pre-rental\x20WIP\x20mandatorily\x20records\x20item\x27s\x20original\x20state'},{'metric':'Damage\x20liability\x20accuracy','expected_value':'+70%','evidence':'pre/post\x20WIP\x20hash\x20comparison\x20eliminates\x20unfounded\x20deductions'},{'metric':'Trust\x20score','expected_value':'+25%','evidence':'compensation_fund\x20covers\x20damage\x20risk'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'max_single_transaction':0x2710,'compensation_fund_coverage_ratio':0xa,'other_constraints':['Deposit\x20must\x20be\x20escrowed\x20(no\x20direct\x20transfer)','lock_duration\x20>=\x207d\x20to\x20prevent\x20arbitrary\x20merchant\x20withdrawal']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Requires\x20physical\x20item\x20handover','Has\x20logistics\x20or\x20offline\x20delivery\x20leg']},'similar_industries':['retail','travel'],'novel_capabilities':[]},{'name':'education','display_name':'Education','version':'v1','source':'builtin',...fetchTemplate('education'),'analyze':{'key_questions':['Does\x20tuition\x20release\x20per\x20attended\x20session\x20(Progress\x20node),\x20so\x20undelivered\x20sessions\x20stay\x20refundable\x20if\x20the\x20institution\x20disappears?','Does\x20setting_lock_duration\x20span\x20the\x20full\x20term,\x20so\x20the\x20institution\x20cannot\x20tighten\x20refund\x20rules\x20mid-course?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','allocation.distribute_milestone','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x1,'mode':'amount','description':'1/N\x20of\x20tuition\x20released\x20per\x20session\x20attendance'},'session_threshold':!![]},'service':{'setting_lock_duration':'120d','anti_runaway':!![]}},'expected_benefits':[{'metric':'Refund\x20dispute\x20rate','expected_value':'-50%','evidence':'per-session\x20release\x20distributes\x20tuition\x20by\x20class'},{'metric':'Institution\x20runaway\x20risk','expected_value':'eliminated','evidence':'Funds\x20release\x20per\x20session;\x20undelivered\x20portion\x20is\x20refundable'},{'metric':'Attendance\x20traceability','expected_value':'100%','evidence':'attendance_guard\x20signs\x20each\x20session'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'other_constraints':['setting_lock_duration\x20covers\x20the\x20entire\x20term\x20(>=90d)','Long-cycle\x20projects\x20must\x20monitor\x20>90d\x20progress']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Long-cycle\x20delivery','Requires\x20per-session\x20acceptance','Regulatory\x20intensity:\x20medium']},'similar_industries':['freelance','subscription'],'novel_capabilities':['allocation.distribute_milestone'],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'travel','display_name':'Travel','version':'v1','source':'builtin',...fetchTemplate('travel'),'analyze':{'key_questions':['Does\x20each\x20itinerary\x20segment\x20have\x20its\x20own\x20guard\x20and\x20WIP\x20acceptance,\x20so\x20one\x20failed\x20leg\x20is\x20refundable\x20without\x20unwinding\x20the\x20whole\x20trip?','Is\x20the\x20multi-tier\x20allocation\x20waterfall\x20(agency\x20→\x20hotel/guide/driver)\x20visible\x20on-chain,\x20so\x20the\x20agency\x20cannot\x20silently\x20re-split\x20funds?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'allocation':{'strategy':{'recipient':'entity','count':0x3,'mode':'amount','description':'Deposit\x2020%\x20to\x20agency,\x20final\x2080%\x20to\x20agency,\x20then\x20agency-side\x20Allocation\x20splits\x20to\x20hotel/guide/driver\x20per\x20segment'},'multi_tier_waterfall':!![],'guard_chaining':!![]},'service':{'supply_chain_suborders':!![],'segment_guard_required':!![]}},'expected_benefits':[{'metric':'Fund\x20transparency','expected_value':'100%','evidence':'multi-tier\x20allocation\x20splits\x20per\x20segment\x20to\x20hotel/guide/driver'},{'metric':'Itinerary\x20change\x20disputes','expected_value':'-45%','evidence':'segment\x20WIP\x20accepts\x20each\x20leg'},{'metric':'Breach\x20compensation\x20assurance','expected_value':'+60%','evidence':'compensation_fund\x20covers\x20itinerary\x20breach'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['Multi-tier\x20allocation\x20requires\x20guard\x20chaining\x20validation','deposit\x2020%\x20+\x20final\x2080%\x20two-stage\x20payment']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0x1,'other_conditions':['Multi-segment\x20itinerary\x20combination','Requires\x20hotel/guide/driver\x20multi-party\x20allocation']},'similar_industries':['rental','education'],'novel_capabilities':[]},{'name':'subscription','display_name':'Subscription','version':'v1','source':'builtin',...fetchTemplate('subscription'),'analyze':{'key_questions':['Is\x20every\x20periodic\x20charge\x20gated\x20by\x20an\x20explicit\x20user\x20confirmation,\x20with\x20no\x20auto-renew\x20default?','Can\x20the\x20subscriber\x20cancel\x20anytime\x20effective\x20next\x20period,\x20without\x20a\x20dead-end\x20node\x20in\x20the\x20machine?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'no_auto_renew_trap':!![],'user_confirmed_charge':!![],'cancel_anytime':!![],'next_period_effective':!![]},'service':{'creator_data_subscription':!![],'periodic_billing':!![]}},'expected_benefits':[{'metric':'Renewal\x20rate','expected_value':'+25%','evidence':'loyalty\x20reward\x20+\x20transparent\x20subscription\x20mechanism'},{'metric':'Cancellation\x20disputes','expected_value':'eliminated','evidence':'cancel\x20anytime\x20+\x20no\x20auto-renew\x20trap'},{'metric':'Creator\x20retention','expected_value':'+30%','evidence':'deliver_guard_wip\x20prevents\x20content\x20dropout'}],'risk_appetite':'aggressive','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x3,'other_constraints':['Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in)','charge_guard\x20requires\x20user\x20confirmation\x20each\x20period']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x5,'other_conditions':['Pure-digital\x20delivery','Periodic\x20content\x20or\x20SaaS\x20service']},'similar_industries':['freelance','education'],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'retail','display_name':'Retail','version':'v1','source':'builtin',...fetchTemplate('retail'),'analyze':{'key_questions':['Is\x20the\x20logistics\x20tracking\x20number\x20recorded\x20as\x20WIP\x20before\x20the\x20confirm\x20gate,\x20so\x20receipt\x20disputes\x20have\x20carrier\x20evidence?','Is\x20the\x20refund\x20window\x20at\x20least\x207\x20days\x20with\x20an\x20on-chain\x20refund\x20path\x20that\x20does\x20not\x20rely\x20on\x20merchant\x20goodwill?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','reward.claim_guard','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'wip_field':'tracking_number','confirm_gate':!![],'refund_requires_approval':!![]},'service':{'first_order_discount':!![]}},'expected_benefits':[{'metric':'Return\x20dispute\x20rate','expected_value':'-35%','evidence':'logistics\x20WIP\x20+\x20refund\x20path\x20assurance'},{'metric':'Repurchase\x20rate','expected_value':'+20%','evidence':'spend\x20cashback\x20reward'},{'metric':'Product\x20authenticity\x20traceability','expected_value':'100%','evidence':'WIP\x20verifies\x20product/logistics\x20info'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':![],'compensation_fund_coverage_ratio':0x5,'other_constraints':['refund_window\x20>=\x207d','confirm_gate:\x20only\x20buyer\x20can\x20confirm\x20receipt']},'applicable_conditions':{'business_scale':'medium','min_daily_orders':0xa,'other_conditions':['Has\x20logistics\x20shipping\x20leg','High-frequency\x20small-ticket\x20transactions']},'similar_industries':['rental','subscription'],'novel_capabilities':[],'disabled_builtin_constraints':['require_wip_evidence']},{'name':'retail_d2c','display_name':'Retail\x20D2C\x20(Direct-to-Consumer)','version':'v1','source':'builtin',...fetchTemplate('retail_d2c'),'analyze':{'key_questions':['Do\x20withdraw_guard\x20and\x20refund_guard\x20fully\x20enclose\x20the\x20Allocation\x20escrow,\x20so\x20neither\x20side\x20can\x20move\x20funds\x20outside\x20the\x20contract\x20path?','With\x20no\x20platform\x20arbitration,\x20what\x20off-chain\x20recourse\x20(if\x20any)\x20backs\x20a\x20delivery\x20failure\x20—\x20and\x20is\x20that\x20acceptable\x20for\x20the\x20ticket\x20size?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_withdraw','guard.validate_refund','machine.node_topology','allocation.distribute','service.publish','progress.advance','contact.im_create'],'config_overrides':{'machine':{'wip_required':![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Merchant\x20revenue\x20share','expected_value':'97%','evidence':'No\x20platform\x20commission\x20—\x20only\x203%\x20processing\x20fee'},{'metric':'Fund\x20safety','expected_value':'contract-grade','evidence':'Allocation\x20escrow\x20+\x20Guard\x20verification\x20replaces\x20platform\x20custody'},{'metric':'Delivery\x20reliability','expected_value':'high','evidence':'withdraw_guard\x20enforces\x20delivery\x20confirmation\x20before\x20payment'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![],'other_constraints':['Allocation\x20escrow\x20required\x20(withdraw_guard\x20+\x20refund_guard)','Service\x20↔\x20Guard\x20circular\x20dependency\x20requires\x203-step\x20creation\x20pattern']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Independent\x20storefront\x20(no\x20marketplace)','Merchant-managed\x20logistics','Allocation\x20escrow\x20model']},'similar_industries':['retail','subscription'],'novel_capabilities':['Allocation\x20escrow\x20as\x20platform-custody\x20alternative','Multi-recipient\x20allocation\x20(merchant\x20+\x20processor)'],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']},{'name':'licensing','display_name':'Licensing','version':'v1','source':'builtin',...fetchTemplate('licensing'),'analyze':{'key_questions':['Is\x20the\x20license\x20grant\x20(terms\x20+\x20asset/certificate\x20hash)\x20anchored\x20as\x20a\x20WIP\x20artifact\x20and\x20an\x20evidence\x20Repository\x20row\x20BEFORE\x20release,\x20so\x20a\x20misrepresentation\x20dispute\x20has\x20an\x20on-chain\x20artifact\x20to\x20read?','Does\x20the\x20release\x20split\x20sum\x20to\x20exactly\x2010000\x20bps\x20across\x20explicit\x20NON-EMPTY\x20rights-holder\x20Entities\x20(no\x20empty\x20Entity\x20routing\x20the\x20share\x20to\x20the\x20deployer,\x20no\x20Surplus\x20draining\x20the\x20pool)?','Are\x20the\x20chain\x20GAPs\x20disclosed\x20honestly\x20—\x20the\x20auction\x20resolved\x20OFF-chain\x20(no\x20bid\x20ledger)\x20and\x20usage\x20caps\x20enforced\x20as\x20attested-counter\x20arbitration\x20evidence\x20(no\x20metering\x20oracle),\x20never\x20as\x20chain-enforced\x20limits?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':!![]},'service':{'multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Royalty-split\x20transparency','expected_value':'100%','evidence':'every\x20rights-holder\x20share\x20is\x20an\x20on-chain\x20Rate\x20leg\x20the\x20buyer\x20can\x20audit\x20before\x20ordering'},{'metric':'Misrepresentation\x20dispute\x20rate','expected_value':'-40%','evidence':'inspection-window\x20escrow\x20+\x20grant-artifact\x20WIP\x20anchor\x20the\x20terms\x20before\x20release'},{'metric':'Settlement\x20latency','expected_value':'seconds','evidence':'release\x20fires\x20on\x20buyer\x20accept\x20/\x20time-lock,\x20not\x20a\x20calendar\x20freeze'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['release\x20split\x20Rate\x20legs\x20sum\x20exactly\x2010000\x20(ERATE_NOT_10000);\x20every\x20recipient\x20an\x20explicit\x20NON-EMPTY\x20Entity','inspection/delivery\x20window\x20>=\x203d\x20so\x20the\x20buyer\x20can\x20verify\x20the\x20grant\x20before\x20auto-accept','🔴\x20auction\x20resolved\x20OFF-chain\x20(no\x20bid\x20ledger)\x20and\x20usage\x20caps\x20attested\x20(no\x20oracle)\x20—\x20disclosed,\x20never\x20chain-enforced']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Pure-digital\x20grant\x20(no\x20logistics\x20leg)','Rights-holder\x20/\x20producer\x20/\x20publisher\x20owns\x20the\x20IP','Long-lived\x20value\x20(a\x20royalty\x20share\x20or\x20a\x20license\x20term)']},'similar_industries':['subscription','freelance'],'novel_capabilities':['Multi-recipient\x20royalty\x20split\x20(Allocation\x20Rate\x20plan)','Territory/qualification\x20allowlist\x20buy\x20gate','Inspection-window\x20escrow\x20before\x20release']},{'name':'crowdfunding','display_name':'Crowdfunding','version':'v1','source':'builtin',...fetchTemplate('crowdfunding'),'analyze':{'key_questions':['Is\x20each\x20contribution\x20escrowed\x20to\x20the\x20funder\x27s\x20OWN\x20Order\x20(for_object)\x20and\x20NEVER\x20pooled\x20via\x20balance::join,\x20so\x20per-backer\x20attribution\x20survives\x20settlement\x20or\x20refund?','Does\x20the\x20threshold\x20gate\x20read\x20a\x20WRITER-BOUND\x20Repository\x20numeric\x20row\x20(id_from\x20signer,\x20value\x20=\x20amount)\x20summed\x20via\x20the\x20sum-where\x20query,\x20ANDed\x20with\x20an\x20ABSOLUTE\x20shared\x20campaign\x20deadline\x20—\x20so\x20a\x20funder\x20cannot\x20inflate\x20the\x20total\x20and\x20every\x20backer\x20sees\x20the\x20same\x20cutoff?','Is\x20the\x20aggregate\x20total\x20disclosed\x20honestly\x20as\x20a\x20keeper-attested\x20Repository\x20sum\x20(arbitration\x20evidence,\x20NOT\x20a\x20chain-verified\x20money\x20oracle),\x20and\x20is\x20the\x20escrow-exit\x20two-leg\x20polarity\x20exact\x20(refund\x20claimed_by\x20some==false\x20XOR\x20recover_gate\x20claimed_by\x20some==true,\x20D-BUG-2)?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Backer\x20attribution','expected_value':'100%','evidence':'each\x20contribution\x20is\x20a\x20for_object-bound\x20Allocation\x20on\x20the\x20funder\x27s\x20own\x20Order\x20—\x20never\x20pooled'},{'metric':'Unmet-threshold\x20refund','expected_value':'automatic','evidence':'the\x20sum-where\x20<\x20goal\x20leg\x20fires\x20the\x20refund\x20exit\x20with\x20no\x20merchant\x20approval\x20(D-BUG-2\x20polarity)'},{'metric':'Campaign\x20deadline\x20drift','expected_value':'0','evidence':'one\x20ABSOLUTE\x20Clock\x20timestamp\x20shared\x20by\x20every\x20funder,\x20not\x20per-order\x20entry+duration'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['per-contributor\x20Allocation\x20for_object\x20=\x20own\x20Order;\x20NEVER\x20balance::join\x20(attribution\x20survives)','threshold\x20gate\x20=\x20repository.data\x20sum-where\x20(1174)\x20over\x20WRITER-BOUND\x20rows\x20ANDed\x20with\x20an\x20ABSOLUTE\x20deadline','🔴\x20the\x20aggregate\x20total\x20is\x20a\x20keeper-attested\x20Repository\x20sum\x20(arbitration\x20evidence),\x20NOT\x20a\x20chain-verified\x20money\x20oracle\x20—\x20disclosed','🔴\x20L-01\x20never\x20promises\x20investment\x20returns\x20or\x20promotes\x20coin\x20price;\x20L-05\x20KYC/AML\x20+\x20cross-border\x20caution\x20(HIGH\x20regulatory\x20intensity)']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Aggregate\x20funding\x20goal\x20with\x20a\x20fixed\x20campaign\x20deadline','Per-backer\x20reward\x20tiers\x20or\x20donation\x20(no\x20logistics\x20leg\x20required)','All-or-nothing\x20(refund\x20if\x20unmet)\x20or\x20keep-it-all\x20(no\x20refund)\x20campaign\x20shape']},'similar_industries':['retail','licensing'],'novel_capabilities':['Aggregate-goal\x20threshold\x20gate\x20via\x20writer-bound\x20Repository\x20sum-where','Per-contributor\x20for_object\x20escrow\x20(attribution-preserving,\x20never\x20pooled)','Absolute\x20shared\x20campaign\x20deadline\x20+\x20two-leg\x20escrow-exit\x20(release\x20XOR\x20refund)']},{'name':'delivery','display_name':'Local\x20Delivery','version':'v1','source':'builtin',...fetchTemplate('delivery'),'analyze':{'key_questions':['Who\x20writes\x20the\x20rider\x20roster\x20(permission\x20221)\x20—\x20is\x20that\x20admission\x20power\x20disclosed,\x20and\x20is\x20the\x20roster\x20budget\x20(60\x20rosters\x20/\x2080\x20addresses\x20per\x20Progress)\x20respected?','Does\x20settlement\x20depart\x20a\x20SERIAL\x20claim\x20window\x20(TPL-09)\x20with\x20settle_hours\x20>=\x20claim_window_hours,\x20so\x20no\x20payout\x20can\x20race\x20an\x20open\x20dispute\x20(FACT-ALLOC-03)?','Are\x20handover\x20records\x20(ready/pickup/deliver)\x20writer-bound\x20repository\x20rows,\x20and\x20is\x20the\x20buyer-facing\x20copy\x20honest\x20that\x20dispatch,\x20ETA\x20and\x20rider\x20pay\x20are\x20OFF-CHAIN?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','progress.named_operator','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Silent-buyer\x20stranding','expected_value':'0','evidence':'buyer-first\x20confirmation\x20+\x20keeper\x20auto-confirm\x20within\x20auto_confirm_hours\x20(T-04)'},{'metric':'Payout/claim\x20race','expected_value':'unreachable','evidence':'the\x20serial\x20claim\x20window\x20makes\x20settlement\x20depart\x20only\x20after\x20filing\x20closes\x20(TPL-09)'},{'metric':'Rider\x20money-surface','expected_value':'0\x20legs','evidence':'the\x20escrow\x20can\x20never\x20pay\x20a\x20per-order\x20rider\x20(for_object\x20lock);\x20payroll\x20is\x20the\x20platform\x27s\x20off-chain\x20duty'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':![],'require_wip_evidence':!![],'other_constraints':['rider\x20roster\x20=\x20rider-admission\x20power;\x20disclose\x20the\x20roster\x20writer\x20(NAMED_OPERATOR_ROSTER_UNDISCLOSED)','settle_hours\x20>=\x20claim_window_hours\x20asserted\x20at\x20generation\x20(serial\x20window\x20math)','🔴\x20rider\x20pay\x20is\x20OFF-CHAIN\x20platform\x20payroll\x20—\x20never\x20model\x20a\x20per-order\x20rider\x20payout\x20leg','🔴\x20no\x20ETA/distance\x20oracle\x20—\x20pricing\x20and\x20delivery\x20estimates\x20are\x20not\x20chain-verifiable']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Local\x20fulfillment\x20within\x20minutes-hours\x20windows\x20(perishable\x20or\x20time-boxed)','Per-order\x20dispatched\x20fulfillers\x20(no\x20fixed\x20staff\x20roster)','Fee-graded\x20cancellation\x20(free\x20pre-acceptance,\x20fee\x20post-acceptance)']},'similar_industries':['retail','group_buy'],'novel_capabilities':['Named-operator\x20roster\x20rail\x20for\x20per-order\x20dispatched\x20riders\x20(K-1)','Serial\x20claim\x20window\x20on\x20hours-scale\x20timing\x20(TPL-09)','Fee-graded\x20cancel\x20taxonomy\x20with\x20a\x20dedicated\x20kill\x20terminal']},{'name':'group_buy','display_name':'Community\x20Group-Buy','version':'v1','source':'builtin',...fetchTemplate('group_buy'),'analyze':{'key_questions':['Is\x20the\x20batch\x20cutoff\x20ONE\x20shared\x20absolute\x20timestamp\x20(keeper-written\x20Repository\x20row\x20+\x20time_source\x20oracle),\x20not\x20a\x20per-order\x20entry+duration\x20lock?','Does\x20the\x20leader\x20template\x20fix\x20the\x20supplier\x27s\x20sub-service\x20address\x20in\x20the\x20ConsolidateBatch\x20guard\x20table\x20(b_submission\x20false,\x20Address)\x20so\x20the\x20procurement\x20graph\x20is\x20diligence-able\x20before\x20any\x20buyer\x20pays?','In\x20threshold\x20mode,\x20are\x20contribution\x20rows\x20ORDER-keyed\x20with\x20the\x20escrow-bound\x20aggregate\x20(per-row\x20min(row,\x20order.amount))\x20and\x20the\x20live-escrow\x20+\x20claimed_by-false\x20legs\x20—\x20the\x20three\x20CROWDFUNDING_*\x20blockers\x20armed?']},'capabilities_used':['permission.index_create','permission.role_assign','guard.validate_buy','guard.validate_wip_hash','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance','progress.named_operator','repository.data_write','arb.vote_weighted','contact.im_create'],'config_overrides':{'machine':{'wip_required':!![],'confirm_gate':!![],'refund_requires_approval':![]},'service':{'multi_recipient_allocation':!![]}},'expected_benefits':[{'metric':'Cutoff\x20fairness','expected_value':'1\x20clock','evidence':'one\x20absolute\x20shared\x20cutoff\x20per\x20batch\x20(time_lock_absolute),\x20never\x20per-order\x20entry+duration'},{'metric':'Unformed-batch\x20refund','expected_value':'automatic','evidence':'ThresholdMissed\x20/\x20AbandonTimeout\x20rails\x20refund\x20per-order\x20with\x20no\x20merchant\x20grace'},{'metric':'Procurement\x20diligence','expected_value':'pre-order','evidence':'the\x20supplier\x20sub-service\x20address\x20is\x20a\x20fixed\x20guard-table\x20promise\x20(leader\x20shape)'}],'risk_appetite':'conservative','risk_constraints':{'require_arbitration':!![],'require_compensation_fund':!![],'require_wip_evidence':!![],'other_constraints':['batch\x20cutoff\x20=\x20shared\x20ABSOLUTE\x20timestamp\x20via\x20pattern.time_lock_absolute\x20+\x20time_source_repository_oracle','threshold\x20mode\x20reuses\x20the\x20crowdfunding\x20construction\x20(ORDER-keyed\x20rows,\x20escrow-bound\x20aggregate,\x20CROWDFUNDING_*\x20blockers)','🔴\x20multi-level\x20commission\x20is\x20NOT\x20expressible\x20—\x20single-layer\x20rate\x20leg\x20to\x20the\x20platform\x20Entity\x20with\x20off-chain\x20pass-through,\x20disclosed','🔴\x20delay\x20compensation\x20pays\x20from\x20compensation_fund,\x20NEVER\x20the\x20buyer\x20escrow\x20(Order\x20binds\x20<=\x201\x20allocator);\x20fund\x20pre-locked\x203x\x20(B2)']},'applicable_conditions':{'business_scale':'small','min_daily_orders':0x1,'other_conditions':['Neighborhood\x20batch\x20buying\x20with\x20a\x20daily/periodic\x20cutoff','Pickup-point\x20fulfillment\x20(staffed\x20point\x20or\x20automated\x20locker)','Leader\x20consolidation\x20ahead\x20of\x20a\x20supplier\x20sub-order']},'similar_industries':['crowdfunding','delivery'],'novel_capabilities':['Shared\x20absolute\x20batch\x20cutoff\x20via\x20keeper-written\x20Repository\x20row\x20+\x20time-source\x20oracle','Supply-chain\x20suborder\x20commitment\x20in\x20the\x20guard\x20table\x20(pre-order\x20diligence)','point_type-conditional\x20pickup\x20topology\x20(staffed\x20leader\x20rail\x20vs\x20automated\x20locker)']},{'name':'general','display_name':'General','version':'v1','source':'builtin',...fetchTemplate('general'),'analyze':{'key_questions':['Which\x20trust\x20mechanisms\x20(arbitration,\x20compensation\x20fund,\x20WIP\x20evidence)\x20are\x20missing\x20here,\x20and\x20what\x20does\x20each\x20absence\x20cost\x20in\x20the\x20worst\x20case?','What\x20is\x20the\x20single\x20point\x20of\x20failure\x20—\x20who\x20can\x20unilaterally\x20take\x20funds\x20or\x20stall\x20the\x20workflow?']},'capabilities_used':['permission.index_create','machine.node_topology','treasury.owner_receive','allocation.distribute','service.publish','progress.advance'],'expected_benefits':[{'metric':'Flexibility','expected_value':'100%','evidence':'User\x20customizes\x20all\x20trust\x20mechanism\x20parameters'},{'metric':'Degraded\x20safety','expected_value':'usable','evidence':'Can\x20fall\x20back\x20to\x20general\x20at\x20any\x20time'}],'risk_appetite':'balanced','risk_constraints':{'require_arbitration':![],'require_compensation_fund':![],'require_wip_evidence':![]},'applicable_conditions':{'business_scale':'small','other_conditions':['Fallback\x20degraded\x20mode','Hybrid\x20scenarios\x20not\x20covered\x20by\x20other\x20industries']},'similar_industries':[],'novel_capabilities':[],'disabled_builtin_constraints':['require_arbitration','require_compensation_fund','require_wip_evidence']}];
@@ -1 +1 @@
1
- import{detectFakeOrders,detectShellMerchant,detectNewAccountBurst,detectVoteReciprocity,detectTargetFlood}from'./anti-cheat.js';import{orderCompletionInGraph}from'./expand.js';import{PROPOSAL_GAP_ANALYZER}from'./proposal-graph.js';import{graphFindingPolicy}from'./policy.js';import{analyzeRewardClaimGuard}from'../../knowledge/recipient-constraint.js';import{beginPolicyRun,endPolicyRun}from'../../config/judgment.js';function root(a){const b=a?.['raw'],c=b?.['data']??b;return c&&typeof c==='object'?c:undefined;}function str(a){return typeof a==='string'&&a!=='0x0'?a:undefined;}function big(a){if(a==null)return 0x0n;try{return BigInt(typeof a==='number'?Math['trunc'](a):String(a));}catch{return 0x0n;}}function bool(a){return a===!![]||a===0x1||a==='1';}function asList(a){return Array['isArray'](a)?a:[];}function wfNodeName(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](b+'::node::'['length']):a;}function wfMachineOf(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](0x0,b):'';}export function findingWhere(a){const b=a['id'];if(b['startsWith']('R4:')){const c=b['slice'](0x3),d=c['indexOf'](':'),e=d>=0x0?c['slice'](0x0,d):c,g=d>=0x0?c['slice'](d+0x1):'';return e+':\x20'+g['split']('→')['map'](h=>wfNodeName(h['trim']()))['join']('\x20→\x20');}if(b['startsWith']('R7:treasury:'))return'Treasury\x20'+b['slice']('R7:treasury:'['length']);if(b['startsWith']('R7:reward:'))return'Reward\x20'+b['slice']('R7:reward:'['length']);if(b['startsWith']('R2:'))return b['slice'](0x3);if(b['startsWith']('R5:')){const [h,i]=b['slice'](0x3)['split']('|');return wfNodeName(h??'')+'\x20('+(i??'window')+')';}return a['title']??a['id'];}export function findingWhereResolved(a,b){const c=a['id'];if(c['startsWith']('R4:')){const d=c['slice'](0x3),e=d['indexOf'](':'),g=e>=0x0?d['slice'](0x0,e):d,h=e>=0x0?d['slice'](e+0x1):'',i=b['resolve'](g)['label'],j=l=>b['resolveWf'](l)?.['node']['label']??b['resolve'](l)['label'],k=h['split']('→')['map'](l=>j(l['trim']()))['join']('\x20→\x20');return i+':\x20'+k;}if(c['startsWith']('R7:treasury:'))return'Treasury\x20'+b['resolve'](c['slice']('R7:treasury:'['length']))['label'];if(c['startsWith']('R7:reward:'))return'Reward\x20'+b['resolve'](c['slice']('R7:reward:'['length']))['label'];if(c['startsWith']('R2:'))return b['resolve'](c['slice'](0x3))['label'];if(c['startsWith']('R5:')){const [l,m]=c['slice'](0x3)['split']('|');return b['resolve'](l??'')['label']+'\x20('+(m??'window')+')';}return a['title']??a['id'];}function typedNodes(a,b){const c=[];for(const d of a['visibleNodes']){const e=a['graph']['nodes']['get'](d);if(e?.['kind']==='object'&&e['objectType']===b&&e['raw']&&!e['proposal'])c['push'](e);}return c;}function edgeList(a,b){return a['visibleEdges']['filter'](c=>c['schema']===b);}function out(a,b,c){return a['visibleEdges']['filter'](d=>d['from']===b['toLowerCase']()&&d['schema']===c);}function inc(a,b,c){return a['visibleEdges']['filter'](d=>d['to']===b['toLowerCase']()&&d['schema']===c);}export const RETENTION_RANK={'complete':0x0,'event_full':0x0,'bounded_exact':0x1,'membership':0x1,'derived':0x2,'bounded_window':0x3,'event_degraded':0x3};const WINDOW_LIMIT=0x1450;export function pathConfidence(a,b){let c=0x0,d=![];for(const g of b){c=Math['max'](c,RETENTION_RANK[g['retention']]??0x0);if(g['retention']==='bounded_window'||g['retention']==='event_degraded'||g['truncated'])d=!![];}if(d){let h=0x0;for(const i of b){if(i['retention']!=='bounded_window'&&!i['truncated'])continue;const j=a['visibleEdges']['filter'](l=>l['schema']===i['schema']&&l['from']===i['from'])['length'];h=Math['max'](h,j);const k=a['graph']['truncations']['find'](l=>l['nodeId']===i['from']&&l['schema']===i['schema']);if(k)h=Math['max'](h,k['observed']);}return{'confidence':'windowed','window':{'observed':h||b['length'],'limit':WINDOW_LIMIT}};}const f=c===0x0?'exact':c===0x2?'derived':'bounded';return{'confidence':f};}function makeFinding(a,b,c,d,e){const {confidence:f,window:g}=pathConfidence(a,e['pathEdges']??[]),h=e['severity']??'info';return{'id':b,'kind':c,'severity':h,'title':d,'path':e['path'],'confidence':f,...g?{'window':g}:{},'roles':e['roles']??['neutral'],'detail':e['detail'],'suggestion':e['suggestion'],...e['amounts']?.['length']?{'amounts':e['amounts']}:{},...e['exposure']?{'exposure':e['exposure']}:{}};}const MAX_FINDINGS_PER_RULE=0x14,ROLE_OWNER_OR_ADMIN=0x1|0x2;export function buildControlIndex(a){const b=new Map(),c=new Map(),d=new Map(),f=(h,i,j)=>{const l=h['get'](i)??new Set();l['add'](j),h['set'](i,l);},g=new Map();for(const h of edgeList(a,'eoa.permission')){const i=typeof h['payload']?.['roleBits']==='number'?h['payload']['roleBits']:ROLE_OWNER_OR_ADMIN;if((i&ROLE_OWNER_OR_ADMIN)===0x0)continue;f(g,h['from'],h['to']);}for(const j of edgeList(a,'permission.core_binding')){const k=a['graph']['nodes']['get'](j['to']);if(!k||k['kind']!=='object')continue;f(d,j['to'],j['from']);for(const [l,m]of g){if(!m['has'](j['from']))continue;f(b,j['to'],l),f(c,l,j['to']);}}return{'controllers':b,'objectsByEoa':c,'permsOfObject':d};}function machineViews(a){const b=new Map();for(const d of edgeList(a,'wf.transition')){const f=wfMachineOf(d['from']);if(!f)continue;const g=b['get'](f)??[];g['push'](d),b['set'](f,g);}const c=[];for(const [h,i]of b){const j=a['graph']['nodes']['get'](h);if(!j||!a['visibleNodes']['has'](h))continue;const k=new Set([...(function*(){const l=new Set(i['map'](p=>String(p['payload']?.['node']??''))['filter'](Boolean)),o=new Set(i['map'](p=>String(p['payload']?.['prevNode']??''))['filter'](Boolean));for(const p of l)if(!o['has'](p))yield p;}())]);c['push']({'machine':j,'transitions':i,'terminals':k});}return c;}const ROLES_RISK_NEUTRAL_MERCHANT=['neutral','system','merchant'],R1={'id':'R1','kind':'risk','run'(b){const c=buildControlIndex(b),d=[],e=typedNodes(b,'Service'),f=typedNodes(b,'Arbitration');p:for(const g of e){const h=c['controllers']['get'](g['id']);if(!h)continue;for(const i of f){const j=c['controllers']['get'](i['id']);if(!j)continue;const k=c['permsOfObject']['get'](g['id']),l=c['permsOfObject']['get'](i['id']),m=[...k??[]]['some'](n=>l?.['has'](n));if(m)continue;for(const n of h){if(!j['has'](n))continue;const o=graphFindingPolicy('R1',{'eoa':n});if(!o['enabled'])continue;d['push'](makeFinding(b,'R1:'+g['id']+':'+i['id']+':'+n,'risk','Same-controller\x20arbitration\x20risk:\x20the\x20service\x20and\x20the\x20arbitration\x20service\x20are\x20controlled\x20by\x20the\x20same\x20EOA',{'severity':o['severity']??'high','path':[n,'eoa.permission','permission.core_binding',g['id'],i['id']],'pathEdges':edgeList(b,'permission.core_binding'),'roles':['neutral','system','merchant','arbitrator'],'detail':'EOA\x20'+n+'\x20controls\x20both\x20Service\x20'+g['id']+'\x20and\x20Arbitration\x20'+i['id']+'\x20as\x20owner/admin,\x20'+'and\x20the\x20two\x20are\x20attached\x20to\x20DIFFERENT\x20Permissions\x20(E33\x20only\x20forbids\x20the\x20same\x20Permission,\x20not\x20cross-group\x20arbitration).\x20'+'structurally\x20this\x20EOA\x20can\x20influence\x20both\x20the\x20arbitrated\x20service\x20and\x20the\x20ruling\x20outcome.','suggestion':'Verify\x20the\x20EOA\x27s\x20control\x20relationships;\x20require\x20disjoint\x20owner/admin\x20sets\x20between\x20the\x20service\x20and\x20the\x20arbitration\x20service,\x20or\x20remove\x20that\x20arbitration\x20service\x20from\x20the\x20selectable\x20list.',...o['exposure']?{'exposure':o['exposure']}:{}}));if(d['length']>=MAX_FINDINGS_PER_RULE)break p;}}}return d;}},R2={'id':'R2','kind':'risk','run'(b){const c=[];for(const f of typedNodes(b,'Service')){const g=root(f),h=out(b,f['id'],'service.order');if(h['length']===0x0)continue;let i=0x0n,j=0x0;for(const p of h){const q=root(b['graph']['nodes']['get'](p['to']));if(!q)continue;const r=big(q['amount']);if(r>i)i=r;j++;}if(j===0x0)continue;const k=big(g['compensation_fund']),l=i*0x3n;if(k>=l)continue;const m=f['coinType']?{'coin_type':f['coinType']}:{},n=k<i?'high':'medium',o=graphFindingPolicy('R2',{'r2_level':n});if(!o['enabled'])continue;c['push'](makeFinding(b,'R2:'+f['id'],'risk','Payout\x20exposure:\x20compensation\x20fund\x20cannot\x20cover\x20a\x20maximum-multiple\x20award\x20on\x20the\x20largest\x20windowed\x20order',{'severity':o['severity']??n,'path':[f['id'],'service.order','Order.amount','Service.compensation_fund'],'pathEdges':h,'roles':['neutral','system','merchant','buyer'],'detail':'Compensation\x20fund\x20{fund};\x20largest\x20of\x20'+j+'\x20windowed\x20orders\x20{amount};\x20'+'a\x20maximum-multiple\x20award\x20on\x20it\x20needs\x203x\x20its\x20amount\x20=\x20{needed}.\x20NOTE:\x20awards\x20SPEND\x20the\x20fund\x20—\x20'+'after\x20a\x20payout\x20the\x20remaining\x20fund\x20may\x20drop\x20below\x203x\x20the\x20next\x20large\x20order,\x20which\x20then\x20'+'cannot\x20be\x20created\x20(compensation_fund_below_order_ceiling\x20at\x20buy\x20time).\x20MERCHANT\x20CONSEQUENCE\x20'+'(F-BS-59):\x20the\x20first\x20SKU\x20this\x20wall\x20blocks\x20is\x20your\x20HIGHEST-priced\x20one\x20—\x20a\x20buy\x20on\x20it\x20is\x20refused\x20'+'(effectively\x20delisted)\x20until\x20the\x20fund\x20is\x20topped\x20back\x20above\x203x\x20its\x20price.\x20The\x20buyer-facing\x20gate\x20'+'announces\x20this\x20at\x20purchase\x20time;\x20this\x20surface\x20is\x20the\x20merchant-side\x20notice.','suggestion':'Top\x20up\x20compensation_fund\x20to\x20more\x20than\x203x\x20the\x20largest\x20open\x20order\x20amount\x20(and\x20re-check\x20after\x20every\x20award),\x20or\x20cap\x20the\x20largest\x20order\x20size.','amounts':[{'key':'fund','label':'Compensation\x20fund','raw':k['toString'](),...m},{'key':'amount','label':'Largest\x20windowed\x20order','raw':i['toString'](),...m},{'key':'needed','label':'Max-award\x20requirement\x20(3x\x20largest)','raw':l['toString'](),...m}],...o['exposure']?{'exposure':o['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c;}},CONTROL_TYPES=new Set(['Service','Machine','Treasury']),CONTROL_FANOUT_ALERT=0x3,R3={'id':'R3','kind':'risk','run'(a){const b=buildControlIndex(a),c=[];for(const [d,e]of b['objectsByEoa']){const f=[...e]['filter'](k=>CONTROL_TYPES['has'](a['graph']['nodes']['get'](k)?.['objectType']??''));if(f['length']<CONTROL_FANOUT_ALERT)continue;const g=f['filter'](k=>a['graph']['nodes']['get'](k)?.['objectType']==='Service'),h=g['reduce']((k,l)=>k+out(a,l,'service.order')['length'],0x0),i=f['length']>=0x5?'medium':'low',j=graphFindingPolicy('R3',{'r3_level':i});if(!j['enabled'])continue;c['push'](makeFinding(a,'R3:'+d,'risk','Permission\x20concentration:\x20a\x20single\x20EOA\x20controls\x20multiple\x20business-critical\x20objects',{'severity':j['severity']??i,'path':[d,'eoa.permission','permission.core_binding'],'pathEdges':edgeList(a,'eoa.permission')['concat'](edgeList(a,'permission.core_binding')),'roles':ROLES_RISK_NEUTRAL_MERCHANT,'detail':'EOA\x20'+d+'\x20controls\x20'+f['length']+'\x20Service/Machine/Treasury\x20objects\x20via\x20owner/admin\x20permissions\x20'+('('+g['length']+'\x20of\x20them\x20Services,\x20'+h+'\x20orders\x20visible\x20in\x20the\x20window);\x20business\x20scale\x20does\x20not\x20match\x20permission\x20dispersion.\x20')+('Controlled\x20objects:\x20'+f['slice'](0x0,0xa)['join'](',\x20')+(f['length']>0xa?',\x20and\x20'+(f['length']-0xa)+'\x20more':'')+'.'),'suggestion':'Delegate\x20day-to-day\x20operations\x20to\x20dedicated\x20admin/entity\x20roles\x20and\x20keep\x20owner\x20for\x20emergencies\x20only;\x20avoid\x20attaching\x20core\x20objects\x20to\x20the\x20same\x20permission\x20group.',...j['exposure']?{'exposure':j['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c;}},R4={'id':'R4','kind':'risk','run'(a){const b=[];q:for(const c of machineViews(a)){const d=new Map();for(const g of c['transitions']){if(!c['terminals']['has'](String(g['payload']?.['node']??'')))continue;const h=g['from']+'→'+g['to'],i=d['get'](h)??[];i['push'](g),d['set'](h,i);}for(const [j,k]of d){const l=new Set();let m=![];for(const n of k){if(str(n['payload']?.['namedOperator']))l['add']('name:'+n['payload']['namedOperator']);if(typeof n['payload']?.['permissionIndex']==='number')l['add']('perm:'+n['payload']['permissionIndex']);if(str(n['payload']?.['guard']))m=!![];}if(l['size']===0x1&&!m){const o=[...l][0x0],p=graphFindingPolicy('R4',{'only':o});if(!p['enabled'])continue;b['push'](makeFinding(a,'R4:'+c['machine']['id']+':'+j,'risk','Workflow\x20single\x20point:\x20the\x20only\x20Forward\x20before\x20a\x20terminal\x20state\x20has\x20a\x20single\x20operator\x20and\x20no\x20fallback\x20Guard',{'severity':p['severity']??'medium','path':[c['machine']['id'],'machine.node','wf.transition',j],'pathEdges':k,'roles':['neutral','system','merchant','collaborator'],'detail':'On\x20Machine\x20'+c['machine']['id']+',\x20path\x20'+j+'\x20toward\x20terminal\x20state\x20'+wfNodeName(k[0x0]['to'])+':\x20'+('the\x20only\x20operable\x20party\x20is\x20'+o+'\x20and\x20no\x20Forward\x20has\x20a\x20guard\x20fallback;\x20if\x20that\x20party\x20goes\x20offline\x20the\x20workflow\x20stalls.'),'suggestion':'Add\x20a\x20permissionIndex\x20alternative\x20or\x20attach\x20a\x20guard\x20auto-advance\x20condition\x20to\x20this\x20Forward\x20so\x20one\x20party\x20cannot\x20block\x20the\x20terminal\x20state.',...p['exposure']?{'exposure':p['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break q;}}}return b;}},R5={'id':'R5','kind':'risk','run'(a){const b=[],c=new Set();for(const d of a['graph']['truncations']){if(!a['visibleNodes']['has'](d['nodeId']))continue;const e=d['nodeId']+'|'+d['schema'];if(c['has'](e))continue;c['add'](e),b['push']({'id':'R5:'+e,'kind':'risk','severity':'info','title':'Window\x20truncation:\x20affected\x20conclusions\x20are\x20lower\x20bounds\x20within\x20the\x20<=5200\x20FIFO/ring\x20window\x20only','path':[d['nodeId'],d['schema']],'confidence':'windowed','window':{'observed':d['observed'],'limit':d['limit']??WINDOW_LIMIT},'roles':['neutral','system','merchant','buyer','supplier','arbitrator','collaborator'],'detail':'Fanout\x20of\x20'+d['schema']+'\x20at\x20node\x20'+d['nodeId']+'\x20is\x20truncated\x20(observed\x20'+d['observed']+',\x20window\x20limit\x20'+(d['limit']??WINDOW_LIMIT)+');\x20'+'any\x20conclusion\x20relying\x20on\x20this\x20path\x20must\x20be\x20worded\x20as\x20\x22within\x20the\x20window\x20/\x20at\x20least\x22,\x20never\x20as\x20exhaustive\x20truth.','suggestion':'For\x20exhaustive\x20conclusions\x20switch\x20to\x20the\x20event\x20channel\x20(channel\x20D)\x20or\x20raise\x20perKindCaps\x20within\x20budget.'});if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},R6={'id':'R6','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Service')){const e=root(c);if(!bool(e['bPublished']))continue;if(big(e['setting_lock_duration'])!==0x0n)continue;const f=graphFindingPolicy('R6',{});if(!f['enabled'])continue;b['push'](makeFinding(a,'R6:'+c['id'],'risk','Missing\x20setting\x20lock:\x20published\x20Service\x20has\x20setting_lock_duration=0',{'severity':f['severity']??'medium','path':[c['id'],'Service.setting_lock_duration'],'roles':ROLES_RISK_NEUTRAL_MERCHANT['concat']('buyer'),'detail':'Service\x20'+c['id']+'\x20is\x20published\x20but\x20setting_lock_duration=0:\x20order_allocators\x20/\x20rewards\x20/\x20arbitrations\x20/\x20machine\x20'+'and\x20compensation_fund\x20withdrawals\x20can\x20be\x20changed\x20instantly\x20(default\x20lock\x20is\x2030\x20days);\x20buyers\x20face\x20instantly\x20mutable\x20terms.','suggestion':'Set\x20setting_lock_duration\x20after\x20publishing\x20(30\x20days\x20=\x202592000000\x20ms\x20at\x20minimum);\x20term\x20changes\x20must\x20go\x20through\x20a\x20waiting\x20period.',...f['exposure']?{'exposure':f['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},OBJECT_USER_ROLES=['neutral','system','buyer','supplier'],R7={'id':'R7','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Treasury')){const d=asList(root(c)?.['external_withdraw_guard']);if(d['length']===0x0)continue;const e=graphFindingPolicy('R7-treasury',{});if(!e['enabled'])continue;b['push'](makeFinding(a,'R7:treasury:'+c['id'],'risk','Object-user\x20CRITICAL:\x20Treasury\x20has\x20a\x20permission-free\x20external\x20release\x20path',{'severity':e['severity']??'critical','path':[c['id'],'Treasury.external_withdraw_guard'],'roles':OBJECT_USER_ROLES,'detail':'Treasury\x20'+c['id']+'\x20has\x20'+d['length']+'\x20external_withdraw_guard\x20entry/entries:\x20external_withdraw\x20needs\x20no\x20Treasury\x20'+'Permission\x20—\x20only\x20the\x20Guard\x27s\x20boolean\x20verdict\x20stands\x20between\x20an\x20external\x20caller\x20and\x20the\x20balance.\x20The\x20topology\x20performs\x20'+'no\x20Guard-bytecode\x20analysis,\x20so\x20the\x20Guard\x27s\x20strength\x20is\x20UNVERIFIABLE\x20here.\x20Move\x20truth\x20(protocol\x20140):\x20the\x20destination\x20is\x20'+'forced\x20to\x20the\x20transaction\x20sender\x20(abort\x20code\x2010\x20on\x20mismatch),\x20which\x20blocks\x20third-party\x20redirection\x20but\x20NOT\x20release\x20to\x20a\x20'+'caller\x20whose\x20transaction\x20satisfies\x20a\x20weak\x20Guard\x20(for\x20example,\x20a\x20constant-true\x20root\x20with\x20a\x20static\x20amount\x20slot).','suggestion':'Do\x20not\x20rely\x20on\x20or\x20transact\x20through\x20this\x20Treasury\x20until\x20the\x20owner\x20presents\x20the\x20full\x20Guard\x20definitions;\x20verify\x20the\x20predicate\x20'+'constrains\x20the\x20amount\x20slot;\x20require\x20a\x20testnet\x20regression\x20(recipient\x20!=\x20sender\x20must\x20abort\x20with\x20code\x2010).',...e['exposure']?{'exposure':e['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}for(const f of typedNodes(a,'Reward')){const g=asList(root(f)?.['guards']);if(g['length']===0x0)continue;const h=g['map']((n,o)=>{const p=typeof n['guard']==='string'?n['guard']:'',q=p?a['graph']['nodes']['get'](p):undefined,s=q?root(q):undefined;return analyzeRewardClaimGuard({'entry_index':o,'guard':p,'recipient':n['recipient'],'guard_def':s?{...Array['isArray'](s['table'])?{'table':s['table']}:{},'root':s['root']}:undefined});}),i=h['some'](n=>n['viability']==='viable'),j=h['every'](n=>n['viability']==='blocked'),k=h['filter'](n=>n['viability']==='blocked')['length']+'\x20blocked,\x20'+(h['filter'](n=>n['viability']==='viable')['length']+'\x20viable,\x20')+(h['filter'](n=>n['viability']==='conditional')['length']+'\x20conditional,\x20')+(h['filter'](n=>n['viability']==='unverifiable')['length']+'\x20unverifiable'),l=h['map'](n=>'#'+n['entry_index']+'\x20'+n['viability']+'\x20—\x20'+n['reason'])['join']('\x20|\x20'),m=graphFindingPolicy('R7-reward',{'r7_slot_viability':i?'viable':j?'blocked':'unverifiable','r7_slot_audit':l});if(!m['enabled'])continue;b['push'](makeFinding(a,'R7:reward:'+f['id'],'risk',j?'Reward\x20claim\x20path\x20is\x20permission-free\x20but\x20every\x20payout\x20slot\x20is\x20provably\x20bound\x20(downgraded\x20hint)':'Object-user\x20CRITICAL:\x20Reward\x20has\x20a\x20permission-free\x20claim\x20path\x20with\x20an\x20unverifiable\x20payout\x20slot',{'severity':m['severity']??(j?'info':'critical'),'path':[f['id'],'Reward.guards'],'roles':OBJECT_USER_ROLES,'detail':'Reward\x20'+f['id']+'\x20has\x20'+g['length']+'\x20claim\x20guard\x20entry/entries:\x20claim()\x20needs\x20no\x20Permission,\x20and\x20with\x20a\x20'+'Recipient::GuardIdentifier\x20entry\x20the\x20payout\x20address\x20is\x20read\x20from\x20the\x20claim-time\x20passport\x20submission.\x20'+('Canonical\x20slot\x20audit\x20('+k+').\x20A\x20guard\x20that\x20passes\x20without\x20constraining\x20the\x20recipient\x20slot\x20lets\x20any\x20passing\x20')+'party\x20fill\x20the\x20slot\x20with\x20their\x20own\x20address\x20and\x20claim\x20the\x20pool.','suggestion':j?'Payout\x20slots\x20are\x20constraint-bound\x20per\x20the\x20guard\x20audit;\x20treat\x20this\x20as\x20an\x20informational\x20structure\x20note.':'Do\x20not\x20treat\x20the\x20reward\x20pool\x20as\x20sound\x20until\x20the\x20owner\x20presents\x20the\x20Guard\x20definitions;\x20verify\x20the\x20predicate\x20binds\x20the\x20'+'recipient\x20slot\x20(Signer/entity),\x20or\x20confirm\x20the\x20entries\x20use\x20Entity/Signer\x20recipients\x20that\x20do\x20not\x20depend\x20on\x20submitted\x20slots.',...m['exposure']?{'exposure':m['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},RATE_BASIS=0x2710n;function allocatorsList(a){if(Array['isArray'](a))return a;const b=a?.['allocators'];return asList(b);}function allocationStructuralIssues(a){const b=[];let c=0x0,d=![];for(const e of allocatorsList(a)){const f=e??{};let g=0x0n,h=0x0n,i=![];for(const j of asList(f['sharing'])){const k=j??{},l=Number(k['mode']);if(l===0x2||k['mode']==='Surplus'){c++,d=!![];continue;}if(l===0x3||k['mode']==='RateGross')h+=big(k['sharing']);else l===0x1||k['mode']==='Rate'?g+=big(k['sharing']):i=!![];}g!==0x0n&&g!==RATE_BASIS&&!d&&b['push']('Rate\x20allocation\x20totals\x20'+g+'\x20!=\x2010000\x20basis\x20points\x20with\x20no\x20Surplus\x20fallback;\x20payment\x20will\x20abort'),h>RATE_BASIS&&b['push']('RateGross\x20allocation\x20totals\x20'+h+'\x20>\x2010000\x20basis\x20points;\x20payment\x20will\x20abort\x20(ERATE_EXCEEDS_10000,\x206)'),i&&(f['max']==null||big(f['max'])===0x0n)&&b['push']('Fixed-amount\x20(Amount)\x20allocation\x20Allocator\x20lacks\x20a\x20max\x20cap;\x20excess\x20transfer\x20is\x20possible\x20when\x20the\x20guard\x20triggers');}if(c>0x1)b['push'](c+'\x20Surplus\x20entries\x20(at\x20most\x201\x20is\x20legal);\x20surplus\x20ownership\x20is\x20ambiguous');return[...new Set(b)];}const A1={'id':'A1','kind':'arbitrage','run'(a){const b=[],c=(e,f,g,h)=>{const i=allocationStructuralIssues(f);if(i['length']===0x0||h['has'](e))return;h['add'](e);const j=graphFindingPolicy('A1',{});if(!j['enabled'])return;b['push'](makeFinding(a,'A1:'+e,'arbitrage','Allocation\x20structure\x20mismatch:\x20Rate/Surplus/max\x20configuration\x20has\x20triggerable\x20structural\x20defects',{'severity':j['severity']??'medium','path':[e,'allocators[].sharing'],'pathEdges':g,'roles':['neutral','system','merchant','buyer'],'detail':e+':\x20'+i['join'](';\x20')+'.','suggestion':'Complete\x20Rate\x20groups\x20to\x2010000\x20or\x20configure\x20a\x20single\x20Surplus;\x20fixed-amount\x20Allocators\x20must\x20set\x20max;\x20run\x20the\x20allocation\x20precheck\x20before\x20going\x20live.',...j['exposure']?{'exposure':j['exposure']}:{}}));},d=new Set();for(const e of typedNodes(a,'Allocation')){c(e['id'],root(e)['allocators'],inc(a,e['id'],'order.allocation'),d);}for(const f of typedNodes(a,'Service')){const g=root(f)['order_allocators'];if(g?.['allocators'])c(f['id'],g['allocators'],edgeList(a,'service.order_allocator_guard'),d);}return b['slice'](0x0,MAX_FINDINGS_PER_RULE);}},DISCOUNT_FIXED=0x1,THIRTY_DAYS_MS=0x1en*0x18n*0x3cn*0x3cn*0x3e8n,A2={'id':'A2','kind':'arbitrage','run'(a){const b=[];for(const c of typedNodes(a,'Discount')){const e=root(c),f=big(e['time_end'])-big(e['time_start'])>=THIRTY_DAYS_MS;if(!bool(e['transferable'])||!f)continue;if(Number(e['discount_type'])!==DISCOUNT_FIXED)continue;if(e['benchmark']!=null&&e['benchmark']!=='0')continue;const g=graphFindingPolicy('A2',{});if(!g['enabled'])continue;b['push'](makeFinding(a,'A2:'+c['id'],'arbitrage','Discount\x20combination:\x20transferable\x20+\x20long\x20validity\x20window\x20+\x20fixed-amount\x20discount\x20without\x20benchmark',{'severity':g['severity']??'low','path':[c['id'],'Discount.transferable/time_window/benchmark'],'roles':['neutral','system','merchant'],'detail':'Discount\x20'+c['id']+'\x20is\x20transferable,\x20valid\x20>=30\x20days,\x20is\x20a\x20fixed-amount\x20discount,\x20and\x20has\x20no\x20benchmark\x20price\x20check;\x20'+'this\x20leaves\x20room\x20for\x20coupon\x20hoarding\x20and\x20resale\x20arbitrage.','suggestion':'Shorten\x20the\x20validity\x20window,\x20switch\x20to\x20RATES\x20proportional\x20discounts,\x20or\x20add\x20benchmark\x20Guards;\x20disable\x20transferable\x20if\x20needed.',...g['exposure']?{'exposure':g['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},A3={'id':'A3','kind':'arbitrage','run'(a){const b=[];for(const e of typedNodes(a,'Arbitration')){const f=root(e),g=big(f['fee'])===0x0n&&!str(f['usage_guard']);if(g){const h=graphFindingPolicy('A3',{});h['enabled']&&b['push'](makeFinding(a,'A3:'+e['id'],'arbitrage','Remedy\x20cost\x20structure:\x20zero\x20fee\x20+\x20no\x20usage\x20gate\x20gives\x20malicious\x20disputes\x20a\x20positive-expected-value\x20setup',{'severity':h['severity']??'medium','path':[e['id'],'Arbitration.fee','Arbitration.usage_guard'],'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+e['id']+'\x20has\x20fee=0\x20and\x20an\x20empty\x20usage_guard;\x20combined\x20with\x20the\x203x\x20amount\x20payout\x20cap,\x20single\x20claim,\x20'+'and\x2030-day\x20withdrawal\x20lock\x20rules,\x20filing\x20a\x20malicious\x20dispute\x20carries\x20no\x20structural\x20upfront\x20cost.','suggestion':'Set\x20a\x20non-zero\x20fee\x20to\x20cover\x20adjudication\x20cost,\x20or\x20use\x20usage_guard\x20to\x20require\x20disputing\x20parties\x20to\x20hold\x20on-chain\x20participation\x20credentials.',...h['exposure']?{'exposure':h['exposure']}:{}}));}if(b['length']>=MAX_FINDINGS_PER_RULE)break;}const c=new Map();for(const i of a['visibleNodes']){const j=a['graph']['nodes']['get'](i),k=j?.['raw']?.['type_raw'];if(typeof k!=='string'||!k['includes']('::payment::CoinWrapper<'))continue;const l=k['slice'](k['indexOf']('<')+0x1,k['lastIndexOf']('>'))['trim'](),m=c['get'](l)??[];m['push'](i),c['set'](l,m);}if(c['size']>0x0){const o=[...c['keys']()]['sort']();b['push']({'id':'A3:coinwrapper','kind':'arbitrage','severity':'info','title':'Cross-coin\x20escrow\x20review\x20point:\x20CoinWrapper<K>\x20escrow\x20objects\x20exist\x20in\x20the\x20graph','path':['payment::CoinWrapper'],'confidence':'exact','roles':['neutral','system','arbitrator','merchant'],'detail':'Visible\x20CoinWrapper\x20escrow\x20covers\x20coin\x20types:\x20'+o['join'](',\x20')+'\x20('+[...c['values']()]['reduce']((p,q)=>p+q['length'],0x0)+'\x20objects).\x20'+'v1\x20performs\x20no\x20market\x20valuation;\x20remedy/allocation\x20conclusions\x20across\x20coins\x20require\x20manual\x20review\x20of\x20coin\x20mismatch\x20and\x20depeg\x20risk.','suggestion':'Verify\x20the\x20escrow\x20coin\x20type\x20matches\x20the\x20service\x20coin\x20type\x20T;\x20add\x20independent\x20exchange-rate/oracle\x20evidence\x20before\x20concluding\x20cross-coin\x20cases.'});}return b['slice'](0x0,MAX_FINDINGS_PER_RULE);}};function modeIs(a,b){const c=a['mode'];if(typeof c==='string')return c===b;const d=Number(c);return b==='Amount'&&d===0x0||b==='Rate'&&d===0x1||b==='Surplus'&&d===0x2||b==='RateGross'&&d===0x3;}function recipientKind(a){if(typeof a==='string')return a==='Signer'?'Signer':'Entity';if(a&&typeof a==='object'){const b=a;if('GuardIdentifier'in b)return'GuardIdentifier';if('Signer'in b)return'Signer';if('Entity'in b)return'Entity';}return'other';}const A4={'id':'A4','kind':'risk','run'(b){const c=[];for(const f of typedNodes(b,'Allocation')){const g=root(f),h=allocatorsList(g['allocators']),i=inc(b,f['id'],'order.allocation'),j=g['payment_info']?.['for_object'],k=typeof j==='string'&&j!=='0x0',l=new Set(),m=new Map();for(const p of h){const q=typeof p['guard']==='string'?p['guard']:'',r=asList(p['sharing']);if(r['some'](u=>modeIs(u,'Surplus')))l['add'](q);let t=0x0n;for(const u of r)if(modeIs(u,'Rate')||modeIs(u,'RateGross'))t+=big(u['sharing']);if(t>0x0n&&q)m['set'](q,t);}const n=[...m['keys']()]['filter'](w=>!l['has'](w));if(l['size']>0x0&&n['length']>0x0){const w=graphFindingPolicy('A4',{'a4_case':'drain'});w['enabled']&&c['push'](makeFinding(b,'A4:drain:'+f['id'],'risk','Allocation\x20ordering\x20risk:\x20a\x20Surplus\x20allocator\x20can\x20starve\x20a\x20Rate-only\x20allocator',{'severity':w['severity']??'high','path':[f['id'],'allocators[].sharing[Surplus]','allocators[].sharing[Rate]'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Allocation\x20'+f['id']+':\x20guard(s)\x20['+([...l]['join'](',\x20')||'n/a')+']\x20carry\x20a\x20Surplus\x20share\x20that\x20drains\x20the\x20pool\x20'+('(minus\x20max)\x20when\x20triggered,\x20while\x20guard(s)\x20['+n['join'](',\x20')+']\x20pay\x20only\x20by\x20Rate.\x20If\x20a\x20Surplus\x20guard\x20fires\x20')+'first,\x20the\x20Rate-only\x20guard\x27s\x20allocator\x20sees\x20balance=0\x20and\x20aborts\x20(EAMOUNT_ZERO,\x2014)\x20—\x20the\x20split\x20is\x20order-sensitive\x20and\x20'+'the\x20Rate\x20recipients\x20can\x20be\x20legitimately\x20starved.','suggestion':'Give\x20the\x20Rate-only\x20allocator\x20a\x20Surplus\x20fallback\x20(Rate\x20sum\x20≤\x2010000\x20with\x20a\x20Surplus)\x20or\x20bind\x20both\x20shares\x20under\x20one\x20guard\x20so\x20a\x20'+'single\x20alloc()\x20settles\x20them\x20together;\x20the\x20keeper\x20must\x20record\x20the\x20triggered-guard\x20set\x20to\x20avoid\x20a\x20second\x20drain.',...w['exposure']?{'exposure':w['exposure']}:{}}));}const o=h['some'](x=>asList(x['sharing'])['some'](y=>recipientKind(y['who'])==='GuardIdentifier'));if(o&&!k){const x=graphFindingPolicy('A4',{'a4_case':'unanchored'});x['enabled']&&c['push'](makeFinding(b,'A4:unanchored:'+f['id'],'risk','Unanchored\x20payout\x20recipient:\x20GuardIdentifier\x20routing\x20without\x20a\x20payment_info.for_object\x20binding',{'severity':x['severity']??'high','path':[f['id'],'payment_info.for_object','allocators[].sharing[GuardIdentifier]'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Allocation\x20'+f['id']+'\x20pays\x20a\x20guard-submitted\x20address\x20(Recipient::GuardIdentifier)\x20but\x20declares\x20no\x20'+'payment_info.for_object\x20anchor,\x20so\x20the\x20on-chain\x20submitted==binding\x20check\x20(ERECIPIENT_NOT_FOR_OBJECT,\x2015)\x20never\x20runs.\x20'+'Any\x20party\x20that\x20passes\x20the\x20guard\x20can\x20fill\x20the\x20recipient\x20slot\x20with\x20an\x20arbitrary\x20address\x20and\x20route\x20the\x20payout\x20away.','suggestion':'Set\x20payment_info.for_object\x20to\x20the\x20bound\x20business\x20object\x20(the\x20Order)\x20so\x20the\x20payout\x20address\x20is\x20enforced\x20against\x20it;\x20'+'if\x20a\x20multi-payee\x20(payroll-style)\x20pool\x20is\x20intended,\x20gate\x20the\x20guard\x20so\x20only\x20a\x20trusted\x20submitter\x20can\x20pass.',...x['exposure']?{'exposure':x['exposure']}:{}}));}if(h['length']===0x0)for(const y of i){const z=b['graph']['nodes']['get'](y['from']);if(!z||z['kind']!=='object')continue;const A=orderCompletionInGraph(b['graph'],y['from']);if(A['status']!=='completed')continue;const B=graphFindingPolicy('A4',{'a4_case':'deadlock'});if(!B['enabled'])continue;c['push'](makeFinding(b,'A4:deadlock:'+f['id']+':'+y['from'],'risk','Settlement\x20deadlock:\x20completed\x20order\x20with\x20an\x20allocation\x20pool\x20that\x20has\x20no\x20allocator',{'severity':B['severity']??'critical','path':[y['from'],'order.allocation',f['id'],'allocators'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Order\x20'+y['from']+'\x20reached\x20a\x20completion\x20terminal\x20but\x20its\x20Allocation\x20'+f['id']+'\x20has\x20an\x20empty\x20allocators\x20list\x20—\x20no\x20guard\x20'+'can\x20release\x20the\x20escrowed\x20funds.\x20The\x20amount\x20is\x20locked\x20on-chain\x20with\x20no\x20settlement\x20path;\x20only\x20a\x20manual\x20pool\x20rebuild\x20'+'(or\x20a\x20chain-level\x20remedy)\x20can\x20move\x20it.','suggestion':'Before\x20publishing,\x20ensure\x20every\x20completable\x20path\x20has\x20a\x20matching\x20allocator\x20(settle/refund\x20guards\x20covering\x20each\x20terminal);\x20'+'for\x20an\x20already-live\x20pool\x20the\x20keeper\x20should\x20surface\x20this\x20as\x20a\x20manual-settlement\x20task.',...B['exposure']?{'exposure':B['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c['slice'](0x0,MAX_FINDINGS_PER_RULE);}},SCARCE_PRESENTERS=0x2;function demandGuardIds(a,b){const c=new Set();for(const d of out(a,b,'demand.guard'))c['add'](d['to']);return c;}function serviceGuardIds(a,b){const c=new Set();for(const f of out(a,b['id'],'service.buy_guard'))c['add'](f['to']);const d=out(a,b['id'],'service.machine')[0x0]?.['to'];if(d)for(const g of a['visibleEdges']){if(g['schema']==='wf.forward_guard'&&g['from']['startsWith'](d+'::node::'))c['add'](g['to']);}return c;}const O1={'id':'O1','kind':'opportunity','run'(a){const b=[],c=typedNodes(a,'Service');for(const d of typedNodes(a,'Demand')){const e=out(a,d['id'],'demand.presenter');if(e['length']>=SCARCE_PRESENTERS)continue;const f=demandGuardIds(a,d['id']),g=[];for(const i of c){const j=serviceGuardIds(a,i);if(f['size']===0x0||[...f]['every'](k=>j['has'](k)))g['push'](i['id']);}const h=e;b['push'](makeFinding(a,'O1:'+d['id'],'opportunity','Open\x20demand:\x20few\x20proposals,\x20with\x20structurally\x20capable\x20suppliers\x20present',{'severity':'info','path':[d['id'],'demand.presenter','demand.guard','Service'],'pathEdges':h['concat'](out(a,d['id'],'demand.guard')),'roles':['neutral','system','supplier'],'detail':'Demand\x20'+d['id']+'\x20currently\x20has\x20only\x20'+e['length']+'\x20proposal(s);\x20matched\x20by\x20Guard\x20structure\x20(no\x20Guard\x20bytecode\x20parsing)\x20to\x20'+(g['length']+'\x20candidate\x20Service(s):\x20'+(g['slice'](0x0,0x5)['join'](',\x20')||'(no\x20match\x20in\x20graph)')+'.'),'suggestion':'Candidate\x20suppliers\x20can\x20prepare\x20present\x20evidence\x20(proof\x20of\x20satisfying\x20the\x20demand\x20Guards);\x20the\x20opportunity\x20conclusion\x20is\x20structural\x20only\x20and\x20does\x20not\x20endorse\x20fulfillment\x20capability.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},O2={'id':'O2','kind':'opportunity','run'(a){const b=typedNodes(a,'Service'),c=typedNodes(a,'Demand');if(b['length']===0x0&&c['length']===0x0)return[];const d=b['filter'](f=>bool(root(f)['bPublished'])&&!bool(root(f)['bPaused']))['length'],e=c['filter'](f=>out(a,f['id'],'demand.presenter')['length']===0x0)['length'];return[makeFinding(a,'O2:graph','opportunity','Supply/demand\x20density:\x20in-graph\x20supply\x20and\x20open-demand\x20statistics',{'path':['Service','Demand','demand.presenter'],'pathEdges':edgeList(a,'demand.presenter'),'roles':['neutral','system','supplier','merchant'],'detail':'In\x20the\x20current\x20viewport:\x20'+b['length']+'\x20Service(s)\x20('+d+'\x20published\x20and\x20unpaused),\x20'+c['length']+'\x20Demand(s)\x20'+('('+e+'\x20open\x20demand(s)\x20without\x20proposals).\x20Open-demand/active-supply\x20ratio\x20=\x20')+((d>0x0?(e/d)['toFixed'](0x3):'n/a')+'.'),'suggestion':'A\x20high\x20ratio\x20indicates\x20scarce\x20supply;\x20use\x20category\x20exact-match\x20counts\x20(collectors\x20category_enumerated_count)\x20to\x20pick\x20an\x20entry\x20category.'})];}},O3={'id':'O3','kind':'opportunity','run'(a){const b=[];for(const c of machineViews(a)){const d=new Map();for(const g of c['transitions']){if(str(g['payload']?.['namedOperator'])||g['payload']?.['permissionIndex']!=null)continue;const h=String(g['payload']?.['forward']??g['payload']?.['prevNode']+'→'+g['payload']?.['node']);d['set'](wfNodeName(g['from'])+':'+h,g);}if(d['size']===0x0)continue;const f=[...d['values']()];b['push'](makeFinding(a,'O3:'+c['machine']['id'],'opportunity','Workflow\x20gaps:\x20key\x20Forwards\x20have\x20no\x20operator\x20binding\x20(guard/payment\x20passthrough\x20only)',{'path':[c['machine']['id'],'machine.node','wf.transition'],'pathEdges':f,'roles':['neutral','system','supplier','collaborator','merchant'],'detail':'Machine\x20'+c['machine']['id']+'\x20has\x20'+d['size']+'\x20Forward(s)\x20without\x20namedOperator/permissionIndex\x20binding:\x20'+([...d['keys']()]['slice'](0x0,0x8)['join'](',\x20')+'.\x20These\x20slots\x20can\x20only\x20be\x20satisfied\x20automatically\x20by\x20guards\x20or\x20advanced\x20directly\x20by\x20payment\x20transactions.'),'suggestion':'Suppliers/collaborators\x20can\x20take\x20over\x20these\x20operator\x20slots,\x20or\x20push\x20the\x20merchant\x20to\x20convert\x20implicit\x20passthrough\x20into\x20explicit\x20role\x20bindings.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},O4={'id':'O4','kind':'opportunity','run'(a){const b=[],c=a['graph']['builtAt']||Date['now']();for(const d of typedNodes(a,'Demand')){const f=out(a,d['id'],'demand.presenter');if(f['length']===0x0)continue;const g=f['filter'](k=>typeof k['payload']?.['score']==='number');let h;for(const k of f){const l=typeof k['payload']?.['feedbackTime']==='number'&&k['payload']['feedbackTime']>0x0?k['payload']['feedbackTime']:typeof k['payload']?.['time']==='number'&&k['payload']['time']>0x0?k['payload']['time']:undefined;if(l!=null&&(h==null||l>h))h=l;}const i=h!=null?Math['floor']((c-h)/0x5265c00):undefined,j=h==null?'no\x20row\x20carries\x20a\x20timestamp\x20—\x20staleness\x20unknown':i!=null&&i<=0x1e?'latest\x20feedback\x20'+i+'\x20day(s)\x20ago':'latest\x20feedback\x20'+i+'\x20day(s)\x20ago\x20(stale)';b['push'](makeFinding(a,'O4:'+d['id'],'opportunity','Demand-side\x20feedback\x20signal:\x20presenter\x20acceptance\x20coverage\x20and\x20freshness',{'severity':'info','path':[d['id'],'demand.presenter'],'pathEdges':f,'roles':['neutral','system','supplier','merchant'],'detail':'Demand\x20'+d['id']+':\x20'+f['length']+'\x20presenter(s),\x20'+g['length']+'\x20with\x20an\x20acceptance\x20score\x20'+('(the\x20demander\x27s\x20own\x200-100\x20judgment);\x20'+j+'.\x20Unscored\x20presenters\x20mean\x20the\x20feedback\x20loop\x20has\x20not\x20')+'been\x20exercised\x20yet\x20—\x20the\x20sample\x20is\x20sparse\x20by\x20nature,\x20not\x20a\x20negative\x20verdict.','suggestion':'Suppliers\x20evaluating\x20this\x20demand\x20can\x20read\x20the\x20acceptance\x20coverage\x20and\x20freshness\x20as\x20the\x20demander\x27s\x20engagement\x20quality;\x20'+'read\x20it\x20jointly\x20with\x20the\x20demand\x20Guards\x20(empty\x20=\x20bare\x20present,\x20no\x20acceptance\x20gate).\x20No\x20platform\x20weighting\x20is\x20applied\x20—\x20the\x20score\x20stays\x20the\x20demander\x27s\x20own\x20judgment.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}};function arbitrationCases(a,b){return inc(a,b,'arb.arbitration_service')['map'](c=>a['graph']['nodes']['get'](c['from']))['filter'](c=>!!c&&c['objectType']==='Arb'&&!!c['raw']);}const G1={'id':'G1','kind':'game','run'(a){const b=[];for(const e of typedNodes(a,'Arbitration')){const f=root(e),g=asList(f['voting_guard']),h=new Set(g['map'](l=>l['vote_weight']&&typeof l['vote_weight']==='object'?Object['keys'](l['vote_weight'])[0x0]:'unknown')),i=arbitrationCases(a,e['id']),j=new Map();let k=0x0;for(const l of i){for(const m of asList(root(l)['voted'])){const n=Number(m['weight']??0x0);j['set'](n,(j['get'](n)??0x0)+0x1),k++;}}b['push'](makeFinding(a,'G1:'+e['id'],'game','Voting\x20power\x20structure:\x20arbitration\x20voting\x20Guard\x20configuration\x20vs\x20actual\x20voting\x20weight\x20distribution',{'severity':'info','path':[e['id'],'arbitration.voting_guard','arb.arbitration_service','arb.voter'],'pathEdges':out(a,e['id'],'arbitration.voting_guard')['concat'](edgeList(a,'arb.voter')),'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+e['id']+':\x20voting_guard\x20'+(g['length']===0x0?'empty\x20=\x20open\x20to\x20all\x20members':'weighted\x20('+[...h]['join']('/')+')')+';\x20'+(i['length']+'\x20case(s)\x20in\x20window,\x20'+k+'\x20actual\x20vote(s)')+(j['size']?',\x20weight\x20distribution\x20'+[...j['entries']()]['map'](([o,p])=>'w'+o+'x'+p)['join'](',\x20'):'')+'.','suggestion':'Open\x20voting\x20suits\x20high-frequency\x20low-stakes\x20cases;\x20high-stakes\x20cases\x20should\x20use\x20weighted\x20Guards;\x20this\x20describes\x20the\x20objective\x20situation\x20only\x20—\x20scoring\x20belongs\x20to\x20the\x20game\x20modules.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},G2={'id':'G2','kind':'game','run'(a){const b=[];o:for(const c of machineViews(a)){const d=out(a,c['machine']['id'],'machine.permission')[0x0]?.['to'],f=d?inc(a,d,'permission.entity')['map'](h=>({'eoa':h['to'],'bits':h['payload']?.['permIndices']??[]})):[],g=new Set();for(const h of c['transitions']){const i=String(h['payload']?.['forward']??h['payload']?.['prevNode']+'→'+h['payload']?.['node']),j=wfNodeName(h['from'])+':'+i;if(g['has'](j))continue;let k,l='';if(str(h['payload']?.['namedOperator']))k=0x1,l='namedOperator='+h['payload']['namedOperator'];else{if(h['payload']?.['permissionIndex']!=null){if(!d)continue;const n=Number(h['payload']['permissionIndex']);k=f['filter'](o=>o['bits']['includes'](n))['length'],l='permissionIndex='+n;if(k===0x0)continue;}else continue;}if(k!==0x1)continue;g['add'](j);const m=graphFindingPolicy('G2',{});if(!m['enabled'])continue;b['push'](makeFinding(a,'G2:'+c['machine']['id']+':'+j,'game','Operator\x20replaceable\x20pool\x20=\x201:\x20hold-up\x20slot',{'severity':m['severity']??'low','path':[c['machine']['id'],'machine.node','wf.transition',j],'pathEdges':[h],'roles':['neutral','system','collaborator','merchant','supplier'],'detail':'Forward\x20'+j+'\x20('+l+')\x20on\x20Machine\x20'+c['machine']['id']+'\x20has\x20an\x20operable-party\x20pool\x20of\x20size\x201:\x20'+'that\x20party\x20holds\x20an\x20irreplaceable\x20bargaining\x20position\x20at\x20this\x20workflow\x20node\x20(protocol\x20operation\x20precheck).','suggestion':'Add\x20an\x20alternative\x20entity\x20under\x20the\x20same\x20permissionIndex\x20or\x20a\x20namedOperator\x20backup;\x20sign\x20SLA/penalty\x20terms\x20covering\x20this\x20slot.',...m['exposure']?{'exposure':m['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break o;}}return b;}},G3={'id':'G3','kind':'game','run'(a){const b=[];for(const c of typedNodes(a,'Arbitration')){const e=root(c),f=asList(e['voting_guard']);b['push'](makeFinding(a,'G3:'+c['id'],'game','Remedy\x20strategy\x20parameters:\x20structured\x20inputs\x20for\x20the\x20payoff/waiting\x20matrices',{'severity':'info','path':[c['id'],'Arbitration.fee/usage_guard/voting_guard'],'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+c['id']+':\x20fee='+big(e['fee'])+',\x20usage_guard='+(str(e['usage_guard'])??'none')+',\x20voting_guard='+f['length']+'.\x20'+'Global\x20structural\x20constants:\x20payout\x20cap\x203x\x20amount,\x2030-day\x20compensation\x20withdrawal\x20lock,\x20single\x20claim\x20per\x20payout,\x2030-day\x20withdraw\x20window\x20on\x20uncontested\x20rulings\x20(objection\x20locks\x20the\x20fee\x20until\x20the\x20cycle\x20closes).','suggestion':'Feed\x20these\x20parameters\x20into\x20node-game/arbitration-game\x20payoff\x20and\x20waiting\x20matrices;\x20this\x20analyzer\x20does\x20not\x20score\x20or\x20rank.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},ANTI_CHEAT_ROLES=['neutral','system','merchant','buyer'];function projectOrderEvidence(a,b){const c=[];for(const d of typedNodes(a,'Service')){const f=[...b['controllers']['get'](d['id'])??[]];if(f['length']===0x0)continue;for(const g of out(a,d['id'],'service.order')){const h=a['graph']['nodes']['get'](g['to']);if(!h||h['kind']!=='object'||h['objectType']!=='Order'||!h['raw'])continue;const i=out(a,h['id'],'order.builder')[0x0]?.['to'];if(!i)continue;const j=orderCompletionInGraph(a['graph'],h['id'])['status'],k=String(root(h)?.['amount']??0x0),l=out(a,h['id'],'order.allocation')[0x0]?.['to']??null;for(const m of f){c['push']({'service':d['id'],'id':h['id'],'buyer':i,'seller':m,'amount':k,'status':j,'allocation':l});}}}return c;}function orderCheatEdges(a){return edgeList(a,'service.order')['concat'](edgeList(a,'eoa.permission'))['concat'](edgeList(a,'permission.core_binding'));}function shortRefs(a){const b=a['slice'](0x0,0x5)['join'](',\x20');return a['length']>0x5?b+'\x20and\x20'+a['length']+'\x20object(s)\x20in\x20total':b;}const AC1={'id':'AC1','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='self_buy');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC1',{});if(!e['enabled'])return[];return[makeFinding(a,'AC1:'+d['join'](','),'risk','Fake-order\x20suspicion:\x20windowed\x20order\x20buyers\x20are\x20the\x20selling\x20service\x27s\x20controlling\x20EOA\x20(self-trading)',{'severity':e['severity']??'high','path':['EOA','eoa.permission','permission.core_binding','Service','service.order','Order','order.builder'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20order(s)\x20visible\x20in\x20the\x20window\x20have\x20buyer\x20EOAs\x20that\x20also\x20control\x20the\x20selling\x20Service\x20as\x20owner/admin\x20'+('('+shortRefs(d)+'):\x20buyer\x20and\x20seller\x20sit\x20in\x20the\x20same\x20control\x20set,\x20funds\x20circulate\x20internally,\x20and\x20this\x20is\x20not\x20genuine\x20competitive\x20volume.'),'suggestion':'Exclude\x20these\x20orders\x20from\x20sales/reputation\x20statistics\x20and\x20re-verify\x20via\x20payment\x20allocation\x20legs\x20and\x20time\x20windows;\x20reduce\x20market\x20exposure\x20and\x20recommendation\x20weight\x20for\x20this\x20Service.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC2={'id':'AC2','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='reciprocal_loop');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC2',{'ac_signal_level':c['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC2:'+d['join'](','),'risk','Wash-trading\x20suspicion:\x20reciprocal\x20buy/sell\x20role-swapping\x20fund\x20loops\x20in\x20the\x20window',{'severity':e['severity']??c['severity'],'path':['EOA-A','order.builder','Order@Service-B','service.order','EOA-B','order.builder','Order@Service-A'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20order(s)\x20in\x20the\x20window\x20form\x20a\x20buy/sell\x20swap:\x20control\x20set\x20A\x20buys\x20B\x27s\x20Service\x20while\x20control\x20set\x20B\x20buys\x20A\x27s\x20Service\x20'+('('+shortRefs(d)+').\x20The\x20two-way\x20volume\x20may\x20be\x20mutually\x20staged\x20wash\x20trading.'),'suggestion':'Investigate\x20links\x20between\x20the\x20two\x20control\x20sets\x20(devices/permissions/fund\x20flows);\x20exclude\x20mutually-purchased\x20orders\x20from\x20genuine\x20competitive\x20volume.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC3={'id':'AC3','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='no_allocation');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC3',{'ac_signal_level':c['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC3:'+d['join'](','),'risk','Missing\x20fund\x20closure:\x20completed\x20positive-amount\x20orders\x20lack\x20an\x20Allocation\x20object',{'severity':e['severity']??c['severity'],'path':['Service','service.order','Order','order.allocation'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20completed\x20order(s)\x20in\x20the\x20window\x20(completion\x20authoritatively\x20judged\x20by\x20the\x20order-status\x20terminal\x20node\x20set)\x20with\x20amount>0\x20have\x20no\x20Allocation\x20'+('('+shortRefs(d)+').\x20Protocol\x20rules\x20require\x20positive-amount\x20orders\x20to\x20have\x20an\x20allocation\x20path;\x20its\x20absence\x20means\x20the\x20\x22transaction\x22\x20lacks\x20fund-closure\x20evidence.\x20')+'Zero-amount\x20orders\x20are\x20excluded\x20(no\x20fund\x20flow).','suggestion':'Review\x20original\x20payment\x20records;\x20completed\x20orders\x20without\x20payment\x20evidence\x20must\x20not\x20count\x20toward\x20reputation;\x20audit\x20contract\x20entry\x20points\x20that\x20complete\x20without\x20an\x20Allocation\x20path.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},SHELL_COPY={'shell_no_arbitration':{'title':'Shell\x20merchant:\x20published\x20Service\x20has\x20no\x20arbitration\x20binding,\x20disputes\x20have\x20no\x20remedy\x20path','detail':'The\x20Service\x20is\x20published\x20but\x20arbitrations\x20is\x20empty:\x20buyers\x20have\x20no\x20selectable\x20arbitration\x20service\x20after\x20ordering\x20and\x20disputes\x20cannot\x20enter\x20adjudication.','suggestion':'Remediable\x20without\x20rebuilding:\x20attach\x20an\x20Arbitration\x20(in\x20a\x20different\x20group\x20than\x20the\x20shop\x20Permission)\x20via\x20the\x20arbitration-binding\x20Service\x20update\x20—\x20legal\x20on\x20a\x20published\x20Service.\x20Until\x20bound,\x20downgrade\x20the\x20shop\x20in\x20recommendation\x20ranking.'},'shell_funded_no_arbitration':{'title':'Floating\x20payout\x20funds:\x20compensation\x20fund\x20is\x20funded\x20but\x20no\x20Arbitration\x20exists,\x20payouts\x20cannot\x20be\x20adjudicated\x20or\x20released','detail':'compensation_fund>0\x20with\x20no\x20Arbitration\x20at\x20all:\x20when\x20a\x20payout\x20triggers\x20there\x20is\x20no\x20one\x20to\x20adjudicate\x20and\x20no\x20path\x20to\x20release;\x20the\x20funding\x20is\x20marketing\x20theater.','suggestion':'Remediable\x20without\x20rebuilding:\x20bind\x20an\x20Arbitration\x20first\x20(arbitration-binding\x20Service\x20update)\x20so\x20the\x20fund\x20becomes\x20claimable;\x20until\x20then\x20marketplaces\x20should\x20flag\x20\x27fund\x20without\x20arbitration\x27\x20as\x20high\x20risk\x20and\x20limit\x20exposure.'},'shell_no_machine':{'title':'Shell\x20merchant:\x20published\x20Service\x20has\x20no\x20Machine\x20binding,\x20no\x20structured\x20fulfillment\x20workflow','detail':'The\x20Service\x20is\x20published\x20but\x20machine\x20is\x20empty:\x20no\x20frozen\x20workflow\x20template\x20exists,\x20and\x20delivery/completion\x20nodes\x20carry\x20no\x20on-chain\x20structural\x20constraints.','suggestion':'Bind\x20and\x20publish\x20a\x20Machine\x20before\x20opening;\x20published\x20shops\x20without\x20workflows\x20suit\x20only\x20instant\x20spot-delivery\x20categories.'}},AC4={'id':'AC4','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Service')){const e=root(c);if(!bool(e['bPublished']))continue;const f=e['arbitrations']!=null?asList(e['arbitrations'])['length']:out(a,c['id'],'service.arbitration')['length'],g=str(e['machine'])??out(a,c['id'],'service.machine')[0x0]?.['to']??null,h=detectShellMerchant({'object':c['id'],'arbitrations':Array(f)['fill']('x'),'compensation_fund':String(big(e['compensation_fund'])),'machine':g,'bPublished':!![]}),i=out(a,c['id'],'service.arbitration')['concat'](out(a,c['id'],'service.machine'));for(const j of h){const k=SHELL_COPY[j['code']];if(!k)continue;const l=graphFindingPolicy('AC4',{'ac_shell_code':j['code'],'ac_signal_level':j['severity']});if(!l['enabled'])continue;b['push'](makeFinding(a,'AC4:'+c['id']+':'+j['code'],'risk',k['title'],{'severity':l['severity']??j['severity'],'path':[c['id'],'Service.bPublished','Service.arbitrations','Service.machine','Service.compensation_fund'],'pathEdges':i,'roles':ANTI_CHEAT_ROLES,'detail':k['detail']+'\x20(object:\x20'+c['id']+')','suggestion':k['suggestion'],...l['exposure']?{'exposure':l['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)return b;}}return b;}};function projectVoteEvidence(a){const b=[];for(const f of edgeList(a,'target.vote')){const g=typeof f['payload']?.['voteBits']==='number'?f['payload']['voteBits']:0x0;b['push']({'voter':f['to'],'target':f['from'],'like':(g&0x2)!==0x0,'dislike':(g&0x4)!==0x0,'favor':(g&0x8)!==0x0});}const c=[...new Set(b['map'](h=>h['voter']))],d=[];for(const h of c){const i=out(a,h,'entity.profile')[0x0]?.['payload']?.['registeredAt'];let j=0x0,k=0x0;const l=new Set();for(const m of out(a,h,'eoa.order')){const n=typeof m['payload']?.['roleBits']==='number'?m['payload']['roleBits']:0x0;if((n&0x1)!==0x0)j+=0x1;if((n&0x2)!==0x0)k+=0x1;l['add'](m['to']);}for(const o of['eoa.permission','eoa.contact']){for(const p of out(a,h,o))l['add'](p['to']);}d['push']({'address':h,...typeof i==='number'?{'registeredAt':i}:{},'ordersOwned':j,'ordersAgented':k,'objectsFootprint':l['size']});}return{'votes':b,'profiles':d};}function voteCheatEdges(a){return edgeList(a,'target.vote')['concat'](edgeList(a,'entity.profile'))['concat'](edgeList(a,'eoa.order'));}const AC5={'id':'AC5','kind':'risk','run'(a){const {votes:b,profiles:c}=projectVoteEvidence(a),d=detectNewAccountBurst(b,c,Date['now']())[0x0];if(!d)return[];const e=graphFindingPolicy('AC5',{'ac_signal_level':d['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC5:'+d['refs']?.['join'](','),'risk','Vote-noise\x20suspicion:\x20freshly-registered\x20accounts\x20are\x20casting\x20votes\x20in\x20a\x20burst',{'severity':e['severity']??d['severity'],'path':['EOA','entity.profile','target.vote'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['description']+'.\x20Voter\x20credibility\x20is\x20re-projected\x20from\x20the\x20same\x20graph\x20window:\x20entity\x20registration\x20age\x20(entity.profile),\x20order\x20history\x20(entity_order\x20roles),\x20and\x20object\x20footprint.\x20Fresh\x20accounts\x20voting\x20in\x20volume\x20read\x20as\x20an\x20organized\x20reputation\x20push,\x20not\x20organic\x20discovery.','suggestion':'Down-weight\x20votes\x20from\x20the\x20flagged\x20accounts\x20in\x20account-level\x20reputation\x20aggregates;\x20inspect\x20their\x20registration\x20referrers\x20and\x20object\x20footprint\x20for\x20a\x20shared\x20origin\x20before\x20trusting\x20the\x20targets\x27\x20like\x20counts.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC6={'id':'AC6','kind':'risk','run'(a){const {votes:b}=projectVoteEvidence(a),c=detectVoteReciprocity(b)[0x0];if(!c)return[];const d=graphFindingPolicy('AC6',{'ac_signal_level':c['severity']});if(!d['enabled'])return[];return[makeFinding(a,'AC6:'+c['refs']?.['join'](','),'risk','Vote-ring\x20suspicion:\x20mutual\x20votes\x20between\x20address\x20pairs',{'severity':d['severity']??c['severity'],'path':['EOA-A','target.vote','EOA-B'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':c['description']+'.\x20The\x20registrar\x20carries\x20no\x20order\x20binding,\x20so\x20a\x20like\x20costs\x20only\x20gas\x20—\x20symmetric\x20voting\x20pairs\x20are\x20the\x20cheapest\x20way\x20to\x20manufacture\x20mutual\x20account-level\x20reputation.','suggestion':'Treat\x20mutual\x20pairs\x20as\x20correlated\x20voters:\x20exclude\x20the\x20reciprocal\x20legs\x20from\x20aggregate\x20scoring\x20and\x20check\x20whether\x20the\x20pairs\x20share\x20order\x20history,\x20referrer,\x20or\x20object\x20footprint.',...d['exposure']?{'exposure':d['exposure']}:{}})];}},AC7={'id':'AC7','kind':'risk','run'(a){const {votes:b,profiles:c}=projectVoteEvidence(a),d=detectTargetFlood(b,c,Date['now']());if(d['length']===0x0)return[];const e=[];for(const f of d){const g=graphFindingPolicy('AC7',{'ac_signal_level':f['severity']});if(!g['enabled'])continue;e['push'](makeFinding(a,'AC7:'+f['refs']?.['join'](','),'risk','Vote-noise\x20suspicion:\x20an\x20address\x27s\x20votes\x20are\x20dominated\x20by\x20low-credibility\x20accounts',{'severity':g['severity']??f['severity'],'path':['EOA','entity.profile','target.vote'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':f['description']+'\x20(target:\x20'+f['refs']?.[0x0]+').\x20This\x20is\x20the\x20voter-side\x20mirror\x20of\x20AC1-AC3:\x20the\x20merchant-side\x20reputation\x20anchors\x20on\x20orders\x20with\x20fund\x20closure,\x20while\x20the\x20account-level\x20vote\x20ring\x20has\x20no\x20such\x20gate\x20—\x20its\x20aggregate\x20is\x20only\x20as\x20good\x20as\x20the\x20voters.','suggestion':'Flag\x20the\x20target\x27s\x20vote\x20aggregate\x20as\x20untrusted\x20until\x20the\x20low-credibility\x20share\x20drops;\x20rank\x20exposure\x20by\x20the\x20order-backed\x20reputation\x20layer\x20instead\x20of\x20the\x20vote\x20bitmap.',...g['exposure']?{'exposure':g['exposure']}:{}}));if(e['length']>=MAX_FINDINGS_PER_RULE)break;}return e;}};export const DEFAULT_ANALYZERS=[R1,R2,R3,R4,R5,R6,R7,A1,A2,A3,A4,O1,O2,O3,O4,G1,G2,G3,AC1,AC2,AC3,AC4,AC5,AC6,AC7,PROPOSAL_GAP_ANALYZER];const registry=new Map(DEFAULT_ANALYZERS['map'](b=>[b['id'],b]));export function registerAnalyzer(a){registry['set'](a['id'],a);}export function getAnalyzer(a){return registry['get'](a);}export function listAnalyzers(){return[...registry['keys']()];}export function runAnalyzers(a,b){const c=b?.['only']?new Set(b['only']):undefined,d=[];beginPolicyRun();try{for(const e of registry['values']()){if(c&&!c['has'](e['id']))continue;if(b?.['kinds']&&!b['kinds']['includes'](e['kind']))continue;try{d['push'](...e['run'](a));}catch{}}}finally{endPolicyRun();}return withFindingObjects(d);}const ADDRESS_RE=/\b0x[0-9a-fA-F]{40,64}\b/g;export function withFindingObjects(a){for(const b of a){const c=[],d=new Set(),e=g=>{const h=g['toLowerCase']();if(d['has'](h))return;d['add'](h),c['push'](h);};for(const g of b['path']){if(/^0x[0-9a-fA-F]{40,64}$/['test'](g['trim']()))e(g['trim']());}for(const h of b['detail']['matchAll'](ADDRESS_RE))e(h[0x0]);if(c['length']>0x0)b['objects']=c['slice'](0x0,0xc);}return a;}export function adaptNodeAnalyzer(a){return{'id':a['id'],'kind':a['kind'],'objectType':a['objectType'],'run'(b,c){const d=a['inspect'](b,c);return d['map']((e,f)=>({'id':a['id']+':'+b['id']+'#'+f,'kind':a['kind'],'severity':e['severity']??'info','title':e['title'],'path':[b['id']],'confidence':e['confidence']??'exact','roles':e['roles']??['neutral'],'detail':e['detail'],'suggestion':e['suggestion'],...e['ruleId']?{'ruleId':e['ruleId']}:{},...e['evidence']?{'evidence':e['evidence']}:{},...e['exposure']?{'exposure':e['exposure']}:{},...e['nativeRisk']!==undefined?{'nativeRisk':e['nativeRisk']}:{},...b['proposal']&&!e['confidence']?{'confidence':'derived'}:{},...b['proposal']?{'source':b['proposal']['provenance']==='external'?'external':'proposal'}:{}}));}};}export function runNodeAnalyzers(a,b){const c=[];beginPolicyRun();try{for(const d of b){for(const e of a['visibleNodes']){const f=a['graph']['nodes']['get'](e);if(f?.['kind']!=='object'||d['objectType']!=='*'&&f['objectType']!==d['objectType']||!f['raw'])continue;try{c['push'](...d['run'](f,a));}catch{}}}}finally{endPolicyRun();}return withFindingObjects(c);}
1
+ import{detectFakeOrders,detectShellMerchant,detectNewAccountBurst,detectVoteReciprocity,detectTargetFlood}from'./anti-cheat.js';import{orderCompletionInGraph}from'./expand.js';import{PROPOSAL_GAP_ANALYZER}from'./proposal-graph.js';import{graphFindingPolicy}from'./policy.js';import{analyzeRewardClaimGuard}from'../../knowledge/recipient-constraint.js';import{beginPolicyRun,endPolicyRun}from'../../config/judgment.js';function root(a){const b=a?.['raw'],c=b?.['data']??b;return c&&typeof c==='object'?c:undefined;}function str(a){return typeof a==='string'&&a!=='0x0'?a:undefined;}function big(a){if(a==null)return 0x0n;try{return BigInt(typeof a==='number'?Math['trunc'](a):String(a));}catch{return 0x0n;}}function bool(a){return a===!![]||a===0x1||a==='1';}function asList(a){return Array['isArray'](a)?a:[];}function wfNodeName(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](b+'::node::'['length']):a;}function wfMachineOf(a){const b=a['indexOf']('::node::');return b>=0x0?a['slice'](0x0,b):'';}export function findingWhere(a){const b=a['id'];if(b['startsWith']('R4:')){const c=b['slice'](0x3),d=c['indexOf'](':'),e=d>=0x0?c['slice'](0x0,d):c,g=d>=0x0?c['slice'](d+0x1):'';return e+':\x20'+g['split']('→')['map'](h=>wfNodeName(h['trim']()))['join']('\x20→\x20');}if(b['startsWith']('R7:treasury:'))return'Treasury\x20'+b['slice']('R7:treasury:'['length']);if(b['startsWith']('R7:reward:'))return'Reward\x20'+b['slice']('R7:reward:'['length']);if(b['startsWith']('R2:'))return b['slice'](0x3);if(b['startsWith']('R5:')){const [h,i]=b['slice'](0x3)['split']('|');return wfNodeName(h??'')+'\x20('+(i??'window')+')';}return a['title']??a['id'];}export function findingWhereResolved(a,b){const c=a['id'];if(c['startsWith']('R4:')){const d=c['slice'](0x3),e=d['indexOf'](':'),g=e>=0x0?d['slice'](0x0,e):d,h=e>=0x0?d['slice'](e+0x1):'',i=b['resolve'](g)['label'],j=l=>b['resolveWf'](l)?.['node']['label']??b['resolve'](l)['label'],k=h['split']('→')['map'](l=>j(l['trim']()))['join']('\x20→\x20');return i+':\x20'+k;}if(c['startsWith']('R7:treasury:'))return'Treasury\x20'+b['resolve'](c['slice']('R7:treasury:'['length']))['label'];if(c['startsWith']('R7:reward:'))return'Reward\x20'+b['resolve'](c['slice']('R7:reward:'['length']))['label'];if(c['startsWith']('R2:'))return b['resolve'](c['slice'](0x3))['label'];if(c['startsWith']('R5:')){const [l,m]=c['slice'](0x3)['split']('|');return b['resolve'](l??'')['label']+'\x20('+(m??'window')+')';}return a['title']??a['id'];}function typedNodes(a,b){const c=[];for(const d of a['visibleNodes']){const e=a['graph']['nodes']['get'](d);if(e?.['kind']==='object'&&e['objectType']===b&&e['raw']&&!e['proposal'])c['push'](e);}return c;}function edgeList(a,b){return a['visibleEdges']['filter'](c=>c['schema']===b);}function out(a,b,c){return a['visibleEdges']['filter'](d=>d['from']===b['toLowerCase']()&&d['schema']===c);}function inc(a,b,c){return a['visibleEdges']['filter'](d=>d['to']===b['toLowerCase']()&&d['schema']===c);}export const RETENTION_RANK={'complete':0x0,'event_full':0x0,'bounded_exact':0x1,'membership':0x1,'derived':0x2,'bounded_window':0x3,'event_degraded':0x3};const WINDOW_LIMIT=0x1450;export function pathConfidence(a,b){let c=0x0,d=![];for(const g of b){c=Math['max'](c,RETENTION_RANK[g['retention']]??0x0);if(g['retention']==='bounded_window'||g['retention']==='event_degraded'||g['truncated'])d=!![];}if(d){let h=0x0;for(const i of b){if(i['retention']!=='bounded_window'&&!i['truncated'])continue;const j=a['visibleEdges']['filter'](l=>l['schema']===i['schema']&&l['from']===i['from'])['length'];h=Math['max'](h,j);const k=a['graph']['truncations']['find'](l=>l['nodeId']===i['from']&&l['schema']===i['schema']);if(k)h=Math['max'](h,k['observed']);}return{'confidence':'windowed','window':{'observed':h||b['length'],'limit':WINDOW_LIMIT}};}const f=c===0x0?'exact':c===0x2?'derived':'bounded';return{'confidence':f};}function makeFinding(a,b,c,d,e){const {confidence:f,window:g}=pathConfidence(a,e['pathEdges']??[]),h=e['severity']??'info';return{'id':b,'kind':c,'severity':h,'title':d,'path':e['path'],'confidence':f,...g?{'window':g}:{},'roles':e['roles']??['neutral'],'detail':e['detail'],'suggestion':e['suggestion'],...e['amounts']?.['length']?{'amounts':e['amounts']}:{},...e['exposure']?{'exposure':e['exposure']}:{}};}const MAX_FINDINGS_PER_RULE=0x14,ROLE_OWNER_OR_ADMIN=0x1|0x2;export function buildControlIndex(a){const b=new Map(),c=new Map(),d=new Map(),f=(h,i,j)=>{const l=h['get'](i)??new Set();l['add'](j),h['set'](i,l);},g=new Map();for(const h of edgeList(a,'eoa.permission')){const i=typeof h['payload']?.['roleBits']==='number'?h['payload']['roleBits']:ROLE_OWNER_OR_ADMIN;if((i&ROLE_OWNER_OR_ADMIN)===0x0)continue;f(g,h['from'],h['to']);}for(const j of edgeList(a,'permission.core_binding')){const k=a['graph']['nodes']['get'](j['to']);if(!k||k['kind']!=='object')continue;f(d,j['to'],j['from']);for(const [l,m]of g){if(!m['has'](j['from']))continue;f(b,j['to'],l),f(c,l,j['to']);}}return{'controllers':b,'objectsByEoa':c,'permsOfObject':d};}function machineViews(a){const b=new Map();for(const d of edgeList(a,'wf.transition')){const f=wfMachineOf(d['from']);if(!f)continue;const g=b['get'](f)??[];g['push'](d),b['set'](f,g);}const c=[];for(const [h,i]of b){const j=a['graph']['nodes']['get'](h);if(!j||!a['visibleNodes']['has'](h))continue;const k=new Set([...(function*(){const l=new Set(i['map'](p=>String(p['payload']?.['node']??''))['filter'](Boolean)),o=new Set(i['map'](p=>String(p['payload']?.['prevNode']??''))['filter'](Boolean));for(const p of l)if(!o['has'](p))yield p;}())]);c['push']({'machine':j,'transitions':i,'terminals':k});}return c;}const ROLES_RISK_NEUTRAL_MERCHANT=['neutral','system','merchant'],R1={'id':'R1','kind':'risk','run'(b){const c=buildControlIndex(b),d=[],e=typedNodes(b,'Service'),f=typedNodes(b,'Arbitration');p:for(const g of e){const h=c['controllers']['get'](g['id']);if(!h)continue;for(const i of f){const j=c['controllers']['get'](i['id']);if(!j)continue;const k=c['permsOfObject']['get'](g['id']),l=c['permsOfObject']['get'](i['id']),m=[...k??[]]['some'](n=>l?.['has'](n));if(m)continue;for(const n of h){if(!j['has'](n))continue;const o=graphFindingPolicy('R1',{'eoa':n});if(!o['enabled'])continue;d['push'](makeFinding(b,'R1:'+g['id']+':'+i['id']+':'+n,'risk','Same-controller\x20arbitration\x20risk:\x20the\x20service\x20and\x20the\x20arbitration\x20service\x20are\x20controlled\x20by\x20the\x20same\x20EOA',{'severity':o['severity']??'high','path':[n,'eoa.permission','permission.core_binding',g['id'],i['id']],'pathEdges':edgeList(b,'permission.core_binding'),'roles':['neutral','system','merchant','arbitrator'],'detail':'EOA\x20'+n+'\x20controls\x20both\x20Service\x20'+g['id']+'\x20and\x20Arbitration\x20'+i['id']+'\x20as\x20owner/admin,\x20'+'and\x20the\x20two\x20are\x20attached\x20to\x20DIFFERENT\x20Permissions\x20(E33\x20only\x20forbids\x20the\x20same\x20Permission,\x20not\x20cross-group\x20arbitration).\x20'+'structurally\x20this\x20EOA\x20can\x20influence\x20both\x20the\x20arbitrated\x20service\x20and\x20the\x20ruling\x20outcome.','suggestion':'Verify\x20the\x20EOA\x27s\x20control\x20relationships;\x20require\x20disjoint\x20owner/admin\x20sets\x20between\x20the\x20service\x20and\x20the\x20arbitration\x20service,\x20or\x20remove\x20that\x20arbitration\x20service\x20from\x20the\x20selectable\x20list.',...o['exposure']?{'exposure':o['exposure']}:{}}));if(d['length']>=MAX_FINDINGS_PER_RULE)break p;}}}return d;}},R2={'id':'R2','kind':'risk','run'(b){const c=[];for(const f of typedNodes(b,'Service')){const g=root(f),h=out(b,f['id'],'service.order');if(h['length']===0x0)continue;let i=0x0n,j=0x0;for(const p of h){const q=root(b['graph']['nodes']['get'](p['to']));if(!q)continue;const r=big(q['amount']);if(r>i)i=r;j++;}if(j===0x0)continue;const k=big(g['compensation_fund']),l=i*0x3n;if(k>=l)continue;const m=f['coinType']?{'coin_type':f['coinType']}:{},n=k<i?'high':'medium',o=graphFindingPolicy('R2',{'r2_level':n});if(!o['enabled'])continue;c['push'](makeFinding(b,'R2:'+f['id'],'risk','Payout\x20exposure:\x20compensation\x20fund\x20cannot\x20cover\x20a\x20maximum-multiple\x20award\x20on\x20the\x20largest\x20windowed\x20order',{'severity':o['severity']??n,'path':[f['id'],'service.order','Order.amount','Service.compensation_fund'],'pathEdges':h,'roles':['neutral','system','merchant','buyer'],'detail':'Compensation\x20fund\x20{fund};\x20largest\x20of\x20'+j+'\x20windowed\x20orders\x20{amount};\x20'+'a\x20maximum-multiple\x20award\x20on\x20it\x20needs\x203x\x20its\x20amount\x20=\x20{needed}.\x20NOTE:\x20awards\x20SPEND\x20the\x20fund\x20—\x20'+'after\x20a\x20payout\x20the\x20remaining\x20fund\x20may\x20drop\x20below\x203x\x20the\x20next\x20large\x20order,\x20which\x20then\x20'+'checks\x20out\x20UNDER-COVERED\x20(compensation_fund_below_order_ceiling\x20warning\x20at\x20buy\x20time\x20—\x20拍板⑤\x20'+'dm-mtw-261027\x20demoted\x20the\x20refusal;\x20a\x20max-award\x20ruling\x20on\x20it\x20aborts\x20code\x2027).\x20MERCHANT\x20CONSEQUENCE\x20'+'(F-BS-59):\x20the\x20first\x20SKU\x20this\x20wall\x20hits\x20is\x20your\x20HIGHEST-priced\x20one\x20—\x20its\x20buyers\x20get\x20the\x20'+'under-coverage\x20warning\x20until\x20the\x20fund\x20is\x20topped\x20back\x20above\x203x\x20its\x20price.\x20The\x20buyer-facing\x20'+'warning\x20appears\x20at\x20purchase\x20time;\x20this\x20surface\x20is\x20the\x20merchant-side\x20notice.','suggestion':'Top\x20up\x20compensation_fund\x20to\x20more\x20than\x203x\x20the\x20largest\x20open\x20order\x20amount\x20(and\x20re-check\x20after\x20every\x20award),\x20or\x20cap\x20the\x20largest\x20order\x20size.','amounts':[{'key':'fund','label':'Compensation\x20fund','raw':k['toString'](),...m},{'key':'amount','label':'Largest\x20windowed\x20order','raw':i['toString'](),...m},{'key':'needed','label':'Max-award\x20requirement\x20(3x\x20largest)','raw':l['toString'](),...m}],...o['exposure']?{'exposure':o['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c;}},CONTROL_TYPES=new Set(['Service','Machine','Treasury']),CONTROL_FANOUT_ALERT=0x3,R3={'id':'R3','kind':'risk','run'(a){const b=buildControlIndex(a),c=[];for(const [d,e]of b['objectsByEoa']){const f=[...e]['filter'](k=>CONTROL_TYPES['has'](a['graph']['nodes']['get'](k)?.['objectType']??''));if(f['length']<CONTROL_FANOUT_ALERT)continue;const g=f['filter'](k=>a['graph']['nodes']['get'](k)?.['objectType']==='Service'),h=g['reduce']((k,l)=>k+out(a,l,'service.order')['length'],0x0),i=f['length']>=0x5?'medium':'low',j=graphFindingPolicy('R3',{'r3_level':i});if(!j['enabled'])continue;c['push'](makeFinding(a,'R3:'+d,'risk','Permission\x20concentration:\x20a\x20single\x20EOA\x20controls\x20multiple\x20business-critical\x20objects',{'severity':j['severity']??i,'path':[d,'eoa.permission','permission.core_binding'],'pathEdges':edgeList(a,'eoa.permission')['concat'](edgeList(a,'permission.core_binding')),'roles':ROLES_RISK_NEUTRAL_MERCHANT,'detail':'EOA\x20'+d+'\x20controls\x20'+f['length']+'\x20Service/Machine/Treasury\x20objects\x20via\x20owner/admin\x20permissions\x20'+('('+g['length']+'\x20of\x20them\x20Services,\x20'+h+'\x20orders\x20visible\x20in\x20the\x20window);\x20business\x20scale\x20does\x20not\x20match\x20permission\x20dispersion.\x20')+('Controlled\x20objects:\x20'+f['slice'](0x0,0xa)['join'](',\x20')+(f['length']>0xa?',\x20and\x20'+(f['length']-0xa)+'\x20more':'')+'.'),'suggestion':'Delegate\x20day-to-day\x20operations\x20to\x20dedicated\x20admin/entity\x20roles\x20and\x20keep\x20owner\x20for\x20emergencies\x20only;\x20avoid\x20attaching\x20core\x20objects\x20to\x20the\x20same\x20permission\x20group.',...j['exposure']?{'exposure':j['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c;}},R4={'id':'R4','kind':'risk','run'(a){const b=[];q:for(const c of machineViews(a)){const d=new Map();for(const g of c['transitions']){if(!c['terminals']['has'](String(g['payload']?.['node']??'')))continue;const h=g['from']+'→'+g['to'],i=d['get'](h)??[];i['push'](g),d['set'](h,i);}for(const [j,k]of d){const l=new Set();let m=![];for(const n of k){if(str(n['payload']?.['namedOperator']))l['add']('name:'+n['payload']['namedOperator']);if(typeof n['payload']?.['permissionIndex']==='number')l['add']('perm:'+n['payload']['permissionIndex']);if(str(n['payload']?.['guard']))m=!![];}if(l['size']===0x1&&!m){const o=[...l][0x0],p=graphFindingPolicy('R4',{'only':o});if(!p['enabled'])continue;b['push'](makeFinding(a,'R4:'+c['machine']['id']+':'+j,'risk','Workflow\x20single\x20point:\x20the\x20only\x20Forward\x20before\x20a\x20terminal\x20state\x20has\x20a\x20single\x20operator\x20and\x20no\x20fallback\x20Guard',{'severity':p['severity']??'medium','path':[c['machine']['id'],'machine.node','wf.transition',j],'pathEdges':k,'roles':['neutral','system','merchant','collaborator'],'detail':'On\x20Machine\x20'+c['machine']['id']+',\x20path\x20'+j+'\x20toward\x20terminal\x20state\x20'+wfNodeName(k[0x0]['to'])+':\x20'+('the\x20only\x20operable\x20party\x20is\x20'+o+'\x20and\x20no\x20Forward\x20has\x20a\x20guard\x20fallback;\x20if\x20that\x20party\x20goes\x20offline\x20the\x20workflow\x20stalls.'),'suggestion':'Add\x20a\x20permissionIndex\x20alternative\x20or\x20attach\x20a\x20guard\x20auto-advance\x20condition\x20to\x20this\x20Forward\x20so\x20one\x20party\x20cannot\x20block\x20the\x20terminal\x20state.',...p['exposure']?{'exposure':p['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break q;}}}return b;}},R5={'id':'R5','kind':'risk','run'(a){const b=[],c=new Set();for(const d of a['graph']['truncations']){if(!a['visibleNodes']['has'](d['nodeId']))continue;const e=d['nodeId']+'|'+d['schema'];if(c['has'](e))continue;c['add'](e),b['push']({'id':'R5:'+e,'kind':'risk','severity':'info','title':'Window\x20truncation:\x20affected\x20conclusions\x20are\x20lower\x20bounds\x20within\x20the\x20<=5200\x20FIFO/ring\x20window\x20only','path':[d['nodeId'],d['schema']],'confidence':'windowed','window':{'observed':d['observed'],'limit':d['limit']??WINDOW_LIMIT},'roles':['neutral','system','merchant','buyer','supplier','arbitrator','collaborator'],'detail':'Fanout\x20of\x20'+d['schema']+'\x20at\x20node\x20'+d['nodeId']+'\x20is\x20truncated\x20(observed\x20'+d['observed']+',\x20window\x20limit\x20'+(d['limit']??WINDOW_LIMIT)+');\x20'+'any\x20conclusion\x20relying\x20on\x20this\x20path\x20must\x20be\x20worded\x20as\x20\x22within\x20the\x20window\x20/\x20at\x20least\x22,\x20never\x20as\x20exhaustive\x20truth.','suggestion':'For\x20exhaustive\x20conclusions\x20switch\x20to\x20the\x20event\x20channel\x20(channel\x20D)\x20or\x20raise\x20perKindCaps\x20within\x20budget.'});if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},R6={'id':'R6','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Service')){const e=root(c);if(!bool(e['bPublished']))continue;if(big(e['setting_lock_duration'])!==0x0n)continue;const f=graphFindingPolicy('R6',{});if(!f['enabled'])continue;b['push'](makeFinding(a,'R6:'+c['id'],'risk','Missing\x20setting\x20lock:\x20published\x20Service\x20has\x20setting_lock_duration=0',{'severity':f['severity']??'medium','path':[c['id'],'Service.setting_lock_duration'],'roles':ROLES_RISK_NEUTRAL_MERCHANT['concat']('buyer'),'detail':'Service\x20'+c['id']+'\x20is\x20published\x20but\x20setting_lock_duration=0:\x20order_allocators\x20/\x20rewards\x20/\x20arbitrations\x20/\x20machine\x20'+'and\x20compensation_fund\x20withdrawals\x20can\x20be\x20changed\x20instantly\x20(default\x20lock\x20is\x2030\x20days);\x20buyers\x20face\x20instantly\x20mutable\x20terms.','suggestion':'Set\x20setting_lock_duration\x20after\x20publishing\x20(30\x20days\x20=\x202592000000\x20ms\x20at\x20minimum);\x20term\x20changes\x20must\x20go\x20through\x20a\x20waiting\x20period.',...f['exposure']?{'exposure':f['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},OBJECT_USER_ROLES=['neutral','system','buyer','supplier'],R7={'id':'R7','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Treasury')){const d=asList(root(c)?.['external_withdraw_guard']);if(d['length']===0x0)continue;const e=graphFindingPolicy('R7-treasury',{});if(!e['enabled'])continue;b['push'](makeFinding(a,'R7:treasury:'+c['id'],'risk','Object-user\x20CRITICAL:\x20Treasury\x20has\x20a\x20permission-free\x20external\x20release\x20path',{'severity':e['severity']??'critical','path':[c['id'],'Treasury.external_withdraw_guard'],'roles':OBJECT_USER_ROLES,'detail':'Treasury\x20'+c['id']+'\x20has\x20'+d['length']+'\x20external_withdraw_guard\x20entry/entries:\x20external_withdraw\x20needs\x20no\x20Treasury\x20'+'Permission\x20—\x20only\x20the\x20Guard\x27s\x20boolean\x20verdict\x20stands\x20between\x20an\x20external\x20caller\x20and\x20the\x20balance.\x20The\x20topology\x20performs\x20'+'no\x20Guard-bytecode\x20analysis,\x20so\x20the\x20Guard\x27s\x20strength\x20is\x20UNVERIFIABLE\x20here.\x20Move\x20truth\x20(protocol\x20140):\x20the\x20destination\x20is\x20'+'forced\x20to\x20the\x20transaction\x20sender\x20(abort\x20code\x2010\x20on\x20mismatch),\x20which\x20blocks\x20third-party\x20redirection\x20but\x20NOT\x20release\x20to\x20a\x20'+'caller\x20whose\x20transaction\x20satisfies\x20a\x20weak\x20Guard\x20(for\x20example,\x20a\x20constant-true\x20root\x20with\x20a\x20static\x20amount\x20slot).','suggestion':'Do\x20not\x20rely\x20on\x20or\x20transact\x20through\x20this\x20Treasury\x20until\x20the\x20owner\x20presents\x20the\x20full\x20Guard\x20definitions;\x20verify\x20the\x20predicate\x20'+'constrains\x20the\x20amount\x20slot;\x20require\x20a\x20testnet\x20regression\x20(recipient\x20!=\x20sender\x20must\x20abort\x20with\x20code\x2010).',...e['exposure']?{'exposure':e['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}for(const f of typedNodes(a,'Reward')){const g=asList(root(f)?.['guards']);if(g['length']===0x0)continue;const h=g['map']((n,o)=>{const p=typeof n['guard']==='string'?n['guard']:'',q=p?a['graph']['nodes']['get'](p):undefined,s=q?root(q):undefined;return analyzeRewardClaimGuard({'entry_index':o,'guard':p,'recipient':n['recipient'],'guard_def':s?{...Array['isArray'](s['table'])?{'table':s['table']}:{},'root':s['root']}:undefined});}),i=h['some'](n=>n['viability']==='viable'),j=h['every'](n=>n['viability']==='blocked'),k=h['filter'](n=>n['viability']==='blocked')['length']+'\x20blocked,\x20'+(h['filter'](n=>n['viability']==='viable')['length']+'\x20viable,\x20')+(h['filter'](n=>n['viability']==='conditional')['length']+'\x20conditional,\x20')+(h['filter'](n=>n['viability']==='unverifiable')['length']+'\x20unverifiable'),l=h['map'](n=>'#'+n['entry_index']+'\x20'+n['viability']+'\x20—\x20'+n['reason'])['join']('\x20|\x20'),m=graphFindingPolicy('R7-reward',{'r7_slot_viability':i?'viable':j?'blocked':'unverifiable','r7_slot_audit':l});if(!m['enabled'])continue;b['push'](makeFinding(a,'R7:reward:'+f['id'],'risk',j?'Reward\x20claim\x20path\x20is\x20permission-free\x20but\x20every\x20payout\x20slot\x20is\x20provably\x20bound\x20(downgraded\x20hint)':'Object-user\x20CRITICAL:\x20Reward\x20has\x20a\x20permission-free\x20claim\x20path\x20with\x20an\x20unverifiable\x20payout\x20slot',{'severity':m['severity']??(j?'info':'critical'),'path':[f['id'],'Reward.guards'],'roles':OBJECT_USER_ROLES,'detail':'Reward\x20'+f['id']+'\x20has\x20'+g['length']+'\x20claim\x20guard\x20entry/entries:\x20claim()\x20needs\x20no\x20Permission,\x20and\x20with\x20a\x20'+'Recipient::GuardIdentifier\x20entry\x20the\x20payout\x20address\x20is\x20read\x20from\x20the\x20claim-time\x20passport\x20submission.\x20'+('Canonical\x20slot\x20audit\x20('+k+').\x20A\x20guard\x20that\x20passes\x20without\x20constraining\x20the\x20recipient\x20slot\x20lets\x20any\x20passing\x20')+'party\x20fill\x20the\x20slot\x20with\x20their\x20own\x20address\x20and\x20claim\x20the\x20pool.','suggestion':j?'Payout\x20slots\x20are\x20constraint-bound\x20per\x20the\x20guard\x20audit;\x20treat\x20this\x20as\x20an\x20informational\x20structure\x20note.':'Do\x20not\x20treat\x20the\x20reward\x20pool\x20as\x20sound\x20until\x20the\x20owner\x20presents\x20the\x20Guard\x20definitions;\x20verify\x20the\x20predicate\x20binds\x20the\x20'+'recipient\x20slot\x20(Signer/entity),\x20or\x20confirm\x20the\x20entries\x20use\x20Entity/Signer\x20recipients\x20that\x20do\x20not\x20depend\x20on\x20submitted\x20slots.',...m['exposure']?{'exposure':m['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},RATE_BASIS=0x2710n;function allocatorsList(a){if(Array['isArray'](a))return a;const b=a?.['allocators'];return asList(b);}function allocationStructuralIssues(a){const b=[];let c=0x0,d=![];for(const e of allocatorsList(a)){const f=e??{};let g=0x0n,h=0x0n,i=![];for(const j of asList(f['sharing'])){const k=j??{},l=Number(k['mode']);if(l===0x2||k['mode']==='Surplus'){c++,d=!![];continue;}if(l===0x3||k['mode']==='RateGross')h+=big(k['sharing']);else l===0x1||k['mode']==='Rate'?g+=big(k['sharing']):i=!![];}g!==0x0n&&g!==RATE_BASIS&&!d&&b['push']('Rate\x20allocation\x20totals\x20'+g+'\x20!=\x2010000\x20basis\x20points\x20with\x20no\x20Surplus\x20fallback;\x20payment\x20will\x20abort'),h>RATE_BASIS&&b['push']('RateGross\x20allocation\x20totals\x20'+h+'\x20>\x2010000\x20basis\x20points;\x20payment\x20will\x20abort\x20(ERATE_EXCEEDS_10000,\x206)'),i&&(f['max']==null||big(f['max'])===0x0n)&&b['push']('Fixed-amount\x20(Amount)\x20allocation\x20Allocator\x20lacks\x20a\x20max\x20cap;\x20excess\x20transfer\x20is\x20possible\x20when\x20the\x20guard\x20triggers');}if(c>0x1)b['push'](c+'\x20Surplus\x20entries\x20(at\x20most\x201\x20is\x20legal);\x20surplus\x20ownership\x20is\x20ambiguous');return[...new Set(b)];}const A1={'id':'A1','kind':'arbitrage','run'(a){const b=[],c=(e,f,g,h)=>{const i=allocationStructuralIssues(f);if(i['length']===0x0||h['has'](e))return;h['add'](e);const j=graphFindingPolicy('A1',{});if(!j['enabled'])return;b['push'](makeFinding(a,'A1:'+e,'arbitrage','Allocation\x20structure\x20mismatch:\x20Rate/Surplus/max\x20configuration\x20has\x20triggerable\x20structural\x20defects',{'severity':j['severity']??'medium','path':[e,'allocators[].sharing'],'pathEdges':g,'roles':['neutral','system','merchant','buyer'],'detail':e+':\x20'+i['join'](';\x20')+'.','suggestion':'Complete\x20Rate\x20groups\x20to\x2010000\x20or\x20configure\x20a\x20single\x20Surplus;\x20fixed-amount\x20Allocators\x20must\x20set\x20max;\x20run\x20the\x20allocation\x20precheck\x20before\x20going\x20live.',...j['exposure']?{'exposure':j['exposure']}:{}}));},d=new Set();for(const e of typedNodes(a,'Allocation')){c(e['id'],root(e)['allocators'],inc(a,e['id'],'order.allocation'),d);}for(const f of typedNodes(a,'Service')){const g=root(f)['order_allocators'];if(g?.['allocators'])c(f['id'],g['allocators'],edgeList(a,'service.order_allocator_guard'),d);}return b['slice'](0x0,MAX_FINDINGS_PER_RULE);}},DISCOUNT_FIXED=0x1,THIRTY_DAYS_MS=0x1en*0x18n*0x3cn*0x3cn*0x3e8n,A2={'id':'A2','kind':'arbitrage','run'(a){const b=[];for(const c of typedNodes(a,'Discount')){const e=root(c),f=big(e['time_end'])-big(e['time_start'])>=THIRTY_DAYS_MS;if(!bool(e['transferable'])||!f)continue;if(Number(e['discount_type'])!==DISCOUNT_FIXED)continue;if(e['benchmark']!=null&&e['benchmark']!=='0')continue;const g=graphFindingPolicy('A2',{});if(!g['enabled'])continue;b['push'](makeFinding(a,'A2:'+c['id'],'arbitrage','Discount\x20combination:\x20transferable\x20+\x20long\x20validity\x20window\x20+\x20fixed-amount\x20discount\x20without\x20benchmark',{'severity':g['severity']??'low','path':[c['id'],'Discount.transferable/time_window/benchmark'],'roles':['neutral','system','merchant'],'detail':'Discount\x20'+c['id']+'\x20is\x20transferable,\x20valid\x20>=30\x20days,\x20is\x20a\x20fixed-amount\x20discount,\x20and\x20has\x20no\x20benchmark\x20price\x20check;\x20'+'this\x20leaves\x20room\x20for\x20coupon\x20hoarding\x20and\x20resale\x20arbitrage.','suggestion':'Shorten\x20the\x20validity\x20window,\x20switch\x20to\x20RATES\x20proportional\x20discounts,\x20or\x20add\x20benchmark\x20Guards;\x20disable\x20transferable\x20if\x20needed.',...g['exposure']?{'exposure':g['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},A3={'id':'A3','kind':'arbitrage','run'(a){const b=[];for(const e of typedNodes(a,'Arbitration')){const f=root(e),g=big(f['fee'])===0x0n&&!str(f['usage_guard']);if(g){const h=graphFindingPolicy('A3',{});h['enabled']&&b['push'](makeFinding(a,'A3:'+e['id'],'arbitrage','Remedy\x20cost\x20structure:\x20zero\x20fee\x20+\x20no\x20usage\x20gate\x20gives\x20malicious\x20disputes\x20a\x20positive-expected-value\x20setup',{'severity':h['severity']??'medium','path':[e['id'],'Arbitration.fee','Arbitration.usage_guard'],'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+e['id']+'\x20has\x20fee=0\x20and\x20an\x20empty\x20usage_guard;\x20combined\x20with\x20the\x203x\x20amount\x20payout\x20cap,\x20single\x20claim,\x20'+'and\x2030-day\x20withdrawal\x20lock\x20rules,\x20filing\x20a\x20malicious\x20dispute\x20carries\x20no\x20structural\x20upfront\x20cost.','suggestion':'Set\x20a\x20non-zero\x20fee\x20to\x20cover\x20adjudication\x20cost,\x20or\x20use\x20usage_guard\x20to\x20require\x20disputing\x20parties\x20to\x20hold\x20on-chain\x20participation\x20credentials.',...h['exposure']?{'exposure':h['exposure']}:{}}));}if(b['length']>=MAX_FINDINGS_PER_RULE)break;}const c=new Map();for(const i of a['visibleNodes']){const j=a['graph']['nodes']['get'](i),k=j?.['raw']?.['type_raw'];if(typeof k!=='string'||!k['includes']('::payment::CoinWrapper<'))continue;const l=k['slice'](k['indexOf']('<')+0x1,k['lastIndexOf']('>'))['trim'](),m=c['get'](l)??[];m['push'](i),c['set'](l,m);}if(c['size']>0x0){const o=[...c['keys']()]['sort']();b['push']({'id':'A3:coinwrapper','kind':'arbitrage','severity':'info','title':'Cross-coin\x20escrow\x20review\x20point:\x20CoinWrapper<K>\x20escrow\x20objects\x20exist\x20in\x20the\x20graph','path':['payment::CoinWrapper'],'confidence':'exact','roles':['neutral','system','arbitrator','merchant'],'detail':'Visible\x20CoinWrapper\x20escrow\x20covers\x20coin\x20types:\x20'+o['join'](',\x20')+'\x20('+[...c['values']()]['reduce']((p,q)=>p+q['length'],0x0)+'\x20objects).\x20'+'v1\x20performs\x20no\x20market\x20valuation;\x20remedy/allocation\x20conclusions\x20across\x20coins\x20require\x20manual\x20review\x20of\x20coin\x20mismatch\x20and\x20depeg\x20risk.','suggestion':'Verify\x20the\x20escrow\x20coin\x20type\x20matches\x20the\x20service\x20coin\x20type\x20T;\x20add\x20independent\x20exchange-rate/oracle\x20evidence\x20before\x20concluding\x20cross-coin\x20cases.'});}return b['slice'](0x0,MAX_FINDINGS_PER_RULE);}};function modeIs(a,b){const c=a['mode'];if(typeof c==='string')return c===b;const d=Number(c);return b==='Amount'&&d===0x0||b==='Rate'&&d===0x1||b==='Surplus'&&d===0x2||b==='RateGross'&&d===0x3;}function recipientKind(a){if(typeof a==='string')return a==='Signer'?'Signer':'Entity';if(a&&typeof a==='object'){const b=a;if('GuardIdentifier'in b)return'GuardIdentifier';if('Signer'in b)return'Signer';if('Entity'in b)return'Entity';}return'other';}const A4={'id':'A4','kind':'risk','run'(b){const c=[];for(const f of typedNodes(b,'Allocation')){const g=root(f),h=allocatorsList(g['allocators']),i=inc(b,f['id'],'order.allocation'),j=g['payment_info']?.['for_object'],k=typeof j==='string'&&j!=='0x0',l=new Set(),m=new Map();for(const p of h){const q=typeof p['guard']==='string'?p['guard']:'',r=asList(p['sharing']);if(r['some'](u=>modeIs(u,'Surplus')))l['add'](q);let t=0x0n;for(const u of r)if(modeIs(u,'Rate')||modeIs(u,'RateGross'))t+=big(u['sharing']);if(t>0x0n&&q)m['set'](q,t);}const n=[...m['keys']()]['filter'](w=>!l['has'](w));if(l['size']>0x0&&n['length']>0x0){const w=graphFindingPolicy('A4',{'a4_case':'drain'});w['enabled']&&c['push'](makeFinding(b,'A4:drain:'+f['id'],'risk','Allocation\x20ordering\x20risk:\x20a\x20Surplus\x20allocator\x20can\x20starve\x20a\x20Rate-only\x20allocator',{'severity':w['severity']??'high','path':[f['id'],'allocators[].sharing[Surplus]','allocators[].sharing[Rate]'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Allocation\x20'+f['id']+':\x20guard(s)\x20['+([...l]['join'](',\x20')||'n/a')+']\x20carry\x20a\x20Surplus\x20share\x20that\x20drains\x20the\x20pool\x20'+('(minus\x20max)\x20when\x20triggered,\x20while\x20guard(s)\x20['+n['join'](',\x20')+']\x20pay\x20only\x20by\x20Rate.\x20If\x20a\x20Surplus\x20guard\x20fires\x20')+'first,\x20the\x20Rate-only\x20guard\x27s\x20allocator\x20sees\x20balance=0\x20and\x20aborts\x20(EAMOUNT_ZERO,\x2014)\x20—\x20the\x20split\x20is\x20order-sensitive\x20and\x20'+'the\x20Rate\x20recipients\x20can\x20be\x20legitimately\x20starved.','suggestion':'Give\x20the\x20Rate-only\x20allocator\x20a\x20Surplus\x20fallback\x20(Rate\x20sum\x20≤\x2010000\x20with\x20a\x20Surplus)\x20or\x20bind\x20both\x20shares\x20under\x20one\x20guard\x20so\x20a\x20'+'single\x20alloc()\x20settles\x20them\x20together;\x20the\x20keeper\x20must\x20record\x20the\x20triggered-guard\x20set\x20to\x20avoid\x20a\x20second\x20drain.',...w['exposure']?{'exposure':w['exposure']}:{}}));}const o=h['some'](x=>asList(x['sharing'])['some'](y=>recipientKind(y['who'])==='GuardIdentifier'));if(o&&!k){const x=graphFindingPolicy('A4',{'a4_case':'unanchored'});x['enabled']&&c['push'](makeFinding(b,'A4:unanchored:'+f['id'],'risk','Unanchored\x20payout\x20recipient:\x20GuardIdentifier\x20routing\x20without\x20a\x20payment_info.for_object\x20binding',{'severity':x['severity']??'high','path':[f['id'],'payment_info.for_object','allocators[].sharing[GuardIdentifier]'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Allocation\x20'+f['id']+'\x20pays\x20a\x20guard-submitted\x20address\x20(Recipient::GuardIdentifier)\x20but\x20declares\x20no\x20'+'payment_info.for_object\x20anchor,\x20so\x20the\x20on-chain\x20submitted==binding\x20check\x20(ERECIPIENT_NOT_FOR_OBJECT,\x2015)\x20never\x20runs.\x20'+'Any\x20party\x20that\x20passes\x20the\x20guard\x20can\x20fill\x20the\x20recipient\x20slot\x20with\x20an\x20arbitrary\x20address\x20and\x20route\x20the\x20payout\x20away.','suggestion':'Set\x20payment_info.for_object\x20to\x20the\x20bound\x20business\x20object\x20(the\x20Order)\x20so\x20the\x20payout\x20address\x20is\x20enforced\x20against\x20it;\x20'+'if\x20a\x20multi-payee\x20(payroll-style)\x20pool\x20is\x20intended,\x20gate\x20the\x20guard\x20so\x20only\x20a\x20trusted\x20submitter\x20can\x20pass.',...x['exposure']?{'exposure':x['exposure']}:{}}));}if(h['length']===0x0)for(const y of i){const z=b['graph']['nodes']['get'](y['from']);if(!z||z['kind']!=='object')continue;const A=orderCompletionInGraph(b['graph'],y['from']);if(A['status']!=='completed')continue;const B=graphFindingPolicy('A4',{'a4_case':'deadlock'});if(!B['enabled'])continue;c['push'](makeFinding(b,'A4:deadlock:'+f['id']+':'+y['from'],'risk','Settlement\x20deadlock:\x20completed\x20order\x20with\x20an\x20allocation\x20pool\x20that\x20has\x20no\x20allocator',{'severity':B['severity']??'critical','path':[y['from'],'order.allocation',f['id'],'allocators'],'pathEdges':i,'roles':['neutral','system','merchant','buyer'],'detail':'Order\x20'+y['from']+'\x20reached\x20a\x20completion\x20terminal\x20but\x20its\x20Allocation\x20'+f['id']+'\x20has\x20an\x20empty\x20allocators\x20list\x20—\x20no\x20guard\x20'+'can\x20release\x20the\x20escrowed\x20funds.\x20The\x20amount\x20is\x20locked\x20on-chain\x20with\x20no\x20settlement\x20path;\x20only\x20a\x20manual\x20pool\x20rebuild\x20'+'(or\x20a\x20chain-level\x20remedy)\x20can\x20move\x20it.','suggestion':'Before\x20publishing,\x20ensure\x20every\x20completable\x20path\x20has\x20a\x20matching\x20allocator\x20(settle/refund\x20guards\x20covering\x20each\x20terminal);\x20'+'for\x20an\x20already-live\x20pool\x20the\x20keeper\x20should\x20surface\x20this\x20as\x20a\x20manual-settlement\x20task.',...B['exposure']?{'exposure':B['exposure']}:{}}));if(c['length']>=MAX_FINDINGS_PER_RULE)break;}if(c['length']>=MAX_FINDINGS_PER_RULE)break;}return c['slice'](0x0,MAX_FINDINGS_PER_RULE);}},SCARCE_PRESENTERS=0x2;function demandGuardIds(a,b){const c=new Set();for(const d of out(a,b,'demand.guard'))c['add'](d['to']);return c;}function serviceGuardIds(a,b){const c=new Set();for(const f of out(a,b['id'],'service.buy_guard'))c['add'](f['to']);const d=out(a,b['id'],'service.machine')[0x0]?.['to'];if(d)for(const g of a['visibleEdges']){if(g['schema']==='wf.forward_guard'&&g['from']['startsWith'](d+'::node::'))c['add'](g['to']);}return c;}const O1={'id':'O1','kind':'opportunity','run'(a){const b=[],c=typedNodes(a,'Service');for(const d of typedNodes(a,'Demand')){const e=out(a,d['id'],'demand.presenter');if(e['length']>=SCARCE_PRESENTERS)continue;const f=demandGuardIds(a,d['id']),g=[];for(const i of c){const j=serviceGuardIds(a,i);if(f['size']===0x0||[...f]['every'](k=>j['has'](k)))g['push'](i['id']);}const h=e;b['push'](makeFinding(a,'O1:'+d['id'],'opportunity','Open\x20demand:\x20few\x20proposals,\x20with\x20structurally\x20capable\x20suppliers\x20present',{'severity':'info','path':[d['id'],'demand.presenter','demand.guard','Service'],'pathEdges':h['concat'](out(a,d['id'],'demand.guard')),'roles':['neutral','system','supplier'],'detail':'Demand\x20'+d['id']+'\x20currently\x20has\x20only\x20'+e['length']+'\x20proposal(s);\x20matched\x20by\x20Guard\x20structure\x20(no\x20Guard\x20bytecode\x20parsing)\x20to\x20'+(g['length']+'\x20candidate\x20Service(s):\x20'+(g['slice'](0x0,0x5)['join'](',\x20')||'(no\x20match\x20in\x20graph)')+'.'),'suggestion':'Candidate\x20suppliers\x20can\x20prepare\x20present\x20evidence\x20(proof\x20of\x20satisfying\x20the\x20demand\x20Guards);\x20the\x20opportunity\x20conclusion\x20is\x20structural\x20only\x20and\x20does\x20not\x20endorse\x20fulfillment\x20capability.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},O2={'id':'O2','kind':'opportunity','run'(a){const b=typedNodes(a,'Service'),c=typedNodes(a,'Demand');if(b['length']===0x0&&c['length']===0x0)return[];const d=b['filter'](f=>bool(root(f)['bPublished'])&&!bool(root(f)['bPaused']))['length'],e=c['filter'](f=>out(a,f['id'],'demand.presenter')['length']===0x0)['length'];return[makeFinding(a,'O2:graph','opportunity','Supply/demand\x20density:\x20in-graph\x20supply\x20and\x20open-demand\x20statistics',{'path':['Service','Demand','demand.presenter'],'pathEdges':edgeList(a,'demand.presenter'),'roles':['neutral','system','supplier','merchant'],'detail':'In\x20the\x20current\x20viewport:\x20'+b['length']+'\x20Service(s)\x20('+d+'\x20published\x20and\x20unpaused),\x20'+c['length']+'\x20Demand(s)\x20'+('('+e+'\x20open\x20demand(s)\x20without\x20proposals).\x20Open-demand/active-supply\x20ratio\x20=\x20')+((d>0x0?(e/d)['toFixed'](0x3):'n/a')+'.'),'suggestion':'A\x20high\x20ratio\x20indicates\x20scarce\x20supply;\x20use\x20category\x20exact-match\x20counts\x20(collectors\x20category_enumerated_count)\x20to\x20pick\x20an\x20entry\x20category.'})];}},O3={'id':'O3','kind':'opportunity','run'(a){const b=[];for(const c of machineViews(a)){const d=new Map();for(const g of c['transitions']){if(str(g['payload']?.['namedOperator'])||g['payload']?.['permissionIndex']!=null)continue;const h=String(g['payload']?.['forward']??g['payload']?.['prevNode']+'→'+g['payload']?.['node']);d['set'](wfNodeName(g['from'])+':'+h,g);}if(d['size']===0x0)continue;const f=[...d['values']()];b['push'](makeFinding(a,'O3:'+c['machine']['id'],'opportunity','Workflow\x20gaps:\x20key\x20Forwards\x20have\x20no\x20operator\x20binding\x20(guard/payment\x20passthrough\x20only)',{'path':[c['machine']['id'],'machine.node','wf.transition'],'pathEdges':f,'roles':['neutral','system','supplier','collaborator','merchant'],'detail':'Machine\x20'+c['machine']['id']+'\x20has\x20'+d['size']+'\x20Forward(s)\x20without\x20namedOperator/permissionIndex\x20binding:\x20'+([...d['keys']()]['slice'](0x0,0x8)['join'](',\x20')+'.\x20These\x20slots\x20can\x20only\x20be\x20satisfied\x20automatically\x20by\x20guards\x20or\x20advanced\x20directly\x20by\x20payment\x20transactions.'),'suggestion':'Suppliers/collaborators\x20can\x20take\x20over\x20these\x20operator\x20slots,\x20or\x20push\x20the\x20merchant\x20to\x20convert\x20implicit\x20passthrough\x20into\x20explicit\x20role\x20bindings.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},O4={'id':'O4','kind':'opportunity','run'(a){const b=[],c=a['graph']['builtAt']||Date['now']();for(const d of typedNodes(a,'Demand')){const f=out(a,d['id'],'demand.presenter');if(f['length']===0x0)continue;const g=f['filter'](k=>typeof k['payload']?.['score']==='number');let h;for(const k of f){const l=typeof k['payload']?.['feedbackTime']==='number'&&k['payload']['feedbackTime']>0x0?k['payload']['feedbackTime']:typeof k['payload']?.['time']==='number'&&k['payload']['time']>0x0?k['payload']['time']:undefined;if(l!=null&&(h==null||l>h))h=l;}const i=h!=null?Math['floor']((c-h)/0x5265c00):undefined,j=h==null?'no\x20row\x20carries\x20a\x20timestamp\x20—\x20staleness\x20unknown':i!=null&&i<=0x1e?'latest\x20feedback\x20'+i+'\x20day(s)\x20ago':'latest\x20feedback\x20'+i+'\x20day(s)\x20ago\x20(stale)';b['push'](makeFinding(a,'O4:'+d['id'],'opportunity','Demand-side\x20feedback\x20signal:\x20presenter\x20acceptance\x20coverage\x20and\x20freshness',{'severity':'info','path':[d['id'],'demand.presenter'],'pathEdges':f,'roles':['neutral','system','supplier','merchant'],'detail':'Demand\x20'+d['id']+':\x20'+f['length']+'\x20presenter(s),\x20'+g['length']+'\x20with\x20an\x20acceptance\x20score\x20'+('(the\x20demander\x27s\x20own\x200-100\x20judgment);\x20'+j+'.\x20Unscored\x20presenters\x20mean\x20the\x20feedback\x20loop\x20has\x20not\x20')+'been\x20exercised\x20yet\x20—\x20the\x20sample\x20is\x20sparse\x20by\x20nature,\x20not\x20a\x20negative\x20verdict.','suggestion':'Suppliers\x20evaluating\x20this\x20demand\x20can\x20read\x20the\x20acceptance\x20coverage\x20and\x20freshness\x20as\x20the\x20demander\x27s\x20engagement\x20quality;\x20'+'read\x20it\x20jointly\x20with\x20the\x20demand\x20Guards\x20(empty\x20=\x20bare\x20present,\x20no\x20acceptance\x20gate).\x20No\x20platform\x20weighting\x20is\x20applied\x20—\x20the\x20score\x20stays\x20the\x20demander\x27s\x20own\x20judgment.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}};function arbitrationCases(a,b){return inc(a,b,'arb.arbitration_service')['map'](c=>a['graph']['nodes']['get'](c['from']))['filter'](c=>!!c&&c['objectType']==='Arb'&&!!c['raw']);}const G1={'id':'G1','kind':'game','run'(a){const b=[];for(const e of typedNodes(a,'Arbitration')){const f=root(e),g=asList(f['voting_guard']),h=new Set(g['map'](l=>l['vote_weight']&&typeof l['vote_weight']==='object'?Object['keys'](l['vote_weight'])[0x0]:'unknown')),i=arbitrationCases(a,e['id']),j=new Map();let k=0x0;for(const l of i){for(const m of asList(root(l)['voted'])){const n=Number(m['weight']??0x0);j['set'](n,(j['get'](n)??0x0)+0x1),k++;}}b['push'](makeFinding(a,'G1:'+e['id'],'game','Voting\x20power\x20structure:\x20arbitration\x20voting\x20Guard\x20configuration\x20vs\x20actual\x20voting\x20weight\x20distribution',{'severity':'info','path':[e['id'],'arbitration.voting_guard','arb.arbitration_service','arb.voter'],'pathEdges':out(a,e['id'],'arbitration.voting_guard')['concat'](edgeList(a,'arb.voter')),'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+e['id']+':\x20voting_guard\x20'+(g['length']===0x0?'empty\x20=\x20open\x20to\x20all\x20members':'weighted\x20('+[...h]['join']('/')+')')+';\x20'+(i['length']+'\x20case(s)\x20in\x20window,\x20'+k+'\x20actual\x20vote(s)')+(j['size']?',\x20weight\x20distribution\x20'+[...j['entries']()]['map'](([o,p])=>'w'+o+'x'+p)['join'](',\x20'):'')+'.','suggestion':'Open\x20voting\x20suits\x20high-frequency\x20low-stakes\x20cases;\x20high-stakes\x20cases\x20should\x20use\x20weighted\x20Guards;\x20this\x20describes\x20the\x20objective\x20situation\x20only\x20—\x20scoring\x20belongs\x20to\x20the\x20game\x20modules.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},G2={'id':'G2','kind':'game','run'(a){const b=[];o:for(const c of machineViews(a)){const d=out(a,c['machine']['id'],'machine.permission')[0x0]?.['to'],f=d?inc(a,d,'permission.entity')['map'](h=>({'eoa':h['to'],'bits':h['payload']?.['permIndices']??[]})):[],g=new Set();for(const h of c['transitions']){const i=String(h['payload']?.['forward']??h['payload']?.['prevNode']+'→'+h['payload']?.['node']),j=wfNodeName(h['from'])+':'+i;if(g['has'](j))continue;let k,l='';if(str(h['payload']?.['namedOperator']))k=0x1,l='namedOperator='+h['payload']['namedOperator'];else{if(h['payload']?.['permissionIndex']!=null){if(!d)continue;const n=Number(h['payload']['permissionIndex']);k=f['filter'](o=>o['bits']['includes'](n))['length'],l='permissionIndex='+n;if(k===0x0)continue;}else continue;}if(k!==0x1)continue;g['add'](j);const m=graphFindingPolicy('G2',{});if(!m['enabled'])continue;b['push'](makeFinding(a,'G2:'+c['machine']['id']+':'+j,'game','Operator\x20replaceable\x20pool\x20=\x201:\x20hold-up\x20slot',{'severity':m['severity']??'low','path':[c['machine']['id'],'machine.node','wf.transition',j],'pathEdges':[h],'roles':['neutral','system','collaborator','merchant','supplier'],'detail':'Forward\x20'+j+'\x20('+l+')\x20on\x20Machine\x20'+c['machine']['id']+'\x20has\x20an\x20operable-party\x20pool\x20of\x20size\x201:\x20'+'that\x20party\x20holds\x20an\x20irreplaceable\x20bargaining\x20position\x20at\x20this\x20workflow\x20node\x20(protocol\x20operation\x20precheck).','suggestion':'Add\x20an\x20alternative\x20entity\x20under\x20the\x20same\x20permissionIndex\x20or\x20a\x20namedOperator\x20backup;\x20sign\x20SLA/penalty\x20terms\x20covering\x20this\x20slot.',...m['exposure']?{'exposure':m['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break o;}}return b;}},G3={'id':'G3','kind':'game','run'(a){const b=[];for(const c of typedNodes(a,'Arbitration')){const e=root(c),f=asList(e['voting_guard']);b['push'](makeFinding(a,'G3:'+c['id'],'game','Remedy\x20strategy\x20parameters:\x20structured\x20inputs\x20for\x20the\x20payoff/waiting\x20matrices',{'severity':'info','path':[c['id'],'Arbitration.fee/usage_guard/voting_guard'],'roles':['neutral','system','arbitrator','merchant','buyer'],'detail':'Arbitration\x20'+c['id']+':\x20fee='+big(e['fee'])+',\x20usage_guard='+(str(e['usage_guard'])??'none')+',\x20voting_guard='+f['length']+'.\x20'+'Global\x20structural\x20constants:\x20payout\x20cap\x203x\x20amount,\x2030-day\x20compensation\x20withdrawal\x20lock,\x20single\x20claim\x20per\x20payout,\x2030-day\x20withdraw\x20window\x20on\x20uncontested\x20rulings\x20(objection\x20locks\x20the\x20fee\x20until\x20the\x20cycle\x20closes).','suggestion':'Feed\x20these\x20parameters\x20into\x20node-game/arbitration-game\x20payoff\x20and\x20waiting\x20matrices;\x20this\x20analyzer\x20does\x20not\x20score\x20or\x20rank.'}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},ANTI_CHEAT_ROLES=['neutral','system','merchant','buyer'];function projectOrderEvidence(a,b){const c=[];for(const d of typedNodes(a,'Service')){const f=[...b['controllers']['get'](d['id'])??[]];if(f['length']===0x0)continue;for(const g of out(a,d['id'],'service.order')){const h=a['graph']['nodes']['get'](g['to']);if(!h||h['kind']!=='object'||h['objectType']!=='Order'||!h['raw'])continue;const i=out(a,h['id'],'order.builder')[0x0]?.['to'];if(!i)continue;const j=orderCompletionInGraph(a['graph'],h['id'])['status'],k=String(root(h)?.['amount']??0x0),l=out(a,h['id'],'order.allocation')[0x0]?.['to']??null;for(const m of f){c['push']({'service':d['id'],'id':h['id'],'buyer':i,'seller':m,'amount':k,'status':j,'allocation':l});}}}return c;}function orderCheatEdges(a){return edgeList(a,'service.order')['concat'](edgeList(a,'eoa.permission'))['concat'](edgeList(a,'permission.core_binding'));}function shortRefs(a){const b=a['slice'](0x0,0x5)['join'](',\x20');return a['length']>0x5?b+'\x20and\x20'+a['length']+'\x20object(s)\x20in\x20total':b;}const AC1={'id':'AC1','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='self_buy');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC1',{});if(!e['enabled'])return[];return[makeFinding(a,'AC1:'+d['join'](','),'risk','Fake-order\x20suspicion:\x20windowed\x20order\x20buyers\x20are\x20the\x20selling\x20service\x27s\x20controlling\x20EOA\x20(self-trading)',{'severity':e['severity']??'high','path':['EOA','eoa.permission','permission.core_binding','Service','service.order','Order','order.builder'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20order(s)\x20visible\x20in\x20the\x20window\x20have\x20buyer\x20EOAs\x20that\x20also\x20control\x20the\x20selling\x20Service\x20as\x20owner/admin\x20'+('('+shortRefs(d)+'):\x20buyer\x20and\x20seller\x20sit\x20in\x20the\x20same\x20control\x20set,\x20funds\x20circulate\x20internally,\x20and\x20this\x20is\x20not\x20genuine\x20competitive\x20volume.'),'suggestion':'Exclude\x20these\x20orders\x20from\x20sales/reputation\x20statistics\x20and\x20re-verify\x20via\x20payment\x20allocation\x20legs\x20and\x20time\x20windows;\x20reduce\x20market\x20exposure\x20and\x20recommendation\x20weight\x20for\x20this\x20Service.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC2={'id':'AC2','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='reciprocal_loop');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC2',{'ac_signal_level':c['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC2:'+d['join'](','),'risk','Wash-trading\x20suspicion:\x20reciprocal\x20buy/sell\x20role-swapping\x20fund\x20loops\x20in\x20the\x20window',{'severity':e['severity']??c['severity'],'path':['EOA-A','order.builder','Order@Service-B','service.order','EOA-B','order.builder','Order@Service-A'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20order(s)\x20in\x20the\x20window\x20form\x20a\x20buy/sell\x20swap:\x20control\x20set\x20A\x20buys\x20B\x27s\x20Service\x20while\x20control\x20set\x20B\x20buys\x20A\x27s\x20Service\x20'+('('+shortRefs(d)+').\x20The\x20two-way\x20volume\x20may\x20be\x20mutually\x20staged\x20wash\x20trading.'),'suggestion':'Investigate\x20links\x20between\x20the\x20two\x20control\x20sets\x20(devices/permissions/fund\x20flows);\x20exclude\x20mutually-purchased\x20orders\x20from\x20genuine\x20competitive\x20volume.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC3={'id':'AC3','kind':'risk','run'(a){const b=projectOrderEvidence(a,buildControlIndex(a)),c=detectFakeOrders(b)['find'](f=>f['code']==='no_allocation');if(!c)return[];const d=c['refs']??[],e=graphFindingPolicy('AC3',{'ac_signal_level':c['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC3:'+d['join'](','),'risk','Missing\x20fund\x20closure:\x20completed\x20positive-amount\x20orders\x20lack\x20an\x20Allocation\x20object',{'severity':e['severity']??c['severity'],'path':['Service','service.order','Order','order.allocation'],'pathEdges':orderCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['length']+'\x20completed\x20order(s)\x20in\x20the\x20window\x20(completion\x20authoritatively\x20judged\x20by\x20the\x20order-status\x20terminal\x20node\x20set)\x20with\x20amount>0\x20have\x20no\x20Allocation\x20'+('('+shortRefs(d)+').\x20Protocol\x20rules\x20require\x20positive-amount\x20orders\x20to\x20have\x20an\x20allocation\x20path;\x20its\x20absence\x20means\x20the\x20\x22transaction\x22\x20lacks\x20fund-closure\x20evidence.\x20')+'Zero-amount\x20orders\x20are\x20excluded\x20(no\x20fund\x20flow).','suggestion':'Review\x20original\x20payment\x20records;\x20completed\x20orders\x20without\x20payment\x20evidence\x20must\x20not\x20count\x20toward\x20reputation;\x20audit\x20contract\x20entry\x20points\x20that\x20complete\x20without\x20an\x20Allocation\x20path.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},SHELL_COPY={'shell_no_arbitration':{'title':'Shell\x20merchant:\x20published\x20Service\x20has\x20no\x20arbitration\x20binding,\x20disputes\x20have\x20no\x20remedy\x20path','detail':'The\x20Service\x20is\x20published\x20but\x20arbitrations\x20is\x20empty:\x20buyers\x20have\x20no\x20selectable\x20arbitration\x20service\x20after\x20ordering\x20and\x20disputes\x20cannot\x20enter\x20adjudication.','suggestion':'Remediable\x20without\x20rebuilding:\x20attach\x20an\x20Arbitration\x20(in\x20a\x20different\x20group\x20than\x20the\x20shop\x20Permission)\x20via\x20the\x20arbitration-binding\x20Service\x20update\x20—\x20legal\x20on\x20a\x20published\x20Service.\x20Until\x20bound,\x20downgrade\x20the\x20shop\x20in\x20recommendation\x20ranking.'},'shell_funded_no_arbitration':{'title':'Floating\x20payout\x20funds:\x20compensation\x20fund\x20is\x20funded\x20but\x20no\x20Arbitration\x20exists,\x20payouts\x20cannot\x20be\x20adjudicated\x20or\x20released','detail':'compensation_fund>0\x20with\x20no\x20Arbitration\x20at\x20all:\x20when\x20a\x20payout\x20triggers\x20there\x20is\x20no\x20one\x20to\x20adjudicate\x20and\x20no\x20path\x20to\x20release;\x20the\x20funding\x20is\x20marketing\x20theater.','suggestion':'Remediable\x20without\x20rebuilding:\x20bind\x20an\x20Arbitration\x20first\x20(arbitration-binding\x20Service\x20update)\x20so\x20the\x20fund\x20becomes\x20claimable;\x20until\x20then\x20marketplaces\x20should\x20flag\x20\x27fund\x20without\x20arbitration\x27\x20as\x20high\x20risk\x20and\x20limit\x20exposure.'},'shell_no_machine':{'title':'Shell\x20merchant:\x20published\x20Service\x20has\x20no\x20Machine\x20binding,\x20no\x20structured\x20fulfillment\x20workflow','detail':'The\x20Service\x20is\x20published\x20but\x20machine\x20is\x20empty:\x20no\x20frozen\x20workflow\x20template\x20exists,\x20and\x20delivery/completion\x20nodes\x20carry\x20no\x20on-chain\x20structural\x20constraints.','suggestion':'Bind\x20and\x20publish\x20a\x20Machine\x20before\x20opening;\x20published\x20shops\x20without\x20workflows\x20suit\x20only\x20instant\x20spot-delivery\x20categories.'}},AC4={'id':'AC4','kind':'risk','run'(a){const b=[];for(const c of typedNodes(a,'Service')){const e=root(c);if(!bool(e['bPublished']))continue;const f=e['arbitrations']!=null?asList(e['arbitrations'])['length']:out(a,c['id'],'service.arbitration')['length'],g=str(e['machine'])??out(a,c['id'],'service.machine')[0x0]?.['to']??null,h=detectShellMerchant({'object':c['id'],'arbitrations':Array(f)['fill']('x'),'compensation_fund':String(big(e['compensation_fund'])),'machine':g,'bPublished':!![]}),i=out(a,c['id'],'service.arbitration')['concat'](out(a,c['id'],'service.machine'));for(const j of h){const k=SHELL_COPY[j['code']];if(!k)continue;const l=graphFindingPolicy('AC4',{'ac_shell_code':j['code'],'ac_signal_level':j['severity']});if(!l['enabled'])continue;b['push'](makeFinding(a,'AC4:'+c['id']+':'+j['code'],'risk',k['title'],{'severity':l['severity']??j['severity'],'path':[c['id'],'Service.bPublished','Service.arbitrations','Service.machine','Service.compensation_fund'],'pathEdges':i,'roles':ANTI_CHEAT_ROLES,'detail':k['detail']+'\x20(object:\x20'+c['id']+')','suggestion':k['suggestion'],...l['exposure']?{'exposure':l['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)return b;}}return b;}};function projectVoteEvidence(a){const b=[];for(const f of edgeList(a,'target.vote')){const g=typeof f['payload']?.['voteBits']==='number'?f['payload']['voteBits']:0x0;b['push']({'voter':f['to'],'target':f['from'],'like':(g&0x2)!==0x0,'dislike':(g&0x4)!==0x0,'favor':(g&0x8)!==0x0});}const c=[...new Set(b['map'](h=>h['voter']))],d=[];for(const h of c){const i=out(a,h,'entity.profile')[0x0]?.['payload']?.['registeredAt'];let j=0x0,k=0x0;const l=new Set();for(const m of out(a,h,'eoa.order')){const n=typeof m['payload']?.['roleBits']==='number'?m['payload']['roleBits']:0x0;if((n&0x1)!==0x0)j+=0x1;if((n&0x2)!==0x0)k+=0x1;l['add'](m['to']);}for(const o of['eoa.permission','eoa.contact']){for(const p of out(a,h,o))l['add'](p['to']);}d['push']({'address':h,...typeof i==='number'?{'registeredAt':i}:{},'ordersOwned':j,'ordersAgented':k,'objectsFootprint':l['size']});}return{'votes':b,'profiles':d};}function voteCheatEdges(a){return edgeList(a,'target.vote')['concat'](edgeList(a,'entity.profile'))['concat'](edgeList(a,'eoa.order'));}const AC5={'id':'AC5','kind':'risk','run'(a){const {votes:b,profiles:c}=projectVoteEvidence(a),d=detectNewAccountBurst(b,c,Date['now']())[0x0];if(!d)return[];const e=graphFindingPolicy('AC5',{'ac_signal_level':d['severity']});if(!e['enabled'])return[];return[makeFinding(a,'AC5:'+d['refs']?.['join'](','),'risk','Vote-noise\x20suspicion:\x20freshly-registered\x20accounts\x20are\x20casting\x20votes\x20in\x20a\x20burst',{'severity':e['severity']??d['severity'],'path':['EOA','entity.profile','target.vote'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':d['description']+'.\x20Voter\x20credibility\x20is\x20re-projected\x20from\x20the\x20same\x20graph\x20window:\x20entity\x20registration\x20age\x20(entity.profile),\x20order\x20history\x20(entity_order\x20roles),\x20and\x20object\x20footprint.\x20Fresh\x20accounts\x20voting\x20in\x20volume\x20read\x20as\x20an\x20organized\x20reputation\x20push,\x20not\x20organic\x20discovery.','suggestion':'Down-weight\x20votes\x20from\x20the\x20flagged\x20accounts\x20in\x20account-level\x20reputation\x20aggregates;\x20inspect\x20their\x20registration\x20referrers\x20and\x20object\x20footprint\x20for\x20a\x20shared\x20origin\x20before\x20trusting\x20the\x20targets\x27\x20like\x20counts.',...e['exposure']?{'exposure':e['exposure']}:{}})];}},AC6={'id':'AC6','kind':'risk','run'(a){const {votes:b}=projectVoteEvidence(a),c=detectVoteReciprocity(b)[0x0];if(!c)return[];const d=graphFindingPolicy('AC6',{'ac_signal_level':c['severity']});if(!d['enabled'])return[];return[makeFinding(a,'AC6:'+c['refs']?.['join'](','),'risk','Vote-ring\x20suspicion:\x20mutual\x20votes\x20between\x20address\x20pairs',{'severity':d['severity']??c['severity'],'path':['EOA-A','target.vote','EOA-B'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':c['description']+'.\x20The\x20registrar\x20carries\x20no\x20order\x20binding,\x20so\x20a\x20like\x20costs\x20only\x20gas\x20—\x20symmetric\x20voting\x20pairs\x20are\x20the\x20cheapest\x20way\x20to\x20manufacture\x20mutual\x20account-level\x20reputation.','suggestion':'Treat\x20mutual\x20pairs\x20as\x20correlated\x20voters:\x20exclude\x20the\x20reciprocal\x20legs\x20from\x20aggregate\x20scoring\x20and\x20check\x20whether\x20the\x20pairs\x20share\x20order\x20history,\x20referrer,\x20or\x20object\x20footprint.',...d['exposure']?{'exposure':d['exposure']}:{}})];}},AC7={'id':'AC7','kind':'risk','run'(a){const {votes:b,profiles:c}=projectVoteEvidence(a),d=detectTargetFlood(b,c,Date['now']());if(d['length']===0x0)return[];const e=[];for(const f of d){const g=graphFindingPolicy('AC7',{'ac_signal_level':f['severity']});if(!g['enabled'])continue;e['push'](makeFinding(a,'AC7:'+f['refs']?.['join'](','),'risk','Vote-noise\x20suspicion:\x20an\x20address\x27s\x20votes\x20are\x20dominated\x20by\x20low-credibility\x20accounts',{'severity':g['severity']??f['severity'],'path':['EOA','entity.profile','target.vote'],'pathEdges':voteCheatEdges(a),'roles':ANTI_CHEAT_ROLES,'detail':f['description']+'\x20(target:\x20'+f['refs']?.[0x0]+').\x20This\x20is\x20the\x20voter-side\x20mirror\x20of\x20AC1-AC3:\x20the\x20merchant-side\x20reputation\x20anchors\x20on\x20orders\x20with\x20fund\x20closure,\x20while\x20the\x20account-level\x20vote\x20ring\x20has\x20no\x20such\x20gate\x20—\x20its\x20aggregate\x20is\x20only\x20as\x20good\x20as\x20the\x20voters.','suggestion':'Flag\x20the\x20target\x27s\x20vote\x20aggregate\x20as\x20untrusted\x20until\x20the\x20low-credibility\x20share\x20drops;\x20rank\x20exposure\x20by\x20the\x20order-backed\x20reputation\x20layer\x20instead\x20of\x20the\x20vote\x20bitmap.',...g['exposure']?{'exposure':g['exposure']}:{}}));if(e['length']>=MAX_FINDINGS_PER_RULE)break;}return e;}};export const DEFAULT_ANALYZERS=[R1,R2,R3,R4,R5,R6,R7,A1,A2,A3,A4,O1,O2,O3,O4,G1,G2,G3,AC1,AC2,AC3,AC4,AC5,AC6,AC7,PROPOSAL_GAP_ANALYZER];const registry=new Map(DEFAULT_ANALYZERS['map'](b=>[b['id'],b]));export function registerAnalyzer(a){registry['set'](a['id'],a);}export function getAnalyzer(a){return registry['get'](a);}export function listAnalyzers(){return[...registry['keys']()];}export function runAnalyzers(a,b){const c=b?.['only']?new Set(b['only']):undefined,d=[];beginPolicyRun();try{for(const e of registry['values']()){if(c&&!c['has'](e['id']))continue;if(b?.['kinds']&&!b['kinds']['includes'](e['kind']))continue;try{d['push'](...e['run'](a));}catch{}}}finally{endPolicyRun();}return withFindingObjects(d);}const ADDRESS_RE=/\b0x[0-9a-fA-F]{40,64}\b/g;export function withFindingObjects(a){for(const b of a){const c=[],d=new Set(),e=g=>{const h=g['toLowerCase']();if(d['has'](h))return;d['add'](h),c['push'](h);};for(const g of b['path']){if(/^0x[0-9a-fA-F]{40,64}$/['test'](g['trim']()))e(g['trim']());}for(const h of b['detail']['matchAll'](ADDRESS_RE))e(h[0x0]);if(c['length']>0x0)b['objects']=c['slice'](0x0,0xc);}return a;}export function adaptNodeAnalyzer(a){return{'id':a['id'],'kind':a['kind'],'objectType':a['objectType'],'run'(b,c){const d=a['inspect'](b,c);return d['map']((e,f)=>({'id':a['id']+':'+b['id']+'#'+f,'kind':a['kind'],'severity':e['severity']??'info','title':e['title'],'path':[b['id']],'confidence':e['confidence']??'exact','roles':e['roles']??['neutral'],'detail':e['detail'],'suggestion':e['suggestion'],...e['ruleId']?{'ruleId':e['ruleId']}:{},...e['evidence']?{'evidence':e['evidence']}:{},...e['exposure']?{'exposure':e['exposure']}:{},...e['nativeRisk']!==undefined?{'nativeRisk':e['nativeRisk']}:{},...b['proposal']&&!e['confidence']?{'confidence':'derived'}:{},...b['proposal']?{'source':b['proposal']['provenance']==='external'?'external':'proposal'}:{}}));}};}export function runNodeAnalyzers(a,b){const c=[];beginPolicyRun();try{for(const d of b){for(const e of a['visibleNodes']){const f=a['graph']['nodes']['get'](e);if(f?.['kind']!=='object'||d['objectType']!=='*'&&f['objectType']!==d['objectType']||!f['raw'])continue;try{c['push'](...d['run'](f,a));}catch{}}}}finally{endPolicyRun();}return withFindingObjects(c);}