@wowok/agent-mcp 2.7.5 → 2.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/project/evaluation-fix.spec.d.ts +1 -0
  2. package/dist/project/evaluation-fix.spec.js +1 -0
  3. package/dist/project/evaluation.js +1 -1
  4. package/dist/project/index.js +1 -1
  5. package/dist/project/rollback-policy.js +1 -1
  6. package/dist/safety/confirm-gate.js +1 -1
  7. package/dist/schema/call/allocation.d.ts +9 -0
  8. package/dist/schema/call/arbitration.d.ts +10 -0
  9. package/dist/schema/call/contact.d.ts +10 -0
  10. package/dist/schema/call/demand.d.ts +10 -0
  11. package/dist/schema/call/machine.d.ts +10 -0
  12. package/dist/schema/call/order.d.ts +10 -0
  13. package/dist/schema/call/payment.d.ts +3 -3
  14. package/dist/schema/call/payment.js +1 -1
  15. package/dist/schema/call/permission.d.ts +10 -0
  16. package/dist/schema/call/progress.d.ts +10 -0
  17. package/dist/schema/call/repository.d.ts +10 -0
  18. package/dist/schema/call/reward.d.ts +16 -0
  19. package/dist/schema/call/semantic.js +1 -1
  20. package/dist/schema/call/service.d.ts +16 -0
  21. package/dist/schema/call/treasury.d.ts +16 -0
  22. package/dist/schema/common/index.d.ts +21 -0
  23. package/dist/schema/common/index.js +1 -1
  24. package/dist/schema/local/index.js +1 -1
  25. package/dist/schema/operations.d.ts +68 -1
  26. package/dist/schema/operations.js +1 -1
  27. package/dist/schema/query/index.d.ts +5 -0
  28. package/dist/schema/schema-version.js +1 -1
  29. package/dist/schema-query-impl/index.js +1 -1
  30. package/dist/schemas/index.json +1 -1
  31. package/dist/schemas/onchain_operations.schema.json +274 -7
  32. package/dist/schemas/onchain_operations_allocation.schema.json +12 -0
  33. package/dist/schemas/onchain_operations_arbitration.schema.json +20 -0
  34. package/dist/schemas/onchain_operations_contact.schema.json +20 -0
  35. package/dist/schemas/onchain_operations_demand.schema.json +20 -0
  36. package/dist/schemas/onchain_operations_machine.schema.json +20 -0
  37. package/dist/schemas/onchain_operations_order.schema.json +20 -0
  38. package/dist/schemas/onchain_operations_payment.schema.json +6 -7
  39. package/dist/schemas/onchain_operations_permission.schema.json +20 -0
  40. package/dist/schemas/onchain_operations_progress.schema.json +20 -0
  41. package/dist/schemas/onchain_operations_repository.schema.json +20 -0
  42. package/dist/schemas/onchain_operations_reward.schema.json +32 -0
  43. package/dist/schemas/onchain_operations_service.schema.json +32 -0
  44. package/dist/schemas/onchain_operations_treasury.schema.json +32 -0
  45. package/dist/schemas/query_toolkit.output.json +20 -0
  46. package/dist/tools/handlers/config.js +1 -1
  47. package/dist/tools/handlers/onchain.js +1 -1
  48. package/dist/tools/index.js +1 -1
  49. package/dist/tools/shared.js +1 -1
  50. package/package.json +2 -2
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{describe,it,expect}from'vitest';import{extractProjectEvaluationFacts}from'./evaluation.js';const SERVICE_ADDR='0x142b87262916f7b99dad034940815dd8cf862314c9d4a863a08584265c46b719',MACHINE_ADDR='0x157cf1aa07f1152a593a0a9a92d96ed8fbb146fd48065636565ef0f6b75e9465',PERMISSION_ADDR='0x1035f7c5ade2d66cec5a74dcc9440c80994fb8183dbea8a6da0f6f2cfc40d6bd',GUARD_WITHDRAW='0x1a7427f066374a774532fa677b8ba7a43aa480f6f6e4c9aca84b0a43c4247b76',GUARD_REFUND='0x1a4292ee44ae040988cd2c9a5b62e265246a0c33dad5256e1c63922ea25a7049',ARB_ADDR='0x13d328b529a261fdff25078ce34fff405ee663fe9d82ec1847869877ffc71b8a',CONTACT_ADDR='0x24a455e428ab4332a101d4863090b9204900b2ef8470a4250e6bed8bca12b76d';function projectObject(a,b,c){return{'id':'obj-'+c,'projectId':'p1','objectAddress':a,'objectType':b,'objectName':c,'role':'dependency','tags':null,'addedAt':0x0,'metadata':null};}function cacheEntry(a,b,c){return{'address':a,'objectType':b,'data':JSON['stringify'](c),'fetchedAt':0x0,'network':'testnet'};}describe('evaluate_project\x20A-fix:\x20bindings\x20derived\x20from\x20on-chain\x20cache',()=>{it('detects\x20Service\x20critical\x20bindings\x20with\x20an\x20EMPTY\x20graph\x20(build_graph\x20not\x20run)',()=>{const a={'machine':MACHINE_ADDR,'permission':PERMISSION_ADDR,'um':CONTACT_ADDR,'buy_guard':null,'order_allocators':{'description':'order\x20revenue\x20allocation','threshold':'0','allocators':[{'guard':GUARD_WITHDRAW,'sharing':0x2710},{'guard':GUARD_REFUND,'sharing':0x2710}]},'arbitrations':[ARB_ADDR]},b={'permission':PERMISSION_ADDR},c=[projectObject(SERVICE_ADDR,'Service','myshop_service_v2'),projectObject(MACHINE_ADDR,'Machine','myshop_machine_v2'),projectObject(PERMISSION_ADDR,'Permission','myshop_permission_v2'),projectObject(GUARD_WITHDRAW,'Guard','myshop_withdraw_guard_v2'),projectObject(GUARD_REFUND,'Guard','myshop_refund_guard_v2'),projectObject(ARB_ADDR,'Arbitration','myshop_arbitration_v2'),projectObject(CONTACT_ADDR,'Contact','myshop_aftersales_contact_v2')],d=new Map([[SERVICE_ADDR,cacheEntry(SERVICE_ADDR,'Service',a)],[MACHINE_ADDR,cacheEntry(MACHINE_ADDR,'Machine',b)]]),e=extractProjectEvaluationFacts({'project':{'id':'p1','prefix':'myshop','name':'myshop','description':null,'industry':'retail','perspective':'producer','status':'active','labels':null,'currentVersion':null,'serviceAddress':SERVICE_ADDR,'defaultAccount':null,'network':'testnet','createdAt':0x0,'updatedAt':0x0,'metadata':null},'objects':c,'edges':[],'objectCache':d}),f=g=>SERVICE_ADDR+'#'+g;expect(e['bindingIndex']['get'](f('machine'))?.['has'](MACHINE_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('permission'))?.['has'](PERMISSION_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('order_allocators'))?.['has'](GUARD_WITHDRAW))['toBe'](!![]),expect(e['bindingIndex']['get'](f('order_allocators'))?.['has'](GUARD_REFUND))['toBe'](!![]),expect(e['bindingIndex']['get'](f('arbitrations'))?.['has'](ARB_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](f('um'))?.['has'](CONTACT_ADDR))['toBe'](!![]),expect(e['bindingIndex']['get'](MACHINE_ADDR+'#permission')?.['has'](PERMISSION_ADDR))['toBe'](!![]);}),it('still\x20merges\x20edge-derived\x20bindings\x20when\x20the\x20graph\x20IS\x20built',()=>{const a={'machine':MACHINE_ADDR,'permission':PERMISSION_ADDR},b=[projectObject(SERVICE_ADDR,'Service','myshop_service_v2'),projectObject(MACHINE_ADDR,'Machine','myshop_machine_v2')],c=new Map([[SERVICE_ADDR,cacheEntry(SERVICE_ADDR,'Service',a)]]),d=extractProjectEvaluationFacts({'project':{'id':'p1','prefix':'myshop','name':'myshop','description':null,'industry':'retail','perspective':'producer','status':'active','labels':null,'currentVersion':null,'serviceAddress':SERVICE_ADDR,'defaultAccount':null,'network':'testnet','createdAt':0x0,'updatedAt':0x0,'metadata':null},'objects':b,'edges':[{'id':'e1','projectId':'p1','sourceObject':SERVICE_ADDR,'targetObject':MACHINE_ADDR,'edgeSource':'internal','relationshipType':'bind','fieldName':'machine','depth':0x1,'verified':!![],'weight':0x1,'direction':null,'metadata':null,'cachedAt':0x0}],'objectCache':c});expect(d['bindingIndex']['get'](SERVICE_ADDR+'#machine')?.['has'](MACHINE_ADDR))['toBe'](!![]);});});
@@ -1 +1 @@
1
- import{IndustryModeRegistry}from'../extensions/registry.js';import{collectPermissionIndexes,checkPermissionAuthorization}from'../schema/utils/permission-machine-check.js';import{getEvaluationEngine}from'../evaluation/engine.js';const CRITICAL_BINDINGS=[{'sourceType':'Service','targetType':'Machine','fieldName':'machine','critical':!![]},{'sourceType':'Service','targetType':'Permission','fieldName':'permission','critical':!![]},{'sourceType':'Service','targetType':'Guard','fieldName':'buy_guard','critical':![]},{'sourceType':'Service','targetType':'Allocation','fieldName':'order_allocators','critical':!![]},{'sourceType':'Service','targetType':'Arbitration','fieldName':'arbitrations','critical':![]},{'sourceType':'Machine','targetType':'Permission','fieldName':'permission','critical':!![]}],MERCHANT_REQUIRED_ITEMS=[{'id':'R1','objectType':'Permission','fieldName':'','required':!![],'description':'Governance\x20—\x20who\x20can\x20manage\x20the\x20service'},{'id':'R2','objectType':'Service','fieldName':'','required':!![],'description':'Core\x20offering\x20—\x20the\x20service\x20itself'},{'id':'R3','objectType':'Machine','fieldName':'machine','required':!![],'description':'Workflow\x20—\x20order\x20processing\x20pipeline'},{'id':'R4','objectType':'Guard','fieldName':'','required':!![],'description':'Purchase\x20validation\x20—\x20Guard\x20objects\x20configured\x20(binding\x20to\x20Service.buy_guard\x20is\x20optional)'},{'id':'R5','objectType':'Allocation','fieldName':'order_allocators','required':!![],'description':'Order\x20allocators\x20template\x20—\x20inline\x20Allocators\x20on\x20Service\x20(independent\x20Allocation\x20objects\x20are\x20created\x20per-order)'},{'id':'R6','objectType':'Treasury','fieldName':'','required':!![],'description':'Compensation\x20fund\x20—\x20independent\x20Treasury\x20object\x20for\x20buyer\x20refund\x20protection\x20(industry-aware:\x20optional\x20for\x20freelance)'},{'id':'R7','objectType':'Arbitration','fieldName':'arbitrations','required':!![],'description':'Dispute\x20resolution\x20—\x20arbitration\x20configured\x20(required\x20when\x20compensation_fund\x20>\x200\x20per\x20service.move:494)'},{'id':'R8','objectType':'Contact','fieldName':'','required':!![],'description':'Customer\x20communication\x20—\x20contact\x20info'},{'id':'R9','objectType':'Progress','fieldName':'','required':![],'description':'Order\x20tracking\x20—\x20progress\x20nodes'},{'id':'R10','objectType':'Reward','fieldName':'rewards','required':![],'description':'Customer\x20incentives\x20—\x20reward\x20claims'},{'id':'R11','objectType':'Repository','fieldName':'repositories','required':![],'description':'Documentation\x20—\x20published\x20data'},{'id':'R12','objectType':'Demand','fieldName':'','required':![],'description':'Market\x20discovery\x20—\x20demand\x20signals'}];function resolveRequiredItems(a,b=0x0,c=![]){let d=MERCHANT_REQUIRED_ITEMS;if(a&&a!=='general'){let e;try{e=IndustryModeRegistry['Instance']()['getMode'](a);}catch{}if(e){const f=e['risk_constraints']?.['require_compensation_fund']??!![];!f&&(d=MERCHANT_REQUIRED_ITEMS['map'](g=>{if(g['id']==='R6'||g['id']==='R7')return{...g,'required':![]};return g;}));}}return c&&b===0x0&&(d=d['map'](g=>{if(g['id']==='R6')return{...g,'required':![]};return g;})),b>0x0&&(d=d['map'](g=>g['id']==='R7'?{...g,'required':!![]}:g)),d;}const CONSUMER_DUE_DILIGENCE=[{'id':'E1','check':'Service\x20is\x20published\x20(bPublished=true)','severity':'critical','deduction':-0x1e},{'id':'E2','check':'Service\x20is\x20not\x20paused\x20(bPaused=false)','severity':'warning','deduction':-0x14},{'id':'E3','check':'Machine\x20has\x20workflow\x20nodes','severity':'warning','deduction':-0xf},{'id':'E4','check':'Service\x20has\x20buy_guard\x20(purchase\x20validation)','severity':'info','deduction':0x0},{'id':'E5','check':'Service\x20has\x20compensation_fund\x20(refund\x20protection)','severity':'warning','deduction':-0xf},{'id':'E6','check':'Arbitration\x20is\x20configured\x20(dispute\x20resolution)','severity':'critical','deduction':-0x19},{'id':'E7','check':'Permission\x20is\x20present\x20(governance)','severity':'warning','deduction':-0xa},{'id':'E8','check':'Contact\x20is\x20available\x20(merchant\x20reachable)','severity':'info','deduction':-0x5},{'id':'E9','check':'Repository\x20has\x20published\x20data\x20(transparency)','severity':'info','deduction':-0x5},{'id':'E10','check':'Reward\x20is\x20configured\x20(customer\x20incentives)','severity':'info','deduction':-0x3},{'id':'E11','check':'Service\x20has\x20description\x20(offering\x20clarity)','severity':'info','deduction':-0x5},{'id':'E12','check':'Registrar\x20reputation\x20is\x20positive','severity':'warning','deduction':-0xa}];function clampScore(a){return Math['max'](0x0,Math['min'](0x64,Math['round'](a)));}function shortTypeName(a){if(!a)return'unknown';const b=a['replace'](/<.*>/,'')['trim'](),c=b['split']('::'),d=c[c['length']-0x1]||'unknown';if(d['length']>0x0&&d===d['toLowerCase']())return d['charAt'](0x0)['toUpperCase']()+d['slice'](0x1);return d;}function groupByType(a){const b=new Map();for(const c of a){const d=shortTypeName(c['objectType']);if(!b['has'](d))b['set'](d,[]);b['get'](d)['push'](c);}return b;}function parseCacheData(a){if(!a)return null;try{return JSON['parse'](a['data']);}catch{return null;}}function isAddress(a){return typeof a==='string'&&a['startsWith']('0x')&&a['length']>=0xa;}function countArrayField(a,b){const c=a[b];if(Array['isArray'](c))return c['length'];return 0x0;}export function getNumberField(a,b){if(!a)return 0x0;const c=a[b];if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'){const d=Number(c);if(Number['isFinite'](d))return d;}return 0x0;}export function getMachineNodeCount(a){if(!a)return 0x0;const b=getNumberField(a,'node_count');if(b>0x0)return b;const c=countArrayField(a,'nodes');if(c>0x0)return c;const d=a['nodes'];if(d&&typeof d==='object'){const e=d['fields'];if(e&&typeof e==='object'){const g=getNumberField(e,'size');if(g>0x0)return g;}const f=getNumberField(d,'size');if(f>0x0)return f;}return 0x0;}function extractMachineNodesFromCache(a){if(!a)return[];const b=a['nodes'];if(Array['isArray'](b))return b;const c=a['config'];if(c&&Array['isArray'](c['nodes']))return c['nodes'];const d=a['nodes'];if(d&&typeof d==='object'){const e=d['fields'];if(e&&Array['isArray'](e['contents']))return e['contents'];}return[];}function getBalanceValue(a,b){if(!a)return 0x0;const c=a[b];if(c==null)return 0x0;if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'){const d=Number(c);if(Number['isFinite'](d))return d;}if(typeof c==='object'){const e=c,f=e['value']??e['fields'];if(typeof f==='number'&&Number['isFinite'](f))return f;if(typeof f==='string'){const g=Number(f);if(Number['isFinite'](g))return g;}if(typeof f==='object'&&f!==null){const h=f,i=h['value'];if(typeof i==='number'&&Number['isFinite'](i))return i;if(typeof i==='string'){const j=Number(i);if(Number['isFinite'](j))return j;}}}return 0x0;}function getMaxSalePrice(a){if(!a)return 0x0;const b=a['sales'];if(!Array['isArray'](b)||b['length']===0x0)return 0x0;let c=0x0;for(const d of b){if(typeof d!=='object'||d===null)continue;const e=d['price'];let f=0x0;if(typeof e==='number'&&Number['isFinite'](e))f=e;else{if(typeof e==='string'){const g=Number(e);if(Number['isFinite'](g))f=g;}}if(f>c)c=f;}return c;}function detectCircularRefs(a,b){const c=new Map();for(const i of a){if(i['edgeSource']==='potential')continue;if(!c['has'](i['sourceObject']))c['set'](i['sourceObject'],[]);c['get'](i['sourceObject'])['push'](i['targetObject']);}const d=[],f=new Set(),g=new Set(),h=[];for(const j of c['keys']()){if(f['has'](j))continue;const k=[{'node':j,'nextNeighborIdx':0x0,'neighbors':c['get'](j)??[]}];f['add'](j),g['add'](j),h['push'](j);while(k['length']>0x0){const l=k[k['length']-0x1];if(l['nextNeighborIdx']>=l['neighbors']['length']){k['pop'](),h['pop'](),g['delete'](l['node']);continue;}const m=l['neighbors'][l['nextNeighborIdx']];l['nextNeighborIdx']++;if(!f['has'](m))f['add'](m),g['add'](m),h['push'](m),k['push']({'node':m,'nextNeighborIdx':0x0,'neighbors':c['get'](m)??[]});else{if(g['has'](m)){const n=h['indexOf'](m),o=h['slice'](n)['concat'](m);!isWoWokNormalFundCycle(o,b)&&d['push'](o['join']('→'));}}}}return d;}function isWoWokNormalFundCycle(a,b){if(!b||a['length']<0x3)return![];const c=new Set();for(const f of a){const g=b['get'](f);if(g)c['add'](g);else return![];}if(c['size']===0x2&&c['has']('Order')&&c['has']('Allocation'))return!![];if(c['size']===0x3&&c['has']('Order')&&c['has']('Allocation')&&c['has']('Payment'))return!![];const d=['Service','Machine','Progress','Order'],e=Array['from'](c)['every'](h=>d['includes'](h));if(e&&c['size']>=0x2)return!![];return![];}function adjustWeightsForPerspective(a,b){if(b==='consumer')return a['map'](d=>{if(d['name']==='reputation'||d['name']==='arbitration_coverage'||d['name']==='consumer_diligence')return{...d,'weight':d['weight']*1.4};if(d['name']==='structural_risk'||d['name']==='deployment_readiness')return{...d,'weight':d['weight']*0.7};return d;});if(b==='producer')return a['map'](d=>{if(d['name']==='structural_risk'||d['name']==='deployment_readiness'||d['name']==='binding_completeness')return{...d,'weight':d['weight']*1.3};if(d['name']==='consumer_diligence'||d['name']==='transparency')return{...d,'weight':d['weight']*0.7};return d;});return a;}function normalizeWeights(a){const b=a['reduce']((d,e)=>d+e['weight'],0x0);if(b===0x0)return a;return a['map'](d=>({...d,'weight':d['weight']/b}));}export const RISK_WEIGHTS={'structural_risk':0.25,'fund_safety':0.2,'operational_risk':0.15,'governance_risk':0.1,'graph_coherence':0.2,'mode_registry':0.1};export const TRUST_WEIGHTS={'reputation':0.25,'arbitration_coverage':0.2,'guard_quality':0.2,'transparency':0.15,'consumer_diligence':0.2};export const COMPLETENESS_WEIGHTS={'object_coverage':0.3,'binding_completeness':0.25,'workflow_rationality':0.2,'deployment_readiness':0.25};export const EXTENDED_DIMENSION_WEIGHTS={'escrow_quality':0.15,'proof_integrity':0.1,'arbitration_fairness':0.15,'fee_transparency':0.1,'timeout_protection':0.1,'supplier_visibility':0.1,'content_commitment':0.1,'reputation_verifiability':0.1,'permission_safety':0.1};export function finalizeCriterionScores(a,b){const c=normalizeWeights(adjustWeightsForPerspective(a,b)),d=clampScore(c['reduce']((e,f)=>e+f['score']*f['weight'],0x0));return{'criterionScores':c,'overall':d};}function buildBindingIndex(a){const b=new Map();for(const c of a){if(c['edgeSource']==='potential')continue;if(!c['fieldName'])continue;const d=c['sourceObject']+'#'+c['fieldName'];if(!b['has'](d))b['set'](d,new Set());b['get'](d)['add'](c['targetObject']);}for(const f of a){if(f['edgeSource']!=='potential')continue;if(!f['fieldName'])continue;const g=f['sourceObject']+'#'+f['fieldName'];if(!b['has'](g)||b['get'](g)['size']===0x0){if(!b['has'](g))b['set'](g,new Set());b['get'](g)['add'](f['targetObject']);}}return b;}export function extractProjectEvaluationFacts(a){const {project:b,objects:c,edges:d,objectCache:f,reputation:g}=a,h=groupByType(c),i=buildBindingIndex(d),j=h['get']('Service')??[],k=j[0x0],l=k?parseCacheData(f['get'](k['objectAddress'])):null,m=k?getBalanceValue(l,'compensation_fund'):0x0,n=getMaxSalePrice(l),p=h['get']('Treasury')??[],q=h['get']('Allocation')??[],r=h['get']('Permission')??[],s=h['get']('Machine')??[],t=h['get']('Arbitration')??[],u=h['get']('Repository')??[],v=h['get']('Contact')??[],w=h['get']('Guard')??[],x=h['get']('Proof')??[],y=h['get']('Demand')??[],z=new Set();for(const I of c){if(I['objectAddress'])z['add'](I['objectAddress']);if(I['objectName']){z['add'](I['objectName']);const J=shortTypeName(I['objectType'])['toLowerCase']();z['add'](J+':'+I['objectName']);}}let A=0x0;for(const K of d){if(K['edgeSource']==='potential')continue;if(!z['has'](K['targetObject']))A++;}const B=new Map();for(const L of c){if(L['objectAddress'])B['set'](L['objectAddress'],shortTypeName(L['objectType']));}const C=detectCircularRefs(d,B),D=k?i['get'](k['objectAddress']+'#order_allocators')?.['size']??0x0:0x0,E=q['length']>0x0&&D>0x0;let F=!![],G=0x5;if(b['industry']&&b['industry']!=='general')try{const M=IndustryModeRegistry['Instance']()['getMode'](b['industry']);M&&(F=M['risk_constraints']?.['require_compensation_fund']??!![],M['risk_constraints']?.['compensation_fund_coverage_ratio']&&(G=M['risk_constraints']['compensation_fund_coverage_ratio']));}catch{}const H=new Map();for(const N of r){const O=parseCacheData(f['get'](N['objectAddress']));O&&H['set'](N['objectAddress'],{'address':N['objectAddress'],'entity_count':typeof O['entity_count']==='number'?O['entity_count']:undefined,'perm_remark':Array['isArray'](O['perm_remark'])?O['perm_remark']:undefined,'owner':typeof O['owner']==='string'?O['owner']:typeof O['builder']==='string'?O['builder']:undefined,'admin':Array['isArray'](O['admin'])?O['admin']:undefined});}return{'input':a,'project':b,'objects':c,'edges':d,'byType':h,'bindingIndex':i,'objectCache':f,'reputation':g,'serviceObj':k,'serviceData':l,'compensationBalance':m,'maxSalePrice':n,'treasuries':p,'allocations':q,'permissions':r,'machines':s,'arbitrations':t,'repositories':u,'contacts':v,'guards':w,'proofs':x,'demands':y,'danglingCount':A,'cycles':C,'hasAllocationEscrow':E,'orderAllocatorsBinding':D,'industryRequiresFund':F,'coverageRatio':G,'permDataMap':H};}function evaluateIndustryPattern(a,b,c,d){const e={'strengths':[],'findings':[],'matched':![]},f=a['industry'];if(!f||f==='general')return e;let g;try{g=IndustryModeRegistry['Instance']()['getMode'](f);}catch{return e;}if(!g)return e;const h=groupByType(b),i=buildBindingIndex(d);let j=0x0,k=0x0;const l=g['machine_shape'];if(l['length']>0x0){k++;const q=h['get']('Machine')??[];if(q['length']>0x0){const r=q[0x0],s=parseCacheData(c['get'](r['objectAddress'])),t=getMachineNodeCount(s);if(t>0x0&&t>=l['length'])j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20Machine\x20has\x20'+t+'\x20nodes,\x20covering\x20\x22'+f+'\x22\x20mode\x27s\x20'+l['length']+'\x20expected\x20node(s)');else t>0x0&&e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20Machine\x20has\x20'+t+'\x20nodes,\x20but\x20\x22'+f+'\x22\x20mode\x20expects\x20at\x20least\x20'+l['length'],'deduction':0x0});}}const n=g['guards'];if(n['length']>0x0){k++;const u=h['get']('Guard')??[],v=n['length'],w=n['length']*0x2;if(u['length']>=v&&u['length']<=w)j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+u['length']+'\x20Guard(s)\x20present,\x20within\x20\x22'+f+'\x22\x20mode\x27s\x20expected\x20range\x20['+v+'-'+w+']');else{if(u['length']>0x0&&u['length']<v)e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20'+u['length']+'\x20Guard(s)\x20present,\x20but\x20\x22'+f+'\x22\x20mode\x20expects\x20at\x20least\x20'+v+'\x20(recommended\x20range\x20['+v+'-'+w+'])','deduction':0x0});else u['length']>w&&(j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+u['length']+'\x20Guard(s)\x20present,\x20covering\x20\x22'+f+'\x22\x20mode\x27s\x20'+v+'\x20expected\x20guard(s)'),e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20'+u['length']+'\x20Guard(s)\x20present,\x20exceeds\x20recommended\x20max\x20'+w+'.\x20Consider\x20consolidating\x20guards\x20if\x20some\x20are\x20redundant.','deduction':0x0}));}}const o=g['allocator'];if(o){k++;const x=h['get']('Allocation')??[],y=h['get']('Service')??[],z=y[0x0],A=z?!!i['get'](z['objectAddress']+'#order_allocators')?.['size']:![],B=g['traits']['multi_tier_allocation'];if(A)j++,x['length']>0x0?e['strengths']['push']('Industry\x20pattern\x20match:\x20Service.order_allocators\x20bound\x20+\x20'+x['length']+'\x20Allocation\x20object(s)\x20present\x20(post-order)\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern'):e['strengths']['push']('Industry\x20pattern\x20match:\x20Service.order_allocators\x20template\x20bound\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern\x20(Allocation\x20objects\x20created\x20per-order)');else x['length']>0x0?(j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+x['length']+'\x20Allocation\x20object(s)\x20present\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern')):e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20Service.order_allocators\x20not\x20bound\x20and\x20no\x20Allocation\x20objects\x20—\x20\x22'+f+'\x22\x20mode\x20expects\x20'+(B?'multi-tier':'single-tier')+'\x20allocation\x20(Allocation\x20objects\x20are\x20created\x20per-order,\x20so\x20this\x20is\x20only\x20a\x20template-level\x20gap)','deduction':0x0});}const p=g['risk_constraints']?.['require_compensation_fund']??![];if(p||g['traits']['deposit_required']||g['traits']['trust_sensitivity']!=='low'){k++;const C=h['get']('Treasury')??[],D=h['get']('Service')??[],E=D[0x0],F=E?parseCacheData(c['get'](E['objectAddress'])):null,G=E?getBalanceValue(F,'compensation_fund'):0x0;if(C['length']>0x0||G>0x0){j++;const H=[];if(C['length']>0x0)H['push'](C['length']+'\x20Treasury\x20object(s)');if(G>0x0)H['push']('compensation_fund\x20balance\x20'+G);e['strengths']['push']('Industry\x20pattern\x20match:\x20'+H['join']('\x20+\x20')+'\x20—\x20matching\x20\x22'+f+'\x22\x20trust/deposit\x20pattern');}}e['matched']=k>0x0&&j/k>=0.6;if(e['matched'])e['strengths']['push']('Industry\x20pattern:\x20project\x20structure\x20matches\x20\x22'+f+'\x22\x20mode\x20('+j+'/'+k+'\x20checks\x20passed)');else k>0x0&&e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20project\x20partially\x20matches\x20\x22'+f+'\x22\x20mode\x20('+j+'/'+k+'\x20checks\x20passed)','deduction':0x0});if(f==='freelance'){const I=h['get']('Machine')??[];for(const J of I){const K=parseCacheData(c['get'](J['objectAddress']));if(!K)continue;const L=getMachineNodeCount(K);if(L>0x0){e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'ISSUE-P1-4:\x20freelance\x20project\x20has\x20a\x20Machine\x20with\x20'+L+'\x20node(s).\x20'+'If\x20the\x20workflow\x20includes\x20a\x20\x22delivered\x22\x20state,\x2048h\x20auto-accept\x20requires\x20'+'an\x20off-chain\x20keeper\x20(WoWok\x20Guard\x20does\x20not\x20support\x20time-based\x20triggers).\x20'+'Keeper\x20should\x20poll\x20Progress\x20objects\x20in\x20\x22delivered\x22\x20state\x20and\x20call\x20'+'adminUnhold\x20(permission\x20224)\x20after\x2048h\x20timeout.','deduction':0x0});break;}}}return e;}function evaluateRisk(a){const b=[],d=[],e=extractProjectEvaluationFacts(a),{objects:f,edges:g,objectCache:h,project:i}=e,j=e['bindingIndex'];let k=0x64;const l=e['serviceObj'],m=e['compensationBalance'];if(l)for(const O of CRITICAL_BINDINGS){if(O['sourceType']!=='Service')continue;const P=O['fieldName']==='arbitrations'?m>0x0?!![]:O['critical']:O['critical'],Q=l['objectAddress']+'#'+O['fieldName'],R=j['get'](Q);if(!R||R['size']===0x0){const S=P?-0x19:-0xa;k+=S,b['push']({'criterion':'structural_risk','severity':P?'critical':'warning','message':'Service\x20missing\x20'+O['fieldName']+'\x20binding\x20(expected\x20'+O['targetType']+')'+(O['fieldName']==='arbitrations'?m>0x0?'\x20—\x20required\x20by\x20contract\x20when\x20compensation_fund\x20>\x200\x20(service.move:494)':'\x20—\x20optional\x20when\x20compensation_fund\x20is\x200':''),'deduction':S});}else d['push']('Service\x20has\x20'+O['fieldName']+'\x20binding');}else k=0x1e,b['push']({'criterion':'structural_risk','severity':'critical','message':'No\x20Service\x20object\x20in\x20project\x20—\x20project\x20has\x20no\x20core','deduction':-0x46});k=clampScore(k);let n=0x64;const o=e['treasuries'],p=e['allocations'],q=e['serviceData'],r=e['compensationBalance'],s=e['orderAllocatorsBinding'],t=e['hasAllocationEscrow'],w=e['industryRequiresFund'];if(o['length']===0x0&&r===0x0){if(t)n-=0x5,d['push']('Allocation\x20escrow\x20mode\x20active\x20—\x20funds\x20locked\x20in\x20contract,\x20released\x20by\x20Guard\x20verification'),b['push']({'criterion':'fund_safety','severity':'info','message':'Using\x20Allocation\x20escrow\x20('+p['length']+'\x20Allocation\x20object(s)\x20+\x20order_allocators\x20bound)\x20—\x20fund\x20safety\x20via\x20Guard\x20verification,\x20no\x20Treasury/compensation_fund\x20needed','deduction':-0x5});else w?(n-=0x1e,b['push']({'criterion':'fund_safety','severity':'warning','message':'No\x20Treasury\x20object\x20and\x20Service.compensation_fund\x20is\x20empty\x20—\x20no\x20refund\x20fund\x20for\x20buyers','deduction':-0x1e})):(n-=0xa,b['push']({'criterion':'fund_safety','severity':'info','message':'No\x20Treasury/compensation_fund\x20—\x20industry\x20\x22'+i['industry']+'\x22\x20does\x20not\x20require\x20refund\x20fund\x20(optional)','deduction':-0xa}));}else{o['length']>0x0&&d['push'](o['length']+'\x20Treasury\x20object(s)\x20present\x20—\x20independent\x20fund\x20holder');if(r>0x0){d['push']('Service.compensation_fund\x20has\x20'+r+'\x20units\x20—\x20inline\x20refund\x20fund\x20active');const T=e['maxSalePrice'];if(T>0x0){const U=e['coverageRatio'],V=U*T;r<V?(n-=0xa,b['push']({'criterion':'fund_safety','severity':'warning','message':'Service.compensation_fund\x20balance\x20('+r+')\x20is\x20less\x20than\x20'+U+'×\x20the\x20max\x20order\x20amount\x20('+T+'\x20→\x20threshold\x20'+V+').\x20Refund\x20coverage\x20may\x20be\x20insufficient\x20—\x20top\x20up\x20via\x20service.compensation_fund_add\x20to\x20avoid\x20arbitration\x20rulings\x20exceeding\x20the\x20fund.\x20(industry:\x20'+(i['industry']??'general')+',\x20ratio:\x20'+U+'×)','deduction':-0xa})):b['push']({'criterion':'fund_safety','severity':'info','message':'Service.compensation_fund\x20balance\x20('+r+')\x20covers\x20'+U+'×\x20the\x20max\x20order\x20amount\x20('+T+').\x20Fund\x20is\x20sufficient\x20for\x20refund\x20protection.\x20(industry:\x20'+(i['industry']??'general')+',\x20ratio:\x20'+U+'×)','deduction':0x0});}}else b['push']({'criterion':'fund_safety','severity':'info','message':'Treasury\x20present\x20but\x20Service.compensation_fund\x20balance\x20is\x200\x20—\x20consider\x20depositing\x20refund\x20fund','deduction':-0x5});}n=clampScore(n);let x=0x64;if(l){const W=e['serviceData'];if(W){const X=W['bPaused'],Y=W['bPublished'];Y&&X&&(x-=0x19,b['push']({'criterion':'operational_risk','severity':'warning','message':'Service\x20is\x20published\x20but\x20PAUSED\x20—\x20operations\x20halted','deduction':-0x19})),!Y&&(x-=0xf,b['push']({'criterion':'operational_risk','severity':'info','message':'Service\x20not\x20yet\x20published\x20—\x20project\x20not\x20live','deduction':-0xf}));}}const y=e['arbitrations'];y['length']===0x0?(x-=0x14,b['push']({'criterion':'operational_risk','severity':'warning','message':'No\x20Arbitration\x20object\x20—\x20disputes\x20cannot\x20be\x20resolved','deduction':-0x14})):d['push'](y['length']+'\x20Arbitration\x20object(s)\x20configured');x=clampScore(x);let z=0x64;const A=e['permissions'];A['length']===0x0&&(z-=0x28,b['push']({'criterion':'governance_risk','severity':'critical','message':'No\x20Permission\x20object\x20—\x20project\x20is\x20ungoverned','deduction':-0x28}));if(l){const Z=e['serviceData'];Z&&!isAddress(Z['um'])&&(z-=0x5,b['push']({'criterion':'governance_risk','severity':'info','message':'Service\x20has\x20no\x20UM\x20(manager)\x20—\x20UM\x20is\x20optional;\x20set\x20via\x20um_set\x20if\x20management\x20delegation\x20needed','deduction':-0x5}));}const B=e['machines'];for(const a0 of B){const a1=a0['metadata'],a2=a1?.['config'];if(a2?.['entry_node_forward_hint']){const a6=a2['entry_node_forward_hint'],a7=a6['example_forward'];a7?.['namedOperator']===''&&d['push']('Machine\x20entry\x20forward\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder)\x20—\x20'+'correct\x20for\x20customer-operable\x20nodes.\x20namedOperator=\x27\x27\x20represents\x20'+'the\x20order\x20holder,\x20distinct\x20from\x20merchant\x27s\x20permission\x20index.');}const a3=a2?.['guard_objects'];a3&&a3['length']>0x0&&d['push']('Machine\x20has\x20'+a3['length']+'\x20guard\x20object\x20reference(s)\x20—\x20'+'forward-level\x20permission\x20validation\x20configured');const a4=parseCacheData(h['get'](a0['objectAddress'])),a5=getMachineNodeCount(a4);a5>0x0&&!a2&&b['push']({'criterion':'governance_risk','severity':'info','message':'Machine\x20has\x20'+a5+'\x20node(s).\x20Verify\x20each\x20forward\x20has\x20at\x20least\x20one\x20of\x20'+'namedOperator\x20or\x20permissionIndex.\x20Key:\x20namedOperator=\x27\x27\x20means\x20OrderHolder\x20'+'(customer),\x20NOT\x20\x27anyone\x27.\x20Use\x20non-empty\x20namedOperator\x20for\x20specific\x20roles,\x20'+'or\x20permissionIndex\x20for\x20permission-based\x20access.\x20Both\x20set\x20=\x20OR\x20semantic\x20'+'(either\x20can\x20execute).','deduction':0x0});}const C=e['machines'],D=e['permissions'],E=e['permDataMap'];for(const a8 of C){const a9=a8['objectAddress']+'#permission',aa=j['get'](a9);if(!aa||aa['size']===0x0)continue;let ab=null;for(const ah of aa){ab=ah;break;}if(!ab)continue;const ac=E['get'](ab);if(!ac)continue;const ad=parseCacheData(h['get'](a8['objectAddress']));if(!ad)continue;const ae=extractMachineNodesFromCache(ad);if(ae['length']===0x0)continue;const af=collectPermissionIndexes(ae);if(af['requiredIndexes']['length']===0x0)continue;const ag=checkPermissionAuthorization(af['requiredIndexes'],ac);!ag['allAuthorized']?(z-=0x19,b['push']({'criterion':'governance_risk','severity':'critical','message':'Machine\x20'+a8['objectAddress']['slice'](0x0,0x8)+'\x20has\x20forwards\x20referencing\x20'+('un-authorized\x20permission\x20indexes:\x20['+ag['missingIndexes']['join'](',\x20')+'].\x20')+'These\x20forwards\x20can\x20NEVER\x20be\x20executed\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck.\x20'+'Grant\x20entities\x20for\x20these\x20indexes\x20via\x20permission.op=\x22add\x20perm\x20by\x20index\x22\x20'+'before\x20publishing\x20the\x20Machine.','deduction':-0x19})):d['push']('Machine\x20'+a8['objectAddress']['slice'](0x0,0x8)+':\x20all\x20'+af['requiredIndexes']['length']+'\x20'+'permission\x20index(es)\x20are\x20authorized');}if(l&&y['length']>0x0){const ai=l['objectAddress']+'#permission',aj=j['get'](ai),ak=aj&&aj['size']>0x0?Array['from'](aj)[0x0]:null,al=ak?E['get'](ak):null;for(const am of y){const an=am['objectAddress']+'#permission',ao=j['get'](an),ap=ao&&ao['size']>0x0?Array['from'](ao)[0x0]:null;if(!ak||!ap)continue;if(ak===ap){z-=0x1e,b['push']({'criterion':'governance_risk','severity':'critical','message':'Arbitration\x20'+am['objectAddress']['slice'](0x0,0x8)+'\x20and\x20Service\x20share\x20the\x20SAME\x20'+('Permission\x20object\x20('+ak['slice'](0x0,0x8)+').\x20This\x20breaks\x20dispute\x20')+'fairness\x20—\x20the\x20merchant\x20fully\x20controls\x20arbitration\x20operations.\x20'+'Use\x20a\x20separate\x20Permission\x20object\x20for\x20Arbitration\x20to\x20ensure\x20independent\x20'+'dispute\x20resolution.\x20(per\x20arbitration.move:\x20the\x20permission\x20field\x20controls\x20'+'who\x20can\x20vote,\x20confirm,\x20and\x20execute\x20arbitration\x20rulings)','deduction':-0x1e});continue;}const aq=E['get'](ap);if(al&&aq){const ar=al['owner']?.['toLowerCase'](),as=aq['owner']?.['toLowerCase'](),at=new Set((al['admin']??[])['map'](ax=>ax['toLowerCase']())),au=new Set((aq['admin']??[])['map'](ax=>ax['toLowerCase']())),av=ar&&as&&ar===as,aw=[...at]['some'](ax=>au['has'](ax));if(av||aw){const ax=av&&aw?'owner\x20AND\x20admin\x20overlap':av?'same\x20owner':'admin\x20overlap';z-=0x14,b['push']({'criterion':'governance_risk','severity':'warning','message':'Arbitration\x20'+am['objectAddress']['slice'](0x0,0x8)+'\x20and\x20Service\x20have\x20'+('overlapping\x20Permission\x20control\x20('+ax+').\x20Even\x20with\x20separate\x20')+'Permission\x20objects,\x20shared\x20control\x20undermines\x20dispute\x20independence.\x20'+'The\x20contract\x20only\x20enforces\x20different\x20Permission\x20object\x20addresses\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT)\x20—\x20it\x20does\x20NOT\x20check\x20who\x20controls\x20'+'each\x20Permission,\x20so\x20this\x20governance\x20risk\x20exists\x20on\x20ANY\x20network.\x20'+'Use\x20a\x20completely\x20independent\x20third-party\x20Permission\x20(different\x20owner\x20'+'and\x20admin\x20list)\x20for\x20Arbitration.','deduction':-0x14});}else d['push']('Arbitration\x20'+am['objectAddress']['slice'](0x0,0x8)+'\x20has\x20independent\x20'+'Permission\x20(separate\x20owner/admin)\x20—\x20trustworthy\x20dispute\x20resolution');}}}z=clampScore(z);let F=0x64;const G=e['danglingCount'],H=e['cycles'];if(G>0x0){const ay=-Math['min'](0x14,G*0x3);F+=ay,b['push']({'criterion':'graph_coherence','severity':G>=0x3?'warning':'info','message':G+'\x20edge(s)\x20point\x20to\x20objects\x20outside\x20the\x20project\x20—\x20dangling\x20references','deduction':ay});}H['length']>0x0&&(F-=0xf,b['push']({'criterion':'graph_coherence','severity':'warning','message':H['length']+'\x20circular\x20reference(s)\x20detected:\x20'+H['slice'](0x0,0x2)['join'](';\x20')+(H['length']>0x2?'...':''),'deduction':-0xf}));G===0x0&&H['length']===0x0&&d['push']('Graph\x20is\x20coherent\x20—\x20no\x20dangling\x20refs\x20or\x20cycles');F=clampScore(F);let I=0x64,J='no\x20industry\x20declared\x20—\x20check\x20skipped';if(!i['industry'])b['push']({'criterion':'mode_registry','severity':'info','message':'Project\x20has\x20no\x20industry\x20tag\x20—\x20mode\x20registry\x20gates\x20(metrics/constraints)\x20not\x20evaluated.\x20Set\x20project\x20industry\x20to\x20enable.','deduction':0x0});else try{const az=IndustryModeRegistry['Instance']()['evaluateMode'](i['industry'],i['description']??i['name'],{'prefix':i['prefix'],'network':i['network']==='mainnet'?'mainnet':'testnet','business_intent':i['description']??undefined,'industry':i['industry'],'version':i['currentVersion']??undefined}),aA=az['unmet_conditions']['some'](aB=>aB['includes']('not\x20found'));if(aA)I=0x32,J='mode\x20\x27'+i['industry']+'\x27\x20not\x20registered',b['push']({'criterion':'mode_registry','severity':'warning','message':'Industry\x20mode\x20\x27'+i['industry']+'\x27\x20is\x20not\x20registered\x20in\x20the\x20mode\x20registry\x20—\x20cannot\x20verify\x20capability/conflict/constraint\x20gates.\x20Falling\x20back\x20to\x20unverified\x20mode.','deduction':-0x32});else{for(const aB of az['violated_constraints']){I-=0x19,b['push']({'criterion':'mode_registry','severity':'critical','message':'Mode\x20\x27'+i['industry']+'\x27\x20hard\x20constraint\x20violated:\x20'+aB,'deduction':-0x19});}for(const aC of az['capability_conflicts']){I-=0x14,b['push']({'criterion':'mode_registry','severity':'critical','message':'Mode\x20\x27'+i['industry']+'\x27\x20capability\x20conflict:\x20'+aC,'deduction':-0x14});}for(const aD of az['unmet_conditions']){I-=0xa,b['push']({'criterion':'mode_registry','severity':'warning','message':'Mode\x20\x27'+i['industry']+'\x27\x20soft\x20constraint\x20unmet:\x20'+aD,'deduction':-0xa});}I=clampScore(I),J='metric\x20risk\x20'+az['risk_score']+'\x20/\x20benefit\x20'+az['benefit_score']+'\x20'+('(ratio\x20'+az['risk_benefit_ratio']['toFixed'](0x2)+');\x20')+(az['violated_constraints']['length']+'\x20hard\x20+\x20'+az['unmet_conditions']['length']+'\x20soft\x20constraint\x20issue(s),\x20')+(az['capability_conflicts']['length']+'\x20capability\x20conflict(s)'),az['applicable']&&az['violated_constraints']['length']===0x0&&az['capability_conflicts']['length']===0x0&&az['unmet_conditions']['length']===0x0&&d['push']('Mode\x20\x27'+i['industry']+'\x27\x20passes\x20all\x20mode-registry\x20gates\x20—\x20'+('metric\x20risk\x20'+az['risk_score']+'\x20/\x20benefit\x20'+az['benefit_score']+'\x20')+('(risk-benefit\x20ratio\x20'+az['risk_benefit_ratio']['toFixed'](0x2)+')'));}}catch{J='mode\x20registry\x20unavailable\x20—\x20check\x20skipped';}I=clampScore(I);const {criterionScores:K,overall:L}=finalizeCriterionScores([{'name':'structural_risk','score':k,'weight':RISK_WEIGHTS['structural_risk'],'rationale':CRITICAL_BINDINGS['filter'](aE=>aE['sourceType']==='Service')['length']+'\x20expected\x20Service\x20bindings\x20checked'},{'name':'fund_safety','score':n,'weight':RISK_WEIGHTS['fund_safety'],'rationale':'Treasury\x20+\x20compensation_fund\x20coverage'},{'name':'operational_risk','score':x,'weight':RISK_WEIGHTS['operational_risk'],'rationale':'Service\x20state\x20+\x20arbitration\x20coverage'},{'name':'governance_risk','score':z,'weight':RISK_WEIGHTS['governance_risk'],'rationale':'Permission\x20+\x20UM\x20presence'},{'name':'graph_coherence','score':F,'weight':RISK_WEIGHTS['graph_coherence'],'rationale':G+'\x20dangling\x20+\x20'+H['length']+'\x20circular\x20refs'},{'name':'mode_registry','score':I,'weight':RISK_WEIGHTS['mode_registry'],'rationale':J}],i['perspective']),M=b['filter'](aE=>aE['severity']==='critical')['length'],N=M>0x0?'HIGH\x20RISK:\x20'+M+'\x20critical\x20issue(s).\x20'+b['length']+'\x20total\x20findings.':'Moderate\x20risk:\x20'+b['length']+'\x20finding(s),\x20no\x20critical\x20issues.';return{'evaluationType':'risk','score':L,'summary':N,'criterionScores':K,'findings':b,'strengths':d,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateTrust(a){const b=[],c=[],{objects:d,edges:e,objectCache:f,reputation:g,project:h}=a,i=groupByType(d),j=i['get']('Service')??[];let k=0x32;if(g&&g['size']>0x0&&j[0x0]){const z=g['get'](j[0x0]['objectAddress']);if(z){const A=z['likes']+z['dislikes'];if(A>0x0){const B=z['likes']/A;k=clampScore(0x32+(B-0.5)*0x64);if(B>=0.8)c['push']('Strong\x20reputation:\x20'+z['likes']+'\x20likes\x20vs\x20'+z['dislikes']+'\x20dislikes');else B<0.4&&b['push']({'criterion':'reputation','severity':'warning','message':'Poor\x20reputation:\x20'+z['dislikes']+'\x20dislikes\x20vs\x20'+z['likes']+'\x20likes','deduction':-0x14});}z['favorites']>=0x3&&(c['push'](z['favorites']+'\x20favorites\x20—\x20trusted\x20by\x20other\x20merchants'),k=clampScore(k+0xa));}}else b['push']({'criterion':'reputation','severity':'info','message':'No\x20Registrar\x20reputation\x20data\x20—\x20unknown\x20merchant\x20standing','deduction':-0xa});k=clampScore(k);let l=0x64;const m=i['get']('Arbitration')??[];m['length']===0x0?(l=0x1e,b['push']({'criterion':'arbitration_coverage','severity':'critical','message':'No\x20Arbitration\x20object\x20—\x20buyers\x20have\x20no\x20dispute\x20resolution\x20path','deduction':-0x46})):c['push'](m['length']+'\x20Arbitration\x20object(s)\x20—\x20dispute\x20resolution\x20available');l=clampScore(l);let n=0x3c;const o=i['get']('Guard')??[];o['length']===0x0?(n-=0x14,b['push']({'criterion':'guard_quality','severity':'warning','message':'No\x20Guard\x20objects\x20—\x20no\x20validation\x20rules','deduction':-0x14})):(n=0x50,c['push'](o['length']+'\x20Guard\x20object(s)\x20—\x20validation\x20rules\x20configured'));if(j[0x0]){const C=buildBindingIndex(e),D=j[0x0]['objectAddress']+'#buy_guard';if(C['get'](D)?.['size'])n=clampScore(n+0xf),c['push']('Service\x20has\x20buy_guard\x20bound\x20—\x20purchase\x20validation\x20active');else o['length']>0x0&&c['push']('Guard\x20objects\x20present\x20(buy_guard\x20binding\x20optional)');}n=clampScore(n);let p=0x3c;if(j[0x0]){const E=parseCacheData(f['get'](j[0x0]['objectAddress']));if(E){const F=E['description'];typeof F==='string'&&F['length']>0x0?(p+=0xf,c['push']('Service\x20has\x20description')):b['push']({'criterion':'transparency','severity':'info','message':'Service\x20has\x20no\x20description\x20—\x20buyers\x20cannot\x20evaluate\x20offering','deduction':-0xa});}}const q=i['get']('Repository')??[];q['length']>0x0&&(p=clampScore(p+0xa),c['push'](q['length']+'\x20Repository\x20object(s)\x20—\x20supporting\x20data\x20published'));const r=i['get']('Contact')??[];r['length']>0x0?(p=clampScore(p+0xa),c['push']('Contact\x20information\x20available')):b['push']({'criterion':'transparency','severity':'info','message':'No\x20Contact\x20object\x20—\x20buyers\x20cannot\x20reach\x20merchant','deduction':-0x5});p=clampScore(p);let s=0x64;const t=[],u=buildBindingIndex(e),v=j[0x0];if(v){const G=parseCacheData(f['get'](v['objectAddress']));for(const I of CONSUMER_DUE_DILIGENCE){let J=![];switch(I['id']){case'E1':J=!!G?.['bPublished'];break;case'E2':J=!!G&&!G['bPaused'];break;case'E3':J=(i['get']('Machine')??[])['some'](K=>{const L=parseCacheData(f['get'](K['objectAddress']));return L&&(getNumberField(L,'node_count')>0x0||countArrayField(L,'nodes')>0x0);});break;case'E4':J=!!u['get'](v['objectAddress']+'#buy_guard')?.['size']||(i['get']('Guard')??[])['length']>0x0;break;case'E5':J=getBalanceValue(G,'compensation_fund')>0x0||(i['get']('Treasury')??[])['length']>0x0;break;case'E6':J=(i['get']('Arbitration')??[])['length']>0x0;break;case'E7':J=(i['get']('Permission')??[])['length']>0x0;break;case'E8':J=(i['get']('Contact')??[])['length']>0x0;break;case'E9':J=(i['get']('Repository')??[])['length']>0x0;break;case'E10':J=!!u['get'](v['objectAddress']+'#rewards')?.['size'];break;case'E11':J=!!(G&&typeof G['description']==='string'&&G['description']['length']>0x0);break;case'E12':if(g&&g['size']>0x0){const K=g['get'](v['objectAddress']);J=!!K&&K['likes']>=K['dislikes'];}break;}if(J)t['push'](I['id']);else{let L=I['deduction'],M=I['severity'];if(I['id']==='E5'&&h['industry']&&h['industry']!=='general')try{const O=IndustryModeRegistry['Instance']()['getMode'](h['industry']);O&&O['risk_constraints']?.['require_compensation_fund']===![]&&(L=-0x3,M='info');}catch{}s+=L;const N=I['id']==='E5'&&L!==I['deduction']?'\x20(industry\x20does\x20not\x20require\x20compensation_fund\x20—\x20reduced\x20deduction)':'';b['push']({'criterion':'consumer_diligence','severity':M,'message':I['id']+':\x20'+I['check']+'\x20—\x20FAIL:\x20condition\x20not\x20met'+N+'\x20[severity:\x20'+M+']','deduction':L});}}const H=t['length']/CONSUMER_DUE_DILIGENCE['length'];H>=0.8&&c['push']('Consumer\x20due\x20diligence:\x20'+t['length']+'/'+CONSUMER_DUE_DILIGENCE['length']+'\x20checks\x20passed');}else s=0x14,b['push']({'criterion':'consumer_diligence','severity':'critical','message':'No\x20Service\x20object\x20—\x20consumer\x20due\x20diligence\x20cannot\x20be\x20performed','deduction':-0x50});s=clampScore(s);const {criterionScores:w,overall:x}=finalizeCriterionScores([{'name':'reputation','score':k,'weight':TRUST_WEIGHTS['reputation'],'rationale':'Registrar\x20likes/dislikes\x20+\x20favorites'},{'name':'arbitration_coverage','score':l,'weight':TRUST_WEIGHTS['arbitration_coverage'],'rationale':'Dispute\x20resolution\x20availability'},{'name':'guard_quality','score':n,'weight':TRUST_WEIGHTS['guard_quality'],'rationale':'Validation\x20rules\x20+\x20buy_guard\x20binding'},{'name':'transparency','score':p,'weight':TRUST_WEIGHTS['transparency'],'rationale':'Description\x20+\x20Repository\x20+\x20Contact\x20presence'},{'name':'consumer_diligence','score':s,'weight':TRUST_WEIGHTS['consumer_diligence'],'rationale':t['length']+'/'+CONSUMER_DUE_DILIGENCE['length']+'\x20E-checks\x20passed'}],h['perspective']),y=x>=0x46?'Trusted\x20project\x20(score\x20'+x+'/100).\x20'+c['length']+'\x20strength(s).':'Limited\x20trust\x20signals\x20(score\x20'+x+'/100).\x20'+b['length']+'\x20finding(s).';return{'evaluationType':'trust','score':x,'summary':y,'criterionScores':w,'findings':b,'strengths':c,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateCompleteness(a){const b=[],c=[],{objects:d,edges:f,objectCache:g,project:h}=a,i=groupByType(d),j=i['get']('Service')??[],k=buildBindingIndex(f),l=j[0x0],n=l?parseCacheData(g['get'](l['objectAddress'])):null,p=getBalanceValue(n,'compensation_fund'),q=i['get']('Allocation')??[],r=l?k['get'](l['objectAddress']+'#order_allocators')?.['size']??0x0:0x0,s=q['length']>0x0&&r>0x0,t=resolveRequiredItems(h['industry']??undefined,p,s),u=t['filter'](O=>O['required'])['length'],v=t['filter'](O=>!O['required']);let w=0x0,x=0x0;const y=[],z=[];for(const O of t){const P=(i['get'](O['objectType'])?.['length']??0x0)>0x0,Q=O['fieldName']?!!k['get']((j[0x0]?.['objectAddress']??'')+'#'+O['fieldName'])?.['size']:P;O['required']?Q||!O['fieldName']&&P?w++:y['push'](O['id']+'('+O['objectType']+')'):Q||!O['fieldName']&&P?x++:z['push'](O['id']+'('+O['objectType']+')');}const A=w/u,B=v['length']>0x0?x/v['length']:0x1;let C=clampScore(A*0x50+B*0x14);y['length']>0x0?b['push']({'criterion':'object_coverage','severity':y['length']>=0x3?'critical':'warning','message':'Missing\x20required\x20items:\x20'+y['join'](',\x20')+'\x20—\x20'+y['length']+'/'+u+'\x20required\x20items\x20absent','deduction':-0xf*y['length']}):c['push']('All\x20'+u+'\x20required\x20items\x20present\x20(R1-R8)');if(z['length']>0x0&&z['length']===v['length'])b['push']({'criterion':'object_coverage','severity':'info','message':'No\x20optional\x20items\x20configured:\x20'+z['join'](',\x20')+'\x20—\x20recommended\x20for\x20enhanced\x20UX','deduction':-0x5});else x>0x0&&c['push'](x+'/'+v['length']+'\x20optional\x20items\x20configured\x20(R9-R12)');C=clampScore(C);let D=0x64;if(j[0x0]){const R=j[0x0]['objectAddress'],S=parseCacheData(g['get'](R)),T=getBalanceValue(S,'compensation_fund');let U=0x0,V=0x0;for(const W of CRITICAL_BINDINGS){if(W['sourceType']!=='Service')continue;V++;const X=W['fieldName']==='arbitrations'?T>0x0?!![]:W['critical']:W['critical'],Y=R+'#'+W['fieldName'];if(k['get'](Y)?.['size'])U++;else{const Z=X?-0x14:-0x8;D+=Z,b['push']({'criterion':'binding_completeness','severity':X?'critical':'warning','message':'Service.'+W['fieldName']+'\x20not\x20bound\x20(expected\x20'+W['targetType']+')'+(W['fieldName']==='arbitrations'?T>0x0?'\x20—\x20required\x20by\x20contract\x20when\x20compensation_fund\x20>\x200':'\x20—\x20optional\x20when\x20compensation_fund\x20is\x200':''),'deduction':Z});}}U===V&&c['push']('All\x20'+V+'\x20Service\x20bindings\x20established');}else D=0x0,b['push']({'criterion':'binding_completeness','severity':'critical','message':'No\x20Service\x20object\x20—\x20cannot\x20evaluate\x20bindings','deduction':-0x64});D=clampScore(D);let E=0x50;const F=i['get']('Machine')??[];if(F['length']===0x0)E-=0x14,b['push']({'criterion':'workflow_rationality','severity':'info','message':'No\x20Machine\x20object\x20—\x20bind\x20one\x20before\x20publishing\x20(deploy-time\x20requirement)','deduction':-0x14});else for(const a0 of F){const a1=parseCacheData(g['get'](a0['objectAddress']));if(a1){const a2=getMachineNodeCount(a1);a2>0x0?c['push']('Machine\x20has\x20'+a2+'\x20node(s)'):(E-=0xa,b['push']({'criterion':'workflow_rationality','severity':'info','message':'Machine\x20'+a0['objectAddress']['slice'](0x0,0x8)+'\x20has\x20no\x20nodes','deduction':-0xa}));}}const G=new Set();for(const a3 of d){if(a3['objectAddress'])G['add'](a3['objectAddress']);if(a3['objectName']){G['add'](a3['objectName']);const a4=shortTypeName(a3['objectType'])['toLowerCase']();G['add'](a4+':'+a3['objectName']);}}let H=0x0;for(const a5 of f){if(a5['edgeSource']==='potential')continue;if(!G['has'](a5['targetObject']))H++;}H>0x0&&(E=clampScore(E-Math['min'](0x14,H*0x2)),b['push']({'criterion':'workflow_rationality','severity':'info','message':H+'\x20edge(s)\x20point\x20to\x20objects\x20not\x20in\x20project\x20—\x20dangling\x20references','deduction':-Math['min'](0x14,H*0x2)}));E=clampScore(E);let I=0x64;if(j[0x0]){const a6=parseCacheData(g['get'](j[0x0]['objectAddress']));if(a6){const a7=a6['bPublished'];if(a7){c['push']('Service\x20already\x20published\x20—\x20deployment\x20complete'),I=0x64;const a8=a6['machine'];if(typeof a8==='string'&&a8['startsWith']('0x')){const a9=parseCacheData(g['get'](a8));a9&&a9['bPublished']===![]&&(I-=0xa,b['push']({'criterion':'deployment_readiness','severity':'info','message':'Bound\x20Machine\x20'+a8['slice'](0x0,0x8)+'\x20is\x20not\x20published\x20—\x20order_progress\x20will\x20fail\x20(machine.move\x20E_NOT_PUBLISHED)','deduction':-0xa}));}}else{const aa=k['get'](j[0x0]['objectAddress']+'#machine')?.['size'],ab=k['get'](j[0x0]['objectAddress']+'#permission')?.['size'],ac=k['get'](j[0x0]['objectAddress']+'#order_allocators')?.['size'],ad=getBalanceValue(a6,'compensation_fund'),ae=k['get'](j[0x0]['objectAddress']+'#arbitrations')?.['size'];!aa&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20Machine\x20—\x20cannot\x20publish','deduction':-0x1e}));!ab&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20Permission\x20—\x20cannot\x20publish','deduction':-0x1e}));!ac&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20order_allocators\x20—\x20cannot\x20publish\x20(service.move:493\x20E_NO_ALLOCATOR)','deduction':-0x1e}));ad>0x0&&!ae&&(I-=0x19,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20compensation_fund\x20('+ad+')\x20but\x20no\x20arbitrations\x20—\x20cannot\x20publish\x20(service.move:495\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','deduction':-0x19}));if(aa&&ab&&ac){if(ad>0x0&&ae)c['push']('Service\x20ready\x20to\x20publish\x20(Machine\x20+\x20Permission\x20+\x20order_allocators\x20+\x20arbitrations\x20bound)');else ad===0x0&&c['push']('Service\x20ready\x20to\x20publish\x20(Machine\x20+\x20Permission\x20+\x20order_allocators\x20bound;\x20arbitrations\x20optional\x20when\x20compensation_fund\x20is\x200)');}}}}else I=0x0;I=clampScore(I);const {criterionScores:J,overall:K}=finalizeCriterionScores([{'name':'object_coverage','score':C,'weight':COMPLETENESS_WEIGHTS['object_coverage'],'rationale':'R1-R8:\x20'+w+'/'+u+'\x20required,\x20R9-R12:\x20'+x+'/'+v['length']+'\x20optional'},{'name':'binding_completeness','score':D,'weight':COMPLETENESS_WEIGHTS['binding_completeness'],'rationale':'Service\x20critical\x20bindings\x20checked'},{'name':'workflow_rationality','score':E,'weight':COMPLETENESS_WEIGHTS['workflow_rationality'],'rationale':'Machine\x20nodes\x20+\x20dangling\x20edges'},{'name':'deployment_readiness','score':I,'weight':COMPLETENESS_WEIGHTS['deployment_readiness'],'rationale':'Service\x20publishable\x20state'}],h['perspective']),L=b['filter'](af=>af['severity']==='critical')['length'],M=L>0x0?'Incomplete:\x20'+L+'\x20critical\x20gap(s).\x20Not\x20ready\x20for\x20deployment.':K>=0x50?'Complete\x20project\x20(score\x20'+K+'/100).\x20Ready\x20for\x20deployment.':'Partially\x20complete\x20(score\x20'+K+'/100).\x20'+b['length']+'\x20gap(s)\x20to\x20address.',N=evaluateIndustryPattern(h,d,g,f);return c['push'](...N['strengths']),b['push'](...N['findings']),{'evaluationType':'completeness','score':K,'summary':M,'criterionScores':J,'findings':b,'strengths':c,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateEscrowQuality(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Service')??[],g=e['get']('Allocation')??[],h=buildBindingIndex(c);let i=0x32;const j=[];if(f['length']===0x0)return{'name':'escrow_quality','score':0x0,'weight':EXTENDED_DIMENSION_WEIGHTS['escrow_quality'],'rationale':'No\x20Service\x20object'};const k=f[0x0],l=parseCacheData(d['get'](k['objectAddress'])),m=h['get'](k['objectAddress']+'#order_allocators')?.['size']??0x0;if(m>0x0&&g['length']>0x0)i=0x5a,j['push']('On-chain\x20escrow\x20active:\x20order_allocators\x20bound\x20+\x20Allocation\x20objects\x20present');else{if(m>0x0)i=0x46,j['push']('order_allocators\x20template\x20bound\x20—\x20escrow\x20will\x20activate\x20per-order');else l&&getBalanceValue(l,'compensation_fund')>0x0?(i=0x3c,j['push']('compensation_fund\x20present\x20but\x20no\x20Allocation\x20escrow\x20—\x20funds\x20held\x20by\x20merchant,\x20not\x20locked\x20in\x20contract')):(i=0x14,j['push']('No\x20escrow\x20mechanism\x20—\x20funds\x20flow\x20directly\x20to\x20merchant\x20(high\x20counterparty\x20risk)'));}return{'name':'escrow_quality','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['escrow_quality'],'rationale':j['join'](';\x20')};}function evaluateProofIntegrity(a){const {objects:b,edges:c}=a,d=groupByType(b),e=d['get']('Repository')??[],f=d['get']('Guard')??[],g=d['get']('Proof')??[];let h=0x32;const i=[];return e['length']>0x0&&(h+=0x14,i['push'](e['length']+'\x20Repository\x20object(s)')),f['length']>0x0&&(h+=0xf,i['push'](f['length']+'\x20Guard\x20object(s)')),g['length']>0x0&&(h+=0xf,i['push'](g['length']+'\x20Proof\x20object(s)')),e['length']===0x0&&f['length']===0x0&&(h=0x14,i['push']('No\x20on-chain\x20proof\x20mechanism\x20—\x20evidence\x20can\x20be\x20tampered')),{'name':'proof_integrity','score':clampScore(h),'weight':EXTENDED_DIMENSION_WEIGHTS['proof_integrity'],'rationale':i['join'](',\x20')||'No\x20proof\x20objects'};}function evaluateArbitrationFairness(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Service')??[],g=e['get']('Arbitration')??[],h=buildBindingIndex(c);if(g['length']===0x0)return{'name':'arbitration_fairness','score':0x0,'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':'No\x20Arbitration\x20configured'};let i=0x32;const j=[],k=f[0x0];if(!k)return{'name':'arbitration_fairness','score':0x1e,'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':'No\x20Service\x20to\x20compare\x20against'};const l=k['objectAddress']+'#permission',m=h['get'](l)?.['values']()['next']()['value'];for(const n of g){const o=n['objectAddress']+'#permission',p=h['get'](o)?.['values']()['next']()['value'];if(!m||!p){i-=0xa,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20missing\x20permission\x20binding');continue;}m===p?(i=0xa,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20shares\x20SAME\x20Permission\x20as\x20Service\x20—\x20NOT\x20independent')):(i+=0x1e,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20has\x20independent\x20Permission'));}return{'name':'arbitration_fairness','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':j['join'](';\x20')};}function evaluateFeeTransparency(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Allocation')??[],g=e['get']('Service')??[];let h=0x3c;const i=[];f['length']>0x0&&(h+=0x14,i['push'](f['length']+'\x20Allocation\x20object(s)\x20—\x20fee\x20distribution\x20on-chain'));const j=g[0x0];if(j){const k=parseCacheData(d['get'](j['objectAddress']));k?.['sales']&&Array['isArray'](k['sales'])&&(h+=0xa,i['push'](k['sales']['length']+'\x20sale\x20item(s)\x20—\x20pricing\x20visible')),k?.['compensation_fund']&&getBalanceValue(k,'compensation_fund')>0x0&&(h+=0xa,i['push']('compensation_fund\x20visible'));}return{'name':'fee_transparency','score':clampScore(h),'weight':EXTENDED_DIMENSION_WEIGHTS['fee_transparency'],'rationale':i['join'](',\x20')||'Limited\x20fee\x20visibility'};}function evaluateTimeoutProtection(a){const {objects:b,objectCache:c}=a,d=groupByType(b),e=d['get']('Machine')??[];let f=0x32;const g=[];for(const h of e){const i=parseCacheData(c['get'](h['objectAddress'])),j=getMachineNodeCount(i);if(j>0x0){const k=h['metadata'],l=k?.['config'];if(l?.['timeout_guard']||l?.['time_guard'])f+=0x1e,g['push']('Machine\x20has\x20timeout\x20guard\x20configured');else j>=0x2&&(f+=0xa,g['push']('Machine\x20has\x20'+j+'\x20nodes\x20—\x20workflow\x20structure\x20present'));}}return e['length']===0x0&&(f=0x14,g['push']('No\x20Machine\x20—\x20no\x20workflow\x20timeout\x20protection')),{'name':'timeout_protection','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['timeout_protection'],'rationale':g['join'](';\x20')||'No\x20timeout\x20mechanisms\x20detected'};}function evaluateSupplierVisibility(a){const {objects:b}=a,c=groupByType(b),d=c['get']('Demand')??[],e=c['get']('Allocation')??[];let f=0x3c;const g=[];return d['length']>0x0&&(f+=0x14,g['push'](d['length']+'\x20Demand\x20object(s)\x20—\x20supplier\x20discovery\x20on-chain')),e['length']>0x0&&(f+=0x14,g['push'](e['length']+'\x20Allocation\x20object(s)\x20—\x20supplier\x20payments\x20visible')),d['length']===0x0&&e['length']===0x0&&(f=0x1e,g['push']('No\x20Demand\x20or\x20Allocation\x20—\x20supplier\x20relationships\x20opaque')),{'name':'supplier_visibility','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['supplier_visibility'],'rationale':g['join'](',\x20')||'No\x20supplier\x20transparency'};}function evaluateContentCommitment(a){const {objects:b}=a,c=groupByType(b),d=c['get']('Repository')??[],e=c['get']('Guard')??[];let f=0x32;const g=[];return d['length']>0x0&&(f+=0x19,g['push']('Repository\x20present\x20—\x20content\x20hash\x20commitments\x20possible')),e['length']>0x0&&(f+=0x19,g['push']('Guard\x20present\x20—\x20delivery\x20verification\x20possible')),{'name':'content_commitment','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['content_commitment'],'rationale':g['join'](',\x20')||'No\x20content\x20commitment\x20mechanism'};}function evaluateReputationVerifiability(a){const {reputation:b,objects:c}=a,d=groupByType(c)['get']('Service')??[];let e=0x28;const f=[];if(b&&b['size']>0x0&&d[0x0]){const g=b['get'](d[0x0]['objectAddress']);g&&(e+=0x1e,f['push']('Registrar\x20data:\x20'+g['likes']+'\x20likes,\x20'+g['dislikes']+'\x20dislikes,\x20'+g['favorites']+'\x20favorites'));}return d['length']>0x0&&(e+=0xa,f['push']('Service\x20object\x20present\x20—\x20reputation\x20can\x20accumulate')),{'name':'reputation_verifiability','score':clampScore(e),'weight':EXTENDED_DIMENSION_WEIGHTS['reputation_verifiability'],'rationale':f['join'](',\x20')||'No\x20reputation\x20data\x20available'};}function evaluatePermissionSafety(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Machine')??[],g=e['get']('Permission')??[],h=buildBindingIndex(c);let i=0x3c;const j=[];if(f['length']===0x0)return{'name':'permission_safety','score':0x32,'weight':EXTENDED_DIMENSION_WEIGHTS['permission_safety'],'rationale':'No\x20Machine\x20to\x20check'};const k=new Map();for(const l of g){const m=parseCacheData(d['get'](l['objectAddress']));m&&k['set'](l['objectAddress'],{'address':l['objectAddress'],'entity_count':typeof m['entity_count']==='number'?m['entity_count']:undefined,'perm_remark':Array['isArray'](m['perm_remark'])?m['perm_remark']:undefined,'owner':typeof m['owner']==='string'?m['owner']:undefined,'admin':Array['isArray'](m['admin'])?m['admin']:undefined});}for(const n of f){const o=h['get'](n['objectAddress']+'#permission');if(!o||o['size']===0x0)continue;const p=o['values']()['next']()['value'],q=p?k['get'](p):null;if(!q)continue;const r=parseCacheData(d['get'](n['objectAddress'])),s=extractMachineNodesFromCache(r);if(s['length']===0x0)continue;const t=collectPermissionIndexes(s);if(t['requiredIndexes']['length']===0x0)continue;const u=checkPermissionAuthorization(t['requiredIndexes'],q);!u['allAuthorized']?(i-=0x1e,j['push']('Machine\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20has\x20unauthorized\x20permission\x20indexes:\x20['+u['missingIndexes']['join'](',\x20')+']')):(i+=0x14,j['push']('Machine\x20'+n['objectAddress']['slice'](0x0,0x8)+':\x20all\x20'+t['requiredIndexes']['length']+'\x20permission\x20index(es)\x20authorized'));}return{'name':'permission_safety','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['permission_safety'],'rationale':j['join'](';\x20')||'Permission\x20checks\x20passed'};}function evaluateValueStub(a,b){return{'evaluationType':'value','score':0x0,'summary':'Requires\x20LLM\x20evaluation\x20—\x20semantic\x20prompt\x20assembled.\x20Call\x20save_evaluation\x20with\x20the\x20LLM\x20result.','criterionScores':[],'findings':[],'strengths':[],'needsLlm':!![],'llmPrompt':b,'evaluatedAt':Date['now']()};}export function runEvaluationInternal(a,b,c){const d=filterTemplateObjects(a);switch(b){case'risk':return evaluateRisk(d);case'trust':return evaluateTrust(d);case'completeness':return evaluateCompleteness(d);case'value':return evaluateValueStub(d,c);default:throw new Error('Unknown\x20evaluation\x20type:\x20'+b);}}const PROJECT_EVALUATION_TYPES=['risk','trust','completeness','worth_buying','value'];function makeProjectRule(a){return{'id':'project_'+a,'description':'Project-level\x20'+a+'\x20evaluation\x20(rule-based\x20or\x20LLM-assisted)','dimension':a,'weight':0x1,'evaluation_ids':['project_'+a],'evaluate':b=>{const c=b['entities']['projectEvaluation'],d=b['entities']['llmPrompt'],e=runEvaluationInternal(c,a,d);return b['facts']['criterionScores']=e['criterionScores'],b['facts']['findings']=e['findings'],b['facts']['strengths']=e['strengths'],b['facts']['needsLlm']=e['needsLlm'],b['facts']['llmPrompt']=e['llmPrompt'],{'score':e['score'],'weight':0x1,'reason':e['summary'],'red_flag':e['findings']?.['some'](g=>g['severity']==='critical')??![]};}};}const RISK_CRITERIA=['structural_risk','fund_safety','operational_risk','governance_risk','graph_coherence','mode_registry'],TRUST_CRITERIA=['reputation','arbitration_coverage','guard_quality','transparency','consumer_diligence'],COMPLETENESS_CRITERIA=['object_coverage','binding_completeness','workflow_rationality','deployment_readiness'];function registerRuleBasedProjectEvaluation(a,b,c,d){const e='__project_'+b+'_result';a['registerDataSource']({'id':'project_'+b+'_facts','description':'Extract\x20project\x20facts\x20+\x20run\x20the\x20'+b+'\x20criterion\x20computer\x20(perspective\x20via\x20UserInjection)','evaluation_ids':['project_'+b],'extract':f=>{const g=f['entities']['projectEvaluation'],h=f['injection']?.['preferences']?.['perspective'],i=h&&h!==g['project']['perspective']?{...g,'project':{...g['project'],'perspective':h}}:g,j=d(i);return f['facts'][e]=j,f['facts']['criterionScores']=j['criterionScores'],f['facts']['findings']=j['findings'],f['facts']['strengths']=j['strengths'],f['facts']['needsLlm']=j['needsLlm'],{};}});for(const f of c){a['registerRule']({'id':'project_'+b+'_'+f,'description':'Project\x20'+b+'\x20criterion:\x20'+f,'dimension':b,'weight':0x1,'evaluation_ids':['project_'+b],'evaluate':g=>{const h=g['facts'][e];if(!h)return null;const i=h['criterionScores']['find'](j=>j['name']===f);if(!i)return null;return{'score':i['score'],'weight':i['weight'],'reason':i['rationale']};}});}}function registerWorthBuyingEvaluation(a){a['registerDataSource']({'id':'project_worth_buying_facts','description':'Run\x20risk/trust/completeness\x20via\x20the\x20kernel\x20+\x20D16-D24\x20enrichment\x20+\x20build\x20LLM\x20prompt','evaluation_ids':['project_worth_buying'],'extract':async b=>{const c=b['entities']['projectEvaluation'],d=b['entities']['llmPrompt'],e={'projectEvaluation':c},[f,g,h]=await Promise['all']([a['evaluate']('project_risk',e,b['injection']),a['evaluate']('project_trust',e,b['injection']),a['evaluate']('project_completeness',e,b['injection'])]),i=[evaluateEscrowQuality(c),evaluateProofIntegrity(c),evaluateArbitrationFairness(c),evaluateFeeTransparency(c),evaluateTimeoutProtection(c),evaluateSupplierVisibility(c),evaluateContentCommitment(c),evaluateReputationVerifiability(c),evaluatePermissionSafety(c)],j=i['map'](m=>m['name']+':\x20'+m['score']+'/100\x20—\x20'+m['rationale'])['join']('\x0a'),k=['===\x20RULE-BASED\x20EVALUATION\x20SUMMARY\x20(F-08\x20enriched\x20context)\x20===','','Risk:\x20'+f['total']+'/100\x20—\x20'+f['summary'],...(f['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','Trust:\x20'+g['total']+'/100\x20—\x20'+g['summary'],...(g['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','Completeness:\x20'+h['total']+'/100\x20—\x20'+h['summary'],...(h['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','===\x20EXTENDED\x20DIMENSIONS\x20D16-D24\x20(GLM6/93)\x20===',j,'','===\x20END\x20RULE-BASED\x20SUMMARY\x20===',''],l=k['join']('\x0a');return b['facts']['needsLlm']=!![],b['facts']['llmPrompt']=d?d+'\x0a\x0a'+l:l+'\x0aInstruction:\x20Based\x20on\x20the\x20rule-based\x20summary\x20above,\x20evaluate\x20whether\x20this\x20project\x20is\x20worth\x20buying.\x20Return\x20a\x200-100\x20score\x20and\x20a\x20brief\x20rationale.\x20Focus\x20on\x20buyer\x20risk\x20vs.\x20value\x20proposition.',b['facts']['summary']='Requires\x20LLM\x20evaluation\x20—\x20semantic\x20prompt\x20assembled\x20with\x20rule-based\x20context\x20(risk/trust/completeness\x20+\x20D16-D24\x20extended\x20dimensions).\x20Call\x20save_evaluation\x20with\x20the\x20LLM\x20result.',{};}});}export function registerProjectEvaluations(a=getEvaluationEngine()){registerRuleBasedProjectEvaluation(a,'risk',RISK_CRITERIA,evaluateRisk),registerRuleBasedProjectEvaluation(a,'trust',TRUST_CRITERIA,evaluateTrust),registerRuleBasedProjectEvaluation(a,'completeness',COMPLETENESS_CRITERIA,evaluateCompleteness),registerWorthBuyingEvaluation(a);for(const b of PROJECT_EVALUATION_TYPES){if(b==='risk'||b==='trust'||b==='completeness'||b==='worth_buying')continue;a['registerRule'](makeProjectRule(b));}}registerProjectEvaluations();export async function runEvaluation(a,b,c,d){const e=filterTemplateObjects(a),f=getEvaluationEngine(),g=await f['evaluate']('project_'+b,{'projectEvaluation':e,'llmPrompt':c},d);return{'evaluationType':b,'score':g['total'],'summary':g['summary'],'criterionScores':g['criterionScores']??[],'findings':g['findings']??[],'strengths':g['strengths']??[],'needsLlm':g['needsLlm']??![],'llmPrompt':g['llmPrompt'],'evaluatedAt':Date['now']()};}function filterTemplateObjects(a){const b=i=>{if(!i)return!![];return i['startsWith']('draft:');},c=i=>{if(b(i['objectAddress']))return!![];const j=i['metadata'];return!!(j&&j['status']==='draft');},d=[],e=[];for(const i of a['objects']){c(i)?d['push'](i):e['push'](i);}const f=new Set();for(const j of e){if(j['objectAddress'])f['add'](j['objectAddress']);if(j['objectName']){f['add'](j['objectName']);const k=shortTypeName(j['objectType'])['toLowerCase']();f['add'](k+':'+j['objectName']);}}const g=new Set();for(const l of d){if(l['objectAddress'])g['add'](l['objectAddress']);if(l['objectName']){g['add'](l['objectName']);const m=shortTypeName(l['objectType'])['toLowerCase']();g['add'](m+':'+l['objectName']);}}const h=a['edges']['filter'](n=>{const p=n['metadata'];if(p&&p['blueprint']===!![])return![];const q=b(n['sourceObject'])||g['has'](n['sourceObject']),r=b(n['targetObject'])||g['has'](n['targetObject']);return!q&&!r;});return{...a,'objects':e,'edges':h};}export function compareProjects(a,b){const c=[...a]['sort']((d,e)=>{if(d['score']===null&&e['score']===null)return 0x0;if(d['score']===null)return 0x1;if(e['score']===null)return-0x1;return e['score']-d['score'];});return{'evaluationType':b,'entries':a,'ranking':c,'bestProjectId':c[0x0]?.['score']!==null?c[0x0]?.['projectId']??null:null};}
1
+ import{IndustryModeRegistry}from'../extensions/registry.js';import{collectPermissionIndexes,checkPermissionAuthorization}from'../schema/utils/permission-machine-check.js';import{getEvaluationEngine}from'../evaluation/engine.js';const CRITICAL_BINDINGS=[{'sourceType':'Service','targetType':'Machine','fieldName':'machine','critical':!![]},{'sourceType':'Service','targetType':'Permission','fieldName':'permission','critical':!![]},{'sourceType':'Service','targetType':'Guard','fieldName':'buy_guard','critical':![]},{'sourceType':'Service','targetType':'Allocation','fieldName':'order_allocators','critical':!![]},{'sourceType':'Service','targetType':'Arbitration','fieldName':'arbitrations','critical':![]},{'sourceType':'Machine','targetType':'Permission','fieldName':'permission','critical':!![]}],MERCHANT_REQUIRED_ITEMS=[{'id':'R1','objectType':'Permission','fieldName':'','required':!![],'description':'Governance\x20—\x20who\x20can\x20manage\x20the\x20service'},{'id':'R2','objectType':'Service','fieldName':'','required':!![],'description':'Core\x20offering\x20—\x20the\x20service\x20itself'},{'id':'R3','objectType':'Machine','fieldName':'machine','required':!![],'description':'Workflow\x20—\x20order\x20processing\x20pipeline'},{'id':'R4','objectType':'Guard','fieldName':'','required':!![],'description':'Purchase\x20validation\x20—\x20Guard\x20objects\x20configured\x20(binding\x20to\x20Service.buy_guard\x20is\x20optional)'},{'id':'R5','objectType':'Allocation','fieldName':'order_allocators','required':!![],'description':'Order\x20allocators\x20template\x20—\x20inline\x20Allocators\x20on\x20Service\x20(independent\x20Allocation\x20objects\x20are\x20created\x20per-order)'},{'id':'R6','objectType':'Treasury','fieldName':'','required':!![],'description':'Compensation\x20fund\x20—\x20independent\x20Treasury\x20object\x20for\x20buyer\x20refund\x20protection\x20(industry-aware:\x20optional\x20for\x20freelance)'},{'id':'R7','objectType':'Arbitration','fieldName':'arbitrations','required':!![],'description':'Dispute\x20resolution\x20—\x20arbitration\x20configured\x20(required\x20when\x20compensation_fund\x20>\x200\x20per\x20service.move:494)'},{'id':'R8','objectType':'Contact','fieldName':'','required':!![],'description':'Customer\x20communication\x20—\x20contact\x20info'},{'id':'R9','objectType':'Progress','fieldName':'','required':![],'description':'Order\x20tracking\x20—\x20progress\x20nodes'},{'id':'R10','objectType':'Reward','fieldName':'rewards','required':![],'description':'Customer\x20incentives\x20—\x20reward\x20claims'},{'id':'R11','objectType':'Repository','fieldName':'repositories','required':![],'description':'Documentation\x20—\x20published\x20data'},{'id':'R12','objectType':'Demand','fieldName':'','required':![],'description':'Market\x20discovery\x20—\x20demand\x20signals'}];function resolveRequiredItems(a,b=0x0,c=![]){let d=MERCHANT_REQUIRED_ITEMS;if(a&&a!=='general'){let e;try{e=IndustryModeRegistry['Instance']()['getMode'](a);}catch{}if(e){const f=e['risk_constraints']?.['require_compensation_fund']??!![];!f&&(d=MERCHANT_REQUIRED_ITEMS['map'](g=>{if(g['id']==='R6'||g['id']==='R7')return{...g,'required':![]};return g;}));}}return c&&b===0x0&&(d=d['map'](g=>{if(g['id']==='R6')return{...g,'required':![]};return g;})),b>0x0&&(d=d['map'](g=>g['id']==='R7'?{...g,'required':!![]}:g)),d;}const CONSUMER_DUE_DILIGENCE=[{'id':'E1','check':'Service\x20is\x20published\x20(bPublished=true)','severity':'critical','deduction':-0x1e},{'id':'E2','check':'Service\x20is\x20not\x20paused\x20(bPaused=false)','severity':'warning','deduction':-0x14},{'id':'E3','check':'Machine\x20has\x20workflow\x20nodes','severity':'warning','deduction':-0xf},{'id':'E4','check':'Service\x20has\x20buy_guard\x20(purchase\x20validation)','severity':'info','deduction':0x0},{'id':'E5','check':'Service\x20has\x20compensation_fund\x20(refund\x20protection)','severity':'warning','deduction':-0xf},{'id':'E6','check':'Arbitration\x20is\x20configured\x20(dispute\x20resolution)','severity':'critical','deduction':-0x19},{'id':'E7','check':'Permission\x20is\x20present\x20(governance)','severity':'warning','deduction':-0xa},{'id':'E8','check':'Contact\x20is\x20available\x20(merchant\x20reachable)','severity':'info','deduction':-0x5},{'id':'E9','check':'Repository\x20has\x20published\x20data\x20(transparency)','severity':'info','deduction':-0x5},{'id':'E10','check':'Reward\x20is\x20configured\x20(customer\x20incentives)','severity':'info','deduction':-0x3},{'id':'E11','check':'Service\x20has\x20description\x20(offering\x20clarity)','severity':'info','deduction':-0x5},{'id':'E12','check':'Registrar\x20reputation\x20is\x20positive','severity':'warning','deduction':-0xa}];function clampScore(a){return Math['max'](0x0,Math['min'](0x64,Math['round'](a)));}function shortTypeName(a){if(!a)return'unknown';const b=a['replace'](/<.*>/,'')['trim'](),c=b['split']('::'),d=c[c['length']-0x1]||'unknown';if(d['length']>0x0&&d===d['toLowerCase']())return d['charAt'](0x0)['toUpperCase']()+d['slice'](0x1);return d;}function groupByType(a){const b=new Map();for(const c of a){const d=shortTypeName(c['objectType']);if(!b['has'](d))b['set'](d,[]);b['get'](d)['push'](c);}return b;}function parseCacheData(a){if(!a)return null;try{return JSON['parse'](a['data']);}catch{return null;}}function isAddress(a){return typeof a==='string'&&a['startsWith']('0x')&&a['length']>=0xa;}function countArrayField(a,b){const c=a[b];if(Array['isArray'](c))return c['length'];return 0x0;}export function getNumberField(a,b){if(!a)return 0x0;const c=a[b];if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'){const d=Number(c);if(Number['isFinite'](d))return d;}return 0x0;}export function getMachineNodeCount(a){if(!a)return 0x0;const b=getNumberField(a,'node_count');if(b>0x0)return b;const c=countArrayField(a,'nodes');if(c>0x0)return c;const d=a['nodes'];if(d&&typeof d==='object'){const e=d['fields'];if(e&&typeof e==='object'){const g=getNumberField(e,'size');if(g>0x0)return g;}const f=getNumberField(d,'size');if(f>0x0)return f;}return 0x0;}function extractMachineNodesFromCache(a){if(!a)return[];const b=a['nodes'];if(Array['isArray'](b))return b;const c=a['config'];if(c&&Array['isArray'](c['nodes']))return c['nodes'];const d=a['nodes'];if(d&&typeof d==='object'){const e=d['fields'];if(e&&Array['isArray'](e['contents']))return e['contents'];}return[];}function getBalanceValue(a,b){if(!a)return 0x0;const c=a[b];if(c==null)return 0x0;if(typeof c==='number'&&Number['isFinite'](c))return c;if(typeof c==='string'){const d=Number(c);if(Number['isFinite'](d))return d;}if(typeof c==='object'){const e=c,f=e['value']??e['fields'];if(typeof f==='number'&&Number['isFinite'](f))return f;if(typeof f==='string'){const g=Number(f);if(Number['isFinite'](g))return g;}if(typeof f==='object'&&f!==null){const h=f,i=h['value'];if(typeof i==='number'&&Number['isFinite'](i))return i;if(typeof i==='string'){const j=Number(i);if(Number['isFinite'](j))return j;}}}return 0x0;}function getMaxSalePrice(a){if(!a)return 0x0;const b=a['sales'];if(!Array['isArray'](b)||b['length']===0x0)return 0x0;let c=0x0;for(const d of b){if(typeof d!=='object'||d===null)continue;const e=d['price'];let f=0x0;if(typeof e==='number'&&Number['isFinite'](e))f=e;else{if(typeof e==='string'){const g=Number(e);if(Number['isFinite'](g))f=g;}}if(f>c)c=f;}return c;}function detectCircularRefs(a,b){const c=new Map();for(const i of a){if(i['edgeSource']==='potential')continue;if(!c['has'](i['sourceObject']))c['set'](i['sourceObject'],[]);c['get'](i['sourceObject'])['push'](i['targetObject']);}const d=[],f=new Set(),g=new Set(),h=[];for(const j of c['keys']()){if(f['has'](j))continue;const k=[{'node':j,'nextNeighborIdx':0x0,'neighbors':c['get'](j)??[]}];f['add'](j),g['add'](j),h['push'](j);while(k['length']>0x0){const l=k[k['length']-0x1];if(l['nextNeighborIdx']>=l['neighbors']['length']){k['pop'](),h['pop'](),g['delete'](l['node']);continue;}const m=l['neighbors'][l['nextNeighborIdx']];l['nextNeighborIdx']++;if(!f['has'](m))f['add'](m),g['add'](m),h['push'](m),k['push']({'node':m,'nextNeighborIdx':0x0,'neighbors':c['get'](m)??[]});else{if(g['has'](m)){const n=h['indexOf'](m),o=h['slice'](n)['concat'](m);!isWoWokNormalFundCycle(o,b)&&d['push'](o['join']('→'));}}}}return d;}function isWoWokNormalFundCycle(a,b){if(!b||a['length']<0x3)return![];const c=new Set();for(const f of a){const g=b['get'](f);if(g)c['add'](g);else return![];}if(c['size']===0x2&&c['has']('Order')&&c['has']('Allocation'))return!![];if(c['size']===0x3&&c['has']('Order')&&c['has']('Allocation')&&c['has']('Payment'))return!![];const d=['Service','Machine','Progress','Order'],e=Array['from'](c)['every'](h=>d['includes'](h));if(e&&c['size']>=0x2)return!![];return![];}function adjustWeightsForPerspective(a,b){if(b==='consumer')return a['map'](d=>{if(d['name']==='reputation'||d['name']==='arbitration_coverage'||d['name']==='consumer_diligence')return{...d,'weight':d['weight']*1.4};if(d['name']==='structural_risk'||d['name']==='deployment_readiness')return{...d,'weight':d['weight']*0.7};return d;});if(b==='producer')return a['map'](d=>{if(d['name']==='structural_risk'||d['name']==='deployment_readiness'||d['name']==='binding_completeness')return{...d,'weight':d['weight']*1.3};if(d['name']==='consumer_diligence'||d['name']==='transparency')return{...d,'weight':d['weight']*0.7};return d;});return a;}function normalizeWeights(a){const b=a['reduce']((d,e)=>d+e['weight'],0x0);if(b===0x0)return a;return a['map'](d=>({...d,'weight':d['weight']/b}));}export const RISK_WEIGHTS={'structural_risk':0.25,'fund_safety':0.2,'operational_risk':0.15,'governance_risk':0.1,'graph_coherence':0.2,'mode_registry':0.1};export const TRUST_WEIGHTS={'reputation':0.25,'arbitration_coverage':0.2,'guard_quality':0.2,'transparency':0.15,'consumer_diligence':0.2};export const COMPLETENESS_WEIGHTS={'object_coverage':0.3,'binding_completeness':0.25,'workflow_rationality':0.2,'deployment_readiness':0.25};export const EXTENDED_DIMENSION_WEIGHTS={'escrow_quality':0.15,'proof_integrity':0.1,'arbitration_fairness':0.15,'fee_transparency':0.1,'timeout_protection':0.1,'supplier_visibility':0.1,'content_commitment':0.1,'reputation_verifiability':0.1,'permission_safety':0.1};export function finalizeCriterionScores(a,b){const c=normalizeWeights(adjustWeightsForPerspective(a,b)),d=clampScore(c['reduce']((e,f)=>e+f['score']*f['weight'],0x0));return{'criterionScores':c,'overall':d};}function buildBindingIndex(a){const b=new Map();for(const c of a){if(c['edgeSource']==='potential')continue;if(!c['fieldName'])continue;const d=c['sourceObject']+'#'+c['fieldName'];if(!b['has'](d))b['set'](d,new Set());b['get'](d)['add'](c['targetObject']);}for(const f of a){if(f['edgeSource']!=='potential')continue;if(!f['fieldName'])continue;const g=f['sourceObject']+'#'+f['fieldName'];if(!b['has'](g)||b['get'](g)['size']===0x0){if(!b['has'](g))b['set'](g,new Set());b['get'](g)['add'](f['targetObject']);}}return b;}function buildBindingIndexFromCache(b,c){const d=new Map(),e=(f,g,h)=>{if(!f||!g||!isAddress(h))return;const i=f+'#'+g;if(!d['has'](i))d['set'](i,new Set());d['get'](i)['add'](h);};for(const f of b){if(!f['objectAddress'])continue;const g=parseCacheData(c['get'](f['objectAddress']));if(!g)continue;const h=shortTypeName(f['objectType']);if(h==='Service'){e(f['objectAddress'],'machine',g['machine']),e(f['objectAddress'],'permission',g['permission']),e(f['objectAddress'],'buy_guard',g['buy_guard']),e(f['objectAddress'],'um',g['um']);const i=g['order_allocators'],j=i?.['allocators'];if(Array['isArray'](j))for(const l of j){e(f['objectAddress'],'order_allocators',l?.['guard']);}const k=g['arbitrations'];if(Array['isArray'](k))for(const m of k){e(f['objectAddress'],'arbitrations',m);}}else h==='Machine'&&e(f['objectAddress'],'permission',g['permission']);}return d;}function mergeBindingIndex(...a){const b=new Map();for(const c of a){for(const [d,e]of c){if(!b['has'](d))b['set'](d,new Set());for(const f of e)b['get'](d)['add'](f);}}return b;}export function extractProjectEvaluationFacts(a){const {project:b,objects:c,edges:d,objectCache:f,reputation:g}=a,h=groupByType(c),i=mergeBindingIndex(buildBindingIndex(d),buildBindingIndexFromCache(c,f)),j=h['get']('Service')??[],k=j[0x0],l=k?parseCacheData(f['get'](k['objectAddress'])):null,m=k?getBalanceValue(l,'compensation_fund'):0x0,n=getMaxSalePrice(l),p=h['get']('Treasury')??[],q=h['get']('Allocation')??[],r=h['get']('Permission')??[],s=h['get']('Machine')??[],t=h['get']('Arbitration')??[],u=h['get']('Repository')??[],v=h['get']('Contact')??[],w=h['get']('Guard')??[],x=h['get']('Proof')??[],y=h['get']('Demand')??[],z=new Set();for(const I of c){if(I['objectAddress'])z['add'](I['objectAddress']);if(I['objectName']){z['add'](I['objectName']);const J=shortTypeName(I['objectType'])['toLowerCase']();z['add'](J+':'+I['objectName']);}}let A=0x0;for(const K of d){if(K['edgeSource']==='potential')continue;if(!z['has'](K['targetObject']))A++;}const B=new Map();for(const L of c){if(L['objectAddress'])B['set'](L['objectAddress'],shortTypeName(L['objectType']));}const C=detectCircularRefs(d,B),D=k?i['get'](k['objectAddress']+'#order_allocators')?.['size']??0x0:0x0,E=q['length']>0x0&&D>0x0;let F=!![],G=0x5;if(b['industry']&&b['industry']!=='general')try{const M=IndustryModeRegistry['Instance']()['getMode'](b['industry']);M&&(F=M['risk_constraints']?.['require_compensation_fund']??!![],M['risk_constraints']?.['compensation_fund_coverage_ratio']&&(G=M['risk_constraints']['compensation_fund_coverage_ratio']));}catch{}const H=new Map();for(const N of r){const O=parseCacheData(f['get'](N['objectAddress']));O&&H['set'](N['objectAddress'],{'address':N['objectAddress'],'entity_count':typeof O['entity_count']==='number'?O['entity_count']:undefined,'perm_remark':Array['isArray'](O['perm_remark'])?O['perm_remark']:undefined,'owner':typeof O['owner']==='string'?O['owner']:typeof O['builder']==='string'?O['builder']:undefined,'admin':Array['isArray'](O['admin'])?O['admin']:undefined});}return{'input':a,'project':b,'objects':c,'edges':d,'byType':h,'bindingIndex':i,'objectCache':f,'reputation':g,'serviceObj':k,'serviceData':l,'compensationBalance':m,'maxSalePrice':n,'treasuries':p,'allocations':q,'permissions':r,'machines':s,'arbitrations':t,'repositories':u,'contacts':v,'guards':w,'proofs':x,'demands':y,'danglingCount':A,'cycles':C,'hasAllocationEscrow':E,'orderAllocatorsBinding':D,'industryRequiresFund':F,'coverageRatio':G,'permDataMap':H};}function evaluateIndustryPattern(a,b,c,d){const e={'strengths':[],'findings':[],'matched':![]},f=a['industry'];if(!f||f==='general')return e;let g;try{g=IndustryModeRegistry['Instance']()['getMode'](f);}catch{return e;}if(!g)return e;const h=groupByType(b),i=buildBindingIndex(d);let j=0x0,k=0x0;const l=g['machine_shape'];if(l['length']>0x0){k++;const q=h['get']('Machine')??[];if(q['length']>0x0){const r=q[0x0],s=parseCacheData(c['get'](r['objectAddress'])),t=getMachineNodeCount(s);if(t>0x0&&t>=l['length'])j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20Machine\x20has\x20'+t+'\x20nodes,\x20covering\x20\x22'+f+'\x22\x20mode\x27s\x20'+l['length']+'\x20expected\x20node(s)');else t>0x0&&e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20Machine\x20has\x20'+t+'\x20nodes,\x20but\x20\x22'+f+'\x22\x20mode\x20expects\x20at\x20least\x20'+l['length'],'deduction':0x0});}}const n=g['guards'];if(n['length']>0x0){k++;const u=h['get']('Guard')??[],v=n['length'],w=n['length']*0x2;if(u['length']>=v&&u['length']<=w)j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+u['length']+'\x20Guard(s)\x20present,\x20within\x20\x22'+f+'\x22\x20mode\x27s\x20expected\x20range\x20['+v+'-'+w+']');else{if(u['length']>0x0&&u['length']<v)e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20'+u['length']+'\x20Guard(s)\x20present,\x20but\x20\x22'+f+'\x22\x20mode\x20expects\x20at\x20least\x20'+v+'\x20(recommended\x20range\x20['+v+'-'+w+'])','deduction':0x0});else u['length']>w&&(j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+u['length']+'\x20Guard(s)\x20present,\x20covering\x20\x22'+f+'\x22\x20mode\x27s\x20'+v+'\x20expected\x20guard(s)'),e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20'+u['length']+'\x20Guard(s)\x20present,\x20exceeds\x20recommended\x20max\x20'+w+'.\x20Consider\x20consolidating\x20guards\x20if\x20some\x20are\x20redundant.','deduction':0x0}));}}const o=g['allocator'];if(o){k++;const x=h['get']('Allocation')??[],y=h['get']('Service')??[],z=y[0x0],A=z?!!i['get'](z['objectAddress']+'#order_allocators')?.['size']:![],B=g['traits']['multi_tier_allocation'];if(A)j++,x['length']>0x0?e['strengths']['push']('Industry\x20pattern\x20match:\x20Service.order_allocators\x20bound\x20+\x20'+x['length']+'\x20Allocation\x20object(s)\x20present\x20(post-order)\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern'):e['strengths']['push']('Industry\x20pattern\x20match:\x20Service.order_allocators\x20template\x20bound\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern\x20(Allocation\x20objects\x20created\x20per-order)');else x['length']>0x0?(j++,e['strengths']['push']('Industry\x20pattern\x20match:\x20'+x['length']+'\x20Allocation\x20object(s)\x20present\x20—\x20matching\x20\x22'+f+'\x22\x20allocation\x20pattern')):e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20Service.order_allocators\x20not\x20bound\x20and\x20no\x20Allocation\x20objects\x20—\x20\x22'+f+'\x22\x20mode\x20expects\x20'+(B?'multi-tier':'single-tier')+'\x20allocation\x20(Allocation\x20objects\x20are\x20created\x20per-order,\x20so\x20this\x20is\x20only\x20a\x20template-level\x20gap)','deduction':0x0});}const p=g['risk_constraints']?.['require_compensation_fund']??![];if(p||g['traits']['deposit_required']||g['traits']['trust_sensitivity']!=='low'){k++;const C=h['get']('Treasury')??[],D=h['get']('Service')??[],E=D[0x0],F=E?parseCacheData(c['get'](E['objectAddress'])):null,G=E?getBalanceValue(F,'compensation_fund'):0x0;if(C['length']>0x0||G>0x0){j++;const H=[];if(C['length']>0x0)H['push'](C['length']+'\x20Treasury\x20object(s)');if(G>0x0)H['push']('compensation_fund\x20balance\x20'+G);e['strengths']['push']('Industry\x20pattern\x20match:\x20'+H['join']('\x20+\x20')+'\x20—\x20matching\x20\x22'+f+'\x22\x20trust/deposit\x20pattern');}}e['matched']=k>0x0&&j/k>=0.6;if(e['matched'])e['strengths']['push']('Industry\x20pattern:\x20project\x20structure\x20matches\x20\x22'+f+'\x22\x20mode\x20('+j+'/'+k+'\x20checks\x20passed)');else k>0x0&&e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'Industry\x20pattern:\x20project\x20partially\x20matches\x20\x22'+f+'\x22\x20mode\x20('+j+'/'+k+'\x20checks\x20passed)','deduction':0x0});if(f==='freelance'){const I=h['get']('Machine')??[];for(const J of I){const K=parseCacheData(c['get'](J['objectAddress']));if(!K)continue;const L=getMachineNodeCount(K);if(L>0x0){e['findings']['push']({'criterion':'industry_pattern','severity':'info','message':'ISSUE-P1-4:\x20freelance\x20project\x20has\x20a\x20Machine\x20with\x20'+L+'\x20node(s).\x20'+'If\x20the\x20workflow\x20includes\x20a\x20\x22delivered\x22\x20state,\x2048h\x20auto-accept\x20requires\x20'+'an\x20off-chain\x20keeper\x20(WoWok\x20Guard\x20does\x20not\x20support\x20time-based\x20triggers).\x20'+'Keeper\x20should\x20poll\x20Progress\x20objects\x20in\x20\x22delivered\x22\x20state\x20and\x20call\x20'+'adminUnhold\x20(permission\x20224)\x20after\x2048h\x20timeout.','deduction':0x0});break;}}}return e;}function evaluateRisk(a){const b=[],d=[],e=extractProjectEvaluationFacts(a),{objects:f,edges:g,objectCache:h,project:i}=e,j=e['bindingIndex'],k=g['filter'](P=>P['edgeSource']!=='potential')['length'];f['length']>0x0&&k===0x0&&b['push']({'criterion':'graph_coherence','severity':'warning','message':'Project\x20graph\x20not\x20built\x20(0\x20verified\x20edges)\x20—\x20run\x20build_graph\x20for\x20full\x20graph-based\x20checks\x20(dangling\x20references,\x20circular\x20refs,\x20Machine→Permission).\x20Critical\x20Service\x20bindings\x20are\x20already\x20verified\x20from\x20on-chain\x20object\x20data.','deduction':0x0});let l=0x64;const m=e['serviceObj'],n=e['compensationBalance'];if(m)for(const P of CRITICAL_BINDINGS){if(P['sourceType']!=='Service')continue;const Q=P['fieldName']==='arbitrations'?n>0x0?!![]:P['critical']:P['critical'],R=m['objectAddress']+'#'+P['fieldName'],S=j['get'](R);if(!S||S['size']===0x0){const T=Q?-0x19:-0xa;l+=T,b['push']({'criterion':'structural_risk','severity':Q?'critical':'warning','message':'Service\x20missing\x20'+P['fieldName']+'\x20binding\x20(expected\x20'+P['targetType']+')'+(P['fieldName']==='arbitrations'?n>0x0?'\x20—\x20required\x20by\x20contract\x20when\x20compensation_fund\x20>\x200\x20(service.move:494)':'\x20—\x20optional\x20when\x20compensation_fund\x20is\x200':''),'deduction':T});}else d['push']('Service\x20has\x20'+P['fieldName']+'\x20binding');}else l=0x1e,b['push']({'criterion':'structural_risk','severity':'critical','message':'No\x20Service\x20object\x20in\x20project\x20—\x20project\x20has\x20no\x20core','deduction':-0x46});l=clampScore(l);let o=0x64;const p=e['treasuries'],q=e['allocations'],r=e['serviceData'],s=e['compensationBalance'],t=e['orderAllocatorsBinding'],w=e['hasAllocationEscrow'],x=e['industryRequiresFund'];if(p['length']===0x0&&s===0x0){if(w)o-=0x5,d['push']('Allocation\x20escrow\x20mode\x20active\x20—\x20funds\x20locked\x20in\x20contract,\x20released\x20by\x20Guard\x20verification'),b['push']({'criterion':'fund_safety','severity':'info','message':'Using\x20Allocation\x20escrow\x20('+q['length']+'\x20Allocation\x20object(s)\x20+\x20order_allocators\x20bound)\x20—\x20fund\x20safety\x20via\x20Guard\x20verification,\x20no\x20Treasury/compensation_fund\x20needed','deduction':-0x5});else x?(o-=0x1e,b['push']({'criterion':'fund_safety','severity':'warning','message':'No\x20Treasury\x20object\x20and\x20Service.compensation_fund\x20is\x20empty\x20—\x20no\x20refund\x20fund\x20for\x20buyers','deduction':-0x1e})):(o-=0xa,b['push']({'criterion':'fund_safety','severity':'info','message':'No\x20Treasury/compensation_fund\x20—\x20industry\x20\x22'+i['industry']+'\x22\x20does\x20not\x20require\x20refund\x20fund\x20(optional)','deduction':-0xa}));}else{p['length']>0x0&&d['push'](p['length']+'\x20Treasury\x20object(s)\x20present\x20—\x20independent\x20fund\x20holder');if(s>0x0){d['push']('Service.compensation_fund\x20has\x20'+s+'\x20units\x20—\x20inline\x20refund\x20fund\x20active');const U=e['maxSalePrice'];if(U>0x0){const V=e['coverageRatio'],W=V*U;s<W?(o-=0xa,b['push']({'criterion':'fund_safety','severity':'warning','message':'Service.compensation_fund\x20balance\x20('+s+')\x20is\x20less\x20than\x20'+V+'×\x20the\x20max\x20order\x20amount\x20('+U+'\x20→\x20threshold\x20'+W+').\x20Refund\x20coverage\x20may\x20be\x20insufficient\x20—\x20top\x20up\x20via\x20service.compensation_fund_add\x20to\x20avoid\x20arbitration\x20rulings\x20exceeding\x20the\x20fund.\x20(industry:\x20'+(i['industry']??'general')+',\x20ratio:\x20'+V+'×)','deduction':-0xa})):b['push']({'criterion':'fund_safety','severity':'info','message':'Service.compensation_fund\x20balance\x20('+s+')\x20covers\x20'+V+'×\x20the\x20max\x20order\x20amount\x20('+U+').\x20Fund\x20is\x20sufficient\x20for\x20refund\x20protection.\x20(industry:\x20'+(i['industry']??'general')+',\x20ratio:\x20'+V+'×)','deduction':0x0});}}else b['push']({'criterion':'fund_safety','severity':'info','message':'Treasury\x20present\x20but\x20Service.compensation_fund\x20balance\x20is\x200\x20—\x20consider\x20depositing\x20refund\x20fund','deduction':-0x5});}o=clampScore(o);let y=0x64;if(m){const X=e['serviceData'];if(X){const Y=X['bPaused'],Z=X['bPublished'];Z&&Y&&(y-=0x19,b['push']({'criterion':'operational_risk','severity':'warning','message':'Service\x20is\x20published\x20but\x20PAUSED\x20—\x20operations\x20halted','deduction':-0x19})),!Z&&(y-=0xf,b['push']({'criterion':'operational_risk','severity':'info','message':'Service\x20not\x20yet\x20published\x20—\x20project\x20not\x20live','deduction':-0xf}));}}const z=e['arbitrations'];z['length']===0x0?(y-=0x14,b['push']({'criterion':'operational_risk','severity':'warning','message':'No\x20Arbitration\x20object\x20—\x20disputes\x20cannot\x20be\x20resolved','deduction':-0x14})):d['push'](z['length']+'\x20Arbitration\x20object(s)\x20configured');y=clampScore(y);let A=0x64;const B=e['permissions'];B['length']===0x0&&(A-=0x28,b['push']({'criterion':'governance_risk','severity':'critical','message':'No\x20Permission\x20object\x20—\x20project\x20is\x20ungoverned','deduction':-0x28}));if(m){const a0=e['serviceData'];a0&&!isAddress(a0['um'])&&(A-=0x5,b['push']({'criterion':'governance_risk','severity':'info','message':'Service\x20has\x20no\x20UM\x20(manager)\x20—\x20UM\x20is\x20optional;\x20set\x20via\x20um_set\x20if\x20management\x20delegation\x20needed','deduction':-0x5}));}const C=e['machines'];for(const a1 of C){const a2=a1['metadata'],a3=a2?.['config'];if(a3?.['entry_node_forward_hint']){const a7=a3['entry_node_forward_hint'],a8=a7['example_forward'];a8?.['namedOperator']===''&&d['push']('Machine\x20entry\x20forward\x20uses\x20namedOperator=\x27\x27\x20(OrderHolder)\x20—\x20'+'correct\x20for\x20customer-operable\x20nodes.\x20namedOperator=\x27\x27\x20represents\x20'+'the\x20order\x20holder,\x20distinct\x20from\x20merchant\x27s\x20permission\x20index.');}const a4=a3?.['guard_objects'];a4&&a4['length']>0x0&&d['push']('Machine\x20has\x20'+a4['length']+'\x20guard\x20object\x20reference(s)\x20—\x20'+'forward-level\x20permission\x20validation\x20configured');const a5=parseCacheData(h['get'](a1['objectAddress'])),a6=getMachineNodeCount(a5);a6>0x0&&!a3&&b['push']({'criterion':'governance_risk','severity':'info','message':'Machine\x20has\x20'+a6+'\x20node(s).\x20Verify\x20each\x20forward\x20has\x20at\x20least\x20one\x20of\x20'+'namedOperator\x20or\x20permissionIndex.\x20Key:\x20namedOperator=\x27\x27\x20means\x20OrderHolder\x20'+'(customer),\x20NOT\x20\x27anyone\x27.\x20Use\x20non-empty\x20namedOperator\x20for\x20specific\x20roles,\x20'+'or\x20permissionIndex\x20for\x20permission-based\x20access.\x20Both\x20set\x20=\x20OR\x20semantic\x20'+'(either\x20can\x20execute).','deduction':0x0});}const D=e['machines'],E=e['permissions'],F=e['permDataMap'];for(const a9 of D){const aa=a9['objectAddress']+'#permission',ab=j['get'](aa);if(!ab||ab['size']===0x0)continue;let ac=null;for(const ai of ab){ac=ai;break;}if(!ac)continue;const ad=F['get'](ac);if(!ad)continue;const ae=parseCacheData(h['get'](a9['objectAddress']));if(!ae)continue;const af=extractMachineNodesFromCache(ae);if(af['length']===0x0)continue;const ag=collectPermissionIndexes(af);if(ag['requiredIndexes']['length']===0x0)continue;const ah=checkPermissionAuthorization(ag['requiredIndexes'],ad);!ah['allAuthorized']?(A-=0x19,b['push']({'criterion':'governance_risk','severity':'critical','message':'Machine\x20'+a9['objectAddress']['slice'](0x0,0x8)+'\x20has\x20forwards\x20referencing\x20'+('un-authorized\x20permission\x20indexes:\x20['+ah['missingIndexes']['join'](',\x20')+'].\x20')+'These\x20forwards\x20can\x20NEVER\x20be\x20executed\x20—\x20Progress\x20will\x20be\x20permanently\x20stuck.\x20'+'Grant\x20entities\x20for\x20these\x20indexes\x20via\x20permission.op=\x22add\x20perm\x20by\x20index\x22\x20'+'before\x20publishing\x20the\x20Machine.','deduction':-0x19})):d['push']('Machine\x20'+a9['objectAddress']['slice'](0x0,0x8)+':\x20all\x20'+ag['requiredIndexes']['length']+'\x20'+'permission\x20index(es)\x20are\x20authorized');}if(m&&z['length']>0x0){const aj=m['objectAddress']+'#permission',ak=j['get'](aj),al=ak&&ak['size']>0x0?Array['from'](ak)[0x0]:null,am=al?F['get'](al):null;for(const an of z){const ao=an['objectAddress']+'#permission',ap=j['get'](ao),aq=ap&&ap['size']>0x0?Array['from'](ap)[0x0]:null;if(!al||!aq)continue;if(al===aq){A-=0x1e,b['push']({'criterion':'governance_risk','severity':'critical','message':'Arbitration\x20'+an['objectAddress']['slice'](0x0,0x8)+'\x20and\x20Service\x20share\x20the\x20SAME\x20'+('Permission\x20object\x20('+al['slice'](0x0,0x8)+').\x20This\x20breaks\x20dispute\x20')+'fairness\x20—\x20the\x20merchant\x20fully\x20controls\x20arbitration\x20operations.\x20'+'Use\x20a\x20separate\x20Permission\x20object\x20for\x20Arbitration\x20to\x20ensure\x20independent\x20'+'dispute\x20resolution.\x20(per\x20arbitration.move:\x20the\x20permission\x20field\x20controls\x20'+'who\x20can\x20vote,\x20confirm,\x20and\x20execute\x20arbitration\x20rulings)','deduction':-0x1e});continue;}const ar=F['get'](aq);if(am&&ar){const as=am['owner']?.['toLowerCase'](),at=ar['owner']?.['toLowerCase'](),au=new Set((am['admin']??[])['map'](ay=>ay['toLowerCase']())),av=new Set((ar['admin']??[])['map'](ay=>ay['toLowerCase']())),aw=as&&at&&as===at,ax=[...au]['some'](ay=>av['has'](ay));if(aw||ax){const ay=aw&&ax?'owner\x20AND\x20admin\x20overlap':aw?'same\x20owner':'admin\x20overlap';A-=0x14,b['push']({'criterion':'governance_risk','severity':'warning','message':'Arbitration\x20'+an['objectAddress']['slice'](0x0,0x8)+'\x20and\x20Service\x20have\x20'+('overlapping\x20Permission\x20control\x20('+ay+').\x20Even\x20with\x20separate\x20')+'Permission\x20objects,\x20shared\x20control\x20undermines\x20dispute\x20independence.\x20'+'The\x20contract\x20only\x20enforces\x20different\x20Permission\x20object\x20addresses\x20'+'(E_ARBITRATION_PERMISSION_CONFLICT)\x20—\x20it\x20does\x20NOT\x20check\x20who\x20controls\x20'+'each\x20Permission,\x20so\x20this\x20governance\x20risk\x20exists\x20on\x20ANY\x20network.\x20'+'Use\x20a\x20completely\x20independent\x20third-party\x20Permission\x20(different\x20owner\x20'+'and\x20admin\x20list)\x20for\x20Arbitration.','deduction':-0x14});}else d['push']('Arbitration\x20'+an['objectAddress']['slice'](0x0,0x8)+'\x20has\x20independent\x20'+'Permission\x20(separate\x20owner/admin)\x20—\x20trustworthy\x20dispute\x20resolution');}}}A=clampScore(A);let G=0x64;const H=e['danglingCount'],I=e['cycles'];if(H>0x0){const az=-Math['min'](0x14,H*0x3);G+=az,b['push']({'criterion':'graph_coherence','severity':H>=0x3?'warning':'info','message':H+'\x20edge(s)\x20point\x20to\x20objects\x20outside\x20the\x20project\x20—\x20dangling\x20references','deduction':az});}I['length']>0x0&&(G-=0xf,b['push']({'criterion':'graph_coherence','severity':'warning','message':I['length']+'\x20circular\x20reference(s)\x20detected:\x20'+I['slice'](0x0,0x2)['join'](';\x20')+(I['length']>0x2?'...':''),'deduction':-0xf}));H===0x0&&I['length']===0x0&&d['push']('Graph\x20is\x20coherent\x20—\x20no\x20dangling\x20refs\x20or\x20cycles');G=clampScore(G);let J=0x64,K='no\x20industry\x20declared\x20—\x20check\x20skipped';if(!i['industry'])b['push']({'criterion':'mode_registry','severity':'info','message':'Project\x20has\x20no\x20industry\x20tag\x20—\x20mode\x20registry\x20gates\x20(metrics/constraints)\x20not\x20evaluated.\x20Set\x20project\x20industry\x20to\x20enable.','deduction':0x0});else try{const aA=IndustryModeRegistry['Instance']()['evaluateMode'](i['industry'],i['description']??i['name'],{'prefix':i['prefix'],'network':i['network']==='mainnet'?'mainnet':'testnet','business_intent':i['description']??undefined,'industry':i['industry'],'version':i['currentVersion']??undefined}),aB=aA['unmet_conditions']['some'](aC=>aC['includes']('not\x20found'));if(aB)J=0x32,K='mode\x20\x27'+i['industry']+'\x27\x20not\x20registered',b['push']({'criterion':'mode_registry','severity':'warning','message':'Industry\x20mode\x20\x27'+i['industry']+'\x27\x20is\x20not\x20registered\x20in\x20the\x20mode\x20registry\x20—\x20cannot\x20verify\x20capability/conflict/constraint\x20gates.\x20Falling\x20back\x20to\x20unverified\x20mode.','deduction':-0x32});else{for(const aC of aA['violated_constraints']){J-=0x19,b['push']({'criterion':'mode_registry','severity':'critical','message':'Mode\x20\x27'+i['industry']+'\x27\x20hard\x20constraint\x20violated:\x20'+aC,'deduction':-0x19});}for(const aD of aA['capability_conflicts']){J-=0x14,b['push']({'criterion':'mode_registry','severity':'critical','message':'Mode\x20\x27'+i['industry']+'\x27\x20capability\x20conflict:\x20'+aD,'deduction':-0x14});}for(const aE of aA['unmet_conditions']){J-=0xa,b['push']({'criterion':'mode_registry','severity':'warning','message':'Mode\x20\x27'+i['industry']+'\x27\x20soft\x20constraint\x20unmet:\x20'+aE,'deduction':-0xa});}J=clampScore(J),K='metric\x20risk\x20'+aA['risk_score']+'\x20/\x20benefit\x20'+aA['benefit_score']+'\x20'+('(ratio\x20'+aA['risk_benefit_ratio']['toFixed'](0x2)+');\x20')+(aA['violated_constraints']['length']+'\x20hard\x20+\x20'+aA['unmet_conditions']['length']+'\x20soft\x20constraint\x20issue(s),\x20')+(aA['capability_conflicts']['length']+'\x20capability\x20conflict(s)'),aA['applicable']&&aA['violated_constraints']['length']===0x0&&aA['capability_conflicts']['length']===0x0&&aA['unmet_conditions']['length']===0x0&&d['push']('Mode\x20\x27'+i['industry']+'\x27\x20passes\x20all\x20mode-registry\x20gates\x20—\x20'+('metric\x20risk\x20'+aA['risk_score']+'\x20/\x20benefit\x20'+aA['benefit_score']+'\x20')+('(risk-benefit\x20ratio\x20'+aA['risk_benefit_ratio']['toFixed'](0x2)+')'));}}catch{K='mode\x20registry\x20unavailable\x20—\x20check\x20skipped';}J=clampScore(J);const {criterionScores:L,overall:M}=finalizeCriterionScores([{'name':'structural_risk','score':l,'weight':RISK_WEIGHTS['structural_risk'],'rationale':CRITICAL_BINDINGS['filter'](aF=>aF['sourceType']==='Service')['length']+'\x20expected\x20Service\x20bindings\x20checked'},{'name':'fund_safety','score':o,'weight':RISK_WEIGHTS['fund_safety'],'rationale':'Treasury\x20+\x20compensation_fund\x20coverage'},{'name':'operational_risk','score':y,'weight':RISK_WEIGHTS['operational_risk'],'rationale':'Service\x20state\x20+\x20arbitration\x20coverage'},{'name':'governance_risk','score':A,'weight':RISK_WEIGHTS['governance_risk'],'rationale':'Permission\x20+\x20UM\x20presence'},{'name':'graph_coherence','score':G,'weight':RISK_WEIGHTS['graph_coherence'],'rationale':H+'\x20dangling\x20+\x20'+I['length']+'\x20circular\x20refs'},{'name':'mode_registry','score':J,'weight':RISK_WEIGHTS['mode_registry'],'rationale':K}],i['perspective']),N=b['filter'](aF=>aF['severity']==='critical')['length'],O=N>0x0?'HIGH\x20RISK:\x20'+N+'\x20critical\x20issue(s).\x20'+b['length']+'\x20total\x20findings.':'Moderate\x20risk:\x20'+b['length']+'\x20finding(s),\x20no\x20critical\x20issues.';return{'evaluationType':'risk','score':M,'summary':O,'criterionScores':L,'findings':b,'strengths':d,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateTrust(a){const b=[],c=[],{objects:d,edges:e,objectCache:f,reputation:g,project:h}=a,i=groupByType(d),j=i['get']('Service')??[];let k=0x32;if(g&&g['size']>0x0&&j[0x0]){const z=g['get'](j[0x0]['objectAddress']);if(z){const A=z['likes']+z['dislikes'];if(A>0x0){const B=z['likes']/A;k=clampScore(0x32+(B-0.5)*0x64);if(B>=0.8)c['push']('Strong\x20reputation:\x20'+z['likes']+'\x20likes\x20vs\x20'+z['dislikes']+'\x20dislikes');else B<0.4&&b['push']({'criterion':'reputation','severity':'warning','message':'Poor\x20reputation:\x20'+z['dislikes']+'\x20dislikes\x20vs\x20'+z['likes']+'\x20likes','deduction':-0x14});}z['favorites']>=0x3&&(c['push'](z['favorites']+'\x20favorites\x20—\x20trusted\x20by\x20other\x20merchants'),k=clampScore(k+0xa));}}else b['push']({'criterion':'reputation','severity':'info','message':'No\x20Registrar\x20reputation\x20data\x20—\x20unknown\x20merchant\x20standing','deduction':-0xa});k=clampScore(k);let l=0x64;const m=i['get']('Arbitration')??[];m['length']===0x0?(l=0x1e,b['push']({'criterion':'arbitration_coverage','severity':'critical','message':'No\x20Arbitration\x20object\x20—\x20buyers\x20have\x20no\x20dispute\x20resolution\x20path','deduction':-0x46})):c['push'](m['length']+'\x20Arbitration\x20object(s)\x20—\x20dispute\x20resolution\x20available');l=clampScore(l);let n=0x3c;const o=i['get']('Guard')??[];o['length']===0x0?(n-=0x14,b['push']({'criterion':'guard_quality','severity':'warning','message':'No\x20Guard\x20objects\x20—\x20no\x20validation\x20rules','deduction':-0x14})):(n=0x50,c['push'](o['length']+'\x20Guard\x20object(s)\x20—\x20validation\x20rules\x20configured'));if(j[0x0]){const C=buildBindingIndex(e),D=j[0x0]['objectAddress']+'#buy_guard';if(C['get'](D)?.['size'])n=clampScore(n+0xf),c['push']('Service\x20has\x20buy_guard\x20bound\x20—\x20purchase\x20validation\x20active');else o['length']>0x0&&c['push']('Guard\x20objects\x20present\x20(buy_guard\x20binding\x20optional)');}n=clampScore(n);let p=0x3c;if(j[0x0]){const E=parseCacheData(f['get'](j[0x0]['objectAddress']));if(E){const F=E['description'];typeof F==='string'&&F['length']>0x0?(p+=0xf,c['push']('Service\x20has\x20description')):b['push']({'criterion':'transparency','severity':'info','message':'Service\x20has\x20no\x20description\x20—\x20buyers\x20cannot\x20evaluate\x20offering','deduction':-0xa});}}const q=i['get']('Repository')??[];q['length']>0x0&&(p=clampScore(p+0xa),c['push'](q['length']+'\x20Repository\x20object(s)\x20—\x20supporting\x20data\x20published'));const r=i['get']('Contact')??[];r['length']>0x0?(p=clampScore(p+0xa),c['push']('Contact\x20information\x20available')):b['push']({'criterion':'transparency','severity':'info','message':'No\x20Contact\x20object\x20—\x20buyers\x20cannot\x20reach\x20merchant','deduction':-0x5});p=clampScore(p);let s=0x64;const t=[],u=buildBindingIndex(e),v=j[0x0];if(v){const G=parseCacheData(f['get'](v['objectAddress']));for(const I of CONSUMER_DUE_DILIGENCE){let J=![];switch(I['id']){case'E1':J=!!G?.['bPublished'];break;case'E2':J=!!G&&!G['bPaused'];break;case'E3':J=(i['get']('Machine')??[])['some'](K=>{const L=parseCacheData(f['get'](K['objectAddress']));return L&&(getNumberField(L,'node_count')>0x0||countArrayField(L,'nodes')>0x0);});break;case'E4':J=!!u['get'](v['objectAddress']+'#buy_guard')?.['size']||(i['get']('Guard')??[])['length']>0x0;break;case'E5':J=getBalanceValue(G,'compensation_fund')>0x0||(i['get']('Treasury')??[])['length']>0x0;break;case'E6':J=(i['get']('Arbitration')??[])['length']>0x0;break;case'E7':J=(i['get']('Permission')??[])['length']>0x0;break;case'E8':J=(i['get']('Contact')??[])['length']>0x0;break;case'E9':J=(i['get']('Repository')??[])['length']>0x0;break;case'E10':J=!!u['get'](v['objectAddress']+'#rewards')?.['size'];break;case'E11':J=!!(G&&typeof G['description']==='string'&&G['description']['length']>0x0);break;case'E12':if(g&&g['size']>0x0){const K=g['get'](v['objectAddress']);J=!!K&&K['likes']>=K['dislikes'];}break;}if(J)t['push'](I['id']);else{let L=I['deduction'],M=I['severity'];if(I['id']==='E5'&&h['industry']&&h['industry']!=='general')try{const O=IndustryModeRegistry['Instance']()['getMode'](h['industry']);O&&O['risk_constraints']?.['require_compensation_fund']===![]&&(L=-0x3,M='info');}catch{}s+=L;const N=I['id']==='E5'&&L!==I['deduction']?'\x20(industry\x20does\x20not\x20require\x20compensation_fund\x20—\x20reduced\x20deduction)':'';b['push']({'criterion':'consumer_diligence','severity':M,'message':I['id']+':\x20'+I['check']+'\x20—\x20FAIL:\x20condition\x20not\x20met'+N+'\x20[severity:\x20'+M+']','deduction':L});}}const H=t['length']/CONSUMER_DUE_DILIGENCE['length'];H>=0.8&&c['push']('Consumer\x20due\x20diligence:\x20'+t['length']+'/'+CONSUMER_DUE_DILIGENCE['length']+'\x20checks\x20passed');}else s=0x14,b['push']({'criterion':'consumer_diligence','severity':'critical','message':'No\x20Service\x20object\x20—\x20consumer\x20due\x20diligence\x20cannot\x20be\x20performed','deduction':-0x50});s=clampScore(s);const {criterionScores:w,overall:x}=finalizeCriterionScores([{'name':'reputation','score':k,'weight':TRUST_WEIGHTS['reputation'],'rationale':'Registrar\x20likes/dislikes\x20+\x20favorites'},{'name':'arbitration_coverage','score':l,'weight':TRUST_WEIGHTS['arbitration_coverage'],'rationale':'Dispute\x20resolution\x20availability'},{'name':'guard_quality','score':n,'weight':TRUST_WEIGHTS['guard_quality'],'rationale':'Validation\x20rules\x20+\x20buy_guard\x20binding'},{'name':'transparency','score':p,'weight':TRUST_WEIGHTS['transparency'],'rationale':'Description\x20+\x20Repository\x20+\x20Contact\x20presence'},{'name':'consumer_diligence','score':s,'weight':TRUST_WEIGHTS['consumer_diligence'],'rationale':t['length']+'/'+CONSUMER_DUE_DILIGENCE['length']+'\x20E-checks\x20passed'}],h['perspective']),y=x>=0x46?'Trusted\x20project\x20(score\x20'+x+'/100).\x20'+c['length']+'\x20strength(s).':'Limited\x20trust\x20signals\x20(score\x20'+x+'/100).\x20'+b['length']+'\x20finding(s).';return{'evaluationType':'trust','score':x,'summary':y,'criterionScores':w,'findings':b,'strengths':c,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateCompleteness(a){const b=[],c=[],{objects:d,edges:f,objectCache:g,project:h}=a,i=groupByType(d),j=i['get']('Service')??[],k=buildBindingIndex(f),l=j[0x0],n=l?parseCacheData(g['get'](l['objectAddress'])):null,p=getBalanceValue(n,'compensation_fund'),q=i['get']('Allocation')??[],r=l?k['get'](l['objectAddress']+'#order_allocators')?.['size']??0x0:0x0,s=q['length']>0x0&&r>0x0,t=resolveRequiredItems(h['industry']??undefined,p,s),u=t['filter'](O=>O['required'])['length'],v=t['filter'](O=>!O['required']);let w=0x0,x=0x0;const y=[],z=[];for(const O of t){const P=(i['get'](O['objectType'])?.['length']??0x0)>0x0,Q=O['fieldName']?!!k['get']((j[0x0]?.['objectAddress']??'')+'#'+O['fieldName'])?.['size']:P;O['required']?Q||!O['fieldName']&&P?w++:y['push'](O['id']+'('+O['objectType']+')'):Q||!O['fieldName']&&P?x++:z['push'](O['id']+'('+O['objectType']+')');}const A=w/u,B=v['length']>0x0?x/v['length']:0x1;let C=clampScore(A*0x50+B*0x14);y['length']>0x0?b['push']({'criterion':'object_coverage','severity':y['length']>=0x3?'critical':'warning','message':'Missing\x20required\x20items:\x20'+y['join'](',\x20')+'\x20—\x20'+y['length']+'/'+u+'\x20required\x20items\x20absent','deduction':-0xf*y['length']}):c['push']('All\x20'+u+'\x20required\x20items\x20present\x20(R1-R8)');if(z['length']>0x0&&z['length']===v['length'])b['push']({'criterion':'object_coverage','severity':'info','message':'No\x20optional\x20items\x20configured:\x20'+z['join'](',\x20')+'\x20—\x20recommended\x20for\x20enhanced\x20UX','deduction':-0x5});else x>0x0&&c['push'](x+'/'+v['length']+'\x20optional\x20items\x20configured\x20(R9-R12)');C=clampScore(C);let D=0x64;if(j[0x0]){const R=j[0x0]['objectAddress'],S=parseCacheData(g['get'](R)),T=getBalanceValue(S,'compensation_fund');let U=0x0,V=0x0;for(const W of CRITICAL_BINDINGS){if(W['sourceType']!=='Service')continue;V++;const X=W['fieldName']==='arbitrations'?T>0x0?!![]:W['critical']:W['critical'],Y=R+'#'+W['fieldName'];if(k['get'](Y)?.['size'])U++;else{const Z=X?-0x14:-0x8;D+=Z,b['push']({'criterion':'binding_completeness','severity':X?'critical':'warning','message':'Service.'+W['fieldName']+'\x20not\x20bound\x20(expected\x20'+W['targetType']+')'+(W['fieldName']==='arbitrations'?T>0x0?'\x20—\x20required\x20by\x20contract\x20when\x20compensation_fund\x20>\x200':'\x20—\x20optional\x20when\x20compensation_fund\x20is\x200':''),'deduction':Z});}}U===V&&c['push']('All\x20'+V+'\x20Service\x20bindings\x20established');}else D=0x0,b['push']({'criterion':'binding_completeness','severity':'critical','message':'No\x20Service\x20object\x20—\x20cannot\x20evaluate\x20bindings','deduction':-0x64});D=clampScore(D);let E=0x50;const F=i['get']('Machine')??[];if(F['length']===0x0)E-=0x14,b['push']({'criterion':'workflow_rationality','severity':'info','message':'No\x20Machine\x20object\x20—\x20bind\x20one\x20before\x20publishing\x20(deploy-time\x20requirement)','deduction':-0x14});else for(const a0 of F){const a1=parseCacheData(g['get'](a0['objectAddress']));if(a1){const a2=getMachineNodeCount(a1);a2>0x0?c['push']('Machine\x20has\x20'+a2+'\x20node(s)'):(E-=0xa,b['push']({'criterion':'workflow_rationality','severity':'info','message':'Machine\x20'+a0['objectAddress']['slice'](0x0,0x8)+'\x20has\x20no\x20nodes','deduction':-0xa}));}}const G=new Set();for(const a3 of d){if(a3['objectAddress'])G['add'](a3['objectAddress']);if(a3['objectName']){G['add'](a3['objectName']);const a4=shortTypeName(a3['objectType'])['toLowerCase']();G['add'](a4+':'+a3['objectName']);}}let H=0x0;for(const a5 of f){if(a5['edgeSource']==='potential')continue;if(!G['has'](a5['targetObject']))H++;}H>0x0&&(E=clampScore(E-Math['min'](0x14,H*0x2)),b['push']({'criterion':'workflow_rationality','severity':'info','message':H+'\x20edge(s)\x20point\x20to\x20objects\x20not\x20in\x20project\x20—\x20dangling\x20references','deduction':-Math['min'](0x14,H*0x2)}));E=clampScore(E);let I=0x64;if(j[0x0]){const a6=parseCacheData(g['get'](j[0x0]['objectAddress']));if(a6){const a7=a6['bPublished'];if(a7){c['push']('Service\x20already\x20published\x20—\x20deployment\x20complete'),I=0x64;const a8=a6['machine'];if(typeof a8==='string'&&a8['startsWith']('0x')){const a9=parseCacheData(g['get'](a8));a9&&a9['bPublished']===![]&&(I-=0xa,b['push']({'criterion':'deployment_readiness','severity':'info','message':'Bound\x20Machine\x20'+a8['slice'](0x0,0x8)+'\x20is\x20not\x20published\x20—\x20order_progress\x20will\x20fail\x20(machine.move\x20E_NOT_PUBLISHED)','deduction':-0xa}));}}else{const aa=k['get'](j[0x0]['objectAddress']+'#machine')?.['size'],ab=k['get'](j[0x0]['objectAddress']+'#permission')?.['size'],ac=k['get'](j[0x0]['objectAddress']+'#order_allocators')?.['size'],ad=getBalanceValue(a6,'compensation_fund'),ae=k['get'](j[0x0]['objectAddress']+'#arbitrations')?.['size'];!aa&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20Machine\x20—\x20cannot\x20publish','deduction':-0x1e}));!ab&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20Permission\x20—\x20cannot\x20publish','deduction':-0x1e}));!ac&&(I-=0x1e,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20no\x20order_allocators\x20—\x20cannot\x20publish\x20(service.move:493\x20E_NO_ALLOCATOR)','deduction':-0x1e}));ad>0x0&&!ae&&(I-=0x19,b['push']({'criterion':'deployment_readiness','severity':'critical','message':'Service\x20has\x20compensation_fund\x20('+ad+')\x20but\x20no\x20arbitrations\x20—\x20cannot\x20publish\x20(service.move:495\x20E_ARBITRATION_NOT_SET_WITH_COMPENSATION_FUND)','deduction':-0x19}));if(aa&&ab&&ac){if(ad>0x0&&ae)c['push']('Service\x20ready\x20to\x20publish\x20(Machine\x20+\x20Permission\x20+\x20order_allocators\x20+\x20arbitrations\x20bound)');else ad===0x0&&c['push']('Service\x20ready\x20to\x20publish\x20(Machine\x20+\x20Permission\x20+\x20order_allocators\x20bound;\x20arbitrations\x20optional\x20when\x20compensation_fund\x20is\x200)');}}}}else I=0x0;I=clampScore(I);const {criterionScores:J,overall:K}=finalizeCriterionScores([{'name':'object_coverage','score':C,'weight':COMPLETENESS_WEIGHTS['object_coverage'],'rationale':'R1-R8:\x20'+w+'/'+u+'\x20required,\x20R9-R12:\x20'+x+'/'+v['length']+'\x20optional'},{'name':'binding_completeness','score':D,'weight':COMPLETENESS_WEIGHTS['binding_completeness'],'rationale':'Service\x20critical\x20bindings\x20checked'},{'name':'workflow_rationality','score':E,'weight':COMPLETENESS_WEIGHTS['workflow_rationality'],'rationale':'Machine\x20nodes\x20+\x20dangling\x20edges'},{'name':'deployment_readiness','score':I,'weight':COMPLETENESS_WEIGHTS['deployment_readiness'],'rationale':'Service\x20publishable\x20state'}],h['perspective']),L=b['filter'](af=>af['severity']==='critical')['length'],M=L>0x0?'Incomplete:\x20'+L+'\x20critical\x20gap(s).\x20Not\x20ready\x20for\x20deployment.':K>=0x50?'Complete\x20project\x20(score\x20'+K+'/100).\x20Ready\x20for\x20deployment.':'Partially\x20complete\x20(score\x20'+K+'/100).\x20'+b['length']+'\x20gap(s)\x20to\x20address.',N=evaluateIndustryPattern(h,d,g,f);return c['push'](...N['strengths']),b['push'](...N['findings']),{'evaluationType':'completeness','score':K,'summary':M,'criterionScores':J,'findings':b,'strengths':c,'needsLlm':![],'evaluatedAt':Date['now']()};}function evaluateEscrowQuality(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Service')??[],g=e['get']('Allocation')??[],h=buildBindingIndex(c);let i=0x32;const j=[];if(f['length']===0x0)return{'name':'escrow_quality','score':0x0,'weight':EXTENDED_DIMENSION_WEIGHTS['escrow_quality'],'rationale':'No\x20Service\x20object'};const k=f[0x0],l=parseCacheData(d['get'](k['objectAddress'])),m=h['get'](k['objectAddress']+'#order_allocators')?.['size']??0x0;if(m>0x0&&g['length']>0x0)i=0x5a,j['push']('On-chain\x20escrow\x20active:\x20order_allocators\x20bound\x20+\x20Allocation\x20objects\x20present');else{if(m>0x0)i=0x46,j['push']('order_allocators\x20template\x20bound\x20—\x20escrow\x20will\x20activate\x20per-order');else l&&getBalanceValue(l,'compensation_fund')>0x0?(i=0x3c,j['push']('compensation_fund\x20present\x20but\x20no\x20Allocation\x20escrow\x20—\x20funds\x20held\x20by\x20merchant,\x20not\x20locked\x20in\x20contract')):(i=0x14,j['push']('No\x20escrow\x20mechanism\x20—\x20funds\x20flow\x20directly\x20to\x20merchant\x20(high\x20counterparty\x20risk)'));}return{'name':'escrow_quality','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['escrow_quality'],'rationale':j['join'](';\x20')};}function evaluateProofIntegrity(a){const {objects:b,edges:c}=a,d=groupByType(b),e=d['get']('Repository')??[],f=d['get']('Guard')??[],g=d['get']('Proof')??[];let h=0x32;const i=[];return e['length']>0x0&&(h+=0x14,i['push'](e['length']+'\x20Repository\x20object(s)')),f['length']>0x0&&(h+=0xf,i['push'](f['length']+'\x20Guard\x20object(s)')),g['length']>0x0&&(h+=0xf,i['push'](g['length']+'\x20Proof\x20object(s)')),e['length']===0x0&&f['length']===0x0&&(h=0x14,i['push']('No\x20on-chain\x20proof\x20mechanism\x20—\x20evidence\x20can\x20be\x20tampered')),{'name':'proof_integrity','score':clampScore(h),'weight':EXTENDED_DIMENSION_WEIGHTS['proof_integrity'],'rationale':i['join'](',\x20')||'No\x20proof\x20objects'};}function evaluateArbitrationFairness(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Service')??[],g=e['get']('Arbitration')??[],h=buildBindingIndex(c);if(g['length']===0x0)return{'name':'arbitration_fairness','score':0x0,'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':'No\x20Arbitration\x20configured'};let i=0x32;const j=[],k=f[0x0];if(!k)return{'name':'arbitration_fairness','score':0x1e,'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':'No\x20Service\x20to\x20compare\x20against'};const l=k['objectAddress']+'#permission',m=h['get'](l)?.['values']()['next']()['value'];for(const n of g){const o=n['objectAddress']+'#permission',p=h['get'](o)?.['values']()['next']()['value'];if(!m||!p){i-=0xa,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20missing\x20permission\x20binding');continue;}m===p?(i=0xa,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20shares\x20SAME\x20Permission\x20as\x20Service\x20—\x20NOT\x20independent')):(i+=0x1e,j['push']('Arbitration\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20has\x20independent\x20Permission'));}return{'name':'arbitration_fairness','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['arbitration_fairness'],'rationale':j['join'](';\x20')};}function evaluateFeeTransparency(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Allocation')??[],g=e['get']('Service')??[];let h=0x3c;const i=[];f['length']>0x0&&(h+=0x14,i['push'](f['length']+'\x20Allocation\x20object(s)\x20—\x20fee\x20distribution\x20on-chain'));const j=g[0x0];if(j){const k=parseCacheData(d['get'](j['objectAddress']));k?.['sales']&&Array['isArray'](k['sales'])&&(h+=0xa,i['push'](k['sales']['length']+'\x20sale\x20item(s)\x20—\x20pricing\x20visible')),k?.['compensation_fund']&&getBalanceValue(k,'compensation_fund')>0x0&&(h+=0xa,i['push']('compensation_fund\x20visible'));}return{'name':'fee_transparency','score':clampScore(h),'weight':EXTENDED_DIMENSION_WEIGHTS['fee_transparency'],'rationale':i['join'](',\x20')||'Limited\x20fee\x20visibility'};}function evaluateTimeoutProtection(a){const {objects:b,objectCache:c}=a,d=groupByType(b),e=d['get']('Machine')??[];let f=0x32;const g=[];for(const h of e){const i=parseCacheData(c['get'](h['objectAddress'])),j=getMachineNodeCount(i);if(j>0x0){const k=h['metadata'],l=k?.['config'];if(l?.['timeout_guard']||l?.['time_guard'])f+=0x1e,g['push']('Machine\x20has\x20timeout\x20guard\x20configured');else j>=0x2&&(f+=0xa,g['push']('Machine\x20has\x20'+j+'\x20nodes\x20—\x20workflow\x20structure\x20present'));}}return e['length']===0x0&&(f=0x14,g['push']('No\x20Machine\x20—\x20no\x20workflow\x20timeout\x20protection')),{'name':'timeout_protection','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['timeout_protection'],'rationale':g['join'](';\x20')||'No\x20timeout\x20mechanisms\x20detected'};}function evaluateSupplierVisibility(a){const {objects:b}=a,c=groupByType(b),d=c['get']('Demand')??[],e=c['get']('Allocation')??[];let f=0x3c;const g=[];return d['length']>0x0&&(f+=0x14,g['push'](d['length']+'\x20Demand\x20object(s)\x20—\x20supplier\x20discovery\x20on-chain')),e['length']>0x0&&(f+=0x14,g['push'](e['length']+'\x20Allocation\x20object(s)\x20—\x20supplier\x20payments\x20visible')),d['length']===0x0&&e['length']===0x0&&(f=0x1e,g['push']('No\x20Demand\x20or\x20Allocation\x20—\x20supplier\x20relationships\x20opaque')),{'name':'supplier_visibility','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['supplier_visibility'],'rationale':g['join'](',\x20')||'No\x20supplier\x20transparency'};}function evaluateContentCommitment(a){const {objects:b}=a,c=groupByType(b),d=c['get']('Repository')??[],e=c['get']('Guard')??[];let f=0x32;const g=[];return d['length']>0x0&&(f+=0x19,g['push']('Repository\x20present\x20—\x20content\x20hash\x20commitments\x20possible')),e['length']>0x0&&(f+=0x19,g['push']('Guard\x20present\x20—\x20delivery\x20verification\x20possible')),{'name':'content_commitment','score':clampScore(f),'weight':EXTENDED_DIMENSION_WEIGHTS['content_commitment'],'rationale':g['join'](',\x20')||'No\x20content\x20commitment\x20mechanism'};}function evaluateReputationVerifiability(a){const {reputation:b,objects:c}=a,d=groupByType(c)['get']('Service')??[];let e=0x28;const f=[];if(b&&b['size']>0x0&&d[0x0]){const g=b['get'](d[0x0]['objectAddress']);g&&(e+=0x1e,f['push']('Registrar\x20data:\x20'+g['likes']+'\x20likes,\x20'+g['dislikes']+'\x20dislikes,\x20'+g['favorites']+'\x20favorites'));}return d['length']>0x0&&(e+=0xa,f['push']('Service\x20object\x20present\x20—\x20reputation\x20can\x20accumulate')),{'name':'reputation_verifiability','score':clampScore(e),'weight':EXTENDED_DIMENSION_WEIGHTS['reputation_verifiability'],'rationale':f['join'](',\x20')||'No\x20reputation\x20data\x20available'};}function evaluatePermissionSafety(a){const {objects:b,edges:c,objectCache:d}=a,e=groupByType(b),f=e['get']('Machine')??[],g=e['get']('Permission')??[],h=buildBindingIndex(c);let i=0x3c;const j=[];if(f['length']===0x0)return{'name':'permission_safety','score':0x32,'weight':EXTENDED_DIMENSION_WEIGHTS['permission_safety'],'rationale':'No\x20Machine\x20to\x20check'};const k=new Map();for(const l of g){const m=parseCacheData(d['get'](l['objectAddress']));m&&k['set'](l['objectAddress'],{'address':l['objectAddress'],'entity_count':typeof m['entity_count']==='number'?m['entity_count']:undefined,'perm_remark':Array['isArray'](m['perm_remark'])?m['perm_remark']:undefined,'owner':typeof m['owner']==='string'?m['owner']:undefined,'admin':Array['isArray'](m['admin'])?m['admin']:undefined});}for(const n of f){const o=h['get'](n['objectAddress']+'#permission');if(!o||o['size']===0x0)continue;const p=o['values']()['next']()['value'],q=p?k['get'](p):null;if(!q)continue;const r=parseCacheData(d['get'](n['objectAddress'])),s=extractMachineNodesFromCache(r);if(s['length']===0x0)continue;const t=collectPermissionIndexes(s);if(t['requiredIndexes']['length']===0x0)continue;const u=checkPermissionAuthorization(t['requiredIndexes'],q);!u['allAuthorized']?(i-=0x1e,j['push']('Machine\x20'+n['objectAddress']['slice'](0x0,0x8)+'\x20has\x20unauthorized\x20permission\x20indexes:\x20['+u['missingIndexes']['join'](',\x20')+']')):(i+=0x14,j['push']('Machine\x20'+n['objectAddress']['slice'](0x0,0x8)+':\x20all\x20'+t['requiredIndexes']['length']+'\x20permission\x20index(es)\x20authorized'));}return{'name':'permission_safety','score':clampScore(i),'weight':EXTENDED_DIMENSION_WEIGHTS['permission_safety'],'rationale':j['join'](';\x20')||'Permission\x20checks\x20passed'};}function evaluateValueStub(a,b){return{'evaluationType':'value','score':0x0,'summary':'Requires\x20LLM\x20evaluation\x20—\x20semantic\x20prompt\x20assembled.\x20Call\x20save_evaluation\x20with\x20the\x20LLM\x20result.','criterionScores':[],'findings':[],'strengths':[],'needsLlm':!![],'llmPrompt':b,'evaluatedAt':Date['now']()};}export function runEvaluationInternal(a,b,c){const d=filterTemplateObjects(a);switch(b){case'risk':return evaluateRisk(d);case'trust':return evaluateTrust(d);case'completeness':return evaluateCompleteness(d);case'value':return evaluateValueStub(d,c);default:throw new Error('Unknown\x20evaluation\x20type:\x20'+b);}}const PROJECT_EVALUATION_TYPES=['risk','trust','completeness','worth_buying','value'];function makeProjectRule(a){return{'id':'project_'+a,'description':'Project-level\x20'+a+'\x20evaluation\x20(rule-based\x20or\x20LLM-assisted)','dimension':a,'weight':0x1,'evaluation_ids':['project_'+a],'evaluate':b=>{const c=b['entities']['projectEvaluation'],d=b['entities']['llmPrompt'],e=runEvaluationInternal(c,a,d);return b['facts']['criterionScores']=e['criterionScores'],b['facts']['findings']=e['findings'],b['facts']['strengths']=e['strengths'],b['facts']['needsLlm']=e['needsLlm'],b['facts']['llmPrompt']=e['llmPrompt'],{'score':e['score'],'weight':0x1,'reason':e['summary'],'red_flag':e['findings']?.['some'](g=>g['severity']==='critical')??![]};}};}const RISK_CRITERIA=['structural_risk','fund_safety','operational_risk','governance_risk','graph_coherence','mode_registry'],TRUST_CRITERIA=['reputation','arbitration_coverage','guard_quality','transparency','consumer_diligence'],COMPLETENESS_CRITERIA=['object_coverage','binding_completeness','workflow_rationality','deployment_readiness'];function registerRuleBasedProjectEvaluation(a,b,c,d){const e='__project_'+b+'_result';a['registerDataSource']({'id':'project_'+b+'_facts','description':'Extract\x20project\x20facts\x20+\x20run\x20the\x20'+b+'\x20criterion\x20computer\x20(perspective\x20via\x20UserInjection)','evaluation_ids':['project_'+b],'extract':f=>{const g=f['entities']['projectEvaluation'],h=f['injection']?.['preferences']?.['perspective'],i=h&&h!==g['project']['perspective']?{...g,'project':{...g['project'],'perspective':h}}:g,j=d(i);return f['facts'][e]=j,f['facts']['criterionScores']=j['criterionScores'],f['facts']['findings']=j['findings'],f['facts']['strengths']=j['strengths'],f['facts']['needsLlm']=j['needsLlm'],{};}});for(const f of c){a['registerRule']({'id':'project_'+b+'_'+f,'description':'Project\x20'+b+'\x20criterion:\x20'+f,'dimension':b,'weight':0x1,'evaluation_ids':['project_'+b],'evaluate':g=>{const h=g['facts'][e];if(!h)return null;const i=h['criterionScores']['find'](j=>j['name']===f);if(!i)return null;return{'score':i['score'],'weight':i['weight'],'reason':i['rationale']};}});}}function registerWorthBuyingEvaluation(a){a['registerDataSource']({'id':'project_worth_buying_facts','description':'Run\x20risk/trust/completeness\x20via\x20the\x20kernel\x20+\x20D16-D24\x20enrichment\x20+\x20build\x20LLM\x20prompt','evaluation_ids':['project_worth_buying'],'extract':async b=>{const c=b['entities']['projectEvaluation'],d=b['entities']['llmPrompt'],e={'projectEvaluation':c},[f,g,h]=await Promise['all']([a['evaluate']('project_risk',e,b['injection']),a['evaluate']('project_trust',e,b['injection']),a['evaluate']('project_completeness',e,b['injection'])]),i=[evaluateEscrowQuality(c),evaluateProofIntegrity(c),evaluateArbitrationFairness(c),evaluateFeeTransparency(c),evaluateTimeoutProtection(c),evaluateSupplierVisibility(c),evaluateContentCommitment(c),evaluateReputationVerifiability(c),evaluatePermissionSafety(c)],j=i['map'](m=>m['name']+':\x20'+m['score']+'/100\x20—\x20'+m['rationale'])['join']('\x0a'),k=['===\x20RULE-BASED\x20EVALUATION\x20SUMMARY\x20(F-08\x20enriched\x20context)\x20===','','Risk:\x20'+f['total']+'/100\x20—\x20'+f['summary'],...(f['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','Trust:\x20'+g['total']+'/100\x20—\x20'+g['summary'],...(g['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','Completeness:\x20'+h['total']+'/100\x20—\x20'+h['summary'],...(h['findings']??[])['slice'](0x0,0x3)['map'](m=>'\x20\x20-\x20['+m['severity']+']\x20'+m['message']),'','===\x20EXTENDED\x20DIMENSIONS\x20D16-D24\x20(GLM6/93)\x20===',j,'','===\x20END\x20RULE-BASED\x20SUMMARY\x20===',''],l=k['join']('\x0a');return b['facts']['needsLlm']=!![],b['facts']['llmPrompt']=d?d+'\x0a\x0a'+l:l+'\x0aInstruction:\x20Based\x20on\x20the\x20rule-based\x20summary\x20above,\x20evaluate\x20whether\x20this\x20project\x20is\x20worth\x20buying.\x20Return\x20a\x200-100\x20score\x20and\x20a\x20brief\x20rationale.\x20Focus\x20on\x20buyer\x20risk\x20vs.\x20value\x20proposition.',b['facts']['summary']='Requires\x20LLM\x20evaluation\x20—\x20semantic\x20prompt\x20assembled\x20with\x20rule-based\x20context\x20(risk/trust/completeness\x20+\x20D16-D24\x20extended\x20dimensions).\x20Call\x20save_evaluation\x20with\x20the\x20LLM\x20result.',{};}});}export function registerProjectEvaluations(a=getEvaluationEngine()){registerRuleBasedProjectEvaluation(a,'risk',RISK_CRITERIA,evaluateRisk),registerRuleBasedProjectEvaluation(a,'trust',TRUST_CRITERIA,evaluateTrust),registerRuleBasedProjectEvaluation(a,'completeness',COMPLETENESS_CRITERIA,evaluateCompleteness),registerWorthBuyingEvaluation(a);for(const b of PROJECT_EVALUATION_TYPES){if(b==='risk'||b==='trust'||b==='completeness'||b==='worth_buying')continue;a['registerRule'](makeProjectRule(b));}}registerProjectEvaluations();export async function runEvaluation(a,b,c,d){const e=filterTemplateObjects(a),f=getEvaluationEngine(),g=await f['evaluate']('project_'+b,{'projectEvaluation':e,'llmPrompt':c},d);return{'evaluationType':b,'score':g['total'],'summary':g['summary'],'criterionScores':g['criterionScores']??[],'findings':g['findings']??[],'strengths':g['strengths']??[],'needsLlm':g['needsLlm']??![],'llmPrompt':g['llmPrompt'],'evaluatedAt':Date['now']()};}function filterTemplateObjects(a){const b=i=>{if(!i)return!![];return i['startsWith']('draft:');},c=i=>{if(b(i['objectAddress']))return!![];const j=i['metadata'];return!!(j&&j['status']==='draft');},d=[],e=[];for(const i of a['objects']){c(i)?d['push'](i):e['push'](i);}const f=new Set();for(const j of e){if(j['objectAddress'])f['add'](j['objectAddress']);if(j['objectName']){f['add'](j['objectName']);const k=shortTypeName(j['objectType'])['toLowerCase']();f['add'](k+':'+j['objectName']);}}const g=new Set();for(const l of d){if(l['objectAddress'])g['add'](l['objectAddress']);if(l['objectName']){g['add'](l['objectName']);const m=shortTypeName(l['objectType'])['toLowerCase']();g['add'](m+':'+l['objectName']);}}const h=a['edges']['filter'](n=>{const p=n['metadata'];if(p&&p['blueprint']===!![])return![];const q=b(n['sourceObject'])||g['has'](n['sourceObject']),r=b(n['targetObject'])||g['has'](n['targetObject']);return!q&&!r;});return{...a,'objects':e,'edges':h};}export function compareProjects(a,b){const c=[...a]['sort']((d,e)=>{if(d['score']===null&&e['score']===null)return 0x0;if(d['score']===null)return 0x1;if(e['score']===null)return-0x1;return e['score']-d['score'];});return{'evaluationType':b,'entries':a,'ranking':c,'bestProjectId':c[0x0]?.['score']!==null?c[0x0]?.['projectId']??null:null};}
@@ -1 +1 @@
1
- import{normalizeForProject,extractProjectPrefix,extractAllProjectVersions,TAG_PREFIX}from'./namespace.js';import{ProjectGraph,extractReferences,nodeIdOf}from'./graph.js';import{listProjects,listProjectObjects,listShareableObjects,traceDependencies,traceReferencedBy,prePublishCheck,findCrossProjectReferences}from'./query.js';import{isEnabled as a268a}from'../config/index.js';import{LocalMark,getWowMcpDir}from'@wowok/wowok';import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import*as a268b from'./project-store.js';export*from'./namespace.js';export*from'./graph.js';export*from'./query.js';export*from'./reverse-mapping.js';export*from'./workflow-design-assessment.js';export function isProjectServiceEnabled(){return a268a('project_service');}function scheduleHiddenStep(a,b,c){const d=extractAllProjectVersions(b)['filter'](f=>f['version']!==undefined)['map'](f=>''+TAG_PREFIX['project']+f['prefix']+'_'+f['version']);if(d['length']===0x0||c['length']===0x0)return;const e=async()=>{const f=LocalMark['Instance']();for(const g of c){try{await f['add_tags'](g['target'],d);}catch{}}};typeof setImmediate==='function'?setImmediate(()=>{e()['catch'](()=>{});}):Promise['resolve']()['then'](()=>{e()['catch'](()=>{});});}let GRAPH_INSTANCE=null,GRAPH_HYDRATED=![];function isAutoHydrateEnabled(){const a=process['env']['WOWOK_PROJECT_SERVICE_HYDRATE'];return a==='1'||a==='true';}export function getGraph(){if(!GRAPH_INSTANCE){GRAPH_INSTANCE=new ProjectGraph();if(isAutoHydrateEnabled()&&!GRAPH_HYDRATED){GRAPH_HYDRATED=!![];try{loadGraph();}catch{}}}return GRAPH_INSTANCE;}export function setGraph(a){GRAPH_INSTANCE=a;}const STAGE_CACHE=new Map();function stageCacheKey(a,b){return a+':'+b;}export function getStageCache(a,b){const c=stageCacheKey(a,b),d=STAGE_CACHE['get'](c);if(d)return d;const e=a268b['loadStageState'](a,b);if(e){const f={'stage':e['stage'],'updated_at':e['updated_at']};return STAGE_CACHE['set'](c,f),f;}return undefined;}export function updateStageCache(a,b,c){const d=stageCacheKey(a,b),e=STAGE_CACHE['get'](d),f={'stage':c['stage']??e?.['stage']??0x1,'updated_at':Date['now'](),...e,...c};return STAGE_CACHE['set'](d,f),persistStageState(a,b,f),f;}function persistStageState(a,b,c){try{let d=a268b['loadStageState'](a,b);if(!d){a268b['initProject'](a,b,{'mcpVersion':'project-service-v'+PROJECT_SERVICE_VERSION}),d=a268b['loadStageState'](a,b);if(!d)return;}if(d['archived'])return;d['stage']=c['stage'],d['updated_at']=c['updated_at'],a268b['saveStageState'](a,b,d);}catch{}}export function getProjectStatus(a,b){const c=getStageCache(a,b),d=c?.['stage']??0x1,e={0x1:{'name':'Project\x20Naming','description':'Project\x20namespace\x20established.\x20Ready\x20to\x20analyze\x20business\x20intent.','next':'analyze_intent'},0x2:{'name':'Business\x20Puzzle','description':'Business\x20intent\x20analyzed.\x20Puzzles\x20may\x20need\x20completion\x20before\x20risk\x20assessment.','next':c?.['puzzles']?'aggregate_risks':'analyze_intent'},0x3:{'name':'Risk\x20Calibration','description':'Risks\x20assessed.\x20Fix\x20CRITICAL\x20risks\x20before\x20generating\x20deployment\x20doc.','next':c?.['risk_can_proceed']?'generate_deployment_doc':'aggregate_risks'},0x4:{'name':'Deployment\x20Document','description':'Deployment\x20doc\x20generated.\x20Fix\x20D-errors\x20before\x20substep\x20trace.','next':c?.['doc_error_count']===0x0?'trace_substeps':'generate_deployment_doc'},0x5:{'name':'Substep\x20Trace','description':'Substeps\x20traced.\x20Ready\x20for\x20deployment\x20execution.','next':c?.['trace_can_proceed']?'deploy':'trace_substeps'}},f=e[d];return{'stage':d,'stage_name':f['name'],'stage_description':f['description'],'next_action':f['next'],'can_proceed':d<0x5,'details':c};}export function clearStageCache(a,b){STAGE_CACHE['delete'](stageCacheKey(a,b));}export function normalize(a){if(!isProjectServiceEnabled())return{'data':a['data'],'warnings':[]};return normalizeForProject({'operation_type':a['operation_type'],'data':a['data'],'projectPrefix':a['projectPrefix'],'role':a['role'],'industry':a['industry'],'version':a['version'],'shareable':a['shareable']});}export function observe(a,b,c){if(!isProjectServiceEnabled())return;try{const d=getGraph(),e=b?.['namedNew']??b?.['object'],f=e?.['name'],g=extractAddressFromResult(c),h=nodeIdOf(f,g);if(!h)return;const i=e?.['tags'],j=extractProjectPrefix(i),k=i?.['find'](q=>q['startsWith'](TAG_PREFIX['type'])),l=k?.['slice'](TAG_PREFIX['type']['length']),m=extractAllProjectVersions(i),n=m['map'](q=>q['version']?q['prefix']+'_'+q['version']:q['prefix']),o={'id':h,'project':j,'projects':n['length']>0x0?n:undefined,'type':l,'address':g};d['upsertNode'](o);const p=extractReferences(a,b);for(const q of p){d['addEdge'](h,q['target'],q['kind']);}scheduleHiddenStep(h,i,p);if(a268a('graph_persist'))try{saveGraph();}catch{}}catch{}}function extractAddressFromResult(a){if(!a||typeof a!=='object')return undefined;const b=a?.['object_id']??a?.['objectId']??a?.['effects']?.['created']?.[0x0]?.['reference']?.['objectId']??a?.['objectRef']?.['objectId']??a?.['data']?.['objectId'];if(typeof b==='string'&&b['startsWith']('0x'))return b;const c=a['result']??a['data'];if(c&&typeof c==='object'){const d=c['object_id']??c['objectId']??c['effects']?.['created']?.[0x0]?.['reference']?.['objectId']??c['objectRef']?.['objectId'];if(typeof d==='string'&&d['startsWith']('0x'))return d;}return undefined;}export async function queryProjects(){const a=await listProjects();try{const {LocalProject:b}=await import('@wowok/wowok'),c=await b['Instance']()['listProjects'](),d=c['map'](f=>({'prefix':f['prefix'],'objectCount':0x0,'types':[],'versions':f['currentVersion']?[f['currentVersion']]:[],'objects':[],...f})),e=new Map();for(const f of a)e['set'](f['prefix'],f);for(const g of d){if(!e['has'](g['prefix']))e['set'](g['prefix'],g);}return Array['from'](e['values']());}catch{return a;}}export async function queryProjectObjects(a){return listProjectObjects(a);}export async function queryShareableObjects(){return listShareableObjects();}export function queryDependencies(a){return traceDependencies(getGraph(),a);}export function queryReferencedBy(a){return traceReferencedBy(getGraph(),a);}export function queryPrePublishCheck(a){return prePublishCheck(getGraph(),a);}export function queryCrossProjectReferences(){return findCrossProjectReferences(getGraph());}export function queryGraphStats(){const a=getGraph();return{'nodeCount':a['nodeCount'],'edgeCount':a['edgeCount'],'cycles':a['detectCycles'](),'dangling':a['findDanglingDependencies']()};}function graphFilePath(){return join(getWowMcpDir(),'project-graph.json');}export function saveGraph(){const a=graphFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c=getGraph()['snapshot']();return writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8'),a;}export function loadGraph(){const a=graphFilePath();if(!existsSync(a))return![];try{const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&c['nodes']&&c['edges'])return getGraph()['restore'](c),!![];}catch{}return![];}export function hasPersistedGraph(){return existsSync(graphFilePath());}export const PROJECT_SERVICE_VERSION=0x1;
1
+ import{normalizeForProject,extractProjectPrefix,extractAllProjectVersions,TAG_PREFIX}from'./namespace.js';import{ProjectGraph,extractReferences,nodeIdOf}from'./graph.js';import{listProjects,listProjectObjects,listShareableObjects,traceDependencies,traceReferencedBy,prePublishCheck,findCrossProjectReferences}from'./query.js';import{isEnabled as a269a}from'../config/index.js';import{LocalMark,getWowMcpDir}from'@wowok/wowok';import{readFileSync,writeFileSync,existsSync,mkdirSync}from'fs';import{dirname,join}from'path';import*as a269b from'./project-store.js';export*from'./namespace.js';export*from'./graph.js';export*from'./query.js';export*from'./reverse-mapping.js';export*from'./workflow-design-assessment.js';export function isProjectServiceEnabled(){return a269a('project_service');}function scheduleHiddenStep(a,b,c){const d=extractAllProjectVersions(b)['filter'](f=>f['version']!==undefined)['map'](f=>''+TAG_PREFIX['project']+f['prefix']+'_'+f['version']);if(d['length']===0x0||c['length']===0x0)return;const e=async()=>{const f=LocalMark['Instance']();for(const g of c){try{await f['add_tags'](g['target'],d);}catch{}}};typeof setImmediate==='function'?setImmediate(()=>{e()['catch'](()=>{});}):Promise['resolve']()['then'](()=>{e()['catch'](()=>{});});}let GRAPH_INSTANCE=null,GRAPH_HYDRATED=![];function isAutoHydrateEnabled(){const a=process['env']['WOWOK_PROJECT_SERVICE_HYDRATE'];return a==='1'||a==='true';}export function getGraph(){if(!GRAPH_INSTANCE){GRAPH_INSTANCE=new ProjectGraph();if(isAutoHydrateEnabled()&&!GRAPH_HYDRATED){GRAPH_HYDRATED=!![];try{loadGraph();}catch{}}}return GRAPH_INSTANCE;}export function setGraph(a){GRAPH_INSTANCE=a;}const STAGE_CACHE=new Map();function stageCacheKey(a,b){return a+':'+b;}export function getStageCache(a,b){const c=stageCacheKey(a,b),d=STAGE_CACHE['get'](c);if(d)return d;const e=a269b['loadStageState'](a,b);if(e){const f={'stage':e['stage'],'updated_at':e['updated_at']};return STAGE_CACHE['set'](c,f),f;}return undefined;}export function updateStageCache(a,b,c){const d=stageCacheKey(a,b),e=STAGE_CACHE['get'](d),f={'stage':c['stage']??e?.['stage']??0x1,'updated_at':Date['now'](),...e,...c};return STAGE_CACHE['set'](d,f),persistStageState(a,b,f),f;}function persistStageState(a,b,c){try{let d=a269b['loadStageState'](a,b);if(!d){a269b['initProject'](a,b,{'mcpVersion':'project-service-v'+PROJECT_SERVICE_VERSION}),d=a269b['loadStageState'](a,b);if(!d)return;}if(d['archived'])return;d['stage']=c['stage'],d['updated_at']=c['updated_at'],a269b['saveStageState'](a,b,d);}catch{}}export function getProjectStatus(a,b){const c=getStageCache(a,b),d=c?.['stage']??0x1,e={0x1:{'name':'Project\x20Naming','description':'Project\x20namespace\x20established.\x20Ready\x20to\x20analyze\x20business\x20intent.','next':'analyze_intent'},0x2:{'name':'Business\x20Puzzle','description':'Business\x20intent\x20analyzed.\x20Puzzles\x20may\x20need\x20completion\x20before\x20risk\x20assessment.','next':c?.['puzzles']?'aggregate_risks':'analyze_intent'},0x3:{'name':'Risk\x20Calibration','description':'Risks\x20assessed.\x20Fix\x20CRITICAL\x20risks\x20before\x20generating\x20deployment\x20doc.','next':c?.['risk_can_proceed']?'generate_deployment_doc':'aggregate_risks'},0x4:{'name':'Deployment\x20Document','description':'Deployment\x20doc\x20generated.\x20Fix\x20D-errors\x20before\x20substep\x20trace.','next':c?.['doc_error_count']===0x0?'trace_substeps':'generate_deployment_doc'},0x5:{'name':'Substep\x20Trace','description':'Substeps\x20traced.\x20Ready\x20for\x20deployment\x20execution.','next':c?.['trace_can_proceed']?'deploy':'trace_substeps'}},f=e[d];return{'stage':d,'stage_name':f['name'],'stage_description':f['description'],'next_action':f['next'],'can_proceed':d<0x5,'details':c};}export function clearStageCache(a,b){STAGE_CACHE['delete'](stageCacheKey(a,b));}export function normalize(a){if(!isProjectServiceEnabled())return{'data':a['data'],'warnings':[]};return normalizeForProject({'operation_type':a['operation_type'],'data':a['data'],'projectPrefix':a['projectPrefix'],'role':a['role'],'industry':a['industry'],'version':a['version'],'shareable':a['shareable']});}export function observe(a,b,c){if(!isProjectServiceEnabled())return;try{const d=getGraph(),e=b?.['namedNew']??b?.['object'],f=e?.['name'],g=extractAddressFromResult(c),h=nodeIdOf(f,g);if(!h)return;const i=e?.['tags'],j=extractProjectPrefix(i),k=i?.['find'](q=>q['startsWith'](TAG_PREFIX['type'])),l=k?.['slice'](TAG_PREFIX['type']['length']),m=extractAllProjectVersions(i),n=m['map'](q=>q['version']?q['prefix']+'_'+q['version']:q['prefix']),o={'id':h,'project':j,'projects':n['length']>0x0?n:undefined,'type':l,'address':g};d['upsertNode'](o);const p=extractReferences(a,b);for(const q of p){d['addEdge'](h,q['target'],q['kind']);}scheduleHiddenStep(h,i,p);if(a269a('graph_persist'))try{saveGraph();}catch{}}catch{}}function extractAddressFromResult(a){if(!a||typeof a!=='object')return undefined;const b=a?.['object_id']??a?.['objectId']??a?.['effects']?.['created']?.[0x0]?.['reference']?.['objectId']??a?.['objectRef']?.['objectId']??a?.['data']?.['objectId'];if(typeof b==='string'&&b['startsWith']('0x'))return b;const c=a['result']??a['data'];if(c&&typeof c==='object'){const d=c['object_id']??c['objectId']??c['effects']?.['created']?.[0x0]?.['reference']?.['objectId']??c['objectRef']?.['objectId'];if(typeof d==='string'&&d['startsWith']('0x'))return d;}return undefined;}export async function queryProjects(){const a=await listProjects();try{const {LocalProject:b}=await import('@wowok/wowok'),c=await b['Instance']()['listProjects'](),d=c['map'](f=>({'prefix':f['prefix'],'objectCount':0x0,'types':[],'versions':f['currentVersion']?[f['currentVersion']]:[],'objects':[],...f})),e=new Map();for(const f of a)e['set'](f['prefix'],f);for(const g of d){if(!e['has'](g['prefix']))e['set'](g['prefix'],g);}return Array['from'](e['values']());}catch{return a;}}export async function queryProjectObjects(a){return listProjectObjects(a);}export async function queryShareableObjects(){return listShareableObjects();}export function queryDependencies(a){return traceDependencies(getGraph(),a);}export function queryReferencedBy(a){return traceReferencedBy(getGraph(),a);}export function queryPrePublishCheck(a){return prePublishCheck(getGraph(),a);}export function queryCrossProjectReferences(){return findCrossProjectReferences(getGraph());}export function queryGraphStats(){const a=getGraph();return{'nodeCount':a['nodeCount'],'edgeCount':a['edgeCount'],'cycles':a['detectCycles'](),'dangling':a['findDanglingDependencies']()};}function graphFilePath(){return join(getWowMcpDir(),'project-graph.json');}export function saveGraph(){const a=graphFilePath(),b=dirname(a);if(!existsSync(b))mkdirSync(b,{'recursive':!![]});const c=getGraph()['snapshot']();return writeFileSync(a,JSON['stringify'](c,null,0x2),'utf-8'),a;}export function loadGraph(){const a=graphFilePath();if(!existsSync(a))return![];try{const b=readFileSync(a,'utf-8'),c=JSON['parse'](b);if(c&&c['nodes']&&c['edges'])return getGraph()['restore'](c),!![];}catch{}return![];}export function hasPersistedGraph(){return existsSync(graphFilePath());}export const PROJECT_SERVICE_VERSION=0x1;
@@ -1 +1 @@
1
- import{existsSync,rmSync}from'fs';import{join}from'path';import{loadStageState,projectDir,rollbackStage as a281a}from'./project-store.js';export const REVERSIBILITY_MATRIX=[{'object_type':'permission','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Permission\x20(unpublished):\x20can\x20add\x20tables/admins\x20freely'},{'object_type':'permission','lifecycle_state':'referenced','struct_reversible':'limited','behavior_reversible':!![],'gas_impact':'medium','explanation':'Permission\x20(referenced\x20by\x20published\x20service):\x20modifications\x20limited\x20—\x20affects\x20dependents'},{'object_type':'machine','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Machine\x20(unpublished):\x20can\x20modify\x20nodes/edges/forwards\x20freely'},{'object_type':'machine','lifecycle_state':'published','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Machine\x20(published):\x20structure\x20is\x20immutable\x20—\x20can\x20only\x20advance\x20progress'},{'object_type':'service','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Service\x20(unpublished):\x20can\x20modify\x20fields\x20freely'},{'object_type':'service','lifecycle_state':'published','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Service\x20(published):\x20machine/order_allocators\x20frozen\x20—\x20can\x20still\x20transact\x20normally'},{'object_type':'guard','lifecycle_state':'created','struct_reversible':'immutable','behavior_reversible':![],'gas_impact':'none','explanation':'Guard:\x20create-only\x20semantics\x20—\x20immutable\x20from\x20creation'},{'object_type':'allocation','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Allocator\x20(unbound):\x20can\x20modify\x20strategy\x20freely'},{'object_type':'allocation','lifecycle_state':'bound','struct_reversible':'limited','behavior_reversible':!![],'gas_impact':'medium','explanation':'Allocator\x20(bound\x20to\x20published\x20service):\x20strategy\x20modifications\x20limited'},{'object_type':'treasury','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Treasury:\x20can\x20modify\x20rules\x20freely'},{'object_type':'arb','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Arbitration:\x20can\x20modify\x20rules\x20freely'},{'object_type':'reward','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Reward:\x20can\x20modify\x20rules\x20freely'},{'object_type':'progress','lifecycle_state':'bound','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Progress\x20(bound\x20to\x20machine):\x20cannot\x20swap\x20machine\x20—\x20can\x20only\x20forward'},{'object_type':'order','lifecycle_state':'created','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Order:\x20structure\x20immutable\x20after\x20creation\x20—\x20can\x20only\x20advance\x20state'}];export function queryReversibility(a,b){return REVERSIBILITY_MATRIX['find'](c=>c['object_type']===a&&c['lifecycle_state']===b);}export function getReversibilityForType(a){return REVERSIBILITY_MATRIX['filter'](b=>b['object_type']===a);}export function recommendIterationStrategy(a,b,c){const d=loadStageState(a,b);if(!d)return{'strategy':'in_place','reason':'Project\x20not\x20initialized\x20—\x20no\x20stage\x20state\x20found.\x20Use\x20in-place\x20for\x20new\x20projects.'};if(d['has_published_object']){const f=b['match'](/^v(\d+)$/),g=f?parseInt(f[0x1])+0x1:0x2,h='v'+g;return{'strategy':'fork','reason':'Project\x20has\x20published\x20on-chain\x20objects\x20—\x20in-place\x20modification\x20would\x20break\x20running\x20business.\x20'+('Fork\x20to\x20'+h+'\x20to\x20preserve\x20the\x20original\x20version\x20as\x20a\x20read-only\x20historical\x20snapshot.'),'fork_to_version':h,'published_objects':d['stage_meta'][0x5]?.['committed']?['see\x20deployment/05-substeps/\x20for\x20published\x20object\x20list']:[]};}const e=c??d['stage'];return{'strategy':'in_place','reason':'Project\x20has\x20no\x20published\x20objects\x20(current\x20stage:\x20'+e+').\x20'+'Safe\x20to\x20modify\x20the\x20current\x20version\x20directly\x20—\x20all\x20changes\x20are\x20local\x20and\x20reversible.'};}const STAGE_DIR_SUFFIXES={0x1:'01-namespace',0x2:'02-puzzle',0x3:'03-risk',0x4:'04-steps',0x5:'05-substeps'};export function evaluateRollbackPolicy(a,b,c){const d=loadStageState(a,b);if(!d)return{'allowed':![],'target_stage':c,'current_stage':0x1,'block_reason':'Project\x20not\x20initialized:\x20'+a+'_'+b,'files_to_clean':[],'warnings':[],'iteration_strategy':{'strategy':'in_place','reason':'Project\x20not\x20initialized.'}};const e=d['stage'],f=recommendIterationStrategy(a,b,e);if(d['has_published_object'])return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Project\x20has\x20published\x20on-chain\x20objects\x20—\x20rollback\x20is\x20forbidden\x20(§3.3).\x20'+'Use\x20fork_project\x20to\x20create\x20a\x20new\x20version\x20for\x20modifications.','files_to_clean':[],'warnings':[],'iteration_strategy':f};if(c>=e)return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Target\x20stage\x20'+c+'\x20must\x20be\x20less\x20than\x20current\x20stage\x20'+e+'.','files_to_clean':[],'warnings':[],'iteration_strategy':f};if(c<0x1)return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Cannot\x20rollback\x20below\x20stage\x201.','files_to_clean':[],'warnings':[],'iteration_strategy':f};const g=[],h=[],i=join(projectDir(a,b),'deployment');for(let j=c+0x1;j<=0x5;j++){const k=join(i,STAGE_DIR_SUFFIXES[j]);existsSync(k)&&g['push']('deployment/'+STAGE_DIR_SUFFIXES[j]+'/');}return c<=0x2&&existsSync(i)&&(g['length']=0x0,g['push']('deployment/')),g['length']>0x0&&h['push']('Rollback\x20will\x20delete\x20'+g['length']+'\x20file(s)/directory(ies):\x20'+g['join'](',\x20')+'.\x20'+'This\x20data\x20will\x20be\x20lost\x20—\x20regenerate\x20by\x20re-running\x20the\x20stage\x20action.'),{'allowed':!![],'target_stage':c,'current_stage':e,'files_to_clean':g,'warnings':h,'iteration_strategy':f};}export function rollbackStageWithPolicy(a,b,c,d){const e=evaluateRollbackPolicy(a,b,c);if(!e['allowed'])return{'success':![],'target_stage':c,'previous_stage':e['current_stage'],'files_to_clean':[],'files_cleaned':[],'stage_state':loadStageState(a,b),'warnings':[],'iteration_strategy':e['iteration_strategy'],'message':'Rollback\x20blocked:\x20'+e['block_reason']};const f=[],g=join(projectDir(a,b),'deployment');if(e['files_to_clean']['includes']('deployment/'))existsSync(g)&&(rmSync(g,{'recursive':!![],'force':!![]}),f['push']('deployment/'));else for(const i of e['files_to_clean']){const j=join(projectDir(a,b),i);existsSync(j)&&(rmSync(j,{'recursive':!![],'force':!![]}),f['push'](i));}const h=a281a(a,b,c,{'reason':d??'rollback\x20to\x20stage\x20'+c+'\x20(policy-evaluated)','affectedFiles':f['length']>0x0?f:['stage.json']});return{'success':!![],'target_stage':c,'previous_stage':e['current_stage'],'files_to_clean':e['files_to_clean'],'files_cleaned':f,'stage_state':h,'warnings':e['warnings'],'iteration_strategy':e['iteration_strategy'],'message':'Rolled\x20back\x20from\x20stage\x20'+e['current_stage']+'\x20to\x20'+c+'.\x20'+(f['length']+'\x20file(s)/directory(ies)\x20cleaned.\x20')+'Stage\x20state\x20updated.\x20'+(e['iteration_strategy']['strategy']==='fork'?'Note:\x20this\x20project\x20has\x20published\x20objects\x20—\x20future\x20modifications\x20require\x20fork.':'Project\x20has\x20no\x20published\x20objects\x20—\x20in-place\x20modification\x20is\x20safe.')};}
1
+ import{existsSync,rmSync}from'fs';import{join}from'path';import{loadStageState,projectDir,rollbackStage as a282a}from'./project-store.js';export const REVERSIBILITY_MATRIX=[{'object_type':'permission','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Permission\x20(unpublished):\x20can\x20add\x20tables/admins\x20freely'},{'object_type':'permission','lifecycle_state':'referenced','struct_reversible':'limited','behavior_reversible':!![],'gas_impact':'medium','explanation':'Permission\x20(referenced\x20by\x20published\x20service):\x20modifications\x20limited\x20—\x20affects\x20dependents'},{'object_type':'machine','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Machine\x20(unpublished):\x20can\x20modify\x20nodes/edges/forwards\x20freely'},{'object_type':'machine','lifecycle_state':'published','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Machine\x20(published):\x20structure\x20is\x20immutable\x20—\x20can\x20only\x20advance\x20progress'},{'object_type':'service','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Service\x20(unpublished):\x20can\x20modify\x20fields\x20freely'},{'object_type':'service','lifecycle_state':'published','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Service\x20(published):\x20machine/order_allocators\x20frozen\x20—\x20can\x20still\x20transact\x20normally'},{'object_type':'guard','lifecycle_state':'created','struct_reversible':'immutable','behavior_reversible':![],'gas_impact':'none','explanation':'Guard:\x20create-only\x20semantics\x20—\x20immutable\x20from\x20creation'},{'object_type':'allocation','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Allocator\x20(unbound):\x20can\x20modify\x20strategy\x20freely'},{'object_type':'allocation','lifecycle_state':'bound','struct_reversible':'limited','behavior_reversible':!![],'gas_impact':'medium','explanation':'Allocator\x20(bound\x20to\x20published\x20service):\x20strategy\x20modifications\x20limited'},{'object_type':'treasury','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Treasury:\x20can\x20modify\x20rules\x20freely'},{'object_type':'arb','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Arbitration:\x20can\x20modify\x20rules\x20freely'},{'object_type':'reward','lifecycle_state':'created','struct_reversible':'reversible','behavior_reversible':!![],'gas_impact':'low','explanation':'Reward:\x20can\x20modify\x20rules\x20freely'},{'object_type':'progress','lifecycle_state':'bound','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Progress\x20(bound\x20to\x20machine):\x20cannot\x20swap\x20machine\x20—\x20can\x20only\x20forward'},{'object_type':'order','lifecycle_state':'created','struct_reversible':'immutable','behavior_reversible':!![],'gas_impact':'none','explanation':'Order:\x20structure\x20immutable\x20after\x20creation\x20—\x20can\x20only\x20advance\x20state'}];export function queryReversibility(a,b){return REVERSIBILITY_MATRIX['find'](c=>c['object_type']===a&&c['lifecycle_state']===b);}export function getReversibilityForType(a){return REVERSIBILITY_MATRIX['filter'](b=>b['object_type']===a);}export function recommendIterationStrategy(a,b,c){const d=loadStageState(a,b);if(!d)return{'strategy':'in_place','reason':'Project\x20not\x20initialized\x20—\x20no\x20stage\x20state\x20found.\x20Use\x20in-place\x20for\x20new\x20projects.'};if(d['has_published_object']){const f=b['match'](/^v(\d+)$/),g=f?parseInt(f[0x1])+0x1:0x2,h='v'+g;return{'strategy':'fork','reason':'Project\x20has\x20published\x20on-chain\x20objects\x20—\x20in-place\x20modification\x20would\x20break\x20running\x20business.\x20'+('Fork\x20to\x20'+h+'\x20to\x20preserve\x20the\x20original\x20version\x20as\x20a\x20read-only\x20historical\x20snapshot.'),'fork_to_version':h,'published_objects':d['stage_meta'][0x5]?.['committed']?['see\x20deployment/05-substeps/\x20for\x20published\x20object\x20list']:[]};}const e=c??d['stage'];return{'strategy':'in_place','reason':'Project\x20has\x20no\x20published\x20objects\x20(current\x20stage:\x20'+e+').\x20'+'Safe\x20to\x20modify\x20the\x20current\x20version\x20directly\x20—\x20all\x20changes\x20are\x20local\x20and\x20reversible.'};}const STAGE_DIR_SUFFIXES={0x1:'01-namespace',0x2:'02-puzzle',0x3:'03-risk',0x4:'04-steps',0x5:'05-substeps'};export function evaluateRollbackPolicy(a,b,c){const d=loadStageState(a,b);if(!d)return{'allowed':![],'target_stage':c,'current_stage':0x1,'block_reason':'Project\x20not\x20initialized:\x20'+a+'_'+b,'files_to_clean':[],'warnings':[],'iteration_strategy':{'strategy':'in_place','reason':'Project\x20not\x20initialized.'}};const e=d['stage'],f=recommendIterationStrategy(a,b,e);if(d['has_published_object'])return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Project\x20has\x20published\x20on-chain\x20objects\x20—\x20rollback\x20is\x20forbidden\x20(§3.3).\x20'+'Use\x20fork_project\x20to\x20create\x20a\x20new\x20version\x20for\x20modifications.','files_to_clean':[],'warnings':[],'iteration_strategy':f};if(c>=e)return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Target\x20stage\x20'+c+'\x20must\x20be\x20less\x20than\x20current\x20stage\x20'+e+'.','files_to_clean':[],'warnings':[],'iteration_strategy':f};if(c<0x1)return{'allowed':![],'target_stage':c,'current_stage':e,'block_reason':'Cannot\x20rollback\x20below\x20stage\x201.','files_to_clean':[],'warnings':[],'iteration_strategy':f};const g=[],h=[],i=join(projectDir(a,b),'deployment');for(let j=c+0x1;j<=0x5;j++){const k=join(i,STAGE_DIR_SUFFIXES[j]);existsSync(k)&&g['push']('deployment/'+STAGE_DIR_SUFFIXES[j]+'/');}return c<=0x2&&existsSync(i)&&(g['length']=0x0,g['push']('deployment/')),g['length']>0x0&&h['push']('Rollback\x20will\x20delete\x20'+g['length']+'\x20file(s)/directory(ies):\x20'+g['join'](',\x20')+'.\x20'+'This\x20data\x20will\x20be\x20lost\x20—\x20regenerate\x20by\x20re-running\x20the\x20stage\x20action.'),{'allowed':!![],'target_stage':c,'current_stage':e,'files_to_clean':g,'warnings':h,'iteration_strategy':f};}export function rollbackStageWithPolicy(a,b,c,d){const e=evaluateRollbackPolicy(a,b,c);if(!e['allowed'])return{'success':![],'target_stage':c,'previous_stage':e['current_stage'],'files_to_clean':[],'files_cleaned':[],'stage_state':loadStageState(a,b),'warnings':[],'iteration_strategy':e['iteration_strategy'],'message':'Rollback\x20blocked:\x20'+e['block_reason']};const f=[],g=join(projectDir(a,b),'deployment');if(e['files_to_clean']['includes']('deployment/'))existsSync(g)&&(rmSync(g,{'recursive':!![],'force':!![]}),f['push']('deployment/'));else for(const i of e['files_to_clean']){const j=join(projectDir(a,b),i);existsSync(j)&&(rmSync(j,{'recursive':!![],'force':!![]}),f['push'](i));}const h=a282a(a,b,c,{'reason':d??'rollback\x20to\x20stage\x20'+c+'\x20(policy-evaluated)','affectedFiles':f['length']>0x0?f:['stage.json']});return{'success':!![],'target_stage':c,'previous_stage':e['current_stage'],'files_to_clean':e['files_to_clean'],'files_cleaned':f,'stage_state':h,'warnings':e['warnings'],'iteration_strategy':e['iteration_strategy'],'message':'Rolled\x20back\x20from\x20stage\x20'+e['current_stage']+'\x20to\x20'+c+'.\x20'+(f['length']+'\x20file(s)/directory(ies)\x20cleaned.\x20')+'Stage\x20state\x20updated.\x20'+(e['iteration_strategy']['strategy']==='fork'?'Note:\x20this\x20project\x20has\x20published\x20objects\x20—\x20future\x20modifications\x20require\x20fork.':'Project\x20has\x20no\x20published\x20objects\x20—\x20in-place\x20modification\x20is\x20safe.')};}
@@ -1 +1 @@
1
- import{CONFIRMATION_RULES,resolveOverrideId}from'../knowledge/safety-rules.js';import{isEnabled as a294a}from'../config/index.js';export function isConfirmGateEnabled(){return a294a('confirm_gate');}const internalErrorCounts={};function logInternalError(a,b){const c=a;internalErrorCounts[c]=(internalErrorCounts[c]??0x0)+0x1;const d=internalErrorCounts[c];console['warn']('[ConfirmGate]\x20internal_error\x20context=\x22'+a+'\x22\x20count='+d+'\x20error='+(b instanceof Error?b['message']:String(b)));}export function getFailMode(a){switch(a){case'irreversible':case'publish':case'amount':return'closed';case'standard':case'none':default:return'open';}}function buildInternalErrorResult(){return{'pass':![],'level':'irreversible','preview':{'level':'irreversible','operation':'unknown','irreversible':!![]},'rule_id':'internal_error'};}export function confirmGate(a,b,c,d,f){if(!isConfirmGateEnabled())return{'pass':!![]};if(c?.['confirmed']===!![])return{'pass':!![]};let g,h=null;try{g=CONFIRMATION_RULES['find'](l=>{try{return l['when'](a,b,c);}catch(m){logInternalError('rule_when:'+l['id'],m);if(getFailMode(l['level'])==='closed')throw m;return![];}});}catch(l){h=l;}if(h)return logInternalError('rule_search',h),buildInternalErrorResult();if(!g)return{'pass':!![]};const i=resolveOverrideId(g['id'],a),j=i?f?.[i]:undefined;if(j==='auto')return{'pass':!![]};if(j!=='block'&&g['bypass_on_explicit_intent']&&d&&d['length']>0x0){const m=d['map'](o=>o['toLowerCase']()),n=g['bypass_on_explicit_intent']['some'](o=>m['some'](q=>q['includes'](o['toLowerCase']())));if(n)return{'pass':!![]};}let k;try{k=g['preview'](a,b,c);}catch(o){logInternalError('rule_preview:'+g['id'],o);if(getFailMode(g['level'])==='closed')return buildInternalErrorResult();return{'pass':!![]};}return{'pass':![],'level':g['level'],'preview':k,'rule_id':g['id']};}export function isExplicitlyConfirmed(a){return a?.['confirmed']===!![];}
1
+ import{CONFIRMATION_RULES,resolveOverrideId}from'../knowledge/safety-rules.js';import{isEnabled as a295a}from'../config/index.js';export function isConfirmGateEnabled(){return a295a('confirm_gate');}const internalErrorCounts={};function logInternalError(a,b){const c=a;internalErrorCounts[c]=(internalErrorCounts[c]??0x0)+0x1;const d=internalErrorCounts[c];console['warn']('[ConfirmGate]\x20internal_error\x20context=\x22'+a+'\x22\x20count='+d+'\x20error='+(b instanceof Error?b['message']:String(b)));}export function getFailMode(a){switch(a){case'irreversible':case'publish':case'amount':return'closed';case'standard':case'none':default:return'open';}}function buildInternalErrorResult(){return{'pass':![],'level':'irreversible','preview':{'level':'irreversible','operation':'unknown','irreversible':!![]},'rule_id':'internal_error'};}export function confirmGate(a,b,c,d,f){if(!isConfirmGateEnabled())return{'pass':!![]};if(c?.['confirmed']===!![])return{'pass':!![]};let g,h=null;try{g=CONFIRMATION_RULES['find'](l=>{try{return l['when'](a,b,c);}catch(m){logInternalError('rule_when:'+l['id'],m);if(getFailMode(l['level'])==='closed')throw m;return![];}});}catch(l){h=l;}if(h)return logInternalError('rule_search',h),buildInternalErrorResult();if(!g)return{'pass':!![]};const i=resolveOverrideId(g['id'],a),j=i?f?.[i]:undefined;if(j==='auto')return{'pass':!![]};if(j!=='block'&&g['bypass_on_explicit_intent']&&d&&d['length']>0x0){const m=d['map'](o=>o['toLowerCase']()),n=g['bypass_on_explicit_intent']['some'](o=>m['some'](q=>q['includes'](o['toLowerCase']())));if(n)return{'pass':!![]};}let k;try{k=g['preview'](a,b,c);}catch(o){logInternalError('rule_preview:'+g['id'],o);if(getFailMode(g['level'])==='closed')return buildInternalErrorResult();return{'pass':!![]};}return{'pass':![],'level':g['level'],'preview':k,'rule_id':g['id']};}export function isExplicitlyConfirmed(a){return a?.['confirmed']===!![];}
@@ -55,6 +55,9 @@ export declare const CallAllocation_OperateSchema: z.ZodObject<{
55
55
  id: z.ZodString;
56
56
  balance: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
57
57
  payment: z.ZodString;
58
+ type: z.ZodOptional<z.ZodString>;
59
+ version: z.ZodOptional<z.ZodString>;
60
+ digest: z.ZodOptional<z.ZodString>;
58
61
  }, z.core.$strict>>;
59
62
  }, z.core.$strict>, z.ZodLiteral<"recently">]>>;
60
63
  alloc_by_guard: z.ZodOptional<z.ZodString>;
@@ -114,6 +117,9 @@ export declare const CallAllocation_DataSchema: z.ZodUnion<readonly [z.ZodObject
114
117
  id: z.ZodString;
115
118
  balance: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
116
119
  payment: z.ZodString;
120
+ type: z.ZodOptional<z.ZodString>;
121
+ version: z.ZodOptional<z.ZodString>;
122
+ digest: z.ZodOptional<z.ZodString>;
117
123
  }, z.core.$strict>>;
118
124
  }, z.core.$strict>, z.ZodLiteral<"recently">]>>;
119
125
  alloc_by_guard: z.ZodOptional<z.ZodString>;
@@ -174,6 +180,9 @@ export declare const CallAllocation_InputSchema: z.ZodObject<{
174
180
  id: z.ZodString;
175
181
  balance: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
176
182
  payment: z.ZodString;
183
+ type: z.ZodOptional<z.ZodString>;
184
+ version: z.ZodOptional<z.ZodString>;
185
+ digest: z.ZodOptional<z.ZodString>;
177
186
  }, z.core.$strict>>;
178
187
  }, z.core.$strict>, z.ZodLiteral<"recently">]>>;
179
188
  alloc_by_guard: z.ZodOptional<z.ZodString>;