@wowok/agent-mcp 3.2.6 → 3.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/dist/chain-semantics/field-capability.js +1 -1
  2. package/dist/chain-semantics/freeze-map.js +1 -1
  3. package/dist/chain-semantics/object-graph.js +1 -1
  4. package/dist/communication/wts-attestation.js +1 -1
  5. package/dist/composition/audit.js +1 -1
  6. package/dist/composition/compile.d.ts +3 -2
  7. package/dist/composition/compile.js +1 -1
  8. package/dist/composition/inflight.d.ts +17 -0
  9. package/dist/composition/inflight.js +1 -0
  10. package/dist/config/config-audit.spec.js +1 -1
  11. package/dist/customer/account-events.js +1 -1
  12. package/dist/customer/order-monitor.js +1 -1
  13. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  14. package/dist/evaluation/engine.js +1 -1
  15. package/dist/experience/realtime-feedback.js +1 -1
  16. package/dist/extensions/constraint-registry.d.ts +6 -1
  17. package/dist/extensions/constraint-registry.js +1 -1
  18. package/dist/extensions/index.d.ts +1 -1
  19. package/dist/extensions/index.js +1 -1
  20. package/dist/extensions/industry-pack.d.ts +5 -0
  21. package/dist/extensions/industry-pack.js +1 -1
  22. package/dist/extensions/mode-evaluator.d.ts +3 -2
  23. package/dist/extensions/mode-evaluator.js +1 -1
  24. package/dist/extensions/modes.js +1 -1
  25. package/dist/graph/onchain/analyze.js +1 -1
  26. package/dist/graph/onchain/analyze.spec.js +1 -1
  27. package/dist/graph/onchain/anti-cheat.d.ts +32 -2
  28. package/dist/graph/onchain/anti-cheat.js +1 -1
  29. package/dist/graph/onchain/anti-cheat.spec.js +1 -1
  30. package/dist/graph/onchain/expand.js +1 -1
  31. package/dist/graph/onchain/exposure.js +1 -1
  32. package/dist/graph/onchain/extract.js +1 -1
  33. package/dist/graph/onchain/graph-policy.spec.js +1 -1
  34. package/dist/graph/onchain/index.d.ts +2 -2
  35. package/dist/graph/onchain/index.js +1 -1
  36. package/dist/graph/onchain/project-relationship.js +1 -1
  37. package/dist/graph/onchain/table-ledger.spec.js +1 -1
  38. package/dist/graph/onchain/types.d.ts +3 -0
  39. package/dist/harness/recover.js +1 -1
  40. package/dist/index.js +1 -1
  41. package/dist/knowledge/arbitration-venue-order.d.ts +25 -0
  42. package/dist/knowledge/arbitration-venue-order.js +1 -0
  43. package/dist/knowledge/audit-rules.d.ts +10 -0
  44. package/dist/knowledge/audit-rules.js +1 -1
  45. package/dist/knowledge/baselines/risk-baselines.spec.js +1 -1
  46. package/dist/knowledge/baselines/rules/graph.json +81 -0
  47. package/dist/knowledge/baselines/rules/machine.json +3 -3
  48. package/dist/knowledge/baselines/rules/plan.json +80 -2
  49. package/dist/knowledge/builtin-templates.d.ts +17 -2
  50. package/dist/knowledge/builtin-templates.js +1 -1
  51. package/dist/knowledge/discount-threshold.js +1 -1
  52. package/dist/knowledge/event-semantics.js +1 -1
  53. package/dist/knowledge/getting-started.js +1 -1
  54. package/dist/knowledge/guard-bindings.js +1 -1
  55. package/dist/knowledge/guard-design-patterns.js +1 -1
  56. package/dist/knowledge/guard-field-cognition.js +1 -1
  57. package/dist/knowledge/guard-ledger.js +1 -1
  58. package/dist/knowledge/guard-lint.d.ts +1 -0
  59. package/dist/knowledge/guard-lint.js +1 -1
  60. package/dist/knowledge/guard-node-gates.d.ts +4 -0
  61. package/dist/knowledge/guard-node-gates.js +1 -0
  62. package/dist/knowledge/guard-puzzle.js +1 -1
  63. package/dist/knowledge/guard-risk.js +1 -1
  64. package/dist/knowledge/guard-submission-prompt.d.ts +1 -0
  65. package/dist/knowledge/guard-submission-prompt.js +1 -1
  66. package/dist/knowledge/guard-templates.d.ts +2 -1
  67. package/dist/knowledge/guard-templates.js +1 -1
  68. package/dist/knowledge/guard-translation.js +1 -1
  69. package/dist/knowledge/index.d.ts +2 -2
  70. package/dist/knowledge/index.js +1 -1
  71. package/dist/knowledge/industry-registry.js +1 -1
  72. package/dist/knowledge/jsonrpc-enum.js +1 -1
  73. package/dist/knowledge/machine-topology.d.ts +6 -0
  74. package/dist/knowledge/machine-topology.js +1 -1
  75. package/dist/knowledge/reputation-rules.d.ts +3 -9
  76. package/dist/knowledge/reputation-rules.js +1 -1
  77. package/dist/knowledge/safety-rules.d.ts +10 -1
  78. package/dist/knowledge/safety-rules.js +1 -1
  79. package/dist/knowledge/scenario-modes.js +1 -1
  80. package/dist/knowledge/settlement-semantics.d.ts +1 -0
  81. package/dist/knowledge/settlement-semantics.js +1 -0
  82. package/dist/knowledge/template-loader.d.ts +22 -0
  83. package/dist/knowledge/template-loader.js +1 -1
  84. package/dist/knowledge/template-registry.js +1 -1
  85. package/dist/knowledge/template-scanner.d.ts +14 -0
  86. package/dist/knowledge/template-scanner.js +1 -1
  87. package/dist/knowledge/tools-reference.js +1 -1
  88. package/dist/knowledge/workflow-guidance.d.ts +1 -0
  89. package/dist/knowledge/workflow-guidance.js +1 -1
  90. package/dist/monitor/MonitorLoop.js +1 -1
  91. package/dist/participation/allocation-advice.js +1 -1
  92. package/dist/participation/customer-interest.js +1 -1
  93. package/dist/participation/radar-core.d.ts +6 -1
  94. package/dist/participation/radar-core.js +1 -1
  95. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  96. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  97. package/dist/playbooks/service-build/merchant-guide.d.ts +38 -15
  98. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  99. package/dist/playbooks/service-build/migration-planner.d.ts +7 -0
  100. package/dist/playbooks/service-build/migration-planner.js +1 -1
  101. package/dist/playbooks/service-build/object-panorama.js +1 -1
  102. package/dist/playbooks/service-build/participation-radar.js +1 -1
  103. package/dist/playbooks/service-build/pipeline-actions.d.ts +1 -1
  104. package/dist/playbooks/service-build/pipeline-actions.js +1 -1
  105. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  106. package/dist/playbooks/service-build/risk-aggregator.d.ts +1 -1
  107. package/dist/playbooks/service-build/risk-aggregator.js +1 -1
  108. package/dist/playbooks/service-build/service-panorama.js +1 -1
  109. package/dist/playbooks/service-build/service-quote.js +1 -1
  110. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  111. package/dist/relationship/derivation.d.ts +1 -0
  112. package/dist/review/index.js +1 -1
  113. package/dist/runtime/instance-registry.d.ts +8 -0
  114. package/dist/runtime/instance-registry.js +1 -0
  115. package/dist/safety/confirm-gate.js +1 -1
  116. package/dist/schema/benchmark-migration/index.d.ts +14 -0
  117. package/dist/schema/benchmark-migration/index.js +1 -1
  118. package/dist/schema/call/arbitration.js +1 -1
  119. package/dist/schema/call/base.d.ts +109 -0
  120. package/dist/schema/call/base.js +1 -1
  121. package/dist/schema/call/bridge.d.ts +14 -0
  122. package/dist/schema/call/contact.js +1 -1
  123. package/dist/schema/call/error-codes.d.ts +1 -1
  124. package/dist/schema/call/error-codes.js +1 -1
  125. package/dist/schema/call/guard.d.ts +7 -0
  126. package/dist/schema/call/guard.js +1 -1
  127. package/dist/schema/call/handler.js +1 -1
  128. package/dist/schema/call/machine.d.ts +7 -0
  129. package/dist/schema/call/machine.js +1 -1
  130. package/dist/schema/call/payment.js +1 -1
  131. package/dist/schema/call/permission-handler.js +1 -1
  132. package/dist/schema/call/progress.d.ts +46 -0
  133. package/dist/schema/call/progress.js +1 -1
  134. package/dist/schema/call/semantic.js +1 -1
  135. package/dist/schema/call/service.d.ts +8 -8
  136. package/dist/schema/call/service.js +1 -1
  137. package/dist/schema/common/index.js +1 -1
  138. package/dist/schema/goal/index.d.ts +11 -0
  139. package/dist/schema/goal/planning.d.ts +32 -1
  140. package/dist/schema/goal/planning.js +1 -1
  141. package/dist/schema/industry-pack/index.d.ts +40 -0
  142. package/dist/schema/industry-pack/index.js +1 -1
  143. package/dist/schema/keeper/index.d.ts +13 -0
  144. package/dist/schema/local/index.d.ts +75 -0
  145. package/dist/schema/local/index.js +1 -1
  146. package/dist/schema/messenger/index.d.ts +17 -0
  147. package/dist/schema/messenger/index.js +1 -1
  148. package/dist/schema/operations.d.ts +39 -2
  149. package/dist/schema/operations.js +1 -1
  150. package/dist/schema/query/bi.d.ts +64 -0
  151. package/dist/schema/query/bi.js +1 -1
  152. package/dist/schema/query/index.d.ts +94 -0
  153. package/dist/schema/query/index.js +1 -1
  154. package/dist/schema/schema-version.d.ts +1 -1
  155. package/dist/schema/schema-version.js +1 -1
  156. package/dist/schema/utils/permission-machine-check.js +1 -1
  157. package/dist/schema/workspace/index.d.ts +1 -1
  158. package/dist/schema-query-impl/index.js +1 -1
  159. package/dist/schemas/account_operation.output.json +45 -0
  160. package/dist/schemas/benchmark_migration_operation.output.json +24 -4
  161. package/dist/schemas/benchmark_migration_operation.schema.json +70 -0
  162. package/dist/schemas/bridge_operation.output.json +45 -0
  163. package/dist/schemas/goal_operation.schema.json +78 -0
  164. package/dist/schemas/guard2file.output.json +6 -1
  165. package/dist/schemas/guard2file.schema.json +9 -0
  166. package/dist/schemas/index.json +1 -1
  167. package/dist/schemas/industry_pack_operation.output.json +91 -0
  168. package/dist/schemas/industry_pack_operation.schema.json +19 -1
  169. package/dist/schemas/keeper_operation.output.json +44 -0
  170. package/dist/schemas/local_cache_operation.output.json +45 -0
  171. package/dist/schemas/local_history_operation.output.json +45 -0
  172. package/dist/schemas/local_info_operation.output.json +45 -0
  173. package/dist/schemas/local_mark_operation.output.json +45 -0
  174. package/dist/schemas/machineNode2file.output.json +6 -1
  175. package/dist/schemas/machineNode2file.schema.json +9 -0
  176. package/dist/schemas/messenger_operation.output.json +52 -0
  177. package/dist/schemas/monitor_events.output.json +44 -0
  178. package/dist/schemas/monitor_subscription.output.json +44 -0
  179. package/dist/schemas/onchain_events.output.json +44 -0
  180. package/dist/schemas/onchain_operations.output.json +133 -0
  181. package/dist/schemas/onchain_operations.schema.json +73 -16
  182. package/dist/schemas/onchain_operations_arbitration.schema.json +2 -1
  183. package/dist/schemas/onchain_operations_contact.schema.json +2 -2
  184. package/dist/schemas/onchain_operations_guard.schema.json +2 -2
  185. package/dist/schemas/onchain_operations_machine.schema.json +2 -2
  186. package/dist/schemas/onchain_operations_payment.schema.json +1 -1
  187. package/dist/schemas/onchain_operations_progress.schema.json +57 -0
  188. package/dist/schemas/onchain_operations_service.schema.json +7 -8
  189. package/dist/schemas/onchain_table_data.output.json +81 -13
  190. package/dist/schemas/onchain_table_data.schema.json +21 -21
  191. package/dist/schemas/query_toolkit.output.json +218 -9
  192. package/dist/schemas/query_toolkit.schema.json +50 -26
  193. package/dist/schemas/wowok_buildin_info.output.json +80 -1
  194. package/dist/schemas/wowok_buildin_info.schema.json +1 -1
  195. package/dist/tools/handlers/benchmark-migration.d.ts +1 -0
  196. package/dist/tools/handlers/benchmark-migration.js +1 -1
  197. package/dist/tools/handlers/config.js +1 -1
  198. package/dist/tools/handlers/file-export.js +1 -1
  199. package/dist/tools/handlers/industry-pack.js +1 -1
  200. package/dist/tools/handlers/messenger.js +1 -1
  201. package/dist/tools/handlers/onchain.js +1 -1
  202. package/dist/tools/handlers/review-chain.d.ts +22 -0
  203. package/dist/tools/handlers/review-chain.js +1 -0
  204. package/dist/tools/registry/agent.js +1 -1
  205. package/dist/tools/registry/business.js +1 -1
  206. package/dist/tools/registry/config.js +1 -1
  207. package/dist/tools/registry/evaluation.js +1 -1
  208. package/dist/tools/registry/files.js +1 -1
  209. package/dist/tools/registry/identity.js +1 -1
  210. package/dist/tools/registry/local.js +1 -1
  211. package/dist/tools/registry/messenger.js +1 -1
  212. package/dist/tools/registry/monitor.js +1 -1
  213. package/dist/tools/registry/onchain.js +1 -1
  214. package/dist/tools/registry/query.js +1 -1
  215. package/dist/tools/rules-hook.js +1 -1
  216. package/dist/tools/runtime-health.d.ts +10 -0
  217. package/dist/tools/runtime-health.js +1 -0
  218. package/dist/tools/upgrade-check.d.ts +10 -1
  219. package/dist/tools/upgrade-check.js +1 -1
  220. package/dist/tools/wrap.d.ts +3 -0
  221. package/dist/tools/wrap.js +1 -1
  222. package/package.json +2 -2
