@wowok/agent-mcp 3.3.7 → 3.3.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/dist/chain-semantics/fund-flow.js +1 -1
  2. package/dist/chain-semantics/guard-verbs.js +1 -1
  3. package/dist/chain-semantics/object-graph.js +1 -1
  4. package/dist/communication/message-cursors.d.ts +35 -0
  5. package/dist/communication/message-cursors.js +1 -0
  6. package/dist/communication/wts-attestation.d.ts +5 -0
  7. package/dist/communication/wts-attestation.js +1 -1
  8. package/dist/composition/audit.js +1 -1
  9. package/dist/composition/compile.d.ts +2 -2
  10. package/dist/composition/compile.js +1 -1
  11. package/dist/composition/inflight.d.ts +7 -0
  12. package/dist/composition/inflight.js +1 -1
  13. package/dist/composition/materialize.d.ts +4 -1
  14. package/dist/composition/materialize.js +1 -1
  15. package/dist/config/index.d.ts +1 -0
  16. package/dist/config/index.js +1 -1
  17. package/dist/config/store-policy.d.ts +14 -0
  18. package/dist/config/store-policy.js +1 -0
  19. package/dist/config/store-policy.spec.d.ts +1 -0
  20. package/dist/config/store-policy.spec.js +1 -0
  21. package/dist/customer/industry-risks.js +1 -1
  22. package/dist/customer/user-preferences.js +1 -1
  23. package/dist/evaluation/builtins/graph-service.spec.js +1 -1
  24. package/dist/evaluation/engine.js +1 -1
  25. package/dist/experience/realtime-feedback.js +1 -1
  26. package/dist/extensions/business-modules.d.ts +1 -1
  27. package/dist/extensions/business-modules.js +1 -1
  28. package/dist/extensions/industry-pack.js +1 -1
  29. package/dist/extensions/modes.js +1 -1
  30. package/dist/graph/onchain/analyze.js +1 -1
  31. package/dist/graph/onchain/expand.js +1 -1
  32. package/dist/graph/onchain/exposure.js +1 -1
  33. package/dist/graph/onchain/facts.d.ts +1 -0
  34. package/dist/graph/onchain/facts.js +1 -1
  35. package/dist/graph/onchain/facts.spec.js +1 -1
  36. package/dist/harness/recover.js +1 -1
  37. package/dist/knowledge/acquisition-flywheel.js +1 -1
  38. package/dist/knowledge/allocation-ledger.d.ts +1 -0
  39. package/dist/knowledge/allocation-ledger.js +1 -1
  40. package/dist/knowledge/allocator-rail-verifier.d.ts +6 -2
  41. package/dist/knowledge/allocator-rail-verifier.js +1 -1
  42. package/dist/knowledge/arbitration-ledger.js +1 -1
  43. package/dist/knowledge/audit-rules.d.ts +37 -0
  44. package/dist/knowledge/audit-rules.js +1 -1
  45. package/dist/knowledge/baselines/rules/plan.json +32 -2
  46. package/dist/knowledge/builtin-templates.d.ts +13 -1
  47. package/dist/knowledge/builtin-templates.js +1 -1
  48. package/dist/knowledge/commission-landing.d.ts +26 -0
  49. package/dist/knowledge/commission-landing.js +1 -0
  50. package/dist/knowledge/discount-threshold.js +1 -1
  51. package/dist/knowledge/fund-layer.d.ts +7 -0
  52. package/dist/knowledge/fund-layer.js +1 -1
  53. package/dist/knowledge/getting-started.js +1 -1
  54. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  55. package/dist/knowledge/guard-design-patterns.js +1 -1
  56. package/dist/knowledge/guard-puzzle.js +1 -1
  57. package/dist/knowledge/guard-render.d.ts +7 -0
  58. package/dist/knowledge/guard-render.js +1 -1
  59. package/dist/knowledge/guard-risk.js +1 -1
  60. package/dist/knowledge/guard-templates.d.ts +1 -1
  61. package/dist/knowledge/guard-templates.js +1 -1
  62. package/dist/knowledge/guard-translation.js +1 -1
  63. package/dist/knowledge/index.js +1 -1
  64. package/dist/knowledge/industry-generalizer.js +1 -1
  65. package/dist/knowledge/industry-registry.d.ts +1 -1
  66. package/dist/knowledge/industry-registry.js +1 -1
  67. package/dist/knowledge/industry-strategy.js +1 -1
  68. package/dist/knowledge/jsonrpc-enum.js +1 -1
  69. package/dist/knowledge/machine-fork-watch.d.ts +9 -0
  70. package/dist/knowledge/machine-fork-watch.js +1 -0
  71. package/dist/knowledge/migration-preflight.js +1 -1
  72. package/dist/knowledge/projection.spec.js +1 -1
  73. package/dist/knowledge/scenario-modes.d.ts +8 -2
  74. package/dist/knowledge/scenario-modes.js +1 -1
  75. package/dist/knowledge/semantic-ir.d.ts +24 -5
  76. package/dist/knowledge/semantic-ir.js +1 -1
  77. package/dist/knowledge/service-ledger.js +1 -1
  78. package/dist/knowledge/strategy-manuals.js +1 -1
  79. package/dist/knowledge/template-index.js +1 -1
  80. package/dist/knowledge/template-loader.d.ts +11 -0
  81. package/dist/knowledge/template-loader.js +1 -1
  82. package/dist/knowledge/template-registry.js +1 -1
  83. package/dist/knowledge/template-scanner.d.ts +4 -2
  84. package/dist/knowledge/template-scanner.js +1 -1
  85. package/dist/knowledge/template-validation.js +1 -1
  86. package/dist/knowledge/tools-reference.js +1 -1
  87. package/dist/monitor/MonitorLoop.js +1 -1
  88. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  89. package/dist/playbooks/service-build/machine-panorama.js +1 -1
  90. package/dist/playbooks/service-build/merchant-guide.d.ts +12 -6
  91. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  92. package/dist/playbooks/service-build/migration-planner.d.ts +10 -2
  93. package/dist/playbooks/service-build/migration-planner.js +1 -1
  94. package/dist/playbooks/service-build/mode-actions.d.ts +1 -0
  95. package/dist/playbooks/service-build/mode-actions.js +1 -1
  96. package/dist/playbooks/service-build/object-panorama.js +1 -1
  97. package/dist/playbooks/service-build/participation-radar.js +1 -1
  98. package/dist/playbooks/service-build/relationship-profile.js +1 -1
  99. package/dist/playbooks/service-build/service-panorama.js +1 -1
  100. package/dist/playbooks/service-build/service-quote.js +1 -1
  101. package/dist/playbooks/service-build/service-quote.spec.js +1 -1
  102. package/dist/review/index.js +1 -1
  103. package/dist/safety/confirm-gate.js +1 -1
  104. package/dist/schema/benchmark-migration/index.d.ts +72 -1
  105. package/dist/schema/benchmark-migration/index.js +1 -1
  106. package/dist/schema/call/allocation.d.ts +3 -0
  107. package/dist/schema/call/allocation.js +1 -1
  108. package/dist/schema/call/base.d.ts +24 -0
  109. package/dist/schema/call/bridge.d.ts +6 -0
  110. package/dist/schema/call/error-codes.d.ts +1 -1
  111. package/dist/schema/call/error-codes.js +1 -1
  112. package/dist/schema/call/order.js +1 -1
  113. package/dist/schema/call/semantic.js +1 -1
  114. package/dist/schema/call/service.js +1 -1
  115. package/dist/schema/common/index.js +1 -1
  116. package/dist/schema/config/index.d.ts +24 -0
  117. package/dist/schema/config/index.js +1 -1
  118. package/dist/schema/goal/index.d.ts +14 -0
  119. package/dist/schema/goal/planning.d.ts +26 -0
  120. package/dist/schema/goal/planning.js +1 -1
  121. package/dist/schema/industry-pack/index.d.ts +9 -1
  122. package/dist/schema/industry-pack/modes.d.ts +9 -1
  123. package/dist/schema/industry-pack/modes.js +1 -1
  124. package/dist/schema/local/index.d.ts +60 -0
  125. package/dist/schema/local/index.js +1 -1
  126. package/dist/schema/messenger/index.d.ts +278 -1
  127. package/dist/schema/messenger/index.js +1 -1
  128. package/dist/schema/operations.d.ts +1 -0
  129. package/dist/schema/query/bi.d.ts +38 -0
  130. package/dist/schema/query/bi.js +1 -1
  131. package/dist/schema/query/index.d.ts +3 -0
  132. package/dist/schema/query/index.js +1 -1
  133. package/dist/schema/schema-version.js +1 -1
  134. package/dist/schema/service-clone/index.d.ts +17 -0
  135. package/dist/schema/service-clone/index.js +1 -1
  136. package/dist/schema-query-impl/index.js +1 -1
  137. package/dist/schemas/account_operation.output.json +6 -0
  138. package/dist/schemas/benchmark_migration_operation.output.json +254 -2
  139. package/dist/schemas/benchmark_migration_operation.schema.json +87 -5
  140. package/dist/schemas/bridge_operation.output.json +6 -0
  141. package/dist/schemas/config_operation.output.json +95 -0
  142. package/dist/schemas/config_operation.schema.json +16 -1
  143. package/dist/schemas/goal_operation.schema.json +22 -0
  144. package/dist/schemas/index.json +1 -1
  145. package/dist/schemas/industry_pack_operation.output.json +4 -0
  146. package/dist/schemas/industry_pack_operation.schema.json +40 -3
  147. package/dist/schemas/local_cache_operation.output.json +6 -0
  148. package/dist/schemas/local_history_operation.output.json +6 -0
  149. package/dist/schemas/local_info_operation.output.json +6 -0
  150. package/dist/schemas/local_mark_operation.output.json +6 -0
  151. package/dist/schemas/messenger_operation.output.json +609 -1
  152. package/dist/schemas/messenger_operation.schema.json +96 -1
  153. package/dist/schemas/onchain_operations.output.json +6 -0
  154. package/dist/schemas/onchain_operations.schema.json +334 -7
  155. package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
  156. package/dist/schemas/onchain_operations_guard.schema.json +318 -0
  157. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  158. package/dist/schemas/onchain_operations_service.schema.json +5 -5
  159. package/dist/schemas/query_toolkit.output.json +271 -8
  160. package/dist/schemas/service_clone_operation.output.json +79 -0
  161. package/dist/tools/handlers/benchmark-migration.d.ts +14 -0
  162. package/dist/tools/handlers/benchmark-migration.js +1 -1
  163. package/dist/tools/handlers/config.js +1 -1
  164. package/dist/tools/handlers/messenger.js +1 -1
  165. package/dist/tools/handlers/onchain.d.ts +19 -1
  166. package/dist/tools/handlers/onchain.js +1 -1
  167. package/dist/tools/handlers/query.d.ts +1 -0
  168. package/dist/tools/handlers/query.js +1 -1
  169. package/dist/tools/handlers/service-clone.d.ts +18 -0
  170. package/dist/tools/handlers/service-clone.js +1 -1
  171. package/dist/tools/registry/business.js +1 -1
  172. package/dist/tools/wrap.js +1 -1
  173. package/package.json +2 -2
