#!/usr/bin/env python3 """Smoke-test the 3-channel RRF sidecar.""" import json import urllib.request def call(query, limit=5): req = urllib.request.Request( "http://127.0.0.1:4380/recall", data=json.dumps({"query": query, "limit": limit}).encode(), headers={"content-type": "application/json"}, ) with urllib.request.urlopen(req, timeout=60) as r: return json.loads(r.read()) def show(label, query): print(f"\n=== {label}: query={query!r} ===") try: r = call(query, 5) except Exception as e: print(f"ERROR: {e}") return print(f"phase={r.get('phase')} fused_count={r.get('fused_count')} returned={r.get('returned')}") print(f"channels={r.get('channels')}") if r.get('channel_errors'): print(f"channel_errors={r.get('channel_errors')}") for i, h in enumerate(r.get('hits', [])[:5]): urn = h['urn'][:60] bc = h.get('by_channel', {}) ranks = {k: v.get('rank') for k, v in bc.items()} scores = {k: round(v.get('score', 0), 3) if v.get('score') is not None else None for k, v in bc.items()} score = round(h['score'], 4) print(f" #{h['rrf_rank']} score={score} urn={urn}... via={ranks} scores={scores}") show("Test 1 (entity-rich)", "DNS2 ollama") show("Test 2 (graph-hostile)", "supercalifragilistic") show("Test 3 (single entity)", "Triangles") show("Test 4 (zero entity)", "the and of")