@wowok/agent-mcp 3.1.5 → 3.1.6
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.
- package/dist/evaluation/arbitration-game.js +1 -1
- package/dist/evaluation/builtins/graph-service.js +1 -1
- package/dist/graph/onchain/analyze.js +1 -1
- package/dist/graph/onchain/analyze.spec.js +1 -1
- package/dist/graph/onchain/extract.js +1 -1
- package/dist/graph/onchain/facts.d.ts +1 -0
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/fixtures.js +1 -1
- package/dist/graph/onchain/onchain.spec.js +1 -1
- package/dist/graph/onchain/strategy.js +1 -1
- package/dist/graph/onchain/strategy.spec.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/knowledge/alloc-audit-policy.spec.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +1 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/alloc_audit.json +20 -0
- package/dist/knowledge/baselines/rules/allocation.json +1 -19
- package/dist/knowledge/baselines/rules/arb.json +1 -1
- package/dist/knowledge/baselines/rules/guard.json +8 -8
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +2 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-design-patterns.spec.d.ts +1 -0
- package/dist/knowledge/guard-design-patterns.spec.js +1 -0
- package/dist/knowledge/guard-lint.d.ts +1 -1
- package/dist/knowledge/guard-lint.js +1 -1
- package/dist/knowledge/guard-puzzle.js +1 -1
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/permission-ledger.js +1 -1
- package/dist/knowledge/recipient-constraint.js +1 -1
- package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +1 -0
- package/dist/knowledge/safety-rules.extract-amount.spec.js +1 -0
- package/dist/knowledge/safety-rules.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tool-constraints.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/pipeline-actions.d.ts +1 -1
- package/dist/playbooks/service-build/pipeline-actions.js +1 -1
- package/dist/playbooks/service-build/risk-aggregator.js +1 -1
- package/dist/role/derivation.d.ts +1 -1
- package/dist/role/derivation.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/allocation.d.ts +7 -0
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/arbitration.d.ts +4 -0
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +48 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +26 -0
- package/dist/schema/call/contact.d.ts +4 -0
- package/dist/schema/call/demand.d.ts +4 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/guard.d.ts +12 -0
- package/dist/schema/call/handler.js +1 -1
- package/dist/schema/call/machine.d.ts +8 -0
- package/dist/schema/call/order.d.ts +4 -0
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/payment.d.ts +4 -0
- package/dist/schema/call/permission.d.ts +4 -0
- package/dist/schema/call/personal.d.ts +4 -0
- package/dist/schema/call/progress.d.ts +4 -0
- package/dist/schema/call/proof.d.ts +8 -0
- package/dist/schema/call/repository.d.ts +4 -0
- package/dist/schema/call/repository.js +1 -1
- package/dist/schema/call/reward.d.ts +4 -0
- package/dist/schema/call/semantic-customer-advice.spec.js +1 -1
- package/dist/schema/call/semantic.d.ts +11 -0
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +14 -0
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/call/treasury.d.ts +4 -0
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/keeper/index.d.ts +5 -0
- package/dist/schema/local/index.d.ts +28 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +5 -0
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +83 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +16 -0
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/workflow/index.d.ts +2 -0
- package/dist/schema/workflow/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +25 -1
- package/dist/schemas/bridge_operation.output.json +25 -1
- package/dist/schemas/bridge_operation.schema.json +40 -0
- package/dist/schemas/guard2file.schema.json +8 -0
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/keeper_operation.output.json +24 -1
- package/dist/schemas/local_history_operation.output.json +25 -1
- package/dist/schemas/local_info_operation.output.json +25 -1
- package/dist/schemas/local_mark_operation.output.json +25 -1
- package/dist/schemas/machineNode2file.schema.json +8 -0
- package/dist/schemas/messenger_operation.output.json +24 -1
- package/dist/schemas/messenger_operation.schema.json +2 -2
- package/dist/schemas/monitor_events.output.json +24 -1
- package/dist/schemas/monitor_subscription.output.json +24 -1
- package/dist/schemas/onchain_events.output.json +24 -1
- package/dist/schemas/onchain_operations.output.json +73 -3
- package/dist/schemas/onchain_operations.schema.json +3286 -821
- package/dist/schemas/onchain_operations_allocation.schema.json +12 -0
- package/dist/schemas/onchain_operations_arbitration.schema.json +18 -10
- package/dist/schemas/onchain_operations_contact.schema.json +8 -0
- package/dist/schemas/onchain_operations_demand.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_passport.schema.json +8 -0
- package/dist/schemas/onchain_operations_gen_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_guard.schema.json +2896 -596
- package/dist/schemas/onchain_operations_machine.schema.json +8 -0
- package/dist/schemas/onchain_operations_order.schema.json +10 -2
- package/dist/schemas/onchain_operations_payment.schema.json +8 -0
- package/dist/schemas/onchain_operations_permission.schema.json +8 -0
- package/dist/schemas/onchain_operations_personal.schema.json +8 -0
- package/dist/schemas/onchain_operations_progress.schema.json +8 -0
- package/dist/schemas/onchain_operations_proof.schema.json +8 -0
- package/dist/schemas/onchain_operations_repository.schema.json +14 -6
- package/dist/schemas/onchain_operations_reward.schema.json +8 -0
- package/dist/schemas/onchain_operations_service.schema.json +43 -10
- package/dist/schemas/onchain_operations_treasury.schema.json +8 -0
- package/dist/schemas/onchain_table_data.output.json +35 -12
- package/dist/schemas/query_toolkit.output.json +1179 -10
- package/dist/schemas/query_toolkit.schema.json +11 -11
- package/dist/schemas/workflow_operation.schema.json +8 -0
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.js +1 -1
- package/dist/tools/handlers/dispatch-expectations.spec.d.ts +1 -0
- package/dist/tools/handlers/dispatch-expectations.spec.js +1 -0
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/workflow.js +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getJudgmentDoc}from'../config/judgment.js';import{appetiteMultiplier}from'./game-strategy.js';function arbParams(){return getJudgmentDoc()['game']['arb'];}const ARB_MOVE_SEMANTICS={'Principal_confirming':[{'action':'principal\x20confirm','perspective':'customer','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20the\x20proposition\x20to\x20move\x20to\x20arbitrator\x20confirmation','base_risk':'low'},{'action':'proposition\x20update','perspective':'customer','gain':[],'risk':['case_extended'],'payoff':'modify\x20the\x20proposition\x20before\x20confirming\x20(extends\x20the\x20case)','base_risk':'medium'}],'Arbitrator_confirming':[{'action':'confirm','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20to\x20open\x20voting','base_risk':'low'},{'action':'reset','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'reset\x20back\x20to\x20principal\x20confirmation\x20(extends\x20the\x20case)','base_risk':'high'}],'Voting':[{'action':'vote','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'vote\x20before\x20the\x20deadline','base_risk':'low'},{'action':'deadline\x20change','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'adjust\x20or\x20clear\x20the\x20voting\x20window\x20(prolongs\x20or\x20reopens\x20the\x20case)','base_risk':'medium'}],'Arbitrated':[{'action':'objection','perspective':'customer','gain':['reversal_chance'],'risk':[],'payoff':'object\x20the\x20ruling\x20(only\x20window\x20to\x20overturn)','base_risk':'medium'},{'action':'accept','perspective':'customer','gain':['case_closed'],'risk':['adverse_ruling'],'payoff':'accept\x20and\x20await\x20compensation','base_risk':'low'},{'action':'arb_withdraw','perspective':'all','gain':['fees_received','case_closed'],'risk':[],'payoff':'withdraw\x20the\x20fee\x20balance\x2030\x20days\x20after\
|
|
1
|
+
import{getJudgmentDoc}from'../config/judgment.js';import{appetiteMultiplier}from'./game-strategy.js';function arbParams(){return getJudgmentDoc()['game']['arb'];}const ARB_MOVE_SEMANTICS={'Principal_confirming':[{'action':'principal\x20confirm','perspective':'customer','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20the\x20proposition\x20to\x20move\x20to\x20arbitrator\x20confirmation','base_risk':'low'},{'action':'proposition\x20update','perspective':'customer','gain':[],'risk':['case_extended'],'payoff':'modify\x20the\x20proposition\x20before\x20confirming\x20(extends\x20the\x20case)','base_risk':'medium'}],'Arbitrator_confirming':[{'action':'confirm','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'confirm\x20to\x20open\x20voting','base_risk':'low'},{'action':'reset','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'reset\x20back\x20to\x20principal\x20confirmation\x20(extends\x20the\x20case)','base_risk':'high'}],'Voting':[{'action':'vote','perspective':'arbitrator','gain':['case_advanced'],'risk':[],'payoff':'vote\x20before\x20the\x20deadline','base_risk':'low'},{'action':'deadline\x20change','perspective':'arbitrator','gain':[],'risk':['case_extended'],'payoff':'adjust\x20or\x20clear\x20the\x20voting\x20window\x20(prolongs\x20or\x20reopens\x20the\x20case)','base_risk':'medium'}],'Arbitrated':[{'action':'objection','perspective':'customer','gain':['reversal_chance'],'risk':[],'payoff':'object\x20the\x20ruling\x20(only\x20window\x20to\x20overturn)','base_risk':'medium'},{'action':'accept','perspective':'customer','gain':['case_closed'],'risk':['adverse_ruling'],'payoff':'accept\x20and\x20await\x20compensation','base_risk':'low'},{'action':'arb_withdraw','perspective':'all','gain':['fees_received','case_closed'],'risk':[],'payoff':'withdraw\x20the\x20fee\x20balance\x2030\x20days\x20after\x20an\x20uncontested\x20ruling\x20(closes\x20the\x20case)','base_risk':'low'}],'Objectionable':[{'action':'reset','perspective':'arbitrator','gain':['case_advanced'],'risk':['case_extended'],'payoff':'reset\x20to\x20re-review;\x20the\x20ONLY\x20exit\x20—\x20the\x20fee\x20stays\x20escrowed\x20until\x20the\x20principal\x20re-confirms\x20and\x20a\x20new\x20ruling\x20goes\x20unchallenged\x20(protocol\x20141)','base_risk':'medium'}],'Finished':[{'action':'arb_withdraw','perspective':'all','gain':['fees_received','case_closed'],'risk':[],'payoff':'withdraw\x20fees\x20/\x20compensation','base_risk':'low'}],'Withdrawn':[{'action':'done','perspective':'all','gain':['case_closed'],'risk':[],'payoff':'case\x20closed','base_risk':'low'}]};function dedupe(a){return Array['from'](new Set(a));}function resolveArbInterests(a,b){const c=arbParams(),d=c['role_interests'][a]??{'prefer':[],'avoid':[],'sensitivity':0x1},e=d['sensitivity']*appetiteMultiplier(b?.['risk_appetite']),f=[...d['prefer']],g=[...d['avoid']];for(const h of b?.['requirements']??[]){const i=h['toLowerCase'](),j=new RegExp(c['forbid_pattern'],'i')['test'](i);for(const k of c['keyword_rules']){if(k['when_forbidden']!==j)continue;k['keywords']['some'](l=>i['includes'](l['toLowerCase']()))&&(k['anchor']==='prefer'?f:g)['push'](k['effect']);}}return{'prefer':dedupe(f),'avoid':dedupe(g),'sensitivity':e};}function scoreMove(a,b,c){const {scoring:d}=arbParams(),e=resolveArbInterests(b,c),f=a['gain']['filter'](k=>e['prefer']['includes'](k)),g=a['risk']['filter'](k=>e['avoid']['includes'](k)),h=f['length']*d['per_gain'],i=Math['round'](g['length']*d['per_risk']*e['sensitivity']),j=Math['max'](0x0,Math['min'](0x64,d['base']+h-i));return{'favorability':j,'gain_score':h,'risk_score':i};}export function evaluateArbGame(a,b,c){const d=ARB_MOVE_SEMANTICS[a]??[],e=d['filter'](g=>g['perspective']==='all'||g['perspective']===b),f=e['map'](g=>{const h=scoreMove(g,b,c);return{'action':g['action'],'favorability':h['favorability'],'gain_score':h['gain_score'],'risk_score':h['risk_score'],'is_optimal':![],'payoff_note':g['payoff'],'risk':g['base_risk']};})['sort']((g,h)=>h['favorability']-g['favorability']);return f['length']>0x0&&(f[0x0]['is_optimal']=!![]),{'status':a,'perspective':b,'actions':f,'summary':f['length']===0x0?'No\x20recommended\x20moves\x20for\x20'+b+'\x20in\x20status\x20\x27'+a+'\x27':'Optimal\x20for\x20'+b+'\x20in\x20\x27'+a+'\x27:\x20\x27'+f[0x0]['action']+'\x27\x20('+f[0x0]['payoff_note']+')'};}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{COVERAGE_VOCABULARY}from'../../graph/onchain/facts.js';import{getEvaluationEngine}from'../engine.js';import{defaultWeight,dimensionLabel,gradeWord,severityDeduction}from'../standards.js';export const GRAPH_TRUST_EVALUATION='graph_service_trust';export const GRAPH_RISK_EVALUATION='graph_service_risk';export const GRAPH_RULE_INPUT_FACTS={'trust_arbitration':['arbitration.binding'],'trust_reviews':['reviews.votes'],'trust_fulfillment':['fulfillment.orders'],'trust_fund_safety':['fund.compensation','fund.exposure'],'trust_transparency':['transparency.profile'],'risk_workflow':['risk_workflow.findings'],'risk_fund':['risk_fund.findings'],'risk_trust':['risk_trust.findings'],'risk_behavior':['risk_behavior.findings']};const dsGraphFacts={'id':'ds_graph_facts','description':'Unpack\x20the\x20graph-projected\x20evaluation\x20facts\x20(Task\x2013\x20projection)\x20into\x20the\x20rule\x20context','evaluation_ids':[GRAPH_TRUST_EVALUATION,GRAPH_RISK_EVALUATION],'extract':a=>{const b=a['entities']['graph_facts'],c={'target':b['target'],'completeness':b['completeness']};for(const d of b['facts'])c[d['key']]=d;return c;}};function inputFact(a,b){const c=GRAPH_RULE_INPUT_FACTS[b];return c?a['facts'][c[0x0]]:undefined;}function factOf(a,b){return a['facts']['find'](c=>c['key']===b);}function trustArbitrationRule(){const a='trust_arbitration';return{'id':a,'description':'Arbitration\x20trust\x20dimension\x20(binding\x20material\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value']??[];if(d['length']===0x0)return{'score':0x0,'weight':defaultWeight(a),'reason':'No\x20arbitration\x20binding\x20configured\x20(verified\x20absence)\x20—\x20'+c['evidence'],'mismatched':['arbitration_binding']};let e=0x0;const f=[],g=[];if(d['every'](h=>h['votingGuards']>0x0))e+=0x8,f['push']('arbitrator\x20roster\x20configured');else g['push']('no\x20arbitrator\x20roster');if(d['every'](h=>BigInt(h['fee']||'0')>0x0n))e+=0x6,f['push']('arbitration\x20fee\x20funded');else g['push']('arbitration\x20fee\x20unfunded');if(!d['some'](h=>h['paused']))e+=0x6,f['push']('arbitration\x20active');else g['push']('arbitration\x20paused');return{'score':Math['round'](e/0x14*0x64),'weight':defaultWeight(a),'reason':'Arbitration\x20'+e+'/20\x20—\x20'+c['evidence'],'matched':f,'mismatched':g};}};}function trustReviewsRule(){const a='trust_reviews';return{'id':a,'description':'Review\x20reputation\x20dimension\x20(registrar\x20votes\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value']??{'total':0x0,'like':0x0,'dislike':0x0,'favor':0x0};if(c['state']==='empty'||d['total']===0x0)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20reputation\x20signal\x20(verified\x20empty\x20window)\x20—\x20'+c['evidence']};const e=d['like']/d['total'],f=Math['min'](0x23,Math['round'](e*0x19)+Math['min'](0xa,d['favor']));return{'score':Math['round'](f/0x23*0x64),'weight':defaultWeight(a),'reason':'Reviews\x20'+f+'/35\x20(like\x20rate\x20'+Math['round'](e*0x64)+'%)\x20—\x20'+c['evidence'],'matched':['vote\x20window\x20read\x20without\x20truncation'],'mismatched':d['like']<d['dislike']?['dislike\x20majority']:[]};}};}function trustFulfillmentRule(){const a='trust_fulfillment';return{'id':a,'description':'Fulfillment\x20dimension\x20(windowed\x20order\x20record\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value'];if(c['state']==='empty'||!d||d['observed']===0x0)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20fulfillment\x20record\x20yet\x20(verified\x20empty\x20window)\x20—\x20'+c['evidence']};const e=Math['min'](0xa,Math['floor'](d['observed']/0x5)),f=d['completed']+d['inProgress'],g=f>0x0?Math['round'](d['completed']/f*0xa):0x5,h=Math['min'](0x14,e+g);return{'score':Math['round'](h/0x14*0x64),'weight':defaultWeight(a),'reason':'Fulfillment\x20'+h+'/20\x20(recent\x20orders:\x20'+d['observed']+')\x20—\x20'+c['evidence'],'matched':['completion\x20'+d['completed']+'/'+(f||d['observed'])+'\x20resolved'],'mismatched':d['completed']===0x0?['no\x20completed\x20order\x20in\x20window']:[]};}};}function trustFundSafetyRule(){const a='trust_fund_safety';return{'id':a,'description':'Fund\x20safety\x20dimension\x20(compensation\x20fund\x20vs\x20windowed\x20exposure\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=GRAPH_RULE_INPUT_FACTS[a],d=b['facts'][c[0x0]],e=b['facts'][c[0x1]];if(!d||!e||d['state']==='gap'||e['state']==='gap')return null;const f=BigInt(d['value']?.['fund']??'0'),g=[];let h;const i=e['value'],j=BigInt(i?.['windowedAmount']??'0');if(e['state']==='empty'||j===0x0n){h=f>0x0n?0xf:0x0;if(f===0x0n)g['push']('no\x20compensation\x20fund');}else{if(i['coverageMet'])h=0xf;else{const k=BigInt(i['neededCeiling']||'1');if(f>=j){const l=Number(f*0x3e8n/k)/0x3e8;h=0xa+Math['round']((l-0x1/0x3)/(0x2/0x3)*0x5);}else h=Math['round'](Number(f*0x3e8n/j)/0x3e8*0xa);g['push']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20exposure\x20ceiling');}}return{'score':Math['round'](Math['max'](0x0,h)/0xf*0x64),'weight':defaultWeight(a),'reason':'Fund\x20safety\x20'+Math['max'](0x0,h)+'/15\x20—\x20'+d['evidence']+'\x20'+e['evidence'],'matched':g['length']===0x0?['exposure\x20covered']:[],'mismatched':g};}};}function trustTransparencyRule(){const a='trust_transparency';return{'id':a,'description':'Transparency\x20dimension\x20(snapshot\x20self-description\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value'];if(c['state']==='empty'||!d)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20transparency\x20profile\x20material\x20—\x20'+c['evidence']};let e=0x0;const f=[],g=[];if(d['published'])e+=0x4,f['push']('service\x20published');else g['push']('service\x20unpublished');if(d['description']!=='')e+=0x3,f['push']('description\x20present');else g['push']('empty\x20description');if(d['location']!=='')e+=0x3,f['push']('location\x20present');else g['push']('empty\x20location');return{'score':Math['round'](e/0xa*0x64),'weight':defaultWeight(a),'reason':'Transparency\x20'+e+'/10\x20—\x20'+c['evidence'],'matched':f,'mismatched':g};}};}function riskRule(a){const b=dimensionLabel(a);return{'id':a,'description':b+'\x20structural\x20risk\x20dimension\x20(analyzer\x20findings\x20reused\x20by\x20reference)','dimension':b,get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_RISK_EVALUATION],'evaluate':c=>{const d=inputFact(c,a);if(!d||d['state']==='gap')return null;const e=d['value']
|
|
1
|
+
import{COVERAGE_VOCABULARY}from'../../graph/onchain/facts.js';import{getEvaluationEngine}from'../engine.js';import{defaultWeight,dimensionLabel,gradeWord,severityDeduction}from'../standards.js';export const GRAPH_TRUST_EVALUATION='graph_service_trust';export const GRAPH_RISK_EVALUATION='graph_service_risk';export const GRAPH_RULE_INPUT_FACTS={'trust_arbitration':['arbitration.binding'],'trust_reviews':['reviews.votes'],'trust_fulfillment':['fulfillment.orders'],'trust_fund_safety':['fund.compensation','fund.exposure'],'trust_transparency':['transparency.profile'],'risk_workflow':['risk_workflow.findings'],'risk_fund':['risk_fund.findings'],'risk_trust':['risk_trust.findings'],'risk_behavior':['risk_behavior.findings']};const dsGraphFacts={'id':'ds_graph_facts','description':'Unpack\x20the\x20graph-projected\x20evaluation\x20facts\x20(Task\x2013\x20projection)\x20into\x20the\x20rule\x20context','evaluation_ids':[GRAPH_TRUST_EVALUATION,GRAPH_RISK_EVALUATION],'extract':a=>{const b=a['entities']['graph_facts'],c={'target':b['target'],'completeness':b['completeness']};for(const d of b['facts'])c[d['key']]=d;return c;}};function inputFact(a,b){const c=GRAPH_RULE_INPUT_FACTS[b];return c?a['facts'][c[0x0]]:undefined;}function factOf(a,b){return a['facts']['find'](c=>c['key']===b);}function trustArbitrationRule(){const a='trust_arbitration';return{'id':a,'description':'Arbitration\x20trust\x20dimension\x20(binding\x20material\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value']??[];if(d['length']===0x0)return{'score':0x0,'weight':defaultWeight(a),'reason':'No\x20arbitration\x20binding\x20configured\x20(verified\x20absence)\x20—\x20'+c['evidence'],'mismatched':['arbitration_binding']};let e=0x0;const f=[],g=[];if(d['every'](h=>h['votingGuards']>0x0))e+=0x8,f['push']('arbitrator\x20roster\x20configured');else g['push']('no\x20arbitrator\x20roster');if(d['every'](h=>BigInt(h['fee']||'0')>0x0n))e+=0x6,f['push']('arbitration\x20fee\x20funded');else g['push']('arbitration\x20fee\x20unfunded');if(!d['some'](h=>h['paused']))e+=0x6,f['push']('arbitration\x20active');else g['push']('arbitration\x20paused');return{'score':Math['round'](e/0x14*0x64),'weight':defaultWeight(a),'reason':'Arbitration\x20'+e+'/20\x20—\x20'+c['evidence'],'matched':f,'mismatched':g};}};}function trustReviewsRule(){const a='trust_reviews';return{'id':a,'description':'Review\x20reputation\x20dimension\x20(registrar\x20votes\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value']??{'total':0x0,'like':0x0,'dislike':0x0,'favor':0x0};if(c['state']==='empty'||d['total']===0x0)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20reputation\x20signal\x20(verified\x20empty\x20window)\x20—\x20'+c['evidence']};const e=d['like']/d['total'],f=Math['min'](0x23,Math['round'](e*0x19)+Math['min'](0xa,d['favor']));return{'score':Math['round'](f/0x23*0x64),'weight':defaultWeight(a),'reason':'Reviews\x20'+f+'/35\x20(like\x20rate\x20'+Math['round'](e*0x64)+'%)\x20—\x20'+c['evidence'],'matched':['vote\x20window\x20read\x20without\x20truncation'],'mismatched':d['like']<d['dislike']?['dislike\x20majority']:[]};}};}function trustFulfillmentRule(){const a='trust_fulfillment';return{'id':a,'description':'Fulfillment\x20dimension\x20(windowed\x20order\x20record\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value'];if(c['state']==='empty'||!d||d['observed']===0x0)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20fulfillment\x20record\x20yet\x20(verified\x20empty\x20window)\x20—\x20'+c['evidence']};const e=Math['min'](0xa,Math['floor'](d['observed']/0x5)),f=d['completed']+d['inProgress'],g=f>0x0?Math['round'](d['completed']/f*0xa):0x5,h=Math['min'](0x14,e+g);return{'score':Math['round'](h/0x14*0x64),'weight':defaultWeight(a),'reason':'Fulfillment\x20'+h+'/20\x20(recent\x20orders:\x20'+d['observed']+')\x20—\x20'+c['evidence'],'matched':['completion\x20'+d['completed']+'/'+(f||d['observed'])+'\x20resolved'],'mismatched':d['completed']===0x0?['no\x20completed\x20order\x20in\x20window']:[]};}};}function trustFundSafetyRule(){const a='trust_fund_safety';return{'id':a,'description':'Fund\x20safety\x20dimension\x20(compensation\x20fund\x20vs\x20windowed\x20exposure\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=GRAPH_RULE_INPUT_FACTS[a],d=b['facts'][c[0x0]],e=b['facts'][c[0x1]];if(!d||!e||d['state']==='gap'||e['state']==='gap')return null;const f=BigInt(d['value']?.['fund']??'0'),g=[];let h;const i=e['value'],j=BigInt(i?.['windowedAmount']??'0');if(e['state']==='empty'||j===0x0n){h=f>0x0n?0xf:0x0;if(f===0x0n)g['push']('no\x20compensation\x20fund');}else{if(i['coverageMet'])h=0xf;else{const k=BigInt(i['neededCeiling']||'1');if(f>=j){const l=Number(f*0x3e8n/k)/0x3e8;h=0xa+Math['round']((l-0x1/0x3)/(0x2/0x3)*0x5);}else h=Math['round'](Number(f*0x3e8n/j)/0x3e8*0xa);g['push']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20exposure\x20ceiling');}}return{'score':Math['round'](Math['max'](0x0,h)/0xf*0x64),'weight':defaultWeight(a),'reason':'Fund\x20safety\x20'+Math['max'](0x0,h)+'/15\x20—\x20'+d['evidence']+'\x20'+e['evidence'],'matched':g['length']===0x0?['exposure\x20covered']:[],'mismatched':g};}};}function trustTransparencyRule(){const a='trust_transparency';return{'id':a,'description':'Transparency\x20dimension\x20(snapshot\x20self-description\x20from\x20the\x20graph\x20facts)',get 'dimension'(){return dimensionLabel(a);},get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_TRUST_EVALUATION],'evaluate':b=>{const c=inputFact(b,a);if(!c||c['state']==='gap')return null;const d=c['value'];if(c['state']==='empty'||!d)return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20transparency\x20profile\x20material\x20—\x20'+c['evidence']};let e=0x0;const f=[],g=[];if(d['published'])e+=0x4,f['push']('service\x20published');else g['push']('service\x20unpublished');if(d['description']!=='')e+=0x3,f['push']('description\x20present');else g['push']('empty\x20description');if(d['location']!=='')e+=0x3,f['push']('location\x20present');else g['push']('empty\x20location');return{'score':Math['round'](e/0xa*0x64),'weight':defaultWeight(a),'reason':'Transparency\x20'+e+'/10\x20—\x20'+c['evidence'],'matched':f,'mismatched':g};}};}function riskRule(a){const b=dimensionLabel(a);return{'id':a,'description':b+'\x20structural\x20risk\x20dimension\x20(analyzer\x20findings\x20reused\x20by\x20reference)','dimension':b,get 'weight'(){return defaultWeight(a);},'evaluation_ids':[GRAPH_RISK_EVALUATION],'evaluate':c=>{const d=inputFact(c,a);if(!d||d['state']==='gap')return null;const e=d['value']??{'findings':[],'where':[]},f=e['findings'],g=new Map(f['map']((j,k)=>[j['id'],e['where'][k]??j['id']]));if(d['state']==='empty')return{'score':0x32,'weight':defaultWeight(a),'reason':'No\x20'+b+'\x20material\x20configured\x20(verified\x20absence)\x20—\x20'+d['evidence']};const h=f['reduce']((j,k)=>j+severityDeduction(k['severity']),0x0),i=Math['max'](0x0,0x64-h);return{'score':i,'weight':defaultWeight(a),'reason':f['length']>0x0?f['length']+'\x20structural\x20finding(s):\x20'+f['map'](j=>'['+j['severity']+']\x20'+(g['get'](j['id'])??j['title'])+':\x20'+j['title'])['join'](';\x20')+'\x20—\x20'+d['evidence']:'No\x20structural\x20risk\x20fired\x20—\x20'+d['evidence'],'matched':f['length']===0x0?['no\x20structural\x20findings']:[],'mismatched':[...new Set(f['map'](j=>j['title']))],'finding_refs':f['map'](j=>({'id':j['id'],'title':j['title'],'severity':j['severity']})),'red_flag':f['some'](j=>j['severity']==='critical')};}};}export function registerGraphServiceEvaluations(a=getEvaluationEngine()){a['registerDataSource'](dsGraphFacts);const b=[trustArbitrationRule(),trustReviewsRule(),trustFulfillmentRule(),trustFundSafetyRule(),trustTransparencyRule(),riskRule('risk_workflow'),riskRule('risk_fund'),riskRule('risk_trust'),riskRule('risk_behavior')];for(const c of b)a['registerRule'](c);}function collectUnverified(a){const b=new Map(a['facts']['map'](d=>[d['key'],d['state']])),c=[];for(const [d,e]of Object['entries'](GRAPH_RULE_INPUT_FACTS)){if(e['some'](f=>b['get'](f)==='gap'))c['push'](d);}return c;}function summarize(a,b,c,d){const e=['Service\x20'+b+'\x20'+a['total']+'/100\x20(grade:\x20'+gradeWord(b,a['total'])+')'],f=[...a['breakdown']]['sort']((g,h)=>g['score']-h['score'])[0x0];if(f){const g=(GRAPH_RULE_INPUT_FACTS[f['rule_id']]??[])['map'](h=>factOf(c,h)?.['evidence'])['filter'](Boolean)['join']('\x20');if(g)e['push']('weakest\x20'+dimensionLabel(f['rule_id'])+'\x20'+f['score']+'/100\x20—\x20'+g);}if(d['length']>0x0)e['push']('unverifiable\x20(excluded\x20from\x20aggregation):\x20'+d['map'](dimensionLabel)['join'](',\x20'));if(a['blocked'])e['push']('blocked:\x20'+(a['red_flags'][0x0]??'red\x20flag'));return e['join']('\x20—\x20');}export async function evaluateGraphServiceFacts(a,b){const c=getEvaluationEngine(),d={'graph_facts':a},e=await c['evaluate'](GRAPH_TRUST_EVALUATION,d,b),f=await c['evaluate'](GRAPH_RISK_EVALUATION,d,b),g=collectUnverified(a);return e['unverified']=g,f['unverified']=g,e['summary']=summarize(e,'trust',a,g),f['summary']=summarize(f,'risk',a,g),{'target':a['target'],'trust':e,'risk':f,'completeness':a['completeness'],'coverage':a['slots'],'unverified':g,'vocabulary':COVERAGE_VOCABULARY};}
|
|
@@ -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?.['raw']??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 allocationStructuralIssues(a){const b=[];let c=0x0,d=![];for(const e of asList(a)){const f=e??{};let g=0x0n,h=![];for(const i of asList(f['sharing'])){const j=i??{},k=Number(j['mode']);if(k===0x2||j['mode']==='Surplus'){c++,d=!![];continue;}k===0x1||j['mode']==='Rate'?g+=big(j['sharing']):h=!![];}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&&(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);}},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/objection\x20window.','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,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}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 allocationStructuralIssues(a){const b=[];let c=0x0,d=![];for(const e of asList(a)){const f=e??{};let g=0x0n,h=![];for(const i of asList(f['sharing'])){const j=i??{},k=Number(j['mode']);if(k===0x2||j['mode']==='Surplus'){c++,d=!![];continue;}k===0x1||j['mode']==='Rate'?g+=big(j['sharing']):h=!![];}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&&(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);}},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,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 +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\x2021\x20rules\x20(R1-7/A1-3/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','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\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('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\x2021\x20rules\x20(R1-7/A1-3/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','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('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']([]);});});
|