@@ -1 +1 @@
1
- import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent'],g=f?.['result'];return{'outcome':f?.['outcome']==='executed'?'executed':f?.['outcome']==='pending_input'?'pending_input':'failed','digest':g?.['digest'],'created':Array['isArray'](g?.['created'])?g['created']:[],'error':g?.['error']};};}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return b;case'permission':case'contact':case'repository':default:return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g};}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b){const {plan:c,audit:d}=preflightPlan(a),f=new Map(),g=[],h=b['resolveLate']??DEFAULT_LATE,i=new Map(c['steps']['filter'](m=>m['op']==='create')['map'](m=>[m['id'],m['object']])),j=m=>resolveValue(m,f,h);let k=![];for(const m of c['steps']){if(k){g['push']({'stepId':m['id'],'status':'blocked','error':'halted\x20by\x20earlier\x20failure/blocked\x20publish'});continue;}try{if(m['op']==='publish'){const q=m['preflight']['filter'](t=>t['status']==='fail');if(q['length']>0x0){g['push']({'stepId':m['id'],'status':'blocked','error':'preflight\x20failed:\x20'+q['map'](t=>t['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const r=j(m['target']),s=await b['execute'](i['get'](m['target']['$ref'])??'',{'object':r,'publish':!![]},b['env']);if(s['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':s['error']??s['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':s['digest'],'address':r});continue;}const n=Object['fromEntries'](Object['entries'](m['params'])['map'](([t,u])=>[t,j(u)]));if(m['op']==='create'){const t=adaptCreateData(m,n),u=await b['execute'](m['object'],t,b['env']);if(u['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':u['error']??u['outcome']}),k=!![];continue;}const v=matchCreated(u,CREATABLE_OBJECTS[m['object']]);if(v===undefined){g['push']({'stepId':m['id'],'status':'failed','error':'created\x20'+m['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),k=!![];continue;}f['set'](m['id'],v),g['push']({'stepId':m['id'],'status':'executed','digest':u['digest'],'address':v});continue;}const o=j(m['target']),p=await b['execute'](i['get'](isRef(m['target'])?m['target']['$ref']:'')??'',{'object':o,[m['method']]:n},b['env']);if(p['outcome']!=='executed'){g['push']({'stepId':m['id'],'status':'failed','error':p['error']??p['outcome']}),k=!![];continue;}g['push']({'stepId':m['id'],'status':'executed','digest':p['digest'],'address':o});}catch(w){g['push']({'stepId':m['id'],'status':'failed','error':w instanceof Error?w['message']:String(w)}),k=!![];}}const l=await verifyMaterialization(c,f,b);return{'steps':g,'outputs':Object['fromEntries'](f),'completed':g['every'](x=>x['status']==='executed'),'preflight':d,'readback':l};}export function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=new Map();for(const e of b){const f=e['track']??'settlement';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [g,h]of c){const i=h['flatMap'](l=>(l['sharing']??[])['map'](m=>m['mode']));if(i['some'](l=>l==='Amount')){d['push']({'name':'conservation:'+g,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});continue;}let j=0x0;for(const l of h){for(const m of l['sharing']??[]){if(m['mode']==='Rate'||m['mode']==='RateGross')j+=Number(m['sharing']??0x0);}}const k=i['some'](n=>n==='Surplus');if(j>0x2710)d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20track\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):d['push']({'name':'conservation:'+g,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}return d;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
1
+ import{CREATABLE_OBJECTS,createsOf,isRef,resolveValue}from'./plan.js';import{auditPlan}from'./audit.js';export function handlerExecutor(a){return async(b,c)=>{const {handleOnchainOperations:d}=await import('../tools/handlers/onchain.js'),e=await d({'operation_type':b,'data':c,'env':a}),f=e['structuredContent'],g=f?.['result'];return{'outcome':f?.['outcome']==='executed'?'executed':f?.['outcome']==='pending_input'?'pending_input':'failed','digest':g?.['digest'],'created':Array['isArray'](g?.['created'])?g['created']:[],'error':g?.['error']};};}export function adaptCreateData(a,b){const {name:c,permission:d,type_parameter:e,nodes:f,...g}=b;switch(a['object']){case'service':case'arbitration':return{'object':{'name':c,'type_parameter':e,'permission':d},...g};case'machine':return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g['description']!==undefined?{'description':g['description']}:{},'node':{'op':'add','nodes':f,'bReplace':!![]}};case'guard':return b;case'permission':case'contact':case'repository':default:return{'object':{'name':c,...d!==undefined?{'permission':d}:{}},...g};}}export function preflightPlan(a){const b=auditPlan(a),c=new Set(b['findings']['map'](g=>g['rule_id'])),d=c['has']('ARB-KEY-PLANE-01'),e=b['issues']['length']===0x0&&!b['findings']['some'](g=>g['level']==='critical')&&!d,f=a['steps']['map'](g=>{if(g['op']!=='publish')return g;const h=g['preflight']['map'](i=>{const j=i['check']['endsWith']('_publish')?e:!c['has'](i['check']);return{...i,'status':j?'pass':'fail'};});return{...g,'preflight':h};});return{'plan':{...a,'steps':f},'audit':b};}function stripGenerics(a){return a['replace'](/<.*>$/,'');}function matchCreated(a,b){const c=stripGenerics(b);return a['created']['find'](d=>{if(typeof d['type_raw']!=='string'||typeof d['object']!=='string')return![];return stripGenerics(d['type_raw'])['endsWith']('::'+c);})?.['object'];}const DEFAULT_LATE=a=>{if(a['by']==='address')return a['address'];throw new Error('unresolved\x20late\x20binding\x20(no\x20resolver\x20injected):\x20local_name\x20\x27'+a['mark']+'\x27');};export async function materializePlan(a,b,c){const {plan:d,audit:f}=preflightPlan(a),g=new Map(Object['entries'](c?.['outputs']??{})),h=new Set(c?.['completedSteps']??[]),i=[],j=b['resolveLate']??DEFAULT_LATE,k=new Map(d['steps']['filter'](o=>o['op']==='create')['map'](o=>[o['id'],o['object']])),l=o=>resolveValue(o,g,j);let m=![];for(const o of d['steps']){if(m){i['push']({'stepId':o['id'],'status':'blocked','error':'halted\x20by\x20earlier\x20failure/blocked\x20publish'});continue;}if(h['has'](o['id'])){const p=g['get'](o['id']);if(p===undefined){i['push']({'stepId':o['id'],'status':'failed','error':'resumed\x20step\x20has\x20no\x20recorded\x20output\x20—\x20pass\x20it\x20in\x20previous_outputs'}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','address':p,'error':'resumed\x20from\x20a\x20prior\x20run\x20(adopted,\x20not\x20re-executed)'});continue;}try{if(o['op']==='publish'){const t=o['preflight']['filter'](w=>w['status']==='fail');if(t['length']>0x0){i['push']({'stepId':o['id'],'status':'blocked','error':'preflight\x20failed:\x20'+t['map'](w=>w['check'])['join'](',\x20')+'\x20(refusing\x20to\x20publish\x20—\x20A-2)'});continue;}const u=l(o['target']),v=await b['execute'](k['get'](o['target']['$ref'])??'',{'object':u,'publish':!![]},b['env']);if(v['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':v['error']??v['outcome']}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','digest':v['digest'],'address':u});continue;}const q=Object['fromEntries'](Object['entries'](o['params'])['map'](([w,x])=>[w,l(x)]));if(o['op']==='create'){const w=adaptCreateData(o,q),x=await b['execute'](o['object'],w,b['env']);if(x['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':x['error']??x['outcome']}),m=!![];continue;}const y=matchCreated(x,CREATABLE_OBJECTS[o['object']]);if(y===undefined){i['push']({'stepId':o['id'],'status':'failed','error':'created\x20'+o['object']+'\x20not\x20found\x20in\x20transaction\x20result'}),m=!![];continue;}g['set'](o['id'],y),i['push']({'stepId':o['id'],'status':'executed','digest':x['digest'],'address':y});continue;}const r=l(o['target']),s=await b['execute'](k['get'](isRef(o['target'])?o['target']['$ref']:'')??'',{'object':r,[o['method']]:q},b['env']);if(s['outcome']!=='executed'){i['push']({'stepId':o['id'],'status':'failed','error':s['error']??s['outcome']}),m=!![];continue;}i['push']({'stepId':o['id'],'status':'executed','digest':s['digest'],'address':r});}catch(z){i['push']({'stepId':o['id'],'status':'failed','error':z instanceof Error?z['message']:String(z)}),m=!![];}}const n=await verifyMaterialization(d,g,b);return{'steps':i,'outputs':Object['fromEntries'](g),'completed':i['every'](A=>A['status']==='executed'),'preflight':f,'readback':n};}export function planAllocatorRows(a){const b=[],c=d=>{if(typeof d==='object'&&d!==null&&!Array['isArray'](d)){const e=d;if(Array['isArray'](e['allocators']))d=e['allocators'];}if(!Array['isArray'](d))return;for(const f of d){if(typeof f==='object'&&f!==null)b['push'](f);}};for(const d of a['steps']){if(d['op']==='create'&&d['object']==='service')c(d['params']['order_allocators']);if(d['op']==='configure'&&d['method']==='order_allocators')c(d['params']['allocators']);}return b;}export function conservationCheck(a){const b=planAllocatorRows(a);if(b['length']===0x0)return[{'name':'allocator_conservation','ok':![],'detail':'no\x20allocator\x20rows\x20(PLAN-ALLOC-01)'}];const c=new Map();for(const e of b){const f=e['track']??'settlement';c['set'](f,[...c['get'](f)??[],e]);}const d=[];for(const [g,h]of c){const i=h['flatMap'](l=>(l['sharing']??[])['map'](m=>m['mode']));if(i['some'](l=>l==='Amount')){d['push']({'name':'conservation:'+g,'ok':!![],'detail':'contains\x20Amount-mode\x20row(s)\x20—\x20fixed\x20payouts\x20are\x20not\x20statically\x20verifiable\x20against\x20the\x20escrow\x20total'});continue;}let j=0x0;for(const l of h){for(const m of l['sharing']??[]){if(m['mode']==='Rate'||m['mode']==='RateGross')j+=Number(m['sharing']??0x0);}}const k=i['some'](n=>n==='Surplus');if(j>0x2710)d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20>\x2010000\x20—\x20track\x20pays\x20out\x20MORE\x20than\x20it\x20holds'});else j<0x2710&&!k?d['push']({'name':'conservation:'+g,'ok':![],'detail':'rate\x20sum\x20'+j+'\x20<\x2010000\x20and\x20no\x20Surplus\x20row\x20—\x20the\x20remainder\x20has\x20no\x20fund\x20exit'}):d['push']({'name':'conservation:'+g,'ok':!![],'detail':k?'rate\x20sum\x20'+j+'\x20+\x20Surplus\x20row\x20absorbs\x20the\x20remainder':'rate\x20sum\x20'+j+'\x20==\x2010000'});}return d;}export async function verifyMaterialization(a,b,c){const d=[...conservationCheck(a)];if(c['read']!==undefined)for(const f of createsOf(a,'service')){const g=b['get'](f['id']);if(g===undefined)continue;try{const h=await c['read'](g,'service',c['env']);if(h===undefined||h===null){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':'service\x20'+g+'\x20not\x20readable\x20after\x20creation'});continue;}const i=planAllocatorRows(a)['length'],j=h['order_allocators']?.['allocators']?.['length']??(Array['isArray'](h['order_allocators'])?h['order_allocators']['length']:undefined);j!==undefined&&d['push']({'name':'readback:'+f['id']+':allocators','ok':j>=i,'detail':'on-chain\x20allocator\x20rows\x20'+j+'\x20vs\x20plan\x20'+i});}catch(k){d['push']({'name':'readback:'+f['id'],'ok':![],'detail':k instanceof Error?k['message']:String(k)});}}return{'ok':d['every'](l=>l['ok']),'checks':d};}
@@ -1,3 +1,4 @@
1
1
  export * from "./runtime.js";
