@wowok/agent-mcp 3.1.7 → 3.2.0

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 (220) hide show
  1. package/dist/config/exposure.d.ts +10 -10
  2. package/dist/config/judgment.d.ts +25 -25
  3. package/dist/config/rule-engine.d.ts +25 -25
  4. package/dist/customer/user-preferences.d.ts +2 -2
  5. package/dist/evaluation/arbitration-game.js +1 -1
  6. package/dist/evaluation/capability.d.ts +1 -1
  7. package/dist/evaluation/extract.js +1 -1
  8. package/dist/evaluation/match-operation.js +1 -1
  9. package/dist/extensions/industry-pack.d.ts +3 -2
  10. package/dist/extensions/industry-pack.js +1 -1
  11. package/dist/extensions/modes.js +1 -1
  12. package/dist/extensions/registry.js +1 -1
  13. package/dist/extensions/types.d.ts +1 -0
  14. package/dist/graph/onchain/analyze.js +1 -1
  15. package/dist/graph/onchain/analyze.spec.js +1 -1
  16. package/dist/graph/onchain/edge-schema.js +1 -1
  17. package/dist/graph/onchain/extract.js +1 -1
  18. package/dist/graph/onchain/field-manifest.js +1 -1
  19. package/dist/graph/onchain/project-relationship.js +1 -1
  20. package/dist/graph/onchain/types.d.ts +1 -1
  21. package/dist/harness/recover.js +1 -1
  22. package/dist/keeper/KeeperScan.d.ts +2 -1
  23. package/dist/keeper/KeeperScan.js +1 -1
  24. package/dist/keeper/detectors.d.ts +9 -0
  25. package/dist/keeper/detectors.js +1 -1
  26. package/dist/keeper/keeper.spec.js +1 -1
  27. package/dist/keeper/types.d.ts +1 -1
  28. package/dist/keeper/types.js +1 -1
  29. package/dist/knowledge/allocation-ledger.d.ts +4 -1
  30. package/dist/knowledge/allocation-ledger.js +1 -1
  31. package/dist/knowledge/allocation-puzzle.d.ts +2 -0
  32. package/dist/knowledge/allocation-puzzle.js +1 -1
  33. package/dist/knowledge/allocation-risk.d.ts +1 -1
  34. package/dist/knowledge/allocation-risk.js +1 -1
  35. package/dist/knowledge/arb-risk.d.ts +3 -1
  36. package/dist/knowledge/arb-risk.js +1 -1
  37. package/dist/knowledge/arbitration-ledger.js +1 -1
  38. package/dist/knowledge/arbitration-risk.js +1 -1
  39. package/dist/knowledge/arbitration-templates.d.ts +1 -0
  40. package/dist/knowledge/arbitration-templates.js +1 -1
  41. package/dist/knowledge/audit-rules.d.ts +13 -2
  42. package/dist/knowledge/audit-rules.js +1 -1
  43. package/dist/knowledge/baselines/rules/allocation.json +50 -1
  44. package/dist/knowledge/baselines/rules/arb.json +20 -1
  45. package/dist/knowledge/baselines/rules/arbitration.json +27 -0
  46. package/dist/knowledge/baselines/rules/guard.json +75 -2
  47. package/dist/knowledge/baselines/rules/machine.json +38 -13
  48. package/dist/knowledge/baselines/rules/order.json +2 -2
  49. package/dist/knowledge/builtin-templates.d.ts +3 -1
  50. package/dist/knowledge/builtin-templates.js +1 -1
  51. package/dist/knowledge/event-semantics.js +1 -1
  52. package/dist/knowledge/fund-layer.js +1 -1
  53. package/dist/knowledge/getting-started.js +1 -1
  54. package/dist/knowledge/guard-anchor-reach.d.ts +19 -0
  55. package/dist/knowledge/guard-anchor-reach.js +1 -0
  56. package/dist/knowledge/guard-bindings.js +1 -1
  57. package/dist/knowledge/guard-design-patterns.d.ts +1 -1
  58. package/dist/knowledge/guard-design-patterns.js +1 -1
  59. package/dist/knowledge/guard-ledger.js +1 -1
  60. package/dist/knowledge/guard-lint.js +1 -1
  61. package/dist/knowledge/guard-render.d.ts +6 -0
  62. package/dist/knowledge/guard-render.js +1 -1
  63. package/dist/knowledge/guard-risk.js +1 -1
  64. package/dist/knowledge/guard-submission-prompt.d.ts +6 -0
  65. package/dist/knowledge/guard-submission-prompt.js +1 -1
  66. package/dist/knowledge/guard-templates.d.ts +1 -1
  67. package/dist/knowledge/guard-templates.js +1 -1
  68. package/dist/knowledge/index.d.ts +4 -4
  69. package/dist/knowledge/index.js +1 -1
  70. package/dist/knowledge/industry-generalizer.js +1 -1
  71. package/dist/knowledge/industry-registry.d.ts +1 -1
  72. package/dist/knowledge/industry-registry.js +1 -1
  73. package/dist/knowledge/jsonrpc-enum.js +1 -1
  74. package/dist/knowledge/machine-ledger.js +1 -1
  75. package/dist/knowledge/machine-risk.js +1 -1
  76. package/dist/knowledge/machine-templates.js +1 -1
  77. package/dist/knowledge/order-ledger.js +1 -1
  78. package/dist/knowledge/order-templates.js +1 -1
  79. package/dist/knowledge/permission-ledger.js +1 -1
  80. package/dist/knowledge/release-sentinel.d.ts +12 -0
  81. package/dist/knowledge/release-sentinel.js +1 -0
  82. package/dist/knowledge/repository-write-semantics.d.ts +27 -0
  83. package/dist/knowledge/repository-write-semantics.js +1 -0
  84. package/dist/knowledge/rule-node-analyzers.d.ts +6 -0
  85. package/dist/knowledge/rule-node-analyzers.js +1 -1
  86. package/dist/knowledge/safety-rules.d.ts +5 -1
  87. package/dist/knowledge/safety-rules.js +1 -1
  88. package/dist/knowledge/scenario-modes.d.ts +10 -1
  89. package/dist/knowledge/scenario-modes.js +1 -1
  90. package/dist/knowledge/service-allocation-semantics.d.ts +36 -0
  91. package/dist/knowledge/service-allocation-semantics.js +1 -0
  92. package/dist/knowledge/strategy-manuals.d.ts +3 -5
  93. package/dist/knowledge/strategy-manuals.js +1 -1
  94. package/dist/knowledge/template-loader.d.ts +28 -12
  95. package/dist/knowledge/template-loader.js +1 -1
  96. package/dist/knowledge/template-registry.js +1 -1
  97. package/dist/knowledge/template-scanner.js +1 -1
  98. package/dist/knowledge/tools-reference.js +1 -1
  99. package/dist/knowledge/workflow-guidance.d.ts +26 -0
  100. package/dist/knowledge/workflow-guidance.js +1 -1
  101. package/dist/monitor/MonitorLoop.js +1 -1
  102. package/dist/participation/allocation-advice.d.ts +38 -0
  103. package/dist/participation/allocation-advice.js +1 -0
  104. package/dist/participation/radar-core.d.ts +2 -0
  105. package/dist/persona/types.d.ts +3 -2
  106. package/dist/persona/types.js +1 -1
  107. package/dist/playbooks/service-build/business-puzzle.js +1 -1
  108. package/dist/playbooks/service-build/intent-analyzer.js +1 -1
  109. package/dist/playbooks/service-build/merchant-guide.d.ts +70 -63
  110. package/dist/playbooks/service-build/merchant-guide.js +1 -1
  111. package/dist/playbooks/service-build/migration-planner.js +1 -1
  112. package/dist/playbooks/service-build/mode-actions.d.ts +5 -0
  113. package/dist/playbooks/service-build/mode-actions.js +1 -1
  114. package/dist/playbooks/service-build/participation-radar.js +1 -1
  115. package/dist/playbooks/service-build/semantic-graph.d.ts +1 -0
  116. package/dist/playbooks/service-build/semantic-graph.js +1 -1
  117. package/dist/playbooks/service-build/service-quote.d.ts +2 -0
  118. package/dist/playbooks/service-build/service-quote.js +1 -0
  119. package/dist/relationship/derivation.d.ts +1 -1
  120. package/dist/safety/confirm-gate.js +1 -1
  121. package/dist/schema/benchmark-migration/index.d.ts +30 -8
  122. package/dist/schema/benchmark-migration/index.js +1 -1
  123. package/dist/schema/call/allocation.d.ts +6 -3
  124. package/dist/schema/call/arbitration.js +1 -1
  125. package/dist/schema/call/base.js +1 -1
  126. package/dist/schema/call/guard.d.ts +8 -8
  127. package/dist/schema/call/machine.d.ts +56 -0
  128. package/dist/schema/call/machine.js +1 -1
  129. package/dist/schema/call/order.js +1 -1
  130. package/dist/schema/call/payment.js +1 -1
  131. package/dist/schema/call/semantic.js +1 -1
  132. package/dist/schema/call/service.d.ts +84 -22
  133. package/dist/schema/call/service.js +1 -1
  134. package/dist/schema/common/index.js +1 -1
  135. package/dist/schema/common/tokentype-short-probe.spec.js +1 -0
  136. package/dist/schema/evaluation/index.d.ts +8 -80
  137. package/dist/schema/evaluation/index.js +1 -1
  138. package/dist/schema/goal/index.d.ts +9 -42
  139. package/dist/schema/goal/planning.d.ts +25 -60
  140. package/dist/schema/goal/planning.js +1 -1
  141. package/dist/schema/intent-radar/index.d.ts +2 -20
  142. package/dist/schema/intent-radar/index.js +1 -1
  143. package/dist/schema/interaction/index.d.ts +1 -1
  144. package/dist/schema/keeper/index.d.ts +3 -0
  145. package/dist/schema/keeper/index.js +1 -1
  146. package/dist/schema/local/index.js +1 -1
  147. package/dist/schema/operations.d.ts +74 -14
  148. package/dist/schema/persona/index.d.ts +279 -384
  149. package/dist/schema/persona/index.js +1 -1
  150. package/dist/schema/query/bi.d.ts +149 -10
  151. package/dist/schema/query/bi.js +1 -1
  152. package/dist/schema/query/index.d.ts +35 -16
  153. package/dist/schema/query/index.js +1 -1
  154. package/dist/schema/schema-query/index.d.ts +4 -4
  155. package/dist/schema/schema-version.js +1 -1
  156. package/dist/schema/watch/index.d.ts +2 -2
  157. package/dist/schema-query-impl/index.d.ts +1 -0
  158. package/dist/schema-query-impl/index.js +1 -1
  159. package/dist/schemas/account_operation.output.json +2 -2
  160. package/dist/schemas/benchmark_migration_operation.output.json +116 -2
  161. package/dist/schemas/benchmark_migration_operation.schema.json +2 -10
  162. package/dist/schemas/bridge_operation.output.json +2 -2
  163. package/dist/schemas/evaluation_operation.schema.json +7 -70
  164. package/dist/schemas/goal_operation.schema.json +6 -39
  165. package/dist/schemas/index.json +1 -1
  166. package/dist/schemas/intent_radar.output.json +4 -20
  167. package/dist/schemas/keeper_operation.output.json +2 -2
  168. package/dist/schemas/keeper_operation.schema.json +9 -4
  169. package/dist/schemas/local_history_operation.output.json +2 -2
  170. package/dist/schemas/local_info_operation.output.json +2 -2
  171. package/dist/schemas/local_mark_operation.output.json +2 -2
  172. package/dist/schemas/messenger_operation.output.json +2 -2
  173. package/dist/schemas/monitor_events.output.json +2 -2
  174. package/dist/schemas/monitor_subscription.output.json +2 -2
  175. package/dist/schemas/onchain_events.output.json +2 -2
  176. package/dist/schemas/onchain_operations.output.json +6 -6
  177. package/dist/schemas/onchain_operations.schema.json +227 -54
  178. package/dist/schemas/onchain_operations_allocation.schema.json +11 -10
  179. package/dist/schemas/onchain_operations_arbitration.schema.json +13 -13
  180. package/dist/schemas/onchain_operations_machine.schema.json +27 -5
  181. package/dist/schemas/onchain_operations_order.schema.json +1 -1
  182. package/dist/schemas/onchain_operations_payment.schema.json +2 -2
  183. package/dist/schemas/onchain_operations_reward.schema.json +1 -1
  184. package/dist/schemas/onchain_operations_service.schema.json +171 -21
  185. package/dist/schemas/onchain_operations_treasury.schema.json +1 -1
  186. package/dist/schemas/onchain_table_data.output.json +57 -4
  187. package/dist/schemas/persona_operation.output.json +11 -88
  188. package/dist/schemas/persona_operation.schema.json +4 -32
  189. package/dist/schemas/query_toolkit.output.json +320 -22
  190. package/dist/schemas/query_toolkit.schema.json +53 -0
  191. package/dist/tools/handlers/benchmark-migration.js +1 -1
  192. package/dist/tools/handlers/config.js +1 -1
  193. package/dist/tools/handlers/dispatch-expectations.spec.js +1 -1
  194. package/dist/tools/handlers/keeper.d.ts +1 -1
  195. package/dist/tools/handlers/onchain.js +1 -1
  196. package/dist/tools/handlers/query.js +1 -1
  197. package/dist/tools/handlers/schema-query.js +1 -1
  198. package/dist/tools/index.js +1 -1
  199. package/dist/tools/move-fn-index.gen.js +1 -1
  200. package/dist/tools/registry/business.js +1 -1
  201. package/dist/tools/wrap.js +1 -1
  202. package/package.json +2 -2
  203. package/dist/knowledge/alloc-audit-policy.spec.js +0 -1
  204. package/dist/knowledge/event-semantics.spec.d.ts +0 -1
  205. package/dist/knowledge/event-semantics.spec.js +0 -1
  206. package/dist/knowledge/facts-sync.spec.d.ts +0 -1
  207. package/dist/knowledge/facts-sync.spec.js +0 -1
  208. package/dist/knowledge/guard-design-patterns.spec.d.ts +0 -1
  209. package/dist/knowledge/guard-design-patterns.spec.js +0 -1
  210. package/dist/knowledge/guard-eval.spec.d.ts +0 -1
  211. package/dist/knowledge/guard-eval.spec.js +0 -1
  212. package/dist/knowledge/rule-node-analyzers.spec.d.ts +0 -1
  213. package/dist/knowledge/rule-node-analyzers.spec.js +0 -1
  214. package/dist/knowledge/safety-rules.extract-amount.spec.d.ts +0 -1
  215. package/dist/knowledge/safety-rules.extract-amount.spec.js +0 -1
  216. package/dist/knowledge/template-loader.spec.d.ts +0 -1
  217. package/dist/knowledge/template-loader.spec.js +0 -1
  218. package/dist/knowledge/template-scanner.spec.d.ts +0 -1
  219. package/dist/knowledge/template-scanner.spec.js +0 -1
  220. /package/dist/{knowledge/alloc-audit-policy.spec.d.ts → schema/common/tokentype-short-probe.spec.d.ts} +0 -0
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{readFileSync}from'node:fs';import{fileURLToPath}from'node:url';import{dirname,join}from'node:path';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../graph/onchain/dataplane.js';import{expandTopology}from'../graph/onchain/expand.js';import{buildProposalGraph,buildViewport,runNodeAnalyzers}from'../graph/onchain/index.js';import{RISK_CASES}from'./baselines/risk-cases.js';import{RULE_NODE_ANALYZERS}from'./rule-node-analyzers.js';import{recipientAuditRisks}from'./rule-outcome.js';const REGISTRY_PACKS=new Set(['service','machine','guard','permission','allocation','treasury','arbitration','arb','reward','progress','order','contact','repository','demand','payment','proof','resource','personal','util','registrar','bridge']),CASES=RISK_CASES['filter'](a=>REGISTRY_PACKS['has'](a['pack'])),here=dirname(fileURLToPath(import.meta.url)),SNAPSHOT=JSON['parse'](readFileSync(join(here,'baselines','risk-baselines.json'),'utf-8'));function keysOf(a){return a['map'](b=>b['id']+':'+b['level']['toUpperCase']())['sort']();}async function migratedKeys(a,b){const d={[a['objectType']]:{'puzzle':b,'completeness':{},'missing_dimensions':[]}},e=await buildProposalGraph(d,{'network':ENTRYPOINT['Testnet']}),f=buildViewport(e,e['seed'],'neutral'),h=runNodeAnalyzers(f,RULE_NODE_ANALYZERS);return h['filter'](i=>i['ruleId']!=null)['map'](i=>i['ruleId']+':'+i['severity']['toUpperCase']())['sort']();}describe('rule-pack\x20node\x20analyzers\x20—\x20batch\x20A+B+C\x20parity\x20(T23/T24/T25)',()=>{it['each'](CASES['map'](a=>[a['pack'],a]))('TR-23.1/TR-24.1/TR-25.1\x20%s:\x20empty\x20round\x20reproduces\x20the\x20Task\x202\x20baseline',async(a,b)=>{const d=SNAPSHOT[a];expect(d)['toBeDefined'](),expect(await migratedKeys(b,b['empty']))['toEqual'](keysOf(d['empty']));}),it['each'](CASES['map'](a=>[a['pack'],a]))('TR-23.1/TR-24.1/TR-25.1\x20%s:\x20trigger\x20round\x20reproduces\x20the\x20Task\x202\x20baseline',async(a,b)=>{const d=SNAPSHOT[a];expect(d)['toBeDefined']();const e=await migratedKeys(b,b['trigger']);if(a==='allocation'){const f=e['filter'](h=>h['startsWith']('R-A-'));expect(f)['toEqual'](keysOf(d['trigger']));const g=e['filter'](h=>h['startsWith']('RC-FIND-'));expect(g['length'])['toBeGreaterThan'](0x0),expect(g)['toEqual'](recipientAuditRisks(b['trigger'])['map'](h=>{const i=h??{};return String(i['id'])+':'+String(i['level'])['toUpperCase']();})['sort']());return;}expect(e)['toEqual'](keysOf(d['trigger']));});}),describe('rule-pack\x20exposure\x20attribution\x20passthrough\x20(Phase\x202)',()=>{const a=CASES['find'](d=>d['pack']==='treasury')['run'];function b(c,d=a){const e=d(c),f=Array['isArray'](e)?e:e?.['risks']??e?.['detected_risks'];return f??[];}it('R-T-3-03:\x20delegated\x20withdraw-guard\x20management\x20carries\x20the\x20gated\x20viable\x20gain\x20path',()=>{const c=b({'current_permission_indexes_granted':[0x100]})['find'](d=>d['id']==='R-T-3-03');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeDefined'](),expect(c['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(c['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(c['exposure']['verdict'])['toBe']('confirmed');}),it('R-T-5-02:\x20missing\x20receive\x20permission\x20is\x20a\x20shortfall\x20defect\x20(no\x20gainer,\x20never\x20downgraded)',()=>{const c=b({'current_permission_indexes_granted':[0xfa],'shared_with_allocator':!![]})['find'](d=>d['id']==='R-T-5-02');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeDefined'](),expect(c['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(c['exposure']['gainPaths'])['toEqual']([]),expect(c['exposure']['verdict'])['toBe']('confirmed');}),it('notice-class\x20rules\x20stay\x20unattributed\x20(R-T-1-01\x20description\x20over\x20limit)',()=>{const c=b({'description':'x'['repeat'](0xfa1)})['find'](d=>d['id']==='R-T-1-01');expect(c)['toBeDefined'](),expect(c['exposure'])['toBeUndefined']();}),it('R-A-1-01:\x20empty\x20allocators\x20is\x20a\x20shortfall\x20defect\x20(buyer+merchant\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](g=>g['pack']==='allocation')['run'],d=c({'allocators_config':{'allocators':[]}}),e=Array['isArray'](d)?d:d?.['risks']??d?.['detected_risks'],f=(e??[])['find'](g=>g['id']==='R-A-1-01');expect(f)['toBeDefined'](),expect(f['exposure'])['toBeDefined'](),expect(f['exposure']['lossParties']['map'](g=>g['role'])['sort']())['toEqual'](['buyer','merchant']),expect(f['exposure']['gainPaths'])['toEqual']([]),expect(f['exposure']['verdict'])['toBe']('confirmed');}),it('R-S-2-01:\x20unpinned\x20WIP\x20content\x20—\x20buyer\x20loses,\x20merchant\x20substitution\x20rides\x20the\x20viable\x20payment\x20flow',()=>{const c=CASES['find'](e=>e['pack']==='service')['run'],d=b({'sales':{'op':'add','sales':[{'name':'sku','wip':'https://example.com/a.wip','wip_hash':''}]}},c)['find'](e=>e['id']==='R-S-2-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-S-5-05:\x20funded\x20without\x20arbitration\x20is\x20a\x20shortfall\x20defect\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='service')['run'],d=b({'current_compensation_fund_balance':'100','current_arbitrations_count':0x0},c)['find'](e=>e['id']==='R-S-5-05');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-R-2-05:\x20unconstrained\x20GuardIdentifier\x20recipient\x20slot\x20—\x20conditional\x20pool-drain\x20path',()=>{const c=CASES['find'](e=>e['pack']==='reward')['run'],d=b({'guard_add':[{'guard':'0xg1','recipient':{'GuardIdentifier':0x7},'amount':{'type':'Fixed','value':'100'}}]},c)['find'](e=>e['id']==='R-R-2-05');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('conditional'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-R-7-01:\x20no\x20owner\x20escape\x20guard\x20is\x20a\x20shortfall\x20defect\x20(merchant\x20budget\x20locked,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='reward')['run'],d=b({'coin_add':{'amount':'100','coin_type':'0x2::sui::SUI'}},c)['find'](e=>e['id']==='R-R-7-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('merchant'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-M1-02:\x20no\x20terminal\x20node\x20is\x20a\x20topology\x20freeze\x20(buyer+merchant\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='machine')['run'],d=b({'pairs':[],'nodes':[]},c)['find'](e=>e['rule_id']==='R-M1-02');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role'])['sort']())['toEqual'](['buyer','merchant']),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-X1-07:\x20overstuffed\x20usage_guard\x20is\x20a\x20dispute-access\x20shortfall\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='guard')['run'],d=b({'table':[],'root':{'type':'logic_and','nodes':[{'type':'logic_and','nodes':[{'type':'identifier','value':0x0},{'type':'identifier','value':0x0}]},{'type':'logic_and','nodes':[{'type':'identifier','value':0x0},{'type':'identifier','value':0x0}]},{'type':'identifier','value':0x0}]},'scene':{'id':'arbitration_usage_guard','host_object':'Arbitration','binding_field':'usage_guard'}},c)['find'](e=>e['id']==='R-X1-07');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-O-3-03:\x20arb_claim_compensation\x20is\x20a\x20recourse-exhaustion\x20shortfall\x20(buyer\x20loss,\x20no\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='order')['run'],d=b({'operation':'arb_claim_compensation'},c)['find'](e=>e['id']==='R-O-3-03');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role']))['toEqual'](['buyer']),expect(d['exposure']['gainPaths'])['toEqual']([]),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-PAYMENT-01:\x20unchecked\x20unwrap\x20is\x20an\x20unblockable\x20mismatched-release\x20path\x20(neutral\x20viable\x20gainer)',()=>{const c=CASES['find'](e=>e['pack']==='payment')['run'],d=b({'uses_unsafe_unwrap':!![]},c)['find'](e=>e['id']==='R-PAYMENT-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties']['map'](e=>e['role'])['sort']())['toEqual'](['buyer','merchant']),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('viable'),expect(d['exposure']['verdict'])['toBe']('confirmed');}),it('R-AB-3-01:\x20dominant\x20vote\x20weight\x20is\x20a\x20capture-conditional\x20payout-steering\x20path',()=>{const c=CASES['find'](e=>e['pack']==='arbitration')['run'],d=b({'voting_guard':{'op':'add','guards':[{'guard':'0xg1','vote_weight':{'FixedValue':0x3c}},{'guard':'0xg2','vote_weight':{'FixedValue':0x28}}]}},c)['find'](e=>e['id']==='R-AB-3-01');expect(d)['toBeDefined'](),expect(d['exposure'])['toBeDefined'](),expect(d['exposure']['lossParties'][0x0]['role'])['toBe']('buyer'),expect(d['exposure']['gainPaths'][0x0]['role'])['toBe']('neutral'),expect(d['exposure']['gainPaths'][0x0]['viability'])['toBe']('conditional'),expect(d['exposure']['verdict'])['toBe']('confirmed');});}),describe('rule-pack\x20node\x20analyzers\x20—\x20on-chain\x20fixtures\x20(T23/T24/T25)',()=>{it('TR-23.2\x20SR1\x20state\x20rules\x20fire\x20on\x20a\x20fetched\x20on-chain\x20Service\x20through\x20the\x20unified\x20list',async()=>{const a='0x'+'14'+'cd'['repeat'](0x1f),b=new FakeDataPlane({'objects':new Map([[a['toLowerCase'](),{'object':a,'type':'Service','data':{'bPublished':!![],'bPaused':!![],'compensation_fund':'9','arbitrations':[]}}]]),'keyedFields':new Map(),'tables':new Map()}),c=await expandTopology(b,{'network':ENTRYPOINT['Mainnet'],'seed':a,'edges':{'tableEdges':['machine.node']}}),d=buildViewport(c,a['toLowerCase'](),'neutral'),e=runNodeAnalyzers(d,RULE_NODE_ANALYZERS),f=e['filter'](h=>h['id']['startsWith']('SR1:'));expect(f)['toHaveLength'](0x2),expect(f['every'](h=>h['detail']['includes']('R-S-4-05')||h['detail']['includes']('R-S-5-05')))['toBe'](!![]),expect(f['every'](h=>h['ruleId']===undefined))['toBe'](!![]),expect(f['every'](h=>h['source']===undefined))['toBe'](!![]),expect(e['filter'](h=>h['id']['startsWith']('MK1:')||h['id']['startsWith']('GD1:')||h['id']['startsWith']('PM1:')||h['id']['startsWith']('AL1:')||h['id']['startsWith']('TR1:')||h['id']['startsWith']('AR1:')||h['id']['startsWith']('AR3:')||h['id']['startsWith']('RW1:')||h['id']['startsWith']('PR1:')||h['id']['startsWith']('OR1:')||h['id']['startsWith']('CT1:')||h['id']['startsWith']('RP1:')||h['id']['startsWith']('DM1:')||h['id']['startsWith']('PY1:')||h['id']['startsWith']('PF1:')||h['id']['startsWith']('RS1:')||h['id']['startsWith']('PS1:')||h['id']['startsWith']('UT1:')||h['id']['startsWith']('RG1:')||h['id']['startsWith']('BR1:')))['toEqual']([]);}),it['each']([['Machine','15',{'pairs':[]}],['Guard','19',{'description':'chain\x20guard'}],['Permission','10',{'description':'chain\x20permission'}],['Allocation','18',{'description':'chain\x20allocation'}],['Treasury','1c',{'description':'chain\x20treasury'}],['Arb','11',{'description':'chain\x20arb'}],['Reward','12',{'description':'chain\x20reward'}],['Progress','13',{'description':'chain\x20progress'}],['Order','14',{'description':'chain\x20order'}],['Contact','1d',{'description':'chain\x20contact'}],['Repository','1e',{'description':'chain\x20repository'}],['Demand','1f',{'description':'chain\x20demand'}],['Payment','16',{'description':'chain\x20payment'}],['Resource','17',{'description':'chain\x20resource'}],['Proof','1a',{'description':'chain\x20proof'}],['EntityRegistrar','1b',{'description':'chain\x20registrar'}]])('TR-23.2\x20on-chain\x20%s:\x20packs\x20without\x20an\x20on-chain\x20projection\x20run\x20zero\x20rules\x20(honest\x20zero)',async(a,b,c)=>{const d='0x'+b+'ef'['repeat'](0x1f),e={'object':d,'type':a,'data':c},f=new FakeDataPlane({'objects':new Map([[d['toLowerCase'](),e]]),'keyedFields':new Map(),'tables':new Map()}),h=await expandTopology(f,{'network':ENTRYPOINT['Mainnet'],'seed':d,'edges':{'tableEdges':['machine.node']}});expect(h['nodes']['get'](d['toLowerCase']())?.['state'])['toBe']('fetched');const i=buildViewport(h,d['toLowerCase'](),'neutral');expect(runNodeAnalyzers(i,RULE_NODE_ANALYZERS))['toEqual']([]);});}),describe('rule-pack\x20node\x20analyzers\x20—\x20external\x20fact\x20nodes\x20(TR-25.1)',()=>{const a=CASES['find'](d=>d['pack']==='bridge'),b=CASES['find'](d=>d['pack']==='payment');it('TR-25.1\x20bridge\x20synthesizes\x20a\x20Bridge-typed\x20EXTERNAL\x20fact\x20node;\x20findings\x20stamp\x20source\x20external',async()=>{const c=await buildProposalGraph({'bridge':{'puzzle':a['trigger'],'completeness':{},'missing_dimensions':[]}},{'network':ENTRYPOINT['Testnet']}),d=c['nodes']['get']('proposal::bridge');expect(d?.['kind'])['toBe']('object'),expect(d?.['objectType'])['toBe']('Bridge'),expect(d?.['proposal']?.['provenance'])['toBe']('external');const e=buildViewport(c,'proposal::bridge','neutral'),f=runNodeAnalyzers(e,RULE_NODE_ANALYZERS)['filter'](h=>h['id']['startsWith']('BR1:'));expect(f['length'])['toBeGreaterThan'](0x0),expect(f['every'](h=>h['source']==='external'))['toBe'](!![]);}),it('TR-25.1\x20default\x20proposal\x20nodes\x20stay\x20intent\x20nodes\x20stamped\x20source\x20proposal',async()=>{const c=await buildProposalGraph({'payment':{'puzzle':b['trigger'],'completeness':{},'missing_dimensions':[]}},{'network':ENTRYPOINT['Testnet']}),d=c['nodes']['get']('proposal::payment');expect(d?.['objectType'])['toBe']('Payment'),expect(d?.['proposal']?.['provenance'])['toBeUndefined']();const e=buildViewport(c,'proposal::payment','neutral'),f=runNodeAnalyzers(e,RULE_NODE_ANALYZERS)['filter'](h=>h['id']['startsWith']('PY1:'));expect(f['length'])['toBeGreaterThan'](0x0),expect(f['every'](h=>h['source']==='proposal'))['toBe'](!![]);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{extractAmount}from'./safety-rules.js';describe('extractAmount\x20—\x20docs#48-2\x20zero\x20suppression',()=>{it('returns\x20null\x20for\x20a\x20call\x20with\x20no\x20amount\x20concept\x20at\x20all',()=>{expect(extractAmount({'object':'0xsvc','description':'plain\x20draft\x20edit'}))['toBeNull']();}),it('does\x20not\x20raise\x20Amount:\x200\x20for\x20Rate-mode\x20allocators\x20with\x20default\x20threshold\x200',()=>{const a={'order_allocators':{'threshold':'0','allocators':[{'who':{'GuardIdentifier':0x0},'sharing':[{'mode':'Rate','sharing':'10000'}],'mode':'Rate'}]}};expect(extractAmount(a))['toBeNull']();}),it('does\x20not\x20raise\x20Amount:\x200\x20when\x20every\x20candidate\x20is\x20zero',()=>{expect(extractAmount({'amount':'0','fee':0x0}))['toBeNull']();});}),describe('extractAmount\x20—\x20docs#48-2\x20enumeration\x20sums',()=>{it('sums\x20ALL\x20revenue\x20rows\x20instead\x20of\x20reporting\x20only\x20the\x20first',()=>{const a={'revenue':[{'recipient':'0xa','amount':{'balance':'1000'}},{'recipient':'0xb','amount':{'balance':'2000'}}]};expect(extractAmount(a))['toBe']('3000');}),it('sums\x20Amount-mode\x20allocator\x20shares\x20across\x20every\x20allocator',()=>{const a={'allocators':{'threshold':'0','allocators':[{'who':{'Address':'0xa'},'sharing':[{'mode':'Amount','sharing':'500'}],'mode':'Amount'},{'who':{'Address':'0xb'},'sharing':[{'mode':'Amount','sharing':'700'}],'mode':'Amount'}]}};expect(extractAmount(a))['toBe']('1200');}),it('keeps\x20single-value\x20behavior\x20for\x20direct\x20amount\x20fields',()=>{expect(extractAmount({'amount':'2500000000'}))['toBe']('2500000000'),expect(extractAmount({'fee':0x64}))['toBe']('100'),expect(extractAmount({'deposit':{'coin':{'balance':'7000'}}}))['toBe']('7000');}),it('falls\x20back\x20to\x20the\x20first\x20value\x20when\x20display\x20strings\x20cannot\x20be\x20summed',()=>{const a={'amount':'2.5WOW','fee':'1WOW'};expect(extractAmount(a))['toBe']('2.5WOW');}),it('skips\x20zero\x20entries\x20mixed\x20with\x20real\x20values',()=>{expect(extractAmount({'amount':'0','fee':0x1f4}))['toBe']('500');});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{afterEach,beforeEach,describe,expect,it}from'vitest';import{existsSync,mkdirSync,mkdtempSync,readFileSync,rmSync,utimesSync,writeFileSync}from'node:fs';import{tmpdir}from'node:os';import{join}from'node:path';import{getTemplate,getTemplatesByIndustry,INDUSTRY_VALUES,listTemplates,loadAndValidate,parseTemplateFile,reloadTemplates,resolveTemplatesDir,seedBuiltinTemplates,TEMPLATES_SUBDIR}from'./template-loader.js';import{BUILTIN_TEMPLATES}from'./builtin-templates.js';const COMPETITOR_NAMES=['amazon','etsy','upwork','contra','airbnb','ziroom','coursera','yuanfudao','booking.com','klook','patreon','onlyfans','fiverr','turo','getaround','byju','outschool','thomas\x20cook','apple\x20iap']['map'](a=>new RegExp('\x5cb'+a['replace'](/[.*+?^${}()|[\]\\]/g,'\x5c$&')+'\x5cb','i'));describe('template-loader\x20—\x20builtin\x20catalog',()=>{let a,b,c,d;beforeEach(()=>{c=process['env']['WOWOK_TEMPLATES_DIR'],d=process['env']['WOWOK_LEGACY_TEMPLATES_DIR'],a=mkdtempSync(join(tmpdir(),'wowok-templates-')),b=mkdtempSync(join(tmpdir(),'wowok-templates-legacy-')),process['env']['WOWOK_TEMPLATES_DIR']=a,process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=b,reloadTemplates();}),afterEach(()=>{if(c===undefined)delete process['env']['WOWOK_TEMPLATES_DIR'];else process['env']['WOWOK_TEMPLATES_DIR']=c;if(d===undefined)delete process['env']['WOWOK_LEGACY_TEMPLATES_DIR'];else process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=d;reloadTemplates(),rmSync(a,{'recursive':!![],'force':!![]}),rmSync(b,{'recursive':!![],'force':!![]});}),it('seeds\x20exactly\x2012\x20templates:\x206\x20industries\x20x\x202\x20variants',()=>{const {templates:e,errors:f}=listTemplates();expect(f)['toEqual']([]),expect(e)['toHaveLength'](0xc);const g=new Map();for(const h of e){g['set'](h['industry'],(g['get'](h['industry'])??0x0)+0x1);}for(const i of INDUSTRY_VALUES){expect(g['get'](i),'industry\x20'+i)['toBe'](0x2);}}),it('every\x20industry\x20has\x20one\x20leader\x20and\x20one\x20challenger',()=>{const {templates:e}=listTemplates();for(const f of INDUSTRY_VALUES){const g=e['filter'](h=>h['industry']===f)['map'](h=>h['archetype'])['sort']();expect(g,'industry\x20'+f)['toEqual'](['challenger','leader']);}}),it('ids\x20follow\x20\x27<industry>/<variant>\x27\x20and\x20match\x20the\x20builtin\x20catalog',()=>{const {templates:e}=listTemplates(),f=e['map'](g=>g['id'])['sort']();expect(f)['toEqual'](BUILTIN_TEMPLATES['map'](g=>g['id'])['sort']());for(const g of e){expect(g['id'])['toBe'](g['industry']+'/'+g['variant']);}}),it('seeded\x20files\x20are\x20sanitized\x20—\x20no\x20competitor\x20company\x20names',()=>{seedBuiltinTemplates();const e=[];for(const f of BUILTIN_TEMPLATES){e['push'](join(a,f['industry'],TEMPLATES_SUBDIR,f['variant']+'.md'));}for(const g of e){expect(existsSync(g),g)['toBe'](!![]);const h=readFileSync(g,'utf-8');for(const i of COMPETITOR_NAMES){expect(i['test'](h),g+'\x20matches\x20'+i)['toBe'](![]);}}}),it('seeding\x20is\x20idempotent\x20—\x20existing\x20files\x20are\x20never\x20overwritten',()=>{seedBuiltinTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),f=readFileSync(e,'utf-8')+'\x0a<!--\x20user\x20edit\x20-->\x0a';writeFileSync(e,f,'utf-8'),seedBuiltinTemplates(),expect(readFileSync(e,'utf-8'))['toBe'](f);}),it('migrates\x20legacy\x20flat-root\x20templates\x20into\x20the\x20industry\x20tree',()=>{const e=join(b,'retail','custom-legacy.md');mkdirSync(join(b,'retail'),{'recursive':!![]}),writeFileSync(e,['---','id:\x20retail/custom-legacy','industry:\x20retail','variant:\x20custom-legacy','archetype:\x20challenger','phase:\x201','recommended_role:\x20merchant','role_rationale:\x20legacy\x20test','key_risk:\x20legacy\x20test','machine_shape:\x20[{\x22name\x22:\x20\x22paid\x22,\x20\x22role\x22:\x20\x22entry\x22}]','guards:\x20[]','allocator:\x20{\x22recipient\x22:\x20\x22signer\x22,\x20\x22count\x22:\x201,\x20\x22mode\x22:\x20\x22rate\x22,\x20\x22description\x22:\x20\x22legacy\x22}','fee_params:\x20{}','trust_mechanisms:\x20[]','keeper_dependencies:\x20[]','differences:\x20[]','user_inputs:\x20[]','build_notes:\x20[]','---','legacy\x20body']['join']('\x0a'),'utf-8'),seedBuiltinTemplates();const f=join(a,'retail',TEMPLATES_SUBDIR,'custom-legacy.md');expect(existsSync(f))['toBe'](!![]),expect(existsSync(e))['toBe'](![]),expect(getTemplate('retail/custom-legacy'))['toBeDefined'](),expect(listTemplates()['templates'])['toHaveLength'](0xd);}),it('legacy\x20migration\x20never\x20overwrites\x20an\x20existing\x20target',()=>{seedBuiltinTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),f=readFileSync(e,'utf-8');mkdirSync(join(b,'retail'),{'recursive':!![]}),writeFileSync(join(b,'retail','scale-marketplace.md'),'---\x0aid:\x20retail/scale-marketplace\x0a---\x0aLEGACY\x20CONTENT','utf-8'),reloadTemplates(),seedBuiltinTemplates(),expect(readFileSync(e,'utf-8'))['toBe'](f);}),it('getTemplate\x20/\x20getTemplatesByIndustry\x20resolve\x20by\x20id\x20and\x20industry',()=>{expect(getTemplate('retail/scale-marketplace')?.['archetype'])['toBe']('leader'),expect(getTemplate('nope/nope'))['toBeUndefined']();const e=getTemplatesByIndustry('rental');expect(e)['toHaveLength'](0x2),expect(e['every'](f=>f['industry']==='rental'))['toBe'](!![]);});}),describe('template-loader\x20—\x20parsing\x20and\x20validation',()=>{it('parseTemplateFile\x20splits\x20frontmatter\x20from\x20body',()=>{const a=['---','id:\x20retail/scale-marketplace','phase:\x201','fee_params:\x20{\x22commission_rate_bps\x22:\x201500}','machine_shape:\x20[{\x22name\x22:\x20\x22paid\x22,\x20\x22role\x22:\x20\x22entry\x22}]','---','#\x20Body','','Free-form\x20guidance.']['join']('\x0a'),{frontmatter:b,body:c}=parseTemplateFile(a);expect(b['id'])['toBe']('retail/scale-marketplace'),expect(b['phase'])['toBe'](0x1),expect(b['fee_params'])['toEqual']({'commission_rate_bps':0x5dc}),expect(b['machine_shape'])['toEqual']([{'name':'paid','role':'entry'}]),expect(c)['toContain']('#\x20Body');}),it('rejects\x20files\x20without\x20a\x20frontmatter\x20block',()=>{expect(()=>parseTemplateFile('#\x20no\x20frontmatter'))['toThrow'](/frontmatter/);}),it('rejects\x20unterminated\x20frontmatter',()=>{expect(()=>parseTemplateFile('---\x0aid:\x20a/b\x0ano\x20closing'))['toThrow'](/unterminated/i);}),it('loadAndValidate\x20throws\x20with\x20the\x20file\x20path\x20and\x20issues\x20for\x20invalid\x20frontmatter',()=>{const a=mkdtempSync(join(tmpdir(),'wowok-tpl-bad-')),b=join(a,'bad.md');writeFileSync(b,'---\x0aid:\x20BAD\x20ID\x0aindustry:\x20retail\x0a---\x0abody','utf-8');try{expect(()=>loadAndValidate(b))['toThrow'](new RegExp(b['replace'](/\\/g,'\x5c\x5c')));}finally{rmSync(a,{'recursive':!![],'force':!![]});}});}),describe('template-loader\x20—\x20hot\x20reload',()=>{let a,b,c,d;beforeEach(()=>{c=process['env']['WOWOK_TEMPLATES_DIR'],d=process['env']['WOWOK_LEGACY_TEMPLATES_DIR'],a=mkdtempSync(join(tmpdir(),'wowok-templates-hot-')),b=mkdtempSync(join(tmpdir(),'wowok-templates-hot-legacy-')),process['env']['WOWOK_TEMPLATES_DIR']=a,process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=b,reloadTemplates();}),afterEach(()=>{if(c===undefined)delete process['env']['WOWOK_TEMPLATES_DIR'];else process['env']['WOWOK_TEMPLATES_DIR']=c;if(d===undefined)delete process['env']['WOWOK_LEGACY_TEMPLATES_DIR'];else process['env']['WOWOK_LEGACY_TEMPLATES_DIR']=d;reloadTemplates(),rmSync(a,{'recursive':!![],'force':!![]}),rmSync(b,{'recursive':!![],'force':!![]});}),it('re-reads\x20a\x20file\x20whose\x20mtime\x20changed',()=>{const {templates:e}=listTemplates();expect(e)['toHaveLength'](0xc);const f=join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),g=readFileSync(f,'utf-8'),h=g['replace']('key_risk:\x20','key_risk:\x20MUTATED\x20');writeFileSync(f,h,'utf-8');const i=new Date(Date['now']()+0x1388);utimesSync(f,i,i);const j=getTemplate('retail/scale-marketplace');expect(j?.['key_risk']['startsWith']('MUTATED'))['toBe'](!![]);}),it('drops\x20cache\x20entries\x20whose\x20files\x20vanished',()=>{expect(listTemplates()['templates'])['toHaveLength'](0xc),rmSync(join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md')),expect(listTemplates()['templates'])['toHaveLength'](0xb),expect(getTemplate('retail/scale-marketplace'))['toBeUndefined']();}),it('reports\x20invalid\x20files\x20in\x20errors\x20without\x20breaking\x20the\x20rest',()=>{listTemplates();const e=join(a,'retail',TEMPLATES_SUBDIR,'broken.md');writeFileSync(e,'---\x0aid:\x20retail/broken\x0a---\x0abody','utf-8');const {templates:f,errors:g}=listTemplates();expect(f)['toHaveLength'](0xc),expect(g['length'])['toBe'](0x1),expect(g[0x0])['toContain']('broken.md');}),it('reloadTemplates\x20forces\x20a\x20full\x20re-read',()=>{expect(listTemplates()['templates'])['toHaveLength'](0xc);const e=join(a,'retail',TEMPLATES_SUBDIR,'custom.md');writeFileSync(e,readFileSync(join(a,'retail',TEMPLATES_SUBDIR,'scale-marketplace.md'),'utf-8')['replace']('id:\x20retail/scale-marketplace','id:\x20retail/custom'),'utf-8'),reloadTemplates(),expect(listTemplates()['templates'])['toHaveLength'](0xd),expect(getTemplate('retail/custom'))['toBeDefined']();}),it('resolveTemplatesDir\x20honours\x20the\x20env\x20override',()=>{expect(resolveTemplatesDir())['toBe'](a);});});
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- import{describe,expect,it}from'vitest';import{scanTemplate}from'./template-scanner.js';import{BUILTIN_TEMPLATES,getBuiltinTemplate}from'./builtin-templates.js';function asLoaded(a,b={}){return{...a,'body':'','source_path':'<builtin:'+a['id']+'>',...b};}const base=()=>getBuiltinTemplate('retail/scale-marketplace');describe('scanTemplate\x20—\x20builtin\x20catalog\x20passes',()=>{it('all\x2012\x20built-in\x20templates\x20pass\x20(no\x20CRITICAL\x20findings)',()=>{for(const a of BUILTIN_TEMPLATES){const b=scanTemplate(asLoaded(a));expect(b['template_id'])['toBe'](a['id']),expect(b['passed'],a['id']+'\x20blocked:\x20'+b['red_flags']['join'](';\x20')+'\x20/\x20'+b['findings']['map'](c=>(c['rule_id']??'?')+':'+c['title'])['join'](';\x20'))['toBe'](!![]),expect(b['red_flags'])['toEqual']([]),expect(b['findings']['every'](c=>c['severity']!=='critical'))['toBe'](!![]);}}),it('the\x20synthetic\x20draft\x20machine\x20trips\x20no\x20machine/allocation\x20rule\x20false\x20positives',()=>{for(const a of BUILTIN_TEMPLATES){const b=scanTemplate(asLoaded(a)),c=b['findings']['filter'](d=>d['rule_id']?.['startsWith']('R-M')||d['rule_id']?.['startsWith']('R-A'));expect(c,a['id']+':\x20'+c['map'](d=>d['rule_id'])['join'](','))['toEqual']([]);}});}),describe('scanTemplate\x20—\x20static\x20checks\x20fire\x20on\x20mutations',()=>{const a=()=>getBuiltinTemplate('retail/scale-marketplace');it('R-M1-11:\x20a\x20dispute/refund\x20Machine\x20node\x20is\x20CRITICAL\x20and\x20blocks',()=>{const b=asLoaded(a(),{'machine_shape':[...a()['machine_shape'],{'name':'disputed','role':'Dispute\x20handled\x20inside\x20the\x20Machine'}]}),c=scanTemplate(b);expect(c['passed'])['toBe'](![]),expect(c['risk_level'])['toBe']('critical');const d=c['findings']['find'](e=>e['rule_id']==='R-M1-11');expect(d)['toBeDefined'](),expect(d['severity'])['toBe']('critical'),expect(c['red_flags']['some'](e=>e['includes']('R-M1-11')))['toBe'](!![]);}),it('R-M1-01:\x20an\x20empty\x20machine_shape\x20is\x20CRITICAL\x20and\x20blocks',()=>{const b=scanTemplate(asLoaded(a(),{'machine_shape':[]}));expect(b['passed'])['toBe'](![]),expect(b['findings']['some'](c=>c['rule_id']==='R-M1-01'&&c['severity']==='critical'))['toBe'](!![]);}),it('R1:\x20missing\x20refund\x20path\x20raises\x20a\x20high\x20finding\x20(but\x20does\x20not\x20block)',()=>{const b=a(),c=asLoaded(b,{'guards':b['guards']['filter'](f=>!f['template_id']['includes']('refund')&&!f['template_id']['includes']('cancel')),'allocator':{...b['allocator'],'description':'Settlement\x20split\x20among\x20participants\x20at\x20the\x20release\x20point'}}),d=scanTemplate(c),e=d['findings']['find'](g=>g['rule_id']==='R1');expect(e)['toBeDefined'](),expect(e['severity'])['toBe']('high'),expect(d['passed'])['toBe'](!![]),expect(d['risk_level'])['toBe']('high');}),it('R2:\x20missing\x20independent\x20Arbitration\x20reference\x20raises\x20a\x20high\x20finding',()=>{const b=a(),c=asLoaded(b,{'guards':b['guards']['filter'](e=>e['host']!=='arbitration'),'trust_mechanisms':b['trust_mechanisms']['filter'](e=>!e['startsWith']('R2'))}),d=scanTemplate(c);expect(d['findings']['some'](e=>e['rule_id']==='R2'&&e['severity']==='high'))['toBe'](!![]);}),it('R9:\x20no\x20keeper\x20declarations\x20raises\x20a\x20medium\x20finding',()=>{const b=scanTemplate(asLoaded(a(),{'keeper_dependencies':[]})),c=b['findings']['find'](d=>d['rule_id']==='R9');expect(c)['toBeDefined'](),expect(c['severity'])['toBe']('medium');});}),describe('scanTemplate\x20—\x20result\x20shape',()=>{it('findings\x20are\x20sorted\x20by\x20severity\x20descending;\x20risk_level\x20is\x20the\x20highest',()=>{const a=base(),b=asLoaded(a,{'machine_shape':[...a['machine_shape'],{'name':'refunded','role':'Refund\x20node'}],'keeper_dependencies':[]}),c=scanTemplate(b),d={'low':0x0,'medium':0x1,'high':0x2,'critical':0x3};for(let e=0x1;e<c['findings']['length'];e++){expect(d[c['findings'][e]['severity']])['toBeLessThanOrEqual'](d[c['findings'][e-0x1]['severity']]);}expect(c['risk_level'])['toBe'](c['findings'][0x0]['severity']);}),it('a\x20clean\x20scan\x20reports\x20risk_level\x20from\x20its\x20highest\x20non-critical\x20finding',()=>{const a=scanTemplate(asLoaded(getBuiltinTemplate('freelance/enterprise-talent-market')));expect(a['passed'])['toBe'](!![]),expect(['low','medium','high'])['toContain'](a['risk_level']);});});