@@ -1 +1 @@
1
- import{detectFakeOrders,detectShellMerchant}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'(a){const b=[];for(const c of typedNodes(a,'Service')){const f=root(c),g=out(a,c['id'],'service.order');if(g['length']===0x0)continue;let h=0x0n,i=0x0;for(const o of g){const p=root(a['graph']['nodes']['get'](o['to']));if(!p)continue;h+=big(p['amount']),i++;}if(i===0x0)continue;const j=big(f['compensation_fund']),k=h*0x3n;if(j>=k)continue;const l=c['coinType']?{'coin_type':c['coinType']}:{},m=j<h?'high':'medium',n=graphFindingPolicy('R2',{'r2_level':m});if(!n['enabled'])continue;b['push'](makeFinding(a,'R2:'+c['id'],'risk','Payout\x20exposure:\x20compensation\x20fund\x20is\x20below\x20the\x203x\x20ceiling\x20of\x20windowed\x20order\x20amounts',{'severity':n['severity']??m,'path':[c['id'],'service.order','Order.amount','Service.compensation_fund'],'pathEdges':g,'roles':['neutral','system','merchant','buyer'],'detail':'Compensation\x20fund\x20{fund};\x20'+i+'\x20windowed\x20orders\x20total\x20{amount};\x20'+'the\x20per-order\x20statutory\x20payout\x20cap\x20of\x203x\x20amount\x20gives\x20a\x20structural\x20total\x20exposure\x20of\x20{needed}.','suggestion':'Top\x20up\x20compensation_fund\x20to\x20more\x20than\x203x\x20the\x20windowed\x20amount,\x20or\x20reduce\x20open\x20order\x20volume\x20within\x20the\x20window.','amounts':[{'key':'fund','label':'Compensation\x20fund','raw':j['toString'](),...l},{'key':'amount','label':'Windowed\x20order\x20total','raw':h['toString'](),...l},{'key':'needed','label':'Structural\x20exposure\x20ceiling\x20(3x)','raw':k['toString'](),...l}],...n['exposure']?{'exposure':n['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},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;}};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':'Bind\x20at\x20least\x20one\x20Arbitration\x20in\x20a\x20different\x20group\x20than\x20the\x20shop\x20Permission\x20before\x20publishing;\x20shops\x20without\x20a\x20remedy\x20path\x20should\x20not\x20be\x20recommended.'},'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':'Bind\x20an\x20arbitration\x20service\x20before\x20advertising\x20payout\x20guarantees;\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;}};export const DEFAULT_ANALYZERS=[R1,R2,R3,R4,R5,R6,R7,A1,A2,A3,A4,O1,O2,O3,G1,G2,G3,AC1,AC2,AC3,AC4,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'(a){const b=[];for(const c of typedNodes(a,'Service')){const f=root(c),g=out(a,c['id'],'service.order');if(g['length']===0x0)continue;let h=0x0n,i=0x0;for(const o of g){const p=root(a['graph']['nodes']['get'](o['to']));if(!p)continue;h+=big(p['amount']),i++;}if(i===0x0)continue;const j=big(f['compensation_fund']),k=h*0x3n;if(j>=k)continue;const l=c['coinType']?{'coin_type':c['coinType']}:{},m=j<h?'high':'medium',n=graphFindingPolicy('R2',{'r2_level':m});if(!n['enabled'])continue;b['push'](makeFinding(a,'R2:'+c['id'],'risk','Payout\x20exposure:\x20compensation\x20fund\x20is\x20below\x20the\x203x\x20ceiling\x20of\x20windowed\x20order\x20amounts',{'severity':n['severity']??m,'path':[c['id'],'service.order','Order.amount','Service.compensation_fund'],'pathEdges':g,'roles':['neutral','system','merchant','buyer'],'detail':'Compensation\x20fund\x20{fund};\x20'+i+'\x20windowed\x20orders\x20total\x20{amount};\x20'+'the\x20per-order\x20statutory\x20payout\x20cap\x20of\x203x\x20amount\x20gives\x20a\x20structural\x20total\x20exposure\x20of\x20{needed}.','suggestion':'Top\x20up\x20compensation_fund\x20to\x20more\x20than\x203x\x20the\x20windowed\x20amount,\x20or\x20reduce\x20open\x20order\x20volume\x20within\x20the\x20window.','amounts':[{'key':'fund','label':'Compensation\x20fund','raw':j['toString'](),...l},{'key':'amount','label':'Windowed\x20order\x20total','raw':h['toString'](),...l},{'key':'needed','label':'Structural\x20exposure\x20ceiling\x20(3x)','raw':k['toString'](),...l}],...n['exposure']?{'exposure':n['exposure']}:{}}));if(b['length']>=MAX_FINDINGS_PER_RULE)break;}return b;}},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 +1 @@
1
- import{describe,it,expect}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{buildViewport,runAnalyzers,runNodeAnalyzers,adaptNodeAnalyzer,listAnalyzers,registerAnalyzer,findingWhere}from'./index.js';describe('findingWhere',()=>{it('renders\x20R4\x20as\x20machine\x20+\x20node\x20names\x20(no\x20::node::\x20grammar,\x20no\x20R4:\x20prefix)',()=>{expect(findingWhere({'id':'R4:myshop_machine:myshop_machine::node::Order\x20Confirmed→myshop_machine::node::Order\x20Cancel'}))['toBe']('myshop_machine:\x20Order\x20Confirmed\x20→\x20Order\x20Cancel');}),it('renders\x20R7/R2\x20as\x20object\x20kind\x20+\x20name',()=>{expect(findingWhere({'id':'R7:reward:0x1f2e'}))['toBe']('Reward\x200x1f2e'),expect(findingWhere({'id':'R7:treasury:0xabc'}))['toBe']('Treasury\x200xabc'),expect(findingWhere({'id':'R2:0x14519d'}))['toBe']('0x14519d');}),it('falls\x20back\x20to\x20the\x20finding\x20title\x20for\x20unknown\x20id\x20shapes',()=>{expect(findingWhere({'id':'R1:weird','title':'Arb\x20permission\x20shared\x20with\x20the\x20merchant'}))['toBe']('Arb\x20permission\x20shared\x20with\x20the\x20merchant');});});const FAMILY={'eoa.permission':'R','permission.core_binding':'R','permission.entity':'W','service.order':'R','service.machine':'F','service.buy_guard':'F','machine.permission':'F','machine.node':'W','wf.transition':'W','wf.forward_guard':'W','order.allocation':'F','demand.guard':'R','demand.presenter':'R','arbitration.voting_guard':'F','arb.arbitration_service':'F','arb.voter':'S'};class GB{['nodes']=new Map();['edges']=[];['out']=new Map();['inc']=new Map();['truncations']=[];['eoa'](a){return this['nodes']['set'](a,{'id':a,'kind':'eoa','state':'fetched','origins':[],'depth':0x0}),this;}['obj'](a,b,c,d){return this['nodes']['set'](a,{'id':a,'kind':'object','objectType':b,'state':'fetched','origins':[],'depth':0x1,'raw':{'object':a,'type':b,...d?{'type_raw':d}:{},'data':c}}),this;}['edge'](a,b,c,d,f,g=![]){const h={'id':a+'|'+b+'→'+c+(d?.['forward']?'|'+d['forward']:''),'schema':a,'family':FAMILY[a]??'F','from':b,'to':c,'retention':f??(FAMILY[a]==='R'?'bounded_exact':'complete'),'observedAt':0x1,...d?{'payload':d}:{},...g?{'truncated':!![]}:{}};return this['edges']['push'](h),(this['out']['get'](b)??this['out']['set'](b,[])['get'](b))['push'](h),(this['inc']['get'](c)??this['inc']['set'](c,[])['get'](c))['push'](h),h;}['trunc'](a,b,c){return this['truncations']['push']({'nodeId':a,'schema':b,'observed':c,'limit':0x1450}),this;}['build'](a='0xseed'){return{'network':ENTRYPOINT['Mainnet'],'seed':a,'builtAt':0x1,'nodes':this['nodes'],'edges':this['edges'],'out':this['out'],'inc':this['inc'],'gaps':[],'truncations':this['truncations'],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['vp'](a='0xseed',b='neutral'){return buildViewport(this['build'](a),a,b);}}const ids=a=>a['map'](b=>b['id']);describe('analyze\x20—\x20registry',()=>{it('ships\x20the\x2022\x20rules\x20(R1-7/A1-4/O1-3/G1-3\x20+\x20anti-cheat\x20AC1-4\x20+\x20proposal.gap)',()=>{expect(listAnalyzers()['sort']())['toEqual'](['R1','R2','R3','R4','R5','R6','R7','A1','A2','A3','A4','O1','O2','O3','G1','G2','G3','AC1','AC2','AC3','AC4','proposal.gap']['sort']());}),it('is\x20fail-soft:\x20a\x20throwing\x20analyzer\x20never\x20aborts\x20the\x20suite',()=>{registerAnalyzer({'id':'__boom','kind':'risk','run':()=>{throw new Error('boom');}});const a=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['vp'](),b=runAnalyzers(a,{'only':['__boom','R6']});expect(ids(b))['toContain']('R6:0xs1'),expect(b['find'](c=>c['id']['startsWith']('__boom')))['toBeUndefined']();}),it('adapts\x20single-object\x20legacy\x20rules\x20through\x20the\x20NodeAnalyzer\x20bridge',()=>{const a=adaptNodeAnalyzer({'id':'legacy-lock','kind':'risk','objectType':'Service','inspect':e=>{const f=e['raw']['data']??{};return f['setting_lock_duration']==='0'?[{'title':'Lock','detail':'d','suggestion':'s','roles':['merchant']}]:[];}}),b=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['vp'](),c=runNodeAnalyzers(b,[a]);expect(c)['toHaveLength'](0x1),expect(c[0x0]['id'])['toBe']('legacy-lock:0xs1#0'),expect(c[0x0]['kind'])['toBe']('risk');});}),describe('analyze\x20—\x20risk\x20rules',()=>{it('R6\x20flags\x20published\x20services\x20without\x20a\x20setting\x20lock',()=>{const a=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['obj']('0xs2','Service',{'bPublished':!![],'setting_lock_duration':'2592000000'})['obj']('0xs3','Service',{'bPublished':![],'setting_lock_duration':'0'})['vp'](),b=runAnalyzers(a,{'only':['R6']});expect(ids(b))['toEqual'](['R6:0xs1']);}),it('R7\x20emits\x20CRITICAL\x20for\x20object\x20users\x20when\x20a\x20Treasury\x20has\x20mounted\x20external\x20withdraw\x20Guards',()=>{const a=new GB();a['obj']('0xt1','Treasury',{'external_withdraw_guard':[{'guard':'0xg1','identifier':0x0,'store_from_id':0x0}]}),a['obj']('0xt2','Treasury',{'external_withdraw_guard':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:treasury:0xt1']),expect(b[0x0]['severity'])['toBe']('critical'),expect(b[0x0]['detail'])['toContain']('code\x2010');}),it('R7\x20emits\x20CRITICAL\x20for\x20object\x20users\x20when\x20a\x20Reward\x20has\x20mounted\x20claim\x20Guards',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1'}]}),a['obj']('0xr2','Reward',{'guards':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('critical'),expect(b[0x0]['detail'])['toContain']('GuardIdentifier');}),it('R7\x20downgrades\x20to\x20info\x20when\x20every\x20payout\x20slot\x20is\x20provably\x20bound\x20(guard\x20defs\x20fetched)',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1','recipient':'0xmerchant'}]}),a['obj']('0xg1','Guard',{'root':{'type':'true'},'table':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('info'),expect(b[0x0]['title'])['toContain']('downgraded\x20hint'),expect(b[0x0]['detail'])['toContain']('1\x20blocked,\x200\x20viable');}),it('R7\x20keeps\x20CRITICAL\x20when\x20a\x20fetched\x20guard\x20leaves\x20the\x20payout\x20slot\x20viable',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1','recipient':'Signer'}]}),a['obj']('0xg1','Guard',{'root':{'type':'true'},'table':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('critical');}),it('R7\x20carries\x20drill-through\x20objects\x20—\x20the\x20FULL\x20reward\x20address\x20from\x20path/detail',()=>{const a='0x1a77893aaa0f0000000000000000000000000000000000000000000000aa1234',b=new GB();b['obj'](a,'Reward',{'guards':[{'guard':'0xg1'}]});const c=runAnalyzers(b['vp'](),{'only':['R7']});expect(c)['toHaveLength'](0x1),expect(c[0x0]['objects'])['toEqual']([a]);}),it('R2\x20measures\x20the\x20compensation\x20fund\x20against\x203x\x20windowed\x20order\x20volume',()=>{const a=new GB();a['obj']('0xs1','Service',{'bPublished':!![],'compensation_fund':'100'}),a['obj']('0xo1','Order',{'amount':'100'}),a['obj']('0xo2','Order',{'amount':'100'}),a['edge']('service.order','0xs1','0xo1',undefined,'bounded_window'),a['edge']('service.order','0xs1','0xo2',undefined,'bounded_window',!![]);const b=runAnalyzers(a['vp'](),{'only':['R2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['severity'])['toBe']('high'),expect(b[0x0]['confidence'])['toBe']('windowed'),expect(b[0x0]['window']?.['limit'])['toBe'](0x1450),expect(b[0x0]['detail'])['toContain']('{fund}'),expect(b[0x0]['detail'])['not']['toContain']('base\x20units'),expect(b[0x0]['amounts']?.['map'](c=>c['key']))['toEqual'](['fund','amount','needed']),expect(b[0x0]['amounts']?.['every'](c=>c['raw']==='100'||c['raw']==='200'||c['raw']==='600'))['toBe'](!![]);}),it('R1\x20flags\x20one\x20EOA\x20controlling\x20a\x20shop\x20and\x20an\x20arbitration\x20service\x20across\x20distinct\x20permissions',()=>{const a=new GB();a['eoa']('0xe1'),a['obj']('0xp1','Permission',{'owner':'0xe1'}),a['obj']('0xp2','Permission',{'owner':'0xe1'}),a['obj']('0xs1','Service',{}),a['obj']('0xa1','Arbitration',{'fee':'0'}),a['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x3}),a['edge']('eoa.permission','0xe1','0xp2',{'roleBits':0x3}),a['edge']('permission.core_binding','0xp1','0xs1'),a['edge']('permission.core_binding','0xp2','0xa1');const b=runAnalyzers(a['vp'](),{'only':['R1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['severity'])['toBe']('high');const c=new GB();c['eoa']('0xe1')['obj']('0xp1','Permission',{})['obj']('0xs1','Service',{})['obj']('0xa1','Arbitration',{'fee':'0'}),c['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x3}),c['edge']('permission.core_binding','0xp1','0xs1'),c['edge']('permission.core_binding','0xp1','0xa1'),expect(runAnalyzers(c['vp'](),{'only':['R1']}))['toHaveLength'](0x0);}),it('R3\x20flags\x20concentrated\x20control\x20of\x20core\x20objects',()=>{const a=new GB();a['eoa']('0xe1')['obj']('0xp1','Permission',{}),a['obj']('0xs1','Service',{})['obj']('0xs2','Service',{})['obj']('0xm1','Machine',{}),a['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x1});for(const c of['0xs1','0xs2','0xm1'])a['edge']('permission.core_binding','0xp1',c);const b=runAnalyzers(a['vp'](),{'only':['R3']});expect(ids(b))['toEqual'](['R3:0xe1']);}),it('R4\x20flags\x20a\x20unique\x20operator\x20with\x20no\x20backup\x20guard\x20on\x20a\x20terminal-entering\x20forward',()=>{const a=new GB();a['obj']('0xm1','Machine',{'bPublished':!![]}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::delivered',{'node':'delivered','prevNode':'paid','forward':'go','namedOperator':'alice'});const b=runAnalyzers(a['vp'](),{'only':['R4']});expect(b)['toHaveLength'](0x1);const c=new GB();c['obj']('0xm1','Machine',{'bPublished':!![]}),c['edge']('wf.transition','0xm1::node::paid','0xm1::node::delivered',{'node':'delivered','prevNode':'paid','forward':'go','namedOperator':'alice','guard':'0xg1'}),expect(runAnalyzers(c['vp'](),{'only':['R4']}))['toHaveLength'](0x0);}),it('R5\x20reports\x20window\x20truncations\x20as\x20downgraded\x20meta\x20findings',()=>{const a=new GB()['obj']('0xs1','Service',{})['trunc']('0xs1','service.order',0x1450),b=runAnalyzers(a['vp'](),{'only':['R5']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['confidence'])['toBe']('windowed'),expect(b[0x0]['window'])['toEqual']({'observed':0x1450,'limit':0x1450});});}),describe('analyze\x20—\x20arbitrage\x20rules',()=>{it('A1\x20detects\x20rate-basis\x20mismatch,\x20surplus\x20duplication\x20and\x20missing\x20max',()=>{const a=new GB();a['obj']('0xal1','Allocation',{'allocators':[{'guard':'0xg1','max':null,'sharing':[{'who':'0xa','mode':0x0,'sharing':'100'}]},{'guard':'0xg2','sharing':[{'who':'0xb','mode':0x1,'sharing':'9000'}]},{'guard':'0xg3','sharing':[{'who':'0xc','mode':0x2}]},{'guard':'0xg4','sharing':[{'who':'0xd','mode':0x2}]}]});const b=runAnalyzers(a['vp'](),{'only':['A1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('9000'),expect(b[0x0]['detail'])['toContain']('max'),expect(b[0x0]['detail'])['toContain']('Surplus');}),it('A1\x20fires\x20on\x20the\x20real\x20on-chain\x20container\x20shape\x20{threshold,\x20allocators:[…]}',()=>{const a=new GB();a['obj']('0xal2','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xg2','sharing':[{'who':'0xb','mode':0x1,'sharing':'9000'}]}]}});const b=runAnalyzers(a['vp'](),{'only':['A1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('9000');}),it('A4\x20detects\x20Surplus-then-Rate\x20drain\x20across\x20distinct\x20guards',()=>{const a=new GB();a['obj']('0xal3','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xgsettle','sharing':[{'who':'0xmerchant','mode':0x1,'sharing':'9000'},{'who':'0xplatform','mode':0x2}]},{'guard':'0xgrefund','sharing':[{'who':'0xbuyer','mode':0x1,'sharing':'10000'}]}]},'payment_info':{'for_object':'0xorder1'},'balance':'1000000'});const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:drain:0xal3'),expect(b[0x0]['detail'])['toContain']('0xgrefund');}),it('A4\x20flags\x20unanchored\x20GuardIdentifier\x20recipients',()=>{const a=new GB();a['obj']('0xal4','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xgpay','sharing':[{'who':{'GuardIdentifier':0x1},'mode':0x1,'sharing':'10000'}]}]},'balance':'500'});const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:unanchored:0xal4');}),it('A4\x20flags\x20settlement\x20deadlock:\x20completed\x20order\x20on\x20an\x20allocator-less\x20pool',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::completed',{'node':'completed','prevNode':'paid','forward':'settle'}),a['obj']('0xpr9','Progress',{'current':'completed','machine':'0xm1'}),a['obj']('0xord9','Order',{'machine':'0xm1','progress':'0xpr9','amount':'1000'}),a['obj']('0xal5','Allocation',{'allocators':{'threshold':0x1,'allocators':[]},'balance':'1000'}),a['edge']('order.allocation','0xord9','0xal5');const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:deadlock:0xal5:0xord9'),expect(b[0x0]['severity'])['toBe']('critical');}),it('A2\x20flags\x20transferable\x20fixed\x20long-window\x20discounts\x20without\x20a\x20benchmark',()=>{const a=new GB();a['obj']('0xd1','Discount',{'discount_type':0x1,'benchmark':null,'transferable':!![],'time_start':'0','time_end':String(0x1fn*0x18n*0x3cn*0x3cn*0x3e8n)});const b=runAnalyzers(a['vp'](),{'only':['A2']});expect(b)['toHaveLength'](0x1);const c=new GB();c['obj']('0xd2','Discount',{'discount_type':0x1,'benchmark':null,'transferable':![],'time_start':'0','time_end':String(0x1fn*0x18n*0x3cn*0x3cn*0x3e8n)}),expect(runAnalyzers(c['vp'](),{'only':['A2']}))['toHaveLength'](0x0);}),it('A3\x20flags\x20zero-fee/no-usage-guard\x20arbitration\x20and\x20reports\x20CoinWrapper\x20custody',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'0','usage_guard':null,'voting_guard':[]}),a['obj']('0xcw1','Payment',{},'0x2::payment::CoinWrapper<0x2::wow::WOW>');const b=runAnalyzers(a['vp'](),{'only':['A3']});expect(ids(b)['sort']())['toEqual'](['A3:0xa1','A3:coinwrapper']),expect(b['find'](c=>c['id']==='A3:coinwrapper')['detail'])['toContain']('0x2::wow::WOW');});}),describe('analyze\x20—\x20opportunity\x20rules',()=>{it('O1\x20surfaces\x20scarce-presenter\x20demands\x20with\x20structurally\x20matching\x20services',()=>{const a=new GB();a['obj']('0xdm1','Demand',{'guards':[{'guard':'0xg1'}]}),a['edge']('demand.guard','0xdm1','0xg1'),a['obj']('0xs1','Service',{'bPublished':!![]}),a['obj']('0xm1','Machine',{}),a['edge']('service.machine','0xs1','0xm1'),a['edge']('wf.forward_guard','0xm1::node::paid','0xg1');const b=runAnalyzers(a['vp'](),{'only':['O1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('0xs1'),a['eoa']('0u1')['eoa']('0u2'),a['edge']('demand.presenter','0xdm1','0u1',{'service':'0xs1'}),a['edge']('demand.presenter','0xdm1','0u2',{'service':'0xs1'}),expect(runAnalyzers(a['vp'](),{'only':['O1']}))['toHaveLength'](0x0);}),it('O2\x20reports\x20graph\x20supply/demand\x20density',()=>{const a=new GB();a['obj']('0xs1','Service',{'bPublished':!![],'bPaused':![]}),a['obj']('0xs2','Service',{'bPublished':![]}),a['obj']('0xd1','Demand',{});const b=runAnalyzers(a['vp'](),{'only':['O2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('2\x20Service(s)'),expect(b[0x0]['detail'])['toContain']('1\x20open\x20demand(s)');}),it('O3\x20lists\x20operator-less\x20forwards\x20as\x20workflow\x20slots',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::done',{'node':'done','prevNode':'paid','forward':'auto','namedOperator':null,'permissionIndex':null,'guard':'0xg1'});const b=runAnalyzers(a['vp'](),{'only':['O3']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('paid:auto');});}),describe('analyze\x20—\x20game\x20rules',()=>{it('G1\x20reports\x20all-vote\x20vs\x20weighted\x20structures\x20plus\x20observed\x20case\x20weights',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'0','voting_guard':[]}),a['obj']('0xcase1','Arb',{'voted':[{'voter':'0u1','weight':0x1},{'voter':'0u2','weight':0x2}]}),a['edge']('arb.arbitration_service','0xcase1','0xa1');const b=runAnalyzers(a['vp'](),{'only':['G1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('open\x20to\x20all\x20members'),expect(b[0x0]['detail'])['toContain']('w1x1'),expect(b[0x0]['detail'])['toContain']('w2x1');}),it('G2\x20marks\x20a\x20named-operator\x20forward\x20as\x20a\x20pool-of-one\x20hold-up\x20point',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::done',{'node':'done','prevNode':'paid','forward':'sign','namedOperator':'bob'});const b=runAnalyzers(a['vp'](),{'only':['G2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toContain']('paid:sign');}),it('G3\x20emits\x20the\x20relief\x20parameter\x20matrix\x20for\x20every\x20arbitration\x20service',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'5','usage_guard':'0xg1','voting_guard':[{'guard':'0xg2'}]});const b=runAnalyzers(a['vp'](),{'only':['G3']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('fee=5'),expect(b[0x0]['detail'])['toContain']('30-day');});}),describe('analyze\x20—\x20anti-cheat\x20rules\x20(AC1-AC4)',()=>{function a(c,d,e,f){c['eoa'](d),c['edge']('eoa.permission',d,e,{'roleBits':0x1|0x2}),c['edge']('permission.core_binding',e,f);}function b(c,d,e,f){c['obj'](e,'Order',f),c['edge']('service.order',d,e,undefined,'bounded_window'),c['edge']('order.builder',e,String(f['builder']));}it('AC1\x20flags\x20window\x20orders\x20whose\x20buyer\x20controls\x20the\x20selling\x20Service',()=>{const c=new GB();c['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(c,'0u1','0p1','0xs1'),b(c,'0xs1','0o1',{'builder':'0u1','service':'0xs1','amount':'100'});const d=runAnalyzers(c['vp'](),{'only':['AC1']});expect(d)['toHaveLength'](0x1),expect(d[0x0]['severity'])['toBe']('high'),expect(d[0x0]['confidence'])['toBe']('windowed'),expect(d[0x0]['id'])['toContain']('0o1');const e=new GB();e['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(e,'0u1','0p1','0xs1'),b(e,'0xs1','0o1',{'builder':'0u2','service':'0xs1','amount':'100'}),expect(runAnalyzers(e['vp'](),{'only':['AC1']}))['toEqual']([]);}),it('AC2\x20flags\x20reciprocal\x20buying\x20between\x20two\x20controlled\x20Services',()=>{const c=new GB();c['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),c['obj']('0xs2','Service',{'bPublished':!![],'machine':'0xm2'}),a(c,'0u1','0p1','0xs1'),a(c,'0u2','0p2','0xs2'),b(c,'0xs1','0o1',{'builder':'0u2','service':'0xs1','amount':'100'}),b(c,'0xs2','0o2',{'builder':'0u1','service':'0xs2','amount':'100'});const d=runAnalyzers(c['vp'](),{'only':['AC2']});expect(d)['toHaveLength'](0x1),expect(d[0x0]['severity'])['toBe']('medium'),expect(d[0x0]['id'])['toContain']('0o1'),expect(d[0x0]['id'])['toContain']('0o2');}),it('AC3\x20flags\x20completed\x20positive-amount\x20orders\x20without\x20Allocation,\x20but\x20not\x20zero-amount\x20orders',()=>{const c=new GB();c['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(c,'0u1','0p1','0xs1'),b(c,'0xs1','0opaid',{'builder':'0u9','service':'0xs1','amount':'100'}),b(c,'0xs1','0ofree',{'builder':'0u8','service':'0xs1','amount':'0'});const d=runAnalyzers(c['vp'](),{'only':['AC3']});expect(d)['toHaveLength'](0x1),expect(d[0x0]['id'])['toContain']('0opaid'),expect(d[0x0]['id'])['not']['toContain']('0ofree'),c['edge']('order.allocation','0opaid','0al1'),expect(runAnalyzers(c['vp'](),{'only':['AC3']}))['toEqual']([]);}),it('AC4\x20surfaces\x20shell-merchant\x20shapes\x20only\x20for\x20published\x20Services',()=>{const c=new GB();c['obj']('0xs1','Service',{'bPublished':!![],'arbitrations':[],'compensation_fund':'0'});const d=runAnalyzers(c['vp'](),{'only':['AC4']});expect(ids(d)['sort']())['toEqual'](['AC4:0xs1:shell_no_arbitration','AC4:0xs1:shell_no_machine']['sort']());const e=new GB();e['obj']('0xs2','Service',{'bPublished':!![],'arbitrations':[],'compensation_fund':'500'});const f=runAnalyzers(e['vp'](),{'only':['AC4']});expect(f['map'](h=>h['severity'])['sort']())['toEqual'](['high','low','medium']['sort']());const g=new GB();g['obj']('0xs3','Service',{'bPublished':![],'arbitrations':[],'compensation_fund':'500'}),expect(runAnalyzers(g['vp'](),{'only':['AC4']}))['toEqual']([]);});});
1
+ import{describe,it,expect}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{buildViewport,runAnalyzers,runNodeAnalyzers,adaptNodeAnalyzer,listAnalyzers,registerAnalyzer,findingWhere}from'./index.js';describe('findingWhere',()=>{it('renders\x20R4\x20as\x20machine\x20+\x20node\x20names\x20(no\x20::node::\x20grammar,\x20no\x20R4:\x20prefix)',()=>{expect(findingWhere({'id':'R4:myshop_machine:myshop_machine::node::Order\x20Confirmed→myshop_machine::node::Order\x20Cancel'}))['toBe']('myshop_machine:\x20Order\x20Confirmed\x20→\x20Order\x20Cancel');}),it('renders\x20R7/R2\x20as\x20object\x20kind\x20+\x20name',()=>{expect(findingWhere({'id':'R7:reward:0x1f2e'}))['toBe']('Reward\x200x1f2e'),expect(findingWhere({'id':'R7:treasury:0xabc'}))['toBe']('Treasury\x200xabc'),expect(findingWhere({'id':'R2:0x14519d'}))['toBe']('0x14519d');}),it('falls\x20back\x20to\x20the\x20finding\x20title\x20for\x20unknown\x20id\x20shapes',()=>{expect(findingWhere({'id':'R1:weird','title':'Arb\x20permission\x20shared\x20with\x20the\x20merchant'}))['toBe']('Arb\x20permission\x20shared\x20with\x20the\x20merchant');});});const FAMILY={'eoa.permission':'R','permission.core_binding':'R','permission.entity':'W','service.order':'R','service.machine':'F','service.buy_guard':'F','machine.permission':'F','machine.node':'W','wf.transition':'W','wf.forward_guard':'W','order.allocation':'F','demand.guard':'R','demand.presenter':'R','arbitration.voting_guard':'F','arb.arbitration_service':'F','arb.voter':'S'};class GB{['nodes']=new Map();['edges']=[];['out']=new Map();['inc']=new Map();['truncations']=[];['eoa'](a){return this['nodes']['set'](a,{'id':a,'kind':'eoa','state':'fetched','origins':[],'depth':0x0}),this;}['obj'](a,b,c,d){return this['nodes']['set'](a,{'id':a,'kind':'object','objectType':b,'state':'fetched','origins':[],'depth':0x1,'raw':{'object':a,'type':b,...d?{'type_raw':d}:{},'data':c}}),this;}['edge'](a,b,c,d,f,g=![]){const h={'id':a+'|'+b+'→'+c+(d?.['forward']?'|'+d['forward']:''),'schema':a,'family':FAMILY[a]??'F','from':b,'to':c,'retention':f??(FAMILY[a]==='R'?'bounded_exact':'complete'),'observedAt':0x1,...d?{'payload':d}:{},...g?{'truncated':!![]}:{}};return this['edges']['push'](h),(this['out']['get'](b)??this['out']['set'](b,[])['get'](b))['push'](h),(this['inc']['get'](c)??this['inc']['set'](c,[])['get'](c))['push'](h),h;}['trunc'](a,b,c){return this['truncations']['push']({'nodeId':a,'schema':b,'observed':c,'limit':0x1450}),this;}['build'](a='0xseed'){return{'network':ENTRYPOINT['Mainnet'],'seed':a,'builtAt':0x1,'nodes':this['nodes'],'edges':this['edges'],'out':this['out'],'inc':this['inc'],'gaps':[],'truncations':this['truncations'],'rpcReport':{'batches':0x0,'byChannel':{'objects':0x0,'keyedFields':0x0,'tables':0x0,'events':0x0},'dedupHits':0x0},'budgetExhausted':{}};}['vp'](a='0xseed',b='neutral'){return buildViewport(this['build'](a),a,b);}}const ids=a=>a['map'](b=>b['id']);describe('analyze\x20—\x20registry',()=>{it('ships\x20the\x2026\x20rules\x20(R1-7/A1-4/O1-4/G1-3\x20+\x20anti-cheat\x20AC1-7\x20+\x20proposal.gap)',()=>{expect(listAnalyzers()['sort']())['toEqual'](['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']['sort']());}),it('is\x20fail-soft:\x20a\x20throwing\x20analyzer\x20never\x20aborts\x20the\x20suite',()=>{registerAnalyzer({'id':'__boom','kind':'risk','run':()=>{throw new Error('boom');}});const a=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['vp'](),b=runAnalyzers(a,{'only':['__boom','R6']});expect(ids(b))['toContain']('R6:0xs1'),expect(b['find'](c=>c['id']['startsWith']('__boom')))['toBeUndefined']();}),it('adapts\x20single-object\x20legacy\x20rules\x20through\x20the\x20NodeAnalyzer\x20bridge',()=>{const a=adaptNodeAnalyzer({'id':'legacy-lock','kind':'risk','objectType':'Service','inspect':e=>{const f=e['raw']['data']??{};return f['setting_lock_duration']==='0'?[{'title':'Lock','detail':'d','suggestion':'s','roles':['merchant']}]:[];}}),b=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['vp'](),c=runNodeAnalyzers(b,[a]);expect(c)['toHaveLength'](0x1),expect(c[0x0]['id'])['toBe']('legacy-lock:0xs1#0'),expect(c[0x0]['kind'])['toBe']('risk');});}),describe('analyze\x20—\x20risk\x20rules',()=>{it('R6\x20flags\x20published\x20services\x20without\x20a\x20setting\x20lock',()=>{const a=new GB()['obj']('0xs1','Service',{'bPublished':!![],'setting_lock_duration':'0'})['obj']('0xs2','Service',{'bPublished':!![],'setting_lock_duration':'2592000000'})['obj']('0xs3','Service',{'bPublished':![],'setting_lock_duration':'0'})['vp'](),b=runAnalyzers(a,{'only':['R6']});expect(ids(b))['toEqual'](['R6:0xs1']);}),it('R7\x20emits\x20CRITICAL\x20for\x20object\x20users\x20when\x20a\x20Treasury\x20has\x20mounted\x20external\x20withdraw\x20Guards',()=>{const a=new GB();a['obj']('0xt1','Treasury',{'external_withdraw_guard':[{'guard':'0xg1','identifier':0x0,'store_from_id':0x0}]}),a['obj']('0xt2','Treasury',{'external_withdraw_guard':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:treasury:0xt1']),expect(b[0x0]['severity'])['toBe']('critical'),expect(b[0x0]['detail'])['toContain']('code\x2010');}),it('R7\x20emits\x20CRITICAL\x20for\x20object\x20users\x20when\x20a\x20Reward\x20has\x20mounted\x20claim\x20Guards',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1'}]}),a['obj']('0xr2','Reward',{'guards':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('critical'),expect(b[0x0]['detail'])['toContain']('GuardIdentifier');}),it('R7\x20downgrades\x20to\x20info\x20when\x20every\x20payout\x20slot\x20is\x20provably\x20bound\x20(guard\x20defs\x20fetched)',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1','recipient':'0xmerchant'}]}),a['obj']('0xg1','Guard',{'root':{'type':'true'},'table':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('info'),expect(b[0x0]['title'])['toContain']('downgraded\x20hint'),expect(b[0x0]['detail'])['toContain']('1\x20blocked,\x200\x20viable');}),it('R7\x20keeps\x20CRITICAL\x20when\x20a\x20fetched\x20guard\x20leaves\x20the\x20payout\x20slot\x20viable',()=>{const a=new GB();a['obj']('0xr1','Reward',{'guards':[{'guard':'0xg1','recipient':'Signer'}]}),a['obj']('0xg1','Guard',{'root':{'type':'true'},'table':[]});const b=runAnalyzers(a['vp'](),{'only':['R7']});expect(ids(b))['toEqual'](['R7:reward:0xr1']),expect(b[0x0]['severity'])['toBe']('critical');}),it('R7\x20carries\x20drill-through\x20objects\x20—\x20the\x20FULL\x20reward\x20address\x20from\x20path/detail',()=>{const a='0x1a77893aaa0f0000000000000000000000000000000000000000000000aa1234',b=new GB();b['obj'](a,'Reward',{'guards':[{'guard':'0xg1'}]});const c=runAnalyzers(b['vp'](),{'only':['R7']});expect(c)['toHaveLength'](0x1),expect(c[0x0]['objects'])['toEqual']([a]);}),it('R2\x20measures\x20the\x20compensation\x20fund\x20against\x203x\x20windowed\x20order\x20volume',()=>{const a=new GB();a['obj']('0xs1','Service',{'bPublished':!![],'compensation_fund':'100'}),a['obj']('0xo1','Order',{'amount':'100'}),a['obj']('0xo2','Order',{'amount':'100'}),a['edge']('service.order','0xs1','0xo1',undefined,'bounded_window'),a['edge']('service.order','0xs1','0xo2',undefined,'bounded_window',!![]);const b=runAnalyzers(a['vp'](),{'only':['R2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['severity'])['toBe']('high'),expect(b[0x0]['confidence'])['toBe']('windowed'),expect(b[0x0]['window']?.['limit'])['toBe'](0x1450),expect(b[0x0]['detail'])['toContain']('{fund}'),expect(b[0x0]['detail'])['not']['toContain']('base\x20units'),expect(b[0x0]['amounts']?.['map'](c=>c['key']))['toEqual'](['fund','amount','needed']),expect(b[0x0]['amounts']?.['every'](c=>c['raw']==='100'||c['raw']==='200'||c['raw']==='600'))['toBe'](!![]);}),it('R1\x20flags\x20one\x20EOA\x20controlling\x20a\x20shop\x20and\x20an\x20arbitration\x20service\x20across\x20distinct\x20permissions',()=>{const a=new GB();a['eoa']('0xe1'),a['obj']('0xp1','Permission',{'owner':'0xe1'}),a['obj']('0xp2','Permission',{'owner':'0xe1'}),a['obj']('0xs1','Service',{}),a['obj']('0xa1','Arbitration',{'fee':'0'}),a['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x3}),a['edge']('eoa.permission','0xe1','0xp2',{'roleBits':0x3}),a['edge']('permission.core_binding','0xp1','0xs1'),a['edge']('permission.core_binding','0xp2','0xa1');const b=runAnalyzers(a['vp'](),{'only':['R1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['severity'])['toBe']('high');const c=new GB();c['eoa']('0xe1')['obj']('0xp1','Permission',{})['obj']('0xs1','Service',{})['obj']('0xa1','Arbitration',{'fee':'0'}),c['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x3}),c['edge']('permission.core_binding','0xp1','0xs1'),c['edge']('permission.core_binding','0xp1','0xa1'),expect(runAnalyzers(c['vp'](),{'only':['R1']}))['toHaveLength'](0x0);}),it('R3\x20flags\x20concentrated\x20control\x20of\x20core\x20objects',()=>{const a=new GB();a['eoa']('0xe1')['obj']('0xp1','Permission',{}),a['obj']('0xs1','Service',{})['obj']('0xs2','Service',{})['obj']('0xm1','Machine',{}),a['edge']('eoa.permission','0xe1','0xp1',{'roleBits':0x1});for(const c of['0xs1','0xs2','0xm1'])a['edge']('permission.core_binding','0xp1',c);const b=runAnalyzers(a['vp'](),{'only':['R3']});expect(ids(b))['toEqual'](['R3:0xe1']);}),it('R4\x20flags\x20a\x20unique\x20operator\x20with\x20no\x20backup\x20guard\x20on\x20a\x20terminal-entering\x20forward',()=>{const a=new GB();a['obj']('0xm1','Machine',{'bPublished':!![]}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::delivered',{'node':'delivered','prevNode':'paid','forward':'go','namedOperator':'alice'});const b=runAnalyzers(a['vp'](),{'only':['R4']});expect(b)['toHaveLength'](0x1);const c=new GB();c['obj']('0xm1','Machine',{'bPublished':!![]}),c['edge']('wf.transition','0xm1::node::paid','0xm1::node::delivered',{'node':'delivered','prevNode':'paid','forward':'go','namedOperator':'alice','guard':'0xg1'}),expect(runAnalyzers(c['vp'](),{'only':['R4']}))['toHaveLength'](0x0);}),it('R5\x20reports\x20window\x20truncations\x20as\x20downgraded\x20meta\x20findings',()=>{const a=new GB()['obj']('0xs1','Service',{})['trunc']('0xs1','service.order',0x1450),b=runAnalyzers(a['vp'](),{'only':['R5']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['confidence'])['toBe']('windowed'),expect(b[0x0]['window'])['toEqual']({'observed':0x1450,'limit':0x1450});});}),describe('analyze\x20—\x20arbitrage\x20rules',()=>{it('A1\x20detects\x20rate-basis\x20mismatch,\x20surplus\x20duplication\x20and\x20missing\x20max',()=>{const a=new GB();a['obj']('0xal1','Allocation',{'allocators':[{'guard':'0xg1','max':null,'sharing':[{'who':'0xa','mode':0x0,'sharing':'100'}]},{'guard':'0xg2','sharing':[{'who':'0xb','mode':0x1,'sharing':'9000'}]},{'guard':'0xg3','sharing':[{'who':'0xc','mode':0x2}]},{'guard':'0xg4','sharing':[{'who':'0xd','mode':0x2}]}]});const b=runAnalyzers(a['vp'](),{'only':['A1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('9000'),expect(b[0x0]['detail'])['toContain']('max'),expect(b[0x0]['detail'])['toContain']('Surplus');}),it('A1\x20fires\x20on\x20the\x20real\x20on-chain\x20container\x20shape\x20{threshold,\x20allocators:[…]}',()=>{const a=new GB();a['obj']('0xal2','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xg2','sharing':[{'who':'0xb','mode':0x1,'sharing':'9000'}]}]}});const b=runAnalyzers(a['vp'](),{'only':['A1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('9000');}),it('A4\x20detects\x20Surplus-then-Rate\x20drain\x20across\x20distinct\x20guards',()=>{const a=new GB();a['obj']('0xal3','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xgsettle','sharing':[{'who':'0xmerchant','mode':0x1,'sharing':'9000'},{'who':'0xplatform','mode':0x2}]},{'guard':'0xgrefund','sharing':[{'who':'0xbuyer','mode':0x1,'sharing':'10000'}]}]},'payment_info':{'for_object':'0xorder1'},'balance':'1000000'});const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:drain:0xal3'),expect(b[0x0]['detail'])['toContain']('0xgrefund');}),it('A4\x20flags\x20unanchored\x20GuardIdentifier\x20recipients',()=>{const a=new GB();a['obj']('0xal4','Allocation',{'allocators':{'threshold':0x1,'allocators':[{'guard':'0xgpay','sharing':[{'who':{'GuardIdentifier':0x1},'mode':0x1,'sharing':'10000'}]}]},'balance':'500'});const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:unanchored:0xal4');}),it('A4\x20flags\x20settlement\x20deadlock:\x20completed\x20order\x20on\x20an\x20allocator-less\x20pool',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::completed',{'node':'completed','prevNode':'paid','forward':'settle'}),a['obj']('0xpr9','Progress',{'current':'completed','machine':'0xm1'}),a['obj']('0xord9','Order',{'machine':'0xm1','progress':'0xpr9','amount':'1000'}),a['obj']('0xal5','Allocation',{'allocators':{'threshold':0x1,'allocators':[]},'balance':'1000'}),a['edge']('order.allocation','0xord9','0xal5');const b=runAnalyzers(a['vp'](),{'only':['A4']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toBe']('A4:deadlock:0xal5:0xord9'),expect(b[0x0]['severity'])['toBe']('critical');}),it('A2\x20flags\x20transferable\x20fixed\x20long-window\x20discounts\x20without\x20a\x20benchmark',()=>{const a=new GB();a['obj']('0xd1','Discount',{'discount_type':0x1,'benchmark':null,'transferable':!![],'time_start':'0','time_end':String(0x1fn*0x18n*0x3cn*0x3cn*0x3e8n)});const b=runAnalyzers(a['vp'](),{'only':['A2']});expect(b)['toHaveLength'](0x1);const c=new GB();c['obj']('0xd2','Discount',{'discount_type':0x1,'benchmark':null,'transferable':![],'time_start':'0','time_end':String(0x1fn*0x18n*0x3cn*0x3cn*0x3e8n)}),expect(runAnalyzers(c['vp'](),{'only':['A2']}))['toHaveLength'](0x0);}),it('A3\x20flags\x20zero-fee/no-usage-guard\x20arbitration\x20and\x20reports\x20CoinWrapper\x20custody',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'0','usage_guard':null,'voting_guard':[]}),a['obj']('0xcw1','Payment',{},'0x2::payment::CoinWrapper<0x2::wow::WOW>');const b=runAnalyzers(a['vp'](),{'only':['A3']});expect(ids(b)['sort']())['toEqual'](['A3:0xa1','A3:coinwrapper']),expect(b['find'](c=>c['id']==='A3:coinwrapper')['detail'])['toContain']('0x2::wow::WOW');});}),describe('analyze\x20—\x20opportunity\x20rules',()=>{it('O1\x20surfaces\x20scarce-presenter\x20demands\x20with\x20structurally\x20matching\x20services',()=>{const a=new GB();a['obj']('0xdm1','Demand',{'guards':[{'guard':'0xg1'}]}),a['edge']('demand.guard','0xdm1','0xg1'),a['obj']('0xs1','Service',{'bPublished':!![]}),a['obj']('0xm1','Machine',{}),a['edge']('service.machine','0xs1','0xm1'),a['edge']('wf.forward_guard','0xm1::node::paid','0xg1');const b=runAnalyzers(a['vp'](),{'only':['O1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('0xs1'),a['eoa']('0u1')['eoa']('0u2'),a['edge']('demand.presenter','0xdm1','0u1',{'service':'0xs1'}),a['edge']('demand.presenter','0xdm1','0u2',{'service':'0xs1'}),expect(runAnalyzers(a['vp'](),{'only':['O1']}))['toHaveLength'](0x0);}),it('O4\x20projects\x20presenter\x20acceptance\x20coverage\x20and\x20freshness\x20(D-R8);\x20a\x20sparse\x20sample\x20is\x20not\x20a\x20verdict',()=>{const a=new GB();a['obj']('0xdm1','Demand',{'description':'build\x20a\x20shop'}),a['eoa']('0u1')['eoa']('0u2'),a['edge']('demand.presenter','0xdm1','0u1',{'service':'0xs1','score':0x5a,'time':0x190,'feedbackTime':0x1f4}),a['edge']('demand.presenter','0xdm1','0u2',{});const b=runAnalyzers(a['vp'](),{'only':['O4']});expect(ids(b))['toEqual'](['O4:0xdm1']),expect(b[0x0]['detail'])['toContain']('2\x20presenter(s),\x201\x20with\x20an\x20acceptance\x20score'),expect(b[0x0]['detail'])['toContain']('sparse\x20by\x20nature');}),it('O4\x20skips\x20presenter-less\x20demands\x20and\x20reports\x20unknown\x20staleness\x20without\x20timestamps',()=>{const a=new GB();a['obj']('0xdm1','Demand',{}),a['obj']('0xdm2','Demand',{}),a['eoa']('0u1'),a['edge']('demand.presenter','0xdm2','0u1',{'score':0x28});const b=runAnalyzers(a['vp'](),{'only':['O4']});expect(ids(b))['toEqual'](['O4:0xdm2']),expect(b[0x0]['detail'])['toContain']('staleness\x20unknown');}),it('O2\x20reports\x20graph\x20supply/demand\x20density',()=>{const a=new GB();a['obj']('0xs1','Service',{'bPublished':!![],'bPaused':![]}),a['obj']('0xs2','Service',{'bPublished':![]}),a['obj']('0xd1','Demand',{});const b=runAnalyzers(a['vp'](),{'only':['O2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('2\x20Service(s)'),expect(b[0x0]['detail'])['toContain']('1\x20open\x20demand(s)');}),it('O3\x20lists\x20operator-less\x20forwards\x20as\x20workflow\x20slots',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::done',{'node':'done','prevNode':'paid','forward':'auto','namedOperator':null,'permissionIndex':null,'guard':'0xg1'});const b=runAnalyzers(a['vp'](),{'only':['O3']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('paid:auto');});}),describe('analyze\x20—\x20game\x20rules',()=>{it('G1\x20reports\x20all-vote\x20vs\x20weighted\x20structures\x20plus\x20observed\x20case\x20weights',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'0','voting_guard':[]}),a['obj']('0xcase1','Arb',{'voted':[{'voter':'0u1','weight':0x1},{'voter':'0u2','weight':0x2}]}),a['edge']('arb.arbitration_service','0xcase1','0xa1');const b=runAnalyzers(a['vp'](),{'only':['G1']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('open\x20to\x20all\x20members'),expect(b[0x0]['detail'])['toContain']('w1x1'),expect(b[0x0]['detail'])['toContain']('w2x1');}),it('G2\x20marks\x20a\x20named-operator\x20forward\x20as\x20a\x20pool-of-one\x20hold-up\x20point',()=>{const a=new GB();a['obj']('0xm1','Machine',{}),a['edge']('wf.transition','0xm1::node::paid','0xm1::node::done',{'node':'done','prevNode':'paid','forward':'sign','namedOperator':'bob'});const b=runAnalyzers(a['vp'](),{'only':['G2']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['id'])['toContain']('paid:sign');}),it('G3\x20emits\x20the\x20relief\x20parameter\x20matrix\x20for\x20every\x20arbitration\x20service',()=>{const a=new GB();a['obj']('0xa1','Arbitration',{'fee':'5','usage_guard':'0xg1','voting_guard':[{'guard':'0xg2'}]});const b=runAnalyzers(a['vp'](),{'only':['G3']});expect(b)['toHaveLength'](0x1),expect(b[0x0]['detail'])['toContain']('fee=5'),expect(b[0x0]['detail'])['toContain']('30-day');});}),describe('analyze\x20—\x20anti-cheat\x20rules\x20(AC1-AC4)',()=>{function a(d,e,f,g){d['eoa'](e),d['edge']('eoa.permission',e,f,{'roleBits':0x1|0x2}),d['edge']('permission.core_binding',f,g);}function b(d,e,f,g){d['obj'](f,'Order',g),d['edge']('service.order',e,f,undefined,'bounded_window'),d['edge']('order.builder',f,String(g['builder']));}it('AC1\x20flags\x20window\x20orders\x20whose\x20buyer\x20controls\x20the\x20selling\x20Service',()=>{const d=new GB();d['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(d,'0u1','0p1','0xs1'),b(d,'0xs1','0o1',{'builder':'0u1','service':'0xs1','amount':'100'});const e=runAnalyzers(d['vp'](),{'only':['AC1']});expect(e)['toHaveLength'](0x1),expect(e[0x0]['severity'])['toBe']('high'),expect(e[0x0]['confidence'])['toBe']('windowed'),expect(e[0x0]['id'])['toContain']('0o1');const f=new GB();f['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(f,'0u1','0p1','0xs1'),b(f,'0xs1','0o1',{'builder':'0u2','service':'0xs1','amount':'100'}),expect(runAnalyzers(f['vp'](),{'only':['AC1']}))['toEqual']([]);}),it('AC2\x20flags\x20reciprocal\x20buying\x20between\x20two\x20controlled\x20Services',()=>{const d=new GB();d['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),d['obj']('0xs2','Service',{'bPublished':!![],'machine':'0xm2'}),a(d,'0u1','0p1','0xs1'),a(d,'0u2','0p2','0xs2'),b(d,'0xs1','0o1',{'builder':'0u2','service':'0xs1','amount':'100'}),b(d,'0xs2','0o2',{'builder':'0u1','service':'0xs2','amount':'100'});const e=runAnalyzers(d['vp'](),{'only':['AC2']});expect(e)['toHaveLength'](0x1),expect(e[0x0]['severity'])['toBe']('medium'),expect(e[0x0]['id'])['toContain']('0o1'),expect(e[0x0]['id'])['toContain']('0o2');}),it('AC3\x20flags\x20completed\x20positive-amount\x20orders\x20without\x20Allocation,\x20but\x20not\x20zero-amount\x20orders',()=>{const d=new GB();d['obj']('0xs1','Service',{'bPublished':!![],'machine':'0xm1'}),a(d,'0u1','0p1','0xs1'),b(d,'0xs1','0opaid',{'builder':'0u9','service':'0xs1','amount':'100'}),b(d,'0xs1','0ofree',{'builder':'0u8','service':'0xs1','amount':'0'});const e=runAnalyzers(d['vp'](),{'only':['AC3']});expect(e)['toHaveLength'](0x1),expect(e[0x0]['id'])['toContain']('0opaid'),expect(e[0x0]['id'])['not']['toContain']('0ofree'),d['edge']('order.allocation','0opaid','0al1'),expect(runAnalyzers(d['vp'](),{'only':['AC3']}))['toEqual']([]);}),it('AC4\x20surfaces\x20shell-merchant\x20shapes\x20only\x20for\x20published\x20Services',()=>{const d=new GB();d['obj']('0xs1','Service',{'bPublished':!![],'arbitrations':[],'compensation_fund':'0'});const e=runAnalyzers(d['vp'](),{'only':['AC4']});expect(ids(e)['sort']())['toEqual'](['AC4:0xs1:shell_no_arbitration','AC4:0xs1:shell_no_machine']['sort']());const f=new GB();f['obj']('0xs2','Service',{'bPublished':!![],'arbitrations':[],'compensation_fund':'500'});const g=runAnalyzers(f['vp'](),{'only':['AC4']});expect(g['map'](i=>i['severity'])['sort']())['toEqual'](['high','low','medium']['sort']());const h=new GB();h['obj']('0xs3','Service',{'bPublished':![],'arbitrations':[],'compensation_fund':'500'}),expect(runAnalyzers(h['vp'](),{'only':['AC4']}))['toEqual']([]);});function c(){const d=new GB();return d['edge']('target.vote','0xt1','0xv1',{'voteBits':0x2}),d['edge']('target.vote','0xt2','0xv1',{'voteBits':0x2}),d['edge']('target.vote','0xt3','0xv1',{'voteBits':0x4}),d['edge']('target.vote','0xt1','0xv2',{'voteBits':0x2}),d['edge']('entity.profile','0xv1','0xv1',{'registeredAt':Date['now']()-0x2*0x5265c00}),d['edge']('entity.profile','0xv2','0xv2',{'registeredAt':Date['now']()-0x320*0x5265c00}),d['eoa']('0o1'),d['edge']('eoa.order','0xv2','0o1',{'roleBits':0x1}),d;}it('AC5\x20flags\x20the\x20fresh\x20voter\x27s\x20burst\x20through\x20the\x20full\x20graph\x20projection',()=>{const d=runAnalyzers(c()['vp'](),{'only':['AC5']});expect(d)['toHaveLength'](0x1),expect(d[0x0]['severity'])['toBe']('medium'),expect(d[0x0]['id'])['toContain']('0xv1');}),it('AC6\x20flags\x20a\x20mutual\x20vote\x20pair\x20through\x20the\x20full\x20graph\x20projection',()=>{const d=new GB();d['edge']('target.vote','0xa','0xb',{'voteBits':0x2}),d['edge']('target.vote','0xb','0xa',{'voteBits':0x2});const e=runAnalyzers(d['vp'](),{'only':['AC6']});expect(e)['toHaveLength'](0x1),expect(e[0x0]['severity'])['toBe']('medium'),expect(runAnalyzers(c()['vp'](),{'only':['AC6']}))['toEqual']([]);}),it('AC7\x20flags\x20the\x20target\x20whose\x20votes\x20are\x20dominated\x20by\x20low-credibility\x20voters',()=>{const d=new GB();for(const [f,g]of['0xf1','0xf2','0xz','0xok1','0xok2']['entries']()){d['edge']('target.vote','0xt',g,{'voteBits':0x2});const h=g['startsWith']('0xf')||g==='0xz';d['edge']('entity.profile',g,g,h?{'registeredAt':Date['now']()-0x5265c00}:{'registeredAt':Date['now']()-0x384*0x5265c00}),!h&&(d['eoa']('0o'+f),d['edge']('eoa.order',g,'0o'+f,{'roleBits':0x1}));}const e=runAnalyzers(d['vp'](),{'only':['AC7']});expect(e)['toHaveLength'](0x1),expect(e[0x0]['severity'])['toBe']('high'),expect(e[0x0]['id'])['toContain']('0xt');});});
@@ -1,7 +1,7 @@
1
1
  export type AntiCheatSeverity = "high" | "medium" | "low";
2
2
  export interface AntiCheatSignal {
3
- kind: "fake_order" | "fake_review" | "shell_merchant" | "reputation_trade";
4
- code: "self_buy" | "reciprocal_loop" | "no_allocation" | "reviews_unverified" | "reviewer_duplicate" | "review_time_burst" | "shell_no_arbitration" | "shell_funded_no_arbitration" | "shell_no_machine" | "reputation_bound";
3
+ kind: "fake_order" | "fake_review" | "shell_merchant" | "reputation_trade" | "vote_noise";
4
+ code: "self_buy" | "reciprocal_loop" | "no_allocation" | "reviews_unverified" | "reviewer_duplicate" | "review_time_burst" | "shell_no_arbitration" | "shell_funded_no_arbitration" | "shell_no_machine" | "reputation_bound" | "new_account_burst" | "vote_reciprocity" | "single_target_flood";
5
5
  severity: AntiCheatSeverity;
6
6
  description: string;
7
7
  refs?: string[];
@@ -37,3 +37,33 @@ export declare function detectFakeReviews(reviews: ReviewEvidence[]): AntiCheatS
37
37
  export declare function detectShellMerchant(service: MerchantEvidence["service"]): AntiCheatSignal[];
38
38
  export declare function reputationTradeNote(): AntiCheatSignal;
39
39
  export declare function assessAntiCheat(evidence: MerchantEvidence): AntiCheatSignal[];
40
+ export interface VoteEdgeEvidence {
41
+ voter: string;
42
+ target: string;
43
+ like: boolean;
44
+ dislike: boolean;
45
+ favor: boolean;
46
+ }
47
+ export interface VoterProfileEvidence {
48
+ address: string;
49
+ registeredAt?: number;
50
+ ordersOwned: number;
51
+ ordersAgented: number;
52
+ objectsFootprint: number;
53
+ }
54
+ export declare const VOTER_NEW_ACCOUNT_DAYS = 30;
55
+ export declare const VOTER_BURST_MIN_VOTES = 3;
56
+ export declare const VOTER_FLOOD_MIN_VOTES = 5;
57
+ export declare const VOTER_FLOOD_LOW_CRED_RATIO = 0.5;
58
+ export interface VoterCredibility {
59
+ address: string;
60
+ accountAgeDays: number | null;
61
+ ordersCount: number;
62
+ objectsFootprint: number;
63
+ votesCast: number;
64
+ likeRatio: number | null;
65
+ }
66
+ export declare function summarizeVoterCredibility(votes: VoteEdgeEvidence[], profiles: VoterProfileEvidence[], nowMs: number): VoterCredibility[];
67
+ export declare function detectNewAccountBurst(votes: VoteEdgeEvidence[], profiles: VoterProfileEvidence[], nowMs: number): AntiCheatSignal[];
68
+ export declare function detectVoteReciprocity(votes: VoteEdgeEvidence[]): AntiCheatSignal[];
69
+ export declare function detectTargetFlood(votes: VoteEdgeEvidence[], profiles: VoterProfileEvidence[], nowMs: number): AntiCheatSignal[];
@@ -1 +1 @@
1
- function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}export function detectFakeOrders(a){const b=[];if(a['length']===0x0)return b;const c=a['filter'](h=>h['buyer']===h['seller']);c['length']>0x0&&b['push']({'kind':'fake_order','code':'self_buy','severity':'high','description':c['length']+'\x20order(s)\x20with\x20buyer\x20==\x20seller\x20(self-buy-sell)','refs':[...new Set(c['map'](h=>h['id']))]});const d=new Set(a['map'](h=>h['buyer'])),e=new Set(a['map'](h=>h['seller'])),f=a['filter'](h=>d['has'](h['seller'])&&e['has'](h['buyer']));f['length']>=0x2&&b['push']({'kind':'fake_order','code':'reciprocal_loop','severity':'medium','description':f['length']+'\x20order(s)\x20in\x20a\x20reciprocal\x20buyer/seller\x20loop\x20(possible\x20fund\x20circulation)','refs':[...new Set(f['map'](h=>h['id']))]});const g=a['filter'](h=>!h['allocation']&&h['status']==='completed'&&(toBigInt(h['amount'])??0x0n)>0x0n);return g['length']>0x0&&b['push']({'kind':'fake_order','code':'no_allocation','severity':'medium','description':g['length']+'\x20completed\x20positive-amount\x20order(s)\x20without\x20an\x20Allocation\x20(no\x20fund-closure\x20evidence)','refs':[...new Set(g['map'](h=>h['id']))]}),b;}export function detectFakeReviews(a){const b=[];if(a['length']===0x0)return b;const c=a['filter'](g=>!g['verified']);c['length']>0x0&&c['length']===a['length']&&b['push']({'kind':'fake_review','code':'reviews_unverified','severity':'high','description':'all\x20'+a['length']+'\x20review(s)\x20are\x20unverified\x20(no\x20completed-order\x20credential)'});const d=new Map();for(const g of a){d['set'](g['reviewer'],(d['get'](g['reviewer'])??0x0)+0x1);}const e=[...d['values']()]['filter'](h=>h>0x1)['length'];e>0x0&&b['push']({'kind':'fake_review','code':'reviewer_duplicate','severity':'medium','description':e+'\x20address(es)\x20submitted\x20multiple\x20reviews'});const f=a['filter'](h=>h['timestamp']!=null);if(f['length']>0xa){const h=[...f]['sort']((j,k)=>(j['timestamp']??0x0)-(k['timestamp']??0x0)),i=(h[h['length']-0x1]['timestamp']??0x0)-(h[0x0]['timestamp']??0x0);i>0x0&&i<0x36ee80&&b['push']({'kind':'fake_review','code':'review_time_burst','severity':'medium','description':f['length']+'\x20review(s)\x20within\x201\x20hour\x20(concentrated\x20timing)'});}return b;}export function detectShellMerchant(a){const b=[];if(!a['bPublished'])return b;a['arbitrations']['length']===0x0&&b['push']({'kind':'shell_merchant','code':'shell_no_arbitration','severity':a['machine']?'low':'medium','description':'published\x20Service\x20has\x20no\x20Arbitration\x20binding\x20(no\x20dispute\x20path)','refs':[a['object']]});const c=toBigInt(a['compensation_fund'])??0x0n;return c>0x0n&&a['arbitrations']['length']===0x0&&b['push']({'kind':'shell_merchant','code':'shell_funded_no_arbitration','severity':'high','description':'funded\x20compensation_fund\x20but\x20no\x20Arbitration\x20(compensation\x20cannot\x20be\x20ruled/disbursed)','refs':[a['object']]}),!a['machine']&&b['push']({'kind':'shell_merchant','code':'shell_no_machine','severity':'low','description':'published\x20Service\x20has\x20no\x20Machine\x20(no\x20workflow)','refs':[a['object']]}),b;}export function reputationTradeNote(){return{'kind':'reputation_trade','code':'reputation_bound','severity':'low','description':'reputation\x20aggregates\x20by\x20historical\x20fulfillment\x20and\x20is\x20not\x20transferable\x20with\x20the\x20object\x20—\x20reputation\x20trading\x20is\x20structurally\x20prevented'};}export function assessAntiCheat(a){return[...detectFakeOrders(a['orders']),...detectFakeReviews(a['reviews']),...detectShellMerchant(a['service']),reputationTradeNote()];}
1
+ function toBigInt(a){if(a===undefined||a===null)return undefined;try{return BigInt(a);}catch{return undefined;}}export function detectFakeOrders(a){const b=[];if(a['length']===0x0)return b;const c=a['filter'](h=>h['buyer']===h['seller']);c['length']>0x0&&b['push']({'kind':'fake_order','code':'self_buy','severity':'high','description':c['length']+'\x20order(s)\x20with\x20buyer\x20==\x20seller\x20(self-buy-sell)','refs':[...new Set(c['map'](h=>h['id']))]});const d=new Set(a['map'](h=>h['buyer'])),e=new Set(a['map'](h=>h['seller'])),f=a['filter'](h=>d['has'](h['seller'])&&e['has'](h['buyer']));f['length']>=0x2&&b['push']({'kind':'fake_order','code':'reciprocal_loop','severity':'medium','description':f['length']+'\x20order(s)\x20in\x20a\x20reciprocal\x20buyer/seller\x20loop\x20(possible\x20fund\x20circulation)','refs':[...new Set(f['map'](h=>h['id']))]});const g=a['filter'](h=>!h['allocation']&&h['status']==='completed'&&(toBigInt(h['amount'])??0x0n)>0x0n);return g['length']>0x0&&b['push']({'kind':'fake_order','code':'no_allocation','severity':'medium','description':g['length']+'\x20completed\x20positive-amount\x20order(s)\x20without\x20an\x20Allocation\x20(no\x20fund-closure\x20evidence)','refs':[...new Set(g['map'](h=>h['id']))]}),b;}export function detectFakeReviews(a){const b=[];if(a['length']===0x0)return b;const c=a['filter'](g=>!g['verified']);c['length']>0x0&&c['length']===a['length']&&b['push']({'kind':'fake_review','code':'reviews_unverified','severity':'high','description':'all\x20'+a['length']+'\x20review(s)\x20are\x20unverified\x20(no\x20completed-order\x20credential)'});const d=new Map();for(const g of a){d['set'](g['reviewer'],(d['get'](g['reviewer'])??0x0)+0x1);}const e=[...d['values']()]['filter'](h=>h>0x1)['length'];e>0x0&&b['push']({'kind':'fake_review','code':'reviewer_duplicate','severity':'medium','description':e+'\x20address(es)\x20submitted\x20multiple\x20reviews'});const f=a['filter'](h=>h['timestamp']!=null);if(f['length']>0xa){const h=[...f]['sort']((j,k)=>(j['timestamp']??0x0)-(k['timestamp']??0x0)),i=(h[h['length']-0x1]['timestamp']??0x0)-(h[0x0]['timestamp']??0x0);i>0x0&&i<0x36ee80&&b['push']({'kind':'fake_review','code':'review_time_burst','severity':'medium','description':f['length']+'\x20review(s)\x20within\x201\x20hour\x20(concentrated\x20timing)'});}return b;}export function detectShellMerchant(a){const b=[];if(!a['bPublished'])return b;a['arbitrations']['length']===0x0&&b['push']({'kind':'shell_merchant','code':'shell_no_arbitration','severity':a['machine']?'low':'medium','description':'published\x20Service\x20has\x20no\x20Arbitration\x20binding\x20(no\x20dispute\x20path)','refs':[a['object']]});const c=toBigInt(a['compensation_fund'])??0x0n;return c>0x0n&&a['arbitrations']['length']===0x0&&b['push']({'kind':'shell_merchant','code':'shell_funded_no_arbitration','severity':'high','description':'funded\x20compensation_fund\x20but\x20no\x20Arbitration\x20(compensation\x20cannot\x20be\x20ruled/disbursed)','refs':[a['object']]}),!a['machine']&&b['push']({'kind':'shell_merchant','code':'shell_no_machine','severity':'low','description':'published\x20Service\x20has\x20no\x20Machine\x20(no\x20workflow)','refs':[a['object']]}),b;}export function reputationTradeNote(){return{'kind':'reputation_trade','code':'reputation_bound','severity':'low','description':'reputation\x20aggregates\x20by\x20historical\x20fulfillment\x20and\x20is\x20not\x20transferable\x20with\x20the\x20object\x20—\x20reputation\x20trading\x20is\x20structurally\x20prevented'};}export function assessAntiCheat(a){return[...detectFakeOrders(a['orders']),...detectFakeReviews(a['reviews']),...detectShellMerchant(a['service']),reputationTradeNote()];}export const VOTER_NEW_ACCOUNT_DAYS=0x1e;export const VOTER_BURST_MIN_VOTES=0x3;export const VOTER_FLOOD_MIN_VOTES=0x5;export const VOTER_FLOOD_LOW_CRED_RATIO=0.5;const DAY_MS=0x5265c00;function voterCredibilityFlags(a,b){if(!a)return{'low':![],'fresh':![]};const c=a['registeredAt']!=null&&b-a['registeredAt']<VOTER_NEW_ACCOUNT_DAYS*DAY_MS,d=a['ordersOwned']+a['ordersAgented']===0x0&&a['objectsFootprint']<=0x1;return{'low':c||d,'fresh':c};}export function summarizeVoterCredibility(a,b,c){const d=new Map(b['map'](g=>[g['address'],g])),e=new Map();for(const g of a){const h=e['get'](g['voter'])??{'votes':0x0,'likes':0x0};h['votes']+=0x1;if(g['like'])h['likes']+=0x1;e['set'](g['voter'],h);}const f=[];for(const i of new Set([...d['keys'](),...e['keys']()])){const j=d['get'](i),k=e['get'](i);f['push']({'address':i,'accountAgeDays':j?.['registeredAt']!=null?Math['floor']((c-j['registeredAt'])/DAY_MS):null,'ordersCount':(j?.['ordersOwned']??0x0)+(j?.['ordersAgented']??0x0),'objectsFootprint':j?.['objectsFootprint']??0x0,'votesCast':k?.['votes']??0x0,'likeRatio':k&&k['votes']>0x0?k['likes']/k['votes']:null});}return f['sort']((l,m)=>l['address']['localeCompare'](m['address']));}export function detectNewAccountBurst(a,b,c){const d=[];if(a['length']===0x0)return d;const e=new Map(b['map'](h=>[h['address'],h])),f=new Map();for(const h of a){voterCredibilityFlags(e['get'](h['voter']),c)['fresh']&&f['set'](h['voter'],(f['get'](h['voter'])??0x0)+0x1);}const g=[...f['entries']()]['filter'](([,i])=>i>=VOTER_BURST_MIN_VOTES);if(g['length']>0x0){const i=g['reduce']((j,[,k])=>j+k,0x0);d['push']({'kind':'vote_noise','code':'new_account_burst','severity':'medium','description':g['length']+'\x20account(s)\x20registered\x20within\x20'+VOTER_NEW_ACCOUNT_DAYS+'\x20days\x20cast\x20'+i+'\x20vote(s)\x20'+('('+VOTER_BURST_MIN_VOTES+'+\x20each)\x20—\x20organized\x20voting\x20push\x20pattern'),'refs':g['map'](([j])=>j)});}return d;}export function detectVoteReciprocity(a){const b=[];if(a['length']===0x0)return b;const c=new Set(a['map'](e=>e['voter']+'→'+e['target'])),d=new Set();for(const e of a){e['voter']<e['target']&&c['has'](e['target']+'→'+e['voter'])&&d['add'](e['voter']+'|'+e['target']);}return d['size']>0x0&&b['push']({'kind':'vote_noise','code':'vote_reciprocity','severity':'medium','description':d['size']+'\x20mutual\x20vote\x20pair(s)\x20(A\x20voted\x20B\x20and\x20B\x20voted\x20A)\x20—\x20possible\x20vote\x20ring','refs':[...d]['flatMap'](f=>f['split']('|'))}),b;}export function detectTargetFlood(a,b,c){const d=[];if(a['length']===0x0)return d;const e=new Map(b['map'](g=>[g['address'],g])),f=new Map();for(const g of a){const h=f['get'](g['target'])??{'total':0x0,'low':0x0,'voters':[]};h['total']+=0x1;if(voterCredibilityFlags(e['get'](g['voter']),c)['low'])h['low']+=0x1;h['voters']['push'](g['voter']),f['set'](g['target'],h);}for(const [i,j]of[...f['entries']()]['sort']((k,l)=>k[0x0]['localeCompare'](l[0x0]))){j['total']>=VOTER_FLOOD_MIN_VOTES&&j['low']/j['total']>=VOTER_FLOOD_LOW_CRED_RATIO&&d['push']({'kind':'vote_noise','code':'single_target_flood','severity':'high','description':'target\x20received\x20'+j['total']+'\x20vote(s),\x20'+j['low']+'\x20from\x20low-credibility\x20accounts\x20'+'(fresh\x20or\x20zero-history)\x20—\x20the\x20aggregate\x20may\x20be\x20noise\x20rather\x20than\x20signal','refs':[i,...j['voters']]});}return d;}