2
2
  export * from "./severity.js";
3
3
  export * from "./judgment.js";
4
+ export * from "./store-policy.js";
@@ -1 +1 @@
1
- export*from'./runtime.js';export*from'./severity.js';export*from'./judgment.js';
1
+ export*from'./runtime.js';export*from'./severity.js';export*from'./judgment.js';export*from'./store-policy.js';
@@ -0,0 +1,14 @@
1
+ export interface StoreDualPayoutPolicy {
2
+ preauthorized: boolean;
3
+ authorized_at?: string;
4
+ note?: string;
5
+ network?: string;
6
+ }
7
+ export declare function getStoreDualPayoutPolicy(account: string): StoreDualPayoutPolicy | undefined;
8
+ export declare function isDualPayoutPreauthorized(account?: string): boolean;
9
+ export declare function setStoreDualPayoutPreauthorization(account: string, input: {
10
+ confirm: boolean;
11
+ note?: string;
12
+ network?: string;
13
+ }): StoreDualPayoutPolicy;
14
+ export declare function clearStoreDualPayoutPreauthorization(account: string): boolean;
@@ -0,0 +1 @@
1
+ import{existsSync,mkdirSync,readFileSync,writeFileSync}from'fs';import{dirname,join}from'path';import{getWowMcpDir}from'@wowok/wowok';const policyFileName='store-policies.json',normalizeAccount=a=>a['trim']()['toLowerCase']();function policyFilePath(){const a=process['env']['WOWOK_CONFIG_DIR']||getWowMcpDir();return join(a,policyFileName);}function readPolicies(){try{const a=policyFilePath();if(!existsSync(a))return{};const b=JSON['parse'](readFileSync(a,'utf-8'));return b&&typeof b==='object'&&!Array['isArray'](b)?b:{};}catch{return{};}}function writePolicies(a){const b=policyFilePath();mkdirSync(dirname(b),{'recursive':!![]}),writeFileSync(b,JSON['stringify'](a,null,0x2),'utf-8');}export function getStoreDualPayoutPolicy(b){const c=normalizeAccount(b);if(!c)return undefined;return readPolicies()[c];}export function isDualPayoutPreauthorized(a){if(!a)return![];try{return getStoreDualPayoutPolicy(a)?.['preauthorized']===!![];}catch{return![];}}export function setStoreDualPayoutPreauthorization(b,c){const d=normalizeAccount(b);if(!d)throw new Error('\x27account\x27\x20is\x20required\x20(the\x20store\x27s\x20signing\x20account\x20address\x20or\x20local\x20mark-resolvable\x20address)');if(c?.['confirm']!==!![])throw new Error('D-1\x20requires\x20the\x20human\x20merchant\x27s\x20EXPLICIT\x20confirmation:\x20pass\x20confirm=true\x20only\x20after\x20the\x20merchant\x20'+'has\x20reviewed\x20and\x20agreed\x20that\x20THIS\x20store\x27s\x20rails\x20may\x20net\x20arbitration\x20compensation\x20and\x20escrow\x20release\x20'+'on\x20the\x20same\x20order\x20(a\x20standing\x20commercial\x20netting\x20decision).\x20Autonomous\x20agents\x20must\x20not\x20set\x20this\x20—\x20'+'escalate\x20to\x20the\x20human\x20instead.');const e=readPolicies(),f={'preauthorized':!![],'authorized_at':new Date()['toISOString'](),...c['note']?{'note':c['note']}:{},...c['network']?{'network':c['network']}:{}};return e[d]=f,writePolicies(e),f;}export function clearStoreDualPayoutPreauthorization(b){const c=normalizeAccount(b);if(!c)return![];const d=readPolicies();if(!(c in d))return![];return delete d[c],writePolicies(d),!![];}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{mkdtempSync,writeFileSync}from'fs';import{tmpdir}from'os';import{join}from'path';import{describe,expect,it,beforeEach}from'vitest';import{getStoreDualPayoutPolicy,setStoreDualPayoutPreauthorization,clearStoreDualPayoutPreauthorization,isDualPayoutPreauthorized}from'./store-policy.js';const ACC='0xABCdef1234567890abcdef1234567890abcdef12',ACC_LOWER=ACC['toLowerCase']();describe('store-policy\x20D-1\x20ledger',()=>{let a;beforeEach(()=>{a=mkdtempSync(join(tmpdir(),'wowok-store-policy-')),process['env']['WOWOK_CONFIG_DIR']=a;}),it('set\x20WITHOUT\x20confirm\x20throws\x20and\x20records\x20nothing',()=>{expect(()=>setStoreDualPayoutPreauthorization(ACC,{'confirm':![]}))['toThrow'](/confirm=true/),expect(()=>setStoreDualPayoutPreauthorization(ACC,{}))['toThrow'](/confirm=true/),expect(getStoreDualPayoutPolicy(ACC))['toBeUndefined']();}),it('set\x20with\x20confirm:true\x20persists\x20and\x20get\x20roundtrips\x20(case-insensitive\x20key)',()=>{const b=setStoreDualPayoutPreauthorization(ACC,{'confirm':!![],'note':'merchant\x20standing\x20netting','network':'mainnet'});expect(b['preauthorized'])['toBe'](!![]),expect(b['authorized_at'])['toBeTruthy'](),expect(b['note'])['toBe']('merchant\x20standing\x20netting'),expect(getStoreDualPayoutPolicy(ACC['toLowerCase']())?.['preauthorized'])['toBe'](!![]),expect(getStoreDualPayoutPolicy(ACC['toUpperCase']())?.['preauthorized'])['toBe'](!![]),expect(isDualPayoutPreauthorized(ACC))['toBe'](!![]);}),it('unconfigured\x20account\x20→\x20not\x20preauthorized\x20(safe\x20hard-block\x20default)',()=>{expect(getStoreDualPayoutPolicy(ACC))['toBeUndefined'](),expect(isDualPayoutPreauthorized(ACC))['toBe'](![]),expect(isDualPayoutPreauthorized(undefined))['toBe'](![]),expect(isDualPayoutPreauthorized(''))['toBe'](![]);}),it('clear\x20removes\x20an\x20existing\x20record\x20(true)\x20and\x20reports\x20false\x20when\x20absent',()=>{setStoreDualPayoutPreauthorization(ACC,{'confirm':!![]}),expect(clearStoreDualPayoutPreauthorization(ACC['toUpperCase']()))['toBe'](!![]),expect(getStoreDualPayoutPolicy(ACC))['toBeUndefined'](),expect(isDualPayoutPreauthorized(ACC))['toBe'](![]),expect(clearStoreDualPayoutPreauthorization(ACC))['toBe'](![]);}),it('corrupt\x20policy\x20file\x20→\x20fail-soft\x20to\x20not-preauthorized\x20(never\x20crashes\x20the\x20gate\x20read)',()=>{writeFileSync(join(a,'store-policies.json'),'{not\x20json\x20at\x20all','utf-8'),expect(getStoreDualPayoutPolicy(ACC))['toBeUndefined'](),expect(isDualPayoutPreauthorized(ACC))['toBe'](![]),setStoreDualPayoutPreauthorization(ACC,{'confirm':!![]}),expect(isDualPayoutPreauthorized(ACC))['toBe'](!![]);});});
@@ -1 +1 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';const hasRefundPath=a=>a['workflow_analysis']?.['has_refund_path']??![],hasArbitrationPath=a=>a['workflow_analysis']?.['has_arbitration_path']??![],hasMilestoneNodes=a=>a['workflow_analysis']?.['has_milestone_nodes']??![],hasMessenger=a=>a['trust_signals']?.['has_messenger']??![],compensationCoversOrder=a=>a['fund_safety']?.['compensation_covers_order']??![],lockDurationSafe=a=>a['fund_safety']?.['lock_duration_safe']??![],userOperableForwards=a=>a['workflow_analysis']?.['user_operable_forwards']??0x0,wipVerified=a=>a['service_basics']['wip_verified']===!![],hasCompensationFund=a=>a['service_basics']['compensation_fund_balance']>0x0n,deadEndCount=a=>a['workflow_analysis']?.['dead_end_nodes']?.['length']??0x0,trustScore=a=>a['trust_signals']?.['trust_score']??0x0,merchantTotalOrders=a=>a['merchant_behavior']?.['total_orders']??0x0,repeatBuyerRate=a=>a['merchant_behavior']?.['repeat_buyer_rate']??0x0,disputeRate=a=>a['merchant_behavior']?.['dispute_rate']??0x1,INDUSTRY_RISK_CHECKS={'freelance':[{'id':'fr_wip_verified','industry':'freelance','dimension':'trust','description':'WIP\x20hash\x20verified\x20(work\x20traceable)','weight':0x1e,'passed':wipVerified,'advice':'⚠️\x20WIP\x20not\x20verified:\x20freelance\x20deliverables\x20cannot\x20be\x20traced.\x20Recommend\x20asking\x20the\x20merchant\x20to\x20provide\x20a\x20WIP\x20hash\x20and\x20write\x20it\x20into\x20WTS.'},{'id':'fr_milestone_nodes','industry':'freelance','dimension':'workflow','description':'Has\x20milestone\x20nodes\x20(phased\x20acceptance)','weight':0x19,'passed':hasMilestoneNodes,'advice':'⚠️\x20No\x20milestone\x20nodes:\x20delivery\x20is\x20completed\x20in\x20one\x20go\x20without\x20intermediate\x20acceptance.\x20Recommend\x20asking\x20the\x20merchant\x20to\x20add\x20phased\x20delivery\x20nodes.'},{'id':'fr_refund_path','industry':'freelance','dimension':'workflow','description':'Has\x20refund\x20path','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20if\x20freelance\x20order\x20delivery\x20is\x20not\x20satisfactory,\x20funds\x20are\x20hard\x20to\x20recover.'},{'id':'fr_response_time','industry':'freelance','dimension':'trust','description':'Messenger\x20configured\x20(communication\x20response\x20guarantee)','weight':0x14,'passed':hasMessenger,'advice':'⚠️\x20Messenger\x20not\x20configured:\x20cannot\x20conduct\x20requirement\x20confirmation\x20and\x20revision\x20communication.'}],'rental':[{'id':'rt_compensation_full','industry':'rental','dimension':'fund','description':'Compensation\x20fully\x20covers\x20order\x20amount','weight':0x1e,'passed':compensationCoversOrder,'advice':'🔴\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20when\x20rental\x20item\x20is\x20damaged.\x20Recommend\x20choosing\x20a\x20merchant\x20with\x20sufficient\x20compensation\x20fund.'},{'id':'rt_lock_duration','industry':'rental','dimension':'fund','description':'Lock\x20duration\x20safe\x20(compensation\x20cannot\x20be\x20withdrawn\x20by\x20merchant\x20at\x20any\x20time)','weight':0x19,'passed':lockDurationSafe,'advice':'⚠️\x20Lock\x20duration\x20not\x20safe:\x20merchant\x20may\x20withdraw\x20compensation\x20at\x20any\x20time,\x20deposit\x20safety\x20not\x20guaranteed.'},{'id':'rt_arbitration','industry':'rental','dimension':'workflow','description':'Arbitration\x20configured\x20(damage\x20dispute\x20resolution)','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20rental\x20damage\x20disputes.'},{'id':'rt_user_operable','industry':'rental','dimension':'workflow','description':'Has\x20user-operable\x20path\x20(return/confirm)','weight':0x14,'passed':a=>userOperableForwards(a)>0x0,'advice':'🔴\x20No\x20user-operable\x20path:\x20return\x20process\x20relies\x20entirely\x20on\x20merchant,\x20may\x20be\x20maliciously\x20delayed.'}],'education':[{'id':'ed_refund_path','industry':'education','dimension':'workflow','description':'Has\x20refund\x20path\x20(refund\x20guarantee)','weight':0x1e,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20course\x20refund\x20not\x20guaranteed,\x20recommend\x20asking\x20the\x20merchant\x20to\x20configure\x20a\x20refund\x20Allocator.'},{'id':'ed_compensation','industry':'education','dimension':'fund','description':'Has\x20compensation\x20fund','weight':0x19,'passed':hasCompensationFund,'advice':'⚠️\x20No\x20compensation\x20fund:\x20no\x20automatic\x20compensation\x20source\x20when\x20course\x20service\x20quality\x20is\x20not\x20up\x20to\x20standard.'},{'id':'ed_arbitration','industry':'education','dimension':'workflow','description':'Arbitration\x20configured','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20resolution\x20channel\x20for\x20course\x20quality\x20disputes.'},{'id':'ed_long_cycle_ok','industry':'education','dimension':'workflow','description':'Long\x20cycle\x20acceptable\x20(education\x20industry\x20allows\x20long\x20cycles,\x20over\x2090\x20days\x20needs\x20attention)','weight':0x14,'passed':()=>!![],'advice':'ℹ️\x20Long\x20delivery\x20cycles\x20are\x20normal\x20in\x20education,\x20but\x20if\x20the\x20actual\x20cycle\x20exceeds\x2090\x20days,\x20recommend\x20periodically\x20checking\x20learning\x20progress\x20and\x20lesson\x20consumption.'}],'travel':[{'id':'tr_urgent_delivery','industry':'travel','dimension':'workflow','description':'Urgent\x20delivery\x20configuration\x20(needs\x20milestone\x20nodes\x20for\x20phased\x20acceptance)','weight':0x1e,'passed':hasMilestoneNodes,'advice':'⚠️\x20No\x20milestone\x20nodes:\x20travel\x20itinerary\x20has\x20no\x20phased\x20acceptance,\x20recommend\x20setting\x20nodes\x20by\x20itinerary\x20stage.'},{'id':'tr_compensation_full','industry':'travel','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(breach\x20compensation)','weight':0x19,'passed':compensationCoversOrder,'advice':'🔴\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20when\x20itinerary\x20breaches.'},{'id':'tr_refund_path','industry':'travel','dimension':'workflow','description':'Has\x20refund\x20path\x20(itinerary\x20change/cancellation)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20funds\x20hard\x20to\x20recover\x20when\x20itinerary\x20changes\x20or\x20cancels\x20due\x20to\x20force\x20majeure.'},{'id':'tr_messenger','industry':'travel','dimension':'trust','description':'Messenger\x20configured\x20(emergency\x20communication)','weight':0x14,'passed':hasMessenger,'advice':'⚠️\x20Messenger\x20not\x20configured:\x20cannot\x20immediately\x20contact\x20merchant\x20during\x20travel\x20emergencies.'}],'subscription':[{'id':'sub_no_lockin','industry':'subscription','dimension':'workflow','description':'No\x20long-term\x20lock-in\x20(no\x20dead-end\x20nodes,\x20can\x20exit)','weight':0x1e,'passed':a=>deadEndCount(a)===0x0,'advice':'🔴\x20Dead-end\x20nodes\x20exist:\x20subscription\x20may\x20be\x20locked\x20and\x20unable\x20to\x20exit,\x20auto-renewal\x20trap\x20exists.'},{'id':'sub_refund_path','industry':'subscription','dimension':'workflow','description':'Has\x20refund\x20path\x20(exit\x20mechanism)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20remaining\x20cycle\x20fees\x20hard\x20to\x20recover\x20after\x20subscription\x20exit.'},{'id':'sub_user_operable','industry':'subscription','dimension':'workflow','description':'Has\x20user-operable\x20path\x20(pause/downgrade/cancel)','weight':0x19,'passed':a=>userOperableForwards(a)>0x0,'advice':'🔴\x20No\x20user-operable\x20path:\x20subscription\x20status\x20entirely\x20controlled\x20by\x20merchant,\x20cannot\x20pause\x20or\x20cancel\x20independently.'},{'id':'sub_compensation_optional','industry':'subscription','dimension':'fund','description':'Compensation\x20optional\x20(not\x20mandatory\x20for\x20subscription\x20industry)','weight':0x14,'passed':()=>!![],'advice':'ℹ️\x20Compensation\x20is\x20not\x20mandatory\x20for\x20subscription\x20industry;\x20having\x20it\x20is\x20better.'}],'retail':[{'id':'ret_wip_verified','industry':'retail','dimension':'trust','description':'WIP\x20verified\x20(authenticity/logistics\x20traceable)','weight':0x19,'passed':wipVerified,'advice':'⚠️\x20WIP\x20not\x20verified:\x20product\x20traceability\x20info\x20missing,\x20recommend\x20confirming\x20authenticity\x20guarantee.'},{'id':'ret_compensation_full','industry':'retail','dimension':'fund','description':'Compensation\x20fully\x20covers','weight':0x19,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20return/exchange\x20disputes.'},{'id':'ret_refund_path','industry':'retail','dimension':'workflow','description':'Has\x20refund\x20path\x20(return/exchange)','weight':0x19,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20return/exchange\x20not\x20guaranteed.'},{'id':'ret_arbitration','industry':'retail','dimension':'workflow','description':'Arbitration\x20configured','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20for\x20return/exchange\x20disputes.'}],'licensing':[{'id':'lic_wip_verified','industry':'licensing','dimension':'trust','description':'WIP\x20verified\x20(license\x20terms\x20/\x20granted\x20rights\x20hash-anchored)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20WIP\x20not\x20verified:\x20the\x20licensed\x20rights\x20(territory,\x20term,\x20media,\x20caps)\x20are\x20prose-only\x20and\x20cannot\x20be\x20proven\x20in\x20a\x20dispute.\x20Recommend\x20anchoring\x20the\x20license\x20terms\x20as\x20a\x20WIP\x20hash\x20before\x20the\x20grant.'},{'id':'lic_compensation_full','industry':'licensing','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(reporting/accounting\x20honesty\x20backstop)','weight':0x19,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20a\x20licensing\x20buyer\x20is\x20trusting\x20the\x20seller\x27s\x20royalty/usage\x20reporting;\x20without\x20coverage\x20there\x20is\x20no\x20recourse\x20if\x20the\x20accounting\x20is\x20dishonest.'},{'id':'lic_refund_path','industry':'licensing','dimension':'workflow','description':'Has\x20refund\x20path\x20(inspection-window\x20exit\x20before\x20the\x20grant\x20is\x20final)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20the\x20buyer\x20cannot\x20exit\x20during\x20the\x20inspection\x20window\x20if\x20the\x20delivered\x20license/terms\x20do\x20not\x20match\x20what\x20was\x20advertised.'},{'id':'lic_arbitration','industry':'licensing','dimension':'workflow','description':'Arbitration\x20configured\x20(rights/scope\x20dispute\x20resolution)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20scope/territory/royalty\x20disputes.'}],'crowdfunding':[{'id':'cf_wip_verified','industry':'crowdfunding','dimension':'trust','description':'WIP\x20verified\x20(campaign\x20terms\x20/\x20funding\x20goal\x20/\x20deadline\x20hash-anchored)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20WIP\x20not\x20verified:\x20the\x20funding\x20goal,\x20deadline\x20and\x20reward\x20terms\x20are\x20prose-only\x20and\x20cannot\x20be\x20proven\x20in\x20a\x20dispute.\x20Recommend\x20anchoring\x20the\x20campaign\x20terms\x20as\x20a\x20WIP\x20hash\x20before\x20launch.'},{'id':'cf_refund_path','industry':'crowdfunding','dimension':'fund','description':'Has\x20refund\x20path\x20(per-contributor\x20refund\x20if\x20the\x20threshold\x20is\x20missed\x20at\x20deadline)','weight':0x1e,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20on\x20an\x20all-or-nothing\x20campaign\x20a\x20missed\x20threshold\x20MUST\x20refund\x20every\x20contributor\x20automatically.\x20Without\x20a\x20refund\x20leg\x20the\x20escrowed\x20contributions\x20are\x20stranded\x20with\x20the\x20project.\x20(A\x20flexible\x20keep-it-all\x20campaign\x20has\x20no\x20refund\x20by\x20design\x20—\x20verify\x20which\x20model\x20this\x20is\x20before\x20contributing.)'},{'id':'cf_compensation_full','industry':'crowdfunding','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(post-raise\x20delivery\x20backstop)','weight':0x14,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20after\x20a\x20successful\x20raise\x20the\x20funder\x20is\x20trusting\x20the\x20project\x20to\x20deliver;\x20without\x20coverage\x20there\x20is\x20no\x20recourse\x20for\x20non-delivery.'},{'id':'cf_arbitration','industry':'crowdfunding','dimension':'workflow','description':'Arbitration\x20configured\x20(delivery\x20/\x20non-delivery\x20dispute\x20resolution)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20non-delivery\x20or\x20reward-fulfilment\x20disputes\x20after\x20a\x20successful\x20raise.'}]};function commonNeeds(){return[{'id':'need_arbitration','tier':'common','description':'Arbitration\x20configured\x20(dispute\x20resolution\x20channel)','satisfied':hasArbitrationPath,'advice':'Arbitration\x20not\x20configured:\x20no\x20third-party\x20resolution\x20channel\x20for\x20disputes.'},{'id':'need_refund_path','tier':'common','description':'Has\x20refund\x20path','satisfied':hasRefundPath,'advice':'No\x20refund\x20path:\x20funds\x20hard\x20to\x20recover\x20when\x20delivery\x20fails.'},{'id':'need_user_operable','tier':'common','description':'Has\x20user-operable\x20Forward','satisfied':a=>userOperableForwards(a)>0x0,'advice':'No\x20user-operable\x20steps\x20in\x20workflow,\x20order\x20progress\x20depends\x20entirely\x20on\x20merchant.'},{'id':'need_messenger','tier':'common','description':'Messenger\x20configured','satisfied':hasMessenger,'advice':'Merchant\x20has\x20no\x20Messenger\x20channel,\x20cannot\x20negotiate\x20or\x20conduct\x20after-sales\x20communication.'}];}const INDUSTRY_NEEDS={'freelance':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(work\x20IP\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20IP\x20ownership\x20and\x20originality\x20of\x20work\x20cannot\x20be\x20traced.'},{'id':'need_milestone_nodes','tier':'personalized','description':'Milestone\x20nodes\x20(phased\x20feedback)','satisfied':hasMilestoneNodes,'advice':'No\x20milestone\x20nodes:\x20lack\x20of\x20phased\x20feedback\x20and\x20revision\x20round\x20control.'},{'id':'need_merchant_history','tier':'advanced','description':'Merchant\x20history\x20≥3\x20orders\x20(fulfillment\x20experience)','satisfied':a=>merchantTotalOrders(a)>=0x3,'advice':'Merchant\x20history\x20orders\x20less\x20than\x203:\x20fulfillment\x20experience\x20is\x20limited.'}],'rental':[...commonNeeds(),{'id':'need_lock_duration_safe','tier':'personalized','description':'Lock\x20duration\x20safe\x20(deposit\x20cannot\x20be\x20withdrawn)','satisfied':lockDurationSafe,'advice':'Lock\x20duration\x20not\x20safe:\x20deposit\x20may\x20be\x20withdrawn\x20by\x20merchant\x20at\x20any\x20time.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20rental\x20item\x20damage.'},{'id':'need_merchant_history','tier':'advanced','description':'Merchant\x20history\x20≥5\x20orders\x20(rental\x20experience)','satisfied':a=>merchantTotalOrders(a)>=0x5,'advice':'Merchant\x20history\x20orders\x20less\x20than\x205:\x20rental\x20service\x20experience\x20limited.'}],'education':[...commonNeeds(),{'id':'need_has_compensation','tier':'personalized','description':'Has\x20compensation\x20fund\x20(course\x20quality\x20guarantee)','satisfied':hasCompensationFund,'advice':'No\x20compensation\x20fund:\x20no\x20compensation\x20source\x20when\x20course\x20quality\x20is\x20not\x20up\x20to\x20standard.'},{'id':'need_long_cycle_ok','tier':'personalized','description':'Long\x20cycle\x20acceptable','satisfied':()=>!![],'advice':'Long\x20cycles\x20are\x20normal\x20in\x20education;\x20recommend\x20tracking\x20lesson\x20consumption\x20and\x20attendance.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20course\x20reputation\x20may\x20be\x20poor.'}],'travel':[...commonNeeds(),{'id':'need_urgent_delivery','tier':'personalized','description':'Urgent\x20delivery\x20configuration\x20(milestone\x20phasing)','satisfied':hasMilestoneNodes,'advice':'No\x20milestone\x20nodes:\x20itinerary\x20has\x20no\x20phased\x20acceptance,\x20urgent\x20delivery\x20guarantee\x20insufficient.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(breach\x20compensation)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20itinerary\x20breach.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20travel\x20service\x20reputation\x20may\x20be\x20poor.'}],'subscription':[...commonNeeds(),{'id':'need_no_lockin','tier':'personalized','description':'No\x20long-term\x20lock-in\x20(no\x20dead-end\x20nodes)','satisfied':a=>deadEndCount(a)===0x0,'advice':'Dead-end\x20nodes\x20exist:\x20subscription\x20may\x20be\x20locked,\x20auto-renewal\x20trap\x20exists.'},{'id':'need_low_dispute','tier':'personalized','description':'Low\x20dispute\x20rate\x20(≤15%,\x20stable\x20content\x20quality)','satisfied':a=>disputeRate(a)<=0.15,'advice':'Dispute\x20rate\x20is\x20high:\x20subscription\x20content\x20quality\x20may\x20be\x20unstable.'},{'id':'need_repeat_rate','tier':'advanced','description':'Repeat\x20buyer\x20rate\x20≥20%\x20(strong\x20subscription\x20renewal\x20willingness)','satisfied':a=>repeatBuyerRate(a)>=0.2,'advice':'Repeat\x20buyer\x20rate\x20below\x2020%:\x20subscription\x20renewal\x20willingness\x20is\x20weak,\x20service\x20may\x20not\x20be\x20worth\x20long-term\x20subscription.'}],'retail':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(authenticity/logistics\x20traceability)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20product\x20authenticity\x20and\x20logistics\x20traceability\x20info\x20missing.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20return/exchange\x20disputes.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20product\x20or\x20service\x20reputation\x20may\x20be\x20poor.'}],'licensing':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(license\x20terms\x20/\x20granted\x20rights\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20the\x20scope\x20of\x20the\x20granted\x20rights\x20cannot\x20be\x20traced,\x20so\x20an\x20infringement\x20or\x20over-use\x20claim\x20has\x20no\x20on-chain\x20baseline.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(reporting-honesty\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20no\x20recourse\x20if\x20the\x20seller\x27s\x20royalty/usage\x20reporting\x20turns\x20out\x20to\x20be\x20dishonest.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20licensing\x20depends\x20on\x20long-term\x20accounting\x20honesty,\x20so\x20a\x20weak\x20reputation\x20is\x20material.'}],'crowdfunding':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(campaign\x20terms\x20/\x20funding\x20goal\x20/\x20deadline\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20the\x20funding\x20goal\x20and\x20deadline\x20cannot\x20be\x20traced,\x20so\x20a\x20\x27goal\x20reached\x27\x20or\x20\x27refund\x20due\x27\x20claim\x20has\x20no\x20on-chain\x20baseline.'},{'id':'need_threshold_refund','tier':'personalized','description':'Has\x20threshold-refund\x20path\x20(per-contributor\x20refund\x20on\x20a\x20missed\x20funding\x20goal)','satisfied':hasRefundPath,'advice':'No\x20refund\x20path:\x20on\x20an\x20all-or-nothing\x20campaign\x20the\x20contributions\x20would\x20be\x20stranded\x20with\x20the\x20project\x20if\x20the\x20goal\x20is\x20missed.\x20(A\x20flexible\x20keep-it-all\x20campaign\x20is\x20no-refund\x20by\x20design\x20—\x20confirm\x20the\x20model.)'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(post-raise\x20delivery\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20no\x20recourse\x20for\x20non-delivery\x20after\x20a\x20successful\x20raise.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20crowdfunding\x20depends\x20on\x20the\x20project\x20actually\x20delivering\x20after\x20the\x20raise,\x20so\x20a\x20weak\x20reputation\x20is\x20material.'}]};let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryRiskChecks(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['risk_checks'])return b['risk_checks'];}return INDUSTRY_RISK_CHECKS[a];}export function getIndustryNeeds(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['needs'])return b['needs'];}return INDUSTRY_NEEDS[a];}export{CUSTOMER_INTELLIGENCE_VERSION};
1
+ import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';const hasRefundPath=a=>a['workflow_analysis']?.['has_refund_path']??![],hasArbitrationPath=a=>a['workflow_analysis']?.['has_arbitration_path']??![],hasMilestoneNodes=a=>a['workflow_analysis']?.['has_milestone_nodes']??![],hasMessenger=a=>a['trust_signals']?.['has_messenger']??![],compensationCoversOrder=a=>a['fund_safety']?.['compensation_covers_order']??![],lockDurationSafe=a=>a['fund_safety']?.['lock_duration_safe']??![],userOperableForwards=a=>a['workflow_analysis']?.['user_operable_forwards']??0x0,wipVerified=a=>a['service_basics']['wip_verified']===!![],hasCompensationFund=a=>a['service_basics']['compensation_fund_balance']>0x0n,deadEndCount=a=>a['workflow_analysis']?.['dead_end_nodes']?.['length']??0x0,trustScore=a=>a['trust_signals']?.['trust_score']??0x0,merchantTotalOrders=a=>a['merchant_behavior']?.['total_orders']??0x0,repeatBuyerRate=a=>a['merchant_behavior']?.['repeat_buyer_rate']??0x0,disputeRate=a=>a['merchant_behavior']?.['dispute_rate']??0x1,INDUSTRY_RISK_CHECKS={'freelance':[{'id':'fr_wip_verified','industry':'freelance','dimension':'trust','description':'WIP\x20hash\x20verified\x20(work\x20traceable)','weight':0x1e,'passed':wipVerified,'advice':'⚠️\x20WIP\x20not\x20verified:\x20freelance\x20deliverables\x20cannot\x20be\x20traced.\x20Recommend\x20asking\x20the\x20merchant\x20to\x20provide\x20a\x20WIP\x20hash\x20and\x20write\x20it\x20into\x20WTS.'},{'id':'fr_milestone_nodes','industry':'freelance','dimension':'workflow','description':'Has\x20milestone\x20nodes\x20(phased\x20acceptance)','weight':0x19,'passed':hasMilestoneNodes,'advice':'⚠️\x20No\x20milestone\x20nodes:\x20delivery\x20is\x20completed\x20in\x20one\x20go\x20without\x20intermediate\x20acceptance.\x20Recommend\x20asking\x20the\x20merchant\x20to\x20add\x20phased\x20delivery\x20nodes.'},{'id':'fr_refund_path','industry':'freelance','dimension':'workflow','description':'Has\x20refund\x20path','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20if\x20freelance\x20order\x20delivery\x20is\x20not\x20satisfactory,\x20funds\x20are\x20hard\x20to\x20recover.'},{'id':'fr_response_time','industry':'freelance','dimension':'trust','description':'Messenger\x20configured\x20(communication\x20response\x20guarantee)','weight':0x14,'passed':hasMessenger,'advice':'⚠️\x20Messenger\x20not\x20configured:\x20cannot\x20conduct\x20requirement\x20confirmation\x20and\x20revision\x20communication.'}],'rental':[{'id':'rt_compensation_full','industry':'rental','dimension':'fund','description':'Compensation\x20fully\x20covers\x20order\x20amount','weight':0x1e,'passed':compensationCoversOrder,'advice':'🔴\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20when\x20rental\x20item\x20is\x20damaged.\x20Recommend\x20choosing\x20a\x20merchant\x20with\x20sufficient\x20compensation\x20fund.'},{'id':'rt_lock_duration','industry':'rental','dimension':'fund','description':'Lock\x20duration\x20safe\x20(compensation\x20cannot\x20be\x20withdrawn\x20by\x20merchant\x20at\x20any\x20time)','weight':0x19,'passed':lockDurationSafe,'advice':'⚠️\x20Lock\x20duration\x20not\x20safe:\x20merchant\x20may\x20withdraw\x20compensation\x20at\x20any\x20time,\x20deposit\x20safety\x20not\x20guaranteed.'},{'id':'rt_arbitration','industry':'rental','dimension':'workflow','description':'Arbitration\x20configured\x20(damage\x20dispute\x20resolution)','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20rental\x20damage\x20disputes.'},{'id':'rt_user_operable','industry':'rental','dimension':'workflow','description':'Has\x20user-operable\x20path\x20(return/confirm)','weight':0x14,'passed':a=>userOperableForwards(a)>0x0,'advice':'🔴\x20No\x20user-operable\x20path:\x20return\x20process\x20relies\x20entirely\x20on\x20merchant,\x20may\x20be\x20maliciously\x20delayed.'}],'education':[{'id':'ed_refund_path','industry':'education','dimension':'workflow','description':'Has\x20refund\x20path\x20(refund\x20guarantee)','weight':0x1e,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20course\x20refund\x20not\x20guaranteed,\x20recommend\x20asking\x20the\x20merchant\x20to\x20configure\x20a\x20refund\x20Allocator.'},{'id':'ed_compensation','industry':'education','dimension':'fund','description':'Has\x20compensation\x20fund','weight':0x19,'passed':hasCompensationFund,'advice':'⚠️\x20No\x20compensation\x20fund:\x20no\x20automatic\x20compensation\x20source\x20when\x20course\x20service\x20quality\x20is\x20not\x20up\x20to\x20standard.'},{'id':'ed_arbitration','industry':'education','dimension':'workflow','description':'Arbitration\x20configured','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20resolution\x20channel\x20for\x20course\x20quality\x20disputes.'},{'id':'ed_long_cycle_ok','industry':'education','dimension':'workflow','description':'Long\x20cycle\x20acceptable\x20(education\x20industry\x20allows\x20long\x20cycles,\x20over\x2090\x20days\x20needs\x20attention)','weight':0x14,'passed':()=>!![],'advice':'ℹ️\x20Long\x20delivery\x20cycles\x20are\x20normal\x20in\x20education,\x20but\x20if\x20the\x20actual\x20cycle\x20exceeds\x2090\x20days,\x20recommend\x20periodically\x20checking\x20learning\x20progress\x20and\x20lesson\x20consumption.'}],'travel':[{'id':'tr_urgent_delivery','industry':'travel','dimension':'workflow','description':'Urgent\x20delivery\x20configuration\x20(needs\x20milestone\x20nodes\x20for\x20phased\x20acceptance)','weight':0x1e,'passed':hasMilestoneNodes,'advice':'⚠️\x20No\x20milestone\x20nodes:\x20travel\x20itinerary\x20has\x20no\x20phased\x20acceptance,\x20recommend\x20setting\x20nodes\x20by\x20itinerary\x20stage.'},{'id':'tr_compensation_full','industry':'travel','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(breach\x20compensation)','weight':0x19,'passed':compensationCoversOrder,'advice':'🔴\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20when\x20itinerary\x20breaches.'},{'id':'tr_refund_path','industry':'travel','dimension':'workflow','description':'Has\x20refund\x20path\x20(itinerary\x20change/cancellation)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20funds\x20hard\x20to\x20recover\x20when\x20itinerary\x20changes\x20or\x20cancels\x20due\x20to\x20force\x20majeure.'},{'id':'tr_messenger','industry':'travel','dimension':'trust','description':'Messenger\x20configured\x20(emergency\x20communication)','weight':0x14,'passed':hasMessenger,'advice':'⚠️\x20Messenger\x20not\x20configured:\x20cannot\x20immediately\x20contact\x20merchant\x20during\x20travel\x20emergencies.'}],'subscription':[{'id':'sub_no_lockin','industry':'subscription','dimension':'workflow','description':'No\x20long-term\x20lock-in\x20(no\x20dead-end\x20nodes,\x20can\x20exit)','weight':0x1e,'passed':a=>deadEndCount(a)===0x0,'advice':'🔴\x20Dead-end\x20nodes\x20exist:\x20subscription\x20may\x20be\x20locked\x20and\x20unable\x20to\x20exit,\x20auto-renewal\x20trap\x20exists.'},{'id':'sub_refund_path','industry':'subscription','dimension':'workflow','description':'Has\x20refund\x20path\x20(exit\x20mechanism)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20remaining\x20cycle\x20fees\x20hard\x20to\x20recover\x20after\x20subscription\x20exit.'},{'id':'sub_user_operable','industry':'subscription','dimension':'workflow','description':'Has\x20user-operable\x20path\x20(pause/downgrade/cancel)','weight':0x19,'passed':a=>userOperableForwards(a)>0x0,'advice':'🔴\x20No\x20user-operable\x20path:\x20subscription\x20status\x20entirely\x20controlled\x20by\x20merchant,\x20cannot\x20pause\x20or\x20cancel\x20independently.'},{'id':'sub_compensation_optional','industry':'subscription','dimension':'fund','description':'Compensation\x20optional\x20(not\x20mandatory\x20for\x20subscription\x20industry)','weight':0x14,'passed':()=>!![],'advice':'ℹ️\x20Compensation\x20is\x20not\x20mandatory\x20for\x20subscription\x20industry;\x20having\x20it\x20is\x20better.'}],'retail':[{'id':'ret_wip_verified','industry':'retail','dimension':'trust','description':'WIP\x20verified\x20(authenticity/logistics\x20traceable)','weight':0x19,'passed':wipVerified,'advice':'⚠️\x20WIP\x20not\x20verified:\x20product\x20traceability\x20info\x20missing,\x20recommend\x20confirming\x20authenticity\x20guarantee.'},{'id':'ret_compensation_full','industry':'retail','dimension':'fund','description':'Compensation\x20fully\x20covers','weight':0x19,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20return/exchange\x20disputes.'},{'id':'ret_refund_path','industry':'retail','dimension':'workflow','description':'Has\x20refund\x20path\x20(return/exchange)','weight':0x19,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20return/exchange\x20not\x20guaranteed.'},{'id':'ret_arbitration','industry':'retail','dimension':'workflow','description':'Arbitration\x20configured','weight':0x19,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20for\x20return/exchange\x20disputes.'}],'licensing':[{'id':'lic_wip_verified','industry':'licensing','dimension':'trust','description':'WIP\x20verified\x20(license\x20terms\x20/\x20granted\x20rights\x20hash-anchored)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20WIP\x20not\x20verified:\x20the\x20licensed\x20rights\x20(territory,\x20term,\x20media,\x20caps)\x20are\x20prose-only\x20and\x20cannot\x20be\x20proven\x20in\x20a\x20dispute.\x20Recommend\x20anchoring\x20the\x20license\x20terms\x20as\x20a\x20WIP\x20hash\x20before\x20the\x20grant.'},{'id':'lic_compensation_full','industry':'licensing','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(reporting/accounting\x20honesty\x20backstop)','weight':0x19,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20a\x20licensing\x20buyer\x20is\x20trusting\x20the\x20seller\x27s\x20royalty/usage\x20reporting;\x20without\x20coverage\x20there\x20is\x20no\x20recourse\x20if\x20the\x20accounting\x20is\x20dishonest.'},{'id':'lic_refund_path','industry':'licensing','dimension':'workflow','description':'Has\x20refund\x20path\x20(inspection-window\x20exit\x20before\x20the\x20grant\x20is\x20final)','weight':0x19,'passed':hasRefundPath,'advice':'⚠️\x20No\x20refund\x20path:\x20the\x20buyer\x20cannot\x20exit\x20during\x20the\x20inspection\x20window\x20if\x20the\x20delivered\x20license/terms\x20do\x20not\x20match\x20what\x20was\x20advertised.'},{'id':'lic_arbitration','industry':'licensing','dimension':'workflow','description':'Arbitration\x20configured\x20(rights/scope\x20dispute\x20resolution)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20scope/territory/royalty\x20disputes.'}],'crowdfunding':[{'id':'cf_wip_verified','industry':'crowdfunding','dimension':'trust','description':'WIP\x20verified\x20(campaign\x20terms\x20/\x20funding\x20goal\x20/\x20deadline\x20hash-anchored)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20WIP\x20not\x20verified:\x20the\x20funding\x20goal,\x20deadline\x20and\x20reward\x20terms\x20are\x20prose-only\x20and\x20cannot\x20be\x20proven\x20in\x20a\x20dispute.\x20Recommend\x20anchoring\x20the\x20campaign\x20terms\x20as\x20a\x20WIP\x20hash\x20before\x20launch.'},{'id':'cf_refund_path','industry':'crowdfunding','dimension':'fund','description':'Has\x20refund\x20path\x20(per-contributor\x20refund\x20if\x20the\x20threshold\x20is\x20missed\x20at\x20deadline)','weight':0x1e,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20on\x20an\x20all-or-nothing\x20campaign\x20a\x20missed\x20threshold\x20MUST\x20refund\x20every\x20contributor\x20automatically.\x20Without\x20a\x20refund\x20leg\x20the\x20escrowed\x20contributions\x20are\x20stranded\x20with\x20the\x20project.\x20(A\x20flexible\x20keep-it-all\x20campaign\x20has\x20no\x20refund\x20by\x20design\x20—\x20verify\x20which\x20model\x20this\x20is\x20before\x20contributing.)'},{'id':'cf_compensation_full','industry':'crowdfunding','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(post-raise\x20delivery\x20backstop)','weight':0x14,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20after\x20a\x20successful\x20raise\x20the\x20funder\x20is\x20trusting\x20the\x20project\x20to\x20deliver;\x20without\x20coverage\x20there\x20is\x20no\x20recourse\x20for\x20non-delivery.'},{'id':'cf_arbitration','industry':'crowdfunding','dimension':'workflow','description':'Arbitration\x20configured\x20(delivery\x20/\x20non-delivery\x20dispute\x20resolution)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20non-delivery\x20or\x20reward-fulfilment\x20disputes\x20after\x20a\x20successful\x20raise.'}],'delivery':[{'id':'dl_evidence_receipts','industry':'delivery','dimension':'workflow','description':'Delivery\x20evidence\x20receipts\x20(pickup/delivery\x20receipts\x20written\x20as\x20Machine\x20evidence)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20No\x20delivery\x20evidence\x20rail:\x20pickup\x20and\x20handover\x20receipts\x20are\x20the\x20ONLY\x20provable\x20record\x20of\x20who\x20took\x20the\x20food\x20and\x20when\x20it\x20arrived.\x20Without\x20them\x20a\x20missing-order\x20dispute\x20is\x20unwinnable.'},{'id':'dl_refund_path','industry':'delivery','dimension':'fund','description':'Has\x20refund\x20path\x20(claim-window\x20refund\x20for\x20wrong/missing\x20items)','weight':0x19,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20the\x20customer\x27s\x20claim\x20window\x20(wrong\x20item,\x20missing\x20item,\x20cold\x20food)\x20has\x20no\x20money\x20exit\x20—\x20the\x20only\x20recourse\x20is\x20the\x20merchant\x27s\x20goodwill.'},{'id':'dl_compensation_full','industry':'delivery','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(transit-loss\x20remedy)','weight':0x19,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20the\x20transit-loss\x20remedy\x20(refund\x20or\x20re-delivery)\x20has\x20no\x20funding\x20backstop.'},{'id':'dl_arbitration','industry':'delivery','dimension':'trust','description':'Arbitration\x20configured\x20(claim-window\x20dispute\x20resolution)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20claim-window\x20disputes\x20(restaurant\x20vs\x20customer\x20vs\x20platform).'}],'group_buy':[{'id':'gb_cutoff_guard','industry':'group_buy','dimension':'workflow','description':'Absolute\x20cutoff\x20deadline\x20enforced\x20by\x20Guard\x20(release\x20XOR\x20refund\x20at\x20deadline)','weight':0x1e,'passed':wipVerified,'advice':'🔴\x20No\x20absolute\x20cutoff\x20Guard:\x20without\x20a\x20deadline\x20the\x20group\x20can\x20stay\x20half-open\x20forever,\x20and\x20neighbors\x20cannot\x20prove\x20when\x20(or\x20whether)\x20the\x20deal\x20fired.'},{'id':'gb_refund_path','industry':'group_buy','dimension':'fund','description':'Has\x20refund\x20path\x20(threshold-missed\x20refund\x20+\x20unclaimed-pickup\x20expiry\x20refund)','weight':0x1e,'passed':hasRefundPath,'advice':'🔴\x20No\x20refund\x20path:\x20both\x20the\x20threshold-missed\x20refund\x20and\x20the\x20unclaimed-pickup\x20expiry\x20refund\x20are\x20money\x20exits.\x20Without\x20them\x20a\x20dead\x20group\x20strands\x20every\x20neighbor\x27s\x20money\x20with\x20the\x20leader.'},{'id':'gb_compensation_full','industry':'group_buy','dimension':'fund','description':'Compensation\x20fully\x20covers\x20(delivery-delay\x20backstop)','weight':0x14,'passed':compensationCoversOrder,'advice':'⚠️\x20Compensation\x20not\x20fully\x20covered:\x20community\x20groups\x20run\x20on\x20the\x20delivery-delay\x20promise;\x20without\x20a\x20backstop\x20the\x20promise\x20is\x20prose.'},{'id':'gb_arbitration','industry':'group_buy','dimension':'trust','description':'Arbitration\x20configured\x20(goods-quality\x20/\x20leader-sourcing\x20disputes)','weight':0x14,'passed':hasArbitrationPath,'advice':'⚠️\x20Arbitration\x20not\x20configured:\x20no\x20third-party\x20ruling\x20channel\x20for\x20goods-quality\x20or\x20leader-sourcing\x20disputes.'}]};function commonNeeds(){return[{'id':'need_arbitration','tier':'common','description':'Arbitration\x20configured\x20(dispute\x20resolution\x20channel)','satisfied':hasArbitrationPath,'advice':'Arbitration\x20not\x20configured:\x20no\x20third-party\x20resolution\x20channel\x20for\x20disputes.'},{'id':'need_refund_path','tier':'common','description':'Has\x20refund\x20path','satisfied':hasRefundPath,'advice':'No\x20refund\x20path:\x20funds\x20hard\x20to\x20recover\x20when\x20delivery\x20fails.'},{'id':'need_user_operable','tier':'common','description':'Has\x20user-operable\x20Forward','satisfied':a=>userOperableForwards(a)>0x0,'advice':'No\x20user-operable\x20steps\x20in\x20workflow,\x20order\x20progress\x20depends\x20entirely\x20on\x20merchant.'},{'id':'need_messenger','tier':'common','description':'Messenger\x20configured','satisfied':hasMessenger,'advice':'Merchant\x20has\x20no\x20Messenger\x20channel,\x20cannot\x20negotiate\x20or\x20conduct\x20after-sales\x20communication.'}];}const INDUSTRY_NEEDS={'freelance':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(work\x20IP\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20IP\x20ownership\x20and\x20originality\x20of\x20work\x20cannot\x20be\x20traced.'},{'id':'need_milestone_nodes','tier':'personalized','description':'Milestone\x20nodes\x20(phased\x20feedback)','satisfied':hasMilestoneNodes,'advice':'No\x20milestone\x20nodes:\x20lack\x20of\x20phased\x20feedback\x20and\x20revision\x20round\x20control.'},{'id':'need_merchant_history','tier':'advanced','description':'Merchant\x20history\x20≥3\x20orders\x20(fulfillment\x20experience)','satisfied':a=>merchantTotalOrders(a)>=0x3,'advice':'Merchant\x20history\x20orders\x20less\x20than\x203:\x20fulfillment\x20experience\x20is\x20limited.'}],'rental':[...commonNeeds(),{'id':'need_lock_duration_safe','tier':'personalized','description':'Lock\x20duration\x20safe\x20(deposit\x20cannot\x20be\x20withdrawn)','satisfied':lockDurationSafe,'advice':'Lock\x20duration\x20not\x20safe:\x20deposit\x20may\x20be\x20withdrawn\x20by\x20merchant\x20at\x20any\x20time.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20rental\x20item\x20damage.'},{'id':'need_merchant_history','tier':'advanced','description':'Merchant\x20history\x20≥5\x20orders\x20(rental\x20experience)','satisfied':a=>merchantTotalOrders(a)>=0x5,'advice':'Merchant\x20history\x20orders\x20less\x20than\x205:\x20rental\x20service\x20experience\x20limited.'}],'education':[...commonNeeds(),{'id':'need_has_compensation','tier':'personalized','description':'Has\x20compensation\x20fund\x20(course\x20quality\x20guarantee)','satisfied':hasCompensationFund,'advice':'No\x20compensation\x20fund:\x20no\x20compensation\x20source\x20when\x20course\x20quality\x20is\x20not\x20up\x20to\x20standard.'},{'id':'need_long_cycle_ok','tier':'personalized','description':'Long\x20cycle\x20acceptable','satisfied':()=>!![],'advice':'Long\x20cycles\x20are\x20normal\x20in\x20education;\x20recommend\x20tracking\x20lesson\x20consumption\x20and\x20attendance.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20course\x20reputation\x20may\x20be\x20poor.'}],'travel':[...commonNeeds(),{'id':'need_urgent_delivery','tier':'personalized','description':'Urgent\x20delivery\x20configuration\x20(milestone\x20phasing)','satisfied':hasMilestoneNodes,'advice':'No\x20milestone\x20nodes:\x20itinerary\x20has\x20no\x20phased\x20acceptance,\x20urgent\x20delivery\x20guarantee\x20insufficient.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(breach\x20compensation)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20itinerary\x20breach.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20travel\x20service\x20reputation\x20may\x20be\x20poor.'}],'subscription':[...commonNeeds(),{'id':'need_no_lockin','tier':'personalized','description':'No\x20long-term\x20lock-in\x20(no\x20dead-end\x20nodes)','satisfied':a=>deadEndCount(a)===0x0,'advice':'Dead-end\x20nodes\x20exist:\x20subscription\x20may\x20be\x20locked,\x20auto-renewal\x20trap\x20exists.'},{'id':'need_low_dispute','tier':'personalized','description':'Low\x20dispute\x20rate\x20(≤15%,\x20stable\x20content\x20quality)','satisfied':a=>disputeRate(a)<=0.15,'advice':'Dispute\x20rate\x20is\x20high:\x20subscription\x20content\x20quality\x20may\x20be\x20unstable.'},{'id':'need_repeat_rate','tier':'advanced','description':'Repeat\x20buyer\x20rate\x20≥20%\x20(strong\x20subscription\x20renewal\x20willingness)','satisfied':a=>repeatBuyerRate(a)>=0.2,'advice':'Repeat\x20buyer\x20rate\x20below\x2020%:\x20subscription\x20renewal\x20willingness\x20is\x20weak,\x20service\x20may\x20not\x20be\x20worth\x20long-term\x20subscription.'}],'retail':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(authenticity/logistics\x20traceability)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20product\x20authenticity\x20and\x20logistics\x20traceability\x20info\x20missing.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20insufficient\x20payout\x20for\x20return/exchange\x20disputes.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20product\x20or\x20service\x20reputation\x20may\x20be\x20poor.'}],'licensing':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(license\x20terms\x20/\x20granted\x20rights\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20the\x20scope\x20of\x20the\x20granted\x20rights\x20cannot\x20be\x20traced,\x20so\x20an\x20infringement\x20or\x20over-use\x20claim\x20has\x20no\x20on-chain\x20baseline.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(reporting-honesty\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20no\x20recourse\x20if\x20the\x20seller\x27s\x20royalty/usage\x20reporting\x20turns\x20out\x20to\x20be\x20dishonest.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20licensing\x20depends\x20on\x20long-term\x20accounting\x20honesty,\x20so\x20a\x20weak\x20reputation\x20is\x20material.'}],'crowdfunding':[...commonNeeds(),{'id':'need_wip_verified','tier':'personalized','description':'WIP\x20verified\x20(campaign\x20terms\x20/\x20funding\x20goal\x20/\x20deadline\x20traceable)','satisfied':wipVerified,'advice':'WIP\x20not\x20verified:\x20the\x20funding\x20goal\x20and\x20deadline\x20cannot\x20be\x20traced,\x20so\x20a\x20\x27goal\x20reached\x27\x20or\x20\x27refund\x20due\x27\x20claim\x20has\x20no\x20on-chain\x20baseline.'},{'id':'need_threshold_refund','tier':'personalized','description':'Has\x20threshold-refund\x20path\x20(per-contributor\x20refund\x20on\x20a\x20missed\x20funding\x20goal)','satisfied':hasRefundPath,'advice':'No\x20refund\x20path:\x20on\x20an\x20all-or-nothing\x20campaign\x20the\x20contributions\x20would\x20be\x20stranded\x20with\x20the\x20project\x20if\x20the\x20goal\x20is\x20missed.\x20(A\x20flexible\x20keep-it-all\x20campaign\x20is\x20no-refund\x20by\x20design\x20—\x20confirm\x20the\x20model.)'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(post-raise\x20delivery\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20no\x20recourse\x20for\x20non-delivery\x20after\x20a\x20successful\x20raise.'},{'id':'need_high_reputation','tier':'advanced','description':'High\x20reputation\x20score\x20(trust_score\x20≥70)','satisfied':a=>trustScore(a)>=0x46,'advice':'Merchant\x20reputation\x20score\x20below\x2070:\x20crowdfunding\x20depends\x20on\x20the\x20project\x20actually\x20delivering\x20after\x20the\x20raise,\x20so\x20a\x20weak\x20reputation\x20is\x20material.'}],'delivery':[...commonNeeds(),{'id':'need_delivery_evidence','tier':'personalized','description':'Delivery\x20evidence\x20receipts\x20(pickup\x20+\x20handover\x20written\x20to\x20a\x20Repository)','satisfied':wipVerified,'advice':'No\x20delivery\x20evidence\x20rail:\x20pickup/handover\x20receipts\x20cannot\x20be\x20traced,\x20so\x20a\x20missing-order\x20dispute\x20has\x20no\x20on-chain\x20baseline.'},{'id':'need_claim_window','tier':'personalized','description':'Claim\x20window\x20configured\x20(post-delivery\x20dispute\x20window\x20before\x20settlement)','satisfied':hasRefundPath,'advice':'No\x20claim\x20window:\x20settlement\x20fires\x20immediately\x20on\x20delivery\x20—\x20the\x20customer\x20has\x20zero\x20time\x20to\x20check\x20the\x20order\x20before\x20the\x20money\x20is\x20gone.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(transit-loss\x20remedy\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20no\x20funding\x20backstop\x20behind\x20the\x20transit-loss\x20remedy.'}],'group_buy':[...commonNeeds(),{'id':'need_cutoff_guard','tier':'personalized','description':'Absolute\x20cutoff\x20deadline\x20Guard\x20(shared\x20round\x20deadline)','satisfied':wipVerified,'advice':'No\x20absolute\x20cutoff\x20Guard:\x20the\x20group\x20round\x20has\x20no\x20provable\x20deadline\x20—\x20the\x20deal\x20could\x20stay\x20open\x20indefinitely.'},{'id':'need_threshold_refund','tier':'personalized','description':'Has\x20refund\x20path\x20(threshold-missed\x20+\x20unclaimed-pickup\x20expiry\x20refunds)','satisfied':hasRefundPath,'advice':'No\x20refund\x20path:\x20a\x20missed\x20threshold\x20or\x20an\x20unclaimed\x20parcel\x20at\x20the\x20pickup\x20point\x20strands\x20the\x20neighbors\x27\x20money\x20with\x20the\x20leader.'},{'id':'need_compensation_full','tier':'personalized','description':'Compensation\x20fully\x20covers\x20(delivery-delay\x20backstop)','satisfied':compensationCoversOrder,'advice':'Compensation\x20not\x20fully\x20covered:\x20the\x20delivery-delay\x20promise\x20has\x20no\x20funding\x20backstop.'}]};let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryRiskChecks(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['risk_checks'])return b['risk_checks'];}return INDUSTRY_RISK_CHECKS[a];}export function getIndustryNeeds(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['needs'])return b['needs'];}return INDUSTRY_NEEDS[a];}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1 +1 @@
1
- import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export const SUPPORTED_INDUSTRIES=['freelance','rental','education','travel','subscription','retail','licensing','crowdfunding'];const INDUSTRY_TEMPLATES={'freelance':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x4,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'rental':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'normal','after_sales_expectation':'full'},'education':{'max_acceptable_cycle':0x5a,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'travel':{'max_acceptable_cycle':0xe,'response_time_expectation':0x2,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'urgent','after_sales_expectation':'full'},'subscription':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x18,'require_arbitration':![],'require_compensation_fund':![],'risk_appetite':'aggressive','delivery_speed_priority':'normal','after_sales_expectation':'basic'},'retail':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'licensing':{'max_acceptable_cycle':0x3c,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'crowdfunding':{'max_acceptable_cycle':0x2d,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'}},BASE_DEFAULTS={'price_sensitivity':'medium','value_orientation':'balanced','discount_sensitivity':0.3,'delivery_speed_priority':'normal','max_acceptable_cycle':0xe,'response_time_expectation':0x8,'merchant_preference':'neutral','min_order_history':0x3,'bargain_hunting':0.3,'reward_seeking':![],'referral_participation':![],'communication_style':'friendly','transparency_demand':0.5,'after_sales_expectation':'basic','risk_appetite':'balanced','min_trust_score':0x32,'require_arbitration':!![],'require_compensation_fund':!![],'preferred_industries':[],'preferred_tokens':['0x2::wow::WOW'],'preferred_merchants':[]};export function getDefaultPreferences(a){if(!a||!INDUSTRY_TEMPLATES[a])return{...BASE_DEFAULTS};const b=INDUSTRY_TEMPLATES[a];return{...BASE_DEFAULTS,'max_acceptable_cycle':b['max_acceptable_cycle'],'response_time_expectation':b['response_time_expectation'],'require_arbitration':b['require_arbitration'],'require_compensation_fund':b['require_compensation_fund'],'risk_appetite':b['risk_appetite'],'delivery_speed_priority':b['delivery_speed_priority'],'after_sales_expectation':b['after_sales_expectation']};}let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryTemplate(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['preference_template'])return{...b['preference_template']};}return{...INDUSTRY_TEMPLATES[a]};}export function mergePreferences(a,b){return{...a,...b};}export function validatePreferences(a){const b=[];return a['budget_range']&&a['budget_range']['min']>a['budget_range']['max']&&b['push']('budget_range.min\x20>\x20budget_range.max'),(a['discount_sensitivity']<0x0||a['discount_sensitivity']>0x1)&&b['push']('discount_sensitivity\x20must\x20be\x20in\x20[0,1]'),(a['bargain_hunting']<0x0||a['bargain_hunting']>0x1)&&b['push']('bargain_hunting\x20must\x20be\x20in\x20[0,1]'),(a['transparency_demand']<0x0||a['transparency_demand']>0x1)&&b['push']('transparency_demand\x20must\x20be\x20in\x20[0,1]'),(a['min_trust_score']<0x0||a['min_trust_score']>0x64)&&b['push']('min_trust_score\x20must\x20be\x20in\x20[0,100]'),a['max_acceptable_cycle']<0x0&&b['push']('max_acceptable_cycle\x20must\x20be\x20≥\x200'),a['response_time_expectation']<0x0&&b['push']('response_time_expectation\x20must\x20be\x20≥\x200'),b;}export{CUSTOMER_INTELLIGENCE_VERSION};
1
+ import{CUSTOMER_INTELLIGENCE_VERSION}from'./types.js';export const SUPPORTED_INDUSTRIES=['freelance','rental','education','travel','subscription','retail','licensing','crowdfunding','delivery','group_buy'];const INDUSTRY_TEMPLATES={'freelance':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x4,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'rental':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'normal','after_sales_expectation':'full'},'education':{'max_acceptable_cycle':0x5a,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'travel':{'max_acceptable_cycle':0xe,'response_time_expectation':0x2,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'urgent','after_sales_expectation':'full'},'subscription':{'max_acceptable_cycle':0x1e,'response_time_expectation':0x18,'require_arbitration':![],'require_compensation_fund':![],'risk_appetite':'aggressive','delivery_speed_priority':'normal','after_sales_expectation':'basic'},'retail':{'max_acceptable_cycle':0x7,'response_time_expectation':0x8,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'normal','after_sales_expectation':'full'},'licensing':{'max_acceptable_cycle':0x3c,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'crowdfunding':{'max_acceptable_cycle':0x2d,'response_time_expectation':0x18,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'},'delivery':{'max_acceptable_cycle':0x2,'response_time_expectation':0x2,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'balanced','delivery_speed_priority':'urgent','after_sales_expectation':'full'},'group_buy':{'max_acceptable_cycle':0x7,'response_time_expectation':0xc,'require_arbitration':!![],'require_compensation_fund':!![],'risk_appetite':'conservative','delivery_speed_priority':'flexible','after_sales_expectation':'full'}},BASE_DEFAULTS={'price_sensitivity':'medium','value_orientation':'balanced','discount_sensitivity':0.3,'delivery_speed_priority':'normal','max_acceptable_cycle':0xe,'response_time_expectation':0x8,'merchant_preference':'neutral','min_order_history':0x3,'bargain_hunting':0.3,'reward_seeking':![],'referral_participation':![],'communication_style':'friendly','transparency_demand':0.5,'after_sales_expectation':'basic','risk_appetite':'balanced','min_trust_score':0x32,'require_arbitration':!![],'require_compensation_fund':!![],'preferred_industries':[],'preferred_tokens':['0x2::wow::WOW'],'preferred_merchants':[]};export function getDefaultPreferences(a){if(!a||!INDUSTRY_TEMPLATES[a])return{...BASE_DEFAULTS};const b=INDUSTRY_TEMPLATES[a];return{...BASE_DEFAULTS,'max_acceptable_cycle':b['max_acceptable_cycle'],'response_time_expectation':b['response_time_expectation'],'require_arbitration':b['require_arbitration'],'require_compensation_fund':b['require_compensation_fund'],'risk_appetite':b['risk_appetite'],'delivery_speed_priority':b['delivery_speed_priority'],'after_sales_expectation':b['after_sales_expectation']};}let _registryLookup=null;export function _setRegistryLookup(a){_registryLookup=a;}export function getIndustryTemplate(a){if(_registryLookup){const b=_registryLookup(a);if(b?.['preference_template'])return{...b['preference_template']};}return{...INDUSTRY_TEMPLATES[a]};}export function mergePreferences(a,b){return{...a,...b};}export function validatePreferences(a){const b=[];return a['budget_range']&&a['budget_range']['min']>a['budget_range']['max']&&b['push']('budget_range.min\x20>\x20budget_range.max'),(a['discount_sensitivity']<0x0||a['discount_sensitivity']>0x1)&&b['push']('discount_sensitivity\x20must\x20be\x20in\x20[0,1]'),(a['bargain_hunting']<0x0||a['bargain_hunting']>0x1)&&b['push']('bargain_hunting\x20must\x20be\x20in\x20[0,1]'),(a['transparency_demand']<0x0||a['transparency_demand']>0x1)&&b['push']('transparency_demand\x20must\x20be\x20in\x20[0,1]'),(a['min_trust_score']<0x0||a['min_trust_score']>0x64)&&b['push']('min_trust_score\x20must\x20be\x20in\x20[0,100]'),a['max_acceptable_cycle']<0x0&&b['push']('max_acceptable_cycle\x20must\x20be\x20≥\x200'),a['response_time_expectation']<0x0&&b['push']('response_time_expectation\x20must\x20be\x20≥\x200'),b;}export{CUSTOMER_INTELLIGENCE_VERSION};
@@ -1 +1 @@
1
- import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a69a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a69a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20largest-order\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20cannot\x20cover\x20a\x20maximum-multiple\x20award\x20on\x20the\x20largest\x20windowed\x20order'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
1
+ import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a72a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a72a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20largest-order\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20cannot\x20cover\x20a\x20maximum-multiple\x20award\x20on\x20the\x20largest\x20windowed\x20order'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
@@ -1 +1 @@
1
- import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a75a}from'./standards.js';export function levelFromScore(a){return a75a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p){f['push']({'kind':'rule','id':o['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'weight_source':q!==o['weight']?'override':'default','reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'finding_refs':p['finding_refs'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
1
+ import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a78a}from'./standards.js';export function levelFromScore(a){return a78a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p){f['push']({'kind':'rule','id':o['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'weight_source':q!==o['weight']?'override':'default','reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'finding_refs':p['finding_refs'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
@@ -1 +1 @@
1
- import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a100a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a100a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
1
+ import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a103a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a103a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
@@ -1,5 +1,5 @@
1
1
  import type { ProjectObjectType } from "../playbooks/service-build/namespace.js";
2
- export type BusinessModuleId = "milestone_escrow" | "independent_arbitration" | "wip_provenance" | "multi_tier_allocation" | "subscription_with_proof" | "accept_timeout_protection" | "refund_guarantee" | "reputation_on_chain" | "supplier_collaboration" | "damage_attestation" | "discount_lifecycle" | "praise_incentive" | "after_sales_guarantee" | "acceptance_judging" | "installment_deposit" | "affiliate_commission" | "crowdfunding";
2
+ export type BusinessModuleId = "milestone_escrow" | "independent_arbitration" | "wip_provenance" | "multi_tier_allocation" | "subscription_with_proof" | "accept_timeout_protection" | "refund_guarantee" | "reputation_on_chain" | "supplier_collaboration" | "damage_attestation" | "discount_lifecycle" | "praise_incentive" | "after_sales_guarantee" | "acceptance_judging" | "installment_deposit" | "affiliate_commission" | "crowdfunding" | "logistics_fulfillment";
3
3
  export interface ModuleEvaluationImpact {
4
4
  dimension: string;
5
5
  effect: "boost" | "required" | "optional";