Skip to content

armgit / xerj

Public Imported from GitHub
0

AI search engine and MCP server for bots and agents. One Rust binary indexes code, docs, logs, JSONL/CSV and PDFs for BM25 full-text, vector and hybrid search, code search without grep, agent memory and RAG. Elasticsearch-compatible API; Corpus Hub serves hundreds of reference memory corpora.

beir-hybrid: local-judge gate #1060 measured — FAIL on quality, PASS on cost

xerj-orga6c00e8dc651
diff --git a/benchmarks/beir-hybrid/README.md b/benchmarks/beir-hybrid/README.md
index e7b3db1ef..b6124fb3e 100644
--- a/benchmarks/beir-hybrid/README.md
+++ b/benchmarks/beir-hybrid/README.md
@@ -14,6 +14,26 @@ default settings. Metric: nDCG@10 on each dataset's BEIR `test` split, computed
Raw output: [`results/`](./results).
+## The local-judge gate (#1060) — MEASURED 2026-09-30: FAIL on quality, PASS on cost
+
+The rc.80 gate for the opt-in local `judge` stage (PR #1077), on the release
+binary `xerj v1.0.0-rc.78`, same harness protocol (3 runs, shuffled order,
+post-#940 deterministic path — every arm reproduced to the fourth decimal):
+
+| Gate row (issue #1060, verbatim) | Measured | Verdict |
+|---|---|---|
+| beats hybrid 0.699 SciFact by more than the 3-run spread | hybrid+judge **0.5967** vs hybrid **0.7045** (spread 0.0000) — loses by 0.1077 | **FAIL** |
+| beats hybrid 0.345 NFCorpus by more than the 3-run spread | hybrid+judge **0.2924** vs hybrid **0.3419** (spread 0.0000) — loses by 0.0495 | **FAIL** |
+| FiQA ≥ 0.30 (hosted Jev rerank 0.3638) | bm25+judge **0.1650** (vs BM25 0.2382) | **FAIL** |
+| adds ≤ 40 ms p50 for top-30 on CPU | **+0.7 / +0.5 / +0.6 ms** added p50 (SciFact / NFCorpus / FiQA), node pinned to 8 cores; server-side `judged.took_ms` p50 0 ms | **PASS** |
+
+The always-compiled judge is a lexical scorer with no semantic signal, and it
+loses to both first stages on all three datasets. Per the gate's own rule the
+stage stays opt-in and unnamed-by-default — no quality claim ships with it.
+Full analysis, run logs and sha256s:
+[`results/2026-09-30-judge-gate/`](./results/2026-09-30-judge-gate/);
+harness: [`judge_gate.py`](./judge_gate.py).
+
## What this says
1. **Hybrid is the best arm XERJ has, on both datasets, and it already ships.** No new
diff --git a/benchmarks/beir-hybrid/judge_gate.py b/benchmarks/beir-hybrid/judge_gate.py
new file mode 100644
index 000000000..5fbe84522
--- /dev/null
+++ b/benchmarks/beir-hybrid/judge_gate.py
@@ -0,0 +1,216 @@
+"""Local-judge gate harness (issue #1060) — nDCG@10 of the shipped first stages
+with and without the opt-in `judge` block, plus the judge's added latency.
+
+Everything printed comes from a query against a live node; nothing is assumed.
+
+Usage:
+ XERJ_URL=http://localhost:<port> python3 judge_gate.py <dataset_dir> <index> quality [runs]
+ XERJ_URL=http://localhost:<port> python3 judge_gate.py <dataset_dir> <index> latency
+
+`dataset_dir` is an extracted BEIR dataset directory (corpus.jsonl is not read
+here, only queries.jsonl and qrels/test.tsv). Quality mode runs each arm
+`runs` times (default 3) with the query order shuffled per run, mirroring the
+protocol of results/2026-09-20-rerank-full. Latency mode times the same
+hybrid top-30 request with and without the judge block, both carrying `_source`
+so the only difference is the stage.
+
+Arms (quality):
+ bm30 BM25 `multi_match` top-30, no judge (first stage alone)
+ bm30+judge BM25 top-30, judged (query inferred) (hosted-Jev shape)
+ hy30 `hybrid` RRF top-30, no judge (THE bar: 0.699/0.345)
+ hy30+judge `hybrid` RRF top-30, judged (`judge.query`) (the gate arm)
+
+The judge block carries NO `min_p` in the gate arms: it reorders and drops
+nothing, which is the arm a quality gate must measure (a threshold can only
+remove recall). `--min-p <p>` adds a pruned informational arm instead of
+replacing these.
+"""
+import json, math, sys, time, random, urllib.request, urllib.error, collections, os
+
+U = os.environ.get("XERJ_URL", "http://localhost:9410")
+DS = sys.argv[1]
+IDX = sys.argv[2]
+MODE = sys.argv[3] if len(sys.argv) > 3 else "quality"
+RUNS = int(sys.argv[4]) if len(sys.argv) > 4 else 3
+MINP = None
+if "--min-p" in sys.argv:
+ MINP = float(sys.argv[sys.argv.index("--min-p") + 1])
+SIZE = 30
+
+
+def post(p, b):
+ r = urllib.request.Request(U + p, data=json.dumps(b).encode(), method="POST",
+ headers={"content-type": "application/json"})
+ try:
+ return json.loads(urllib.request.urlopen(r, timeout=300).read())
+ except urllib.error.HTTPError as e:
+ return {"_err": e.code, "body": e.read().decode()[:300]}
+
+
+queries = {}
+for l in open(DS + "/queries.jsonl"):
+ d = json.loads(l)
+ queries[d["_id"]] = d["text"]
+qrels = collections.defaultdict(dict)
+for i, l in enumerate(open(DS + "/qrels/test.tsv")):
+ if i == 0:
+ continue
+ q, d, s = l.split("\t")
+ qrels[q][d] = int(s)
+
+
+def ndcg10(ranked, rel):
+ dcg = sum(rel.get(d, 0) / math.log2(i + 2) for i, d in enumerate(ranked[:10]))
+ ideal = sorted(rel.values(), reverse=True)[:10]
+ idcg = sum(g / math.log2(i + 2) for i, g in enumerate(ideal))
+ return dcg / idcg if idcg else 0.0
+
+
+def ids(res):
+ if "_err" in res:
+ raise SystemExit(f"request failed: {res}")
+ return [h["_id"] for h in res.get("hits", {}).get("hits", [])]
+
+
+BM = lambda q: {"multi_match": {"query": q, "fields": ["title", "text"]}}
+SEM = lambda q: {"semantic": {"field": "body", "query": q}}
+HYB = lambda q: {"hybrid": {"queries": [{"query": BM(q)}, {"query": SEM(q)}], "fusion": "rrf"}}
+
+
+def bm30(q):
+ return ids(post(f"/{IDX}/_search", {"size": SIZE, "_source": False, "query": BM(q)}))
+
+
+def hy30(q):
+ return ids(post(f"/{IDX}/_search", {"size": SIZE, "_source": False, "query": HYB(q)}))
+
+
+def judged(q, first, min_p=None):
+ judge = {"local": True}
+ if first == "bm25":
+ body_q = BM(q) # multi_match is an inferable shape
+ else:
+ body_q = HYB(q) # hybrid is not: judge.query is required
+ judge["query"] = q
+ if min_p is not None:
+ judge["min_p"] = min_p
+ r = post(f"/{IDX}/_search", {"size": SIZE, "query": body_q, "judge": judge})
+ if "_err" in r:
+ raise SystemExit(f"judged request failed: {r}")
+ j = r.get("judged", {})
+ if not j.get("applied"):
+ raise SystemExit(f"judge not applied: {json.dumps(j)[:200]}")
+ return (ids(r), j)
+
+
+ARMS = {
+ "bm30": lambda q: (bm30(q), None),
+ "hy30": lambda q: (hy30(q), None),
+ "bm30+judge": lambda q: judged(q, "bm25"),
+ "hy30+judge": lambda q: judged(q, "hybrid"),
+}
+if os.environ.get("ARMS"): # restrict to the named arms, e.g. ARMS=bm30,bm30+judge
+ keep = set(os.environ["ARMS"].split(","))
+ ARMS = {k: v for k, v in ARMS.items() if k in keep}
+if MINP is not None:
+ ARMS[f"hy30+judge min_p={MINP}"] = lambda q: judged(q, "hybrid", MINP)
+
+qids = list(qrels.keys())
+if os.environ.get("LIMIT"): # harness-validation subset; NOT a measurement
+ qids = qids[: int(os.environ["LIMIT"])]
+print(f"index={IDX} queries={len(qids)} mode={MODE} size={SIZE} url={U}")
+print(f"docs={post('/' + IDX + '/_count', {}).get('count')}")
+
+if MODE == "quality":
+ summary = {}
+ per_query = {}
+ for run in range(1, RUNS + 1):
+ order = qids[:]
+ random.Random(1000 + run).shuffle(order)
+ for name, fn in ARMS.items():
+ scores, empties, took, kept, dropped = [], 0, [], [], []
+ for qid in order:
+ t0 = time.time()
+ ranked, j = fn(queries[qid])
+ dt = time.time() - t0
+ if not ranked:
+ empties += 1
+ scores.append(ndcg10(ranked, qrels[qid]))
+ if j:
+ took.append(j.get("took_ms", 0))
+ kept.append(j.get("kept", 0))
+ dropped.append(j.get("dropped", 0))
+ per_query.setdefault((name, qid), []).append((ndcg10(ranked, qrels[qid]), dt))
+ m = sum(scores) / len(scores)
+ summary.setdefault(name, []).append(m)
+ took_s = sorted(took)
+ line = f"run {run} {name:24s} nDCG@10={m:.4f} empty={empties:3d}"
+ if took:
+ line += (f" judge_took_ms_p50={took_s[len(took_s) // 2]} "
+ f"kept_avg={sum(kept) / len(kept):.1f} dropped_avg={sum(dropped) / len(dropped):.1f}")
+ print(line, flush=True)
+ print("\n== per-arm means over runs, spread, and head-to-head vs hy30 ==")
+ results = {}
+ for name, means in summary.items():
+ spread = max(means) - min(means)
+ results[name] = {"runs": means, "mean": sum(means) / len(means), "spread": spread}
+ print(f"{name:26s} runs={' '.join(f'{m:.4f}' for m in means)} mean={sum(means)/len(means):.4f} spread={spread:.4f}")
+ # head-to-head per query (run-mean per query), hy30 vs hy30+judge
+ for a, b in (("hy30", "hy30+judge"), ("bm30", "bm30+judge")):
+ if not all((a, qid) in per_query and (b, qid) in per_query for qid in qids):
+ print(f"{b} vs {a}: skipped (an arm was not run — ARMS filter?)")
+ continue
+ w = l = t = 0
+ deltas = []
+ for qid in qids:
+ va = sum(v for v, _ in per_query[(a, qid)]) / RUNS
+ vb = sum(v for v, _ in per_query[(b, qid)]) / RUNS
+ if vb > va:
+ w += 1
+ elif vb < va:
+ l += 1
+ else:
+ t += 1
+ deltas.append(vb - va)
+ print(f"{b} vs {a}: W/L/T = {w}/{l}/{t} mean per-query delta={sum(deltas)/len(deltas):+.4f}")
+elif MODE == "latency":
+ # Both arms identical except the judge block: same query, same size, both
+ # with _source rendered (the judge refuses _source:false with no fields).
+ FIRST = os.environ.get("FIRST", "hybrid") # "hybrid" or "bm25"
+ FIRSTQ = HYB if FIRST == "hybrid" else BM
+ JUDGE_Q = lambda q: ({"local": True, "query": q} if FIRST == "hybrid"
+ else {"local": True})
+
+ def base(q):
+ t0 = time.time()
+ post(f"/{IDX}/_search", {"size": SIZE, "query": FIRSTQ(q)})
+ return time.time() - t0
+
+ def jud(q):
+ t0 = time.time()
+ r = post(f"/{IDX}/_search", {"size": SIZE, "query": FIRSTQ(q),
+ "judge": JUDGE_Q(q)})
+ dt = time.time() - t0
+ if "_err" in r or not r.get("judged", {}).get("applied"):
+ raise SystemExit(f"judged request failed: {json.dumps(r)[:200]}")
+ return dt, r["judged"].get("took_ms", 0)
+
+ warm = qids[:30]
+ for qid in warm:
+ base(queries[qid]); jud(queries[qid])
+ b, j, took = [], [], []
+ for qid in qids:
+ b.append(base(queries[qid]))
+ dt, ms = jud(queries[qid])
+ j.append(dt)
+ took.append(ms)
+ for name, arr in (("base wall s", b), ("judged wall s", j), ("judge took_ms", took)):
+ arr.sort()
+ p = lambda q: arr[min(int(len(arr) * q), len(arr) - 1)]
+ print(f"{name:16s} p50={p(0.5) * (1000 if 'wall' in name else 1):7.1f} "
+ f"p95={p(0.95) * (1000 if 'wall' in name else 1):7.1f}")
+ bd, jd = sorted(b), sorted(j)
+ p50d = (jd[len(jd) // 2] - bd[len(bd) // 2]) * 1000
+ print(f"added p50 (judged wall - base wall, per-set p50s) = {p50d:.1f} ms")
+ dq = sorted(jx - bx for bx, jx in zip(b, j))
+ print(f"added p50 (per-query delta distribution) = {dq[len(dq)//2]*1000:.1f} ms")
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/README.md b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/README.md
new file mode 100644
index 000000000..e5fec6ea2
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/README.md
@@ -0,0 +1,93 @@
+# Local-judge gate — 2026-09-30: the lexical judge LOSES, and that is the number
+
+The rc.80 release gate for issue #1060's zero-token rerank, measured on the
+release binary (`xerj v1.0.0-rc.78`, main @ a179e1ef3, the staged rc.80-gates
+build — see `manifest.txt`). **Verdict: FAIL on the quality gate, PASS on the
+cost line.** The gate's own rule — "Loses, does not ship, same rule as the
+cross-encoder" — means the judge stays what PR #1077 shipped it as: opt-in,
+named `lexical` in every response, with no quality claim. Nothing was tuned to
+move these numbers: the gate arms carry **no `min_p`** (reorder-only — a
+threshold can only remove recall, so it cannot be part of a passing attempt).
+
+## The gate line, and what measured against it
+
+| Gate row (verbatim from #1060) | Measured | Verdict |
+|---|---|---|
+| beats hybrid 0.699 SciFact by more than the 3-run spread | hybrid+judge **0.5967** vs measured hybrid 0.7045 (spread 0.0000); −0.1077, W/L/T 32/99/169 | **FAIL** |
+| beats hybrid 0.345 NFCorpus by more than the 3-run spread | hybrid+judge **0.2924** vs measured hybrid 0.3419 (spread 0.0000); −0.0495, W/L/T 60/126/137 | **FAIL** |
+| FiQA ≥ 0.30 (hosted Jev rerank 0.3638) | bm25+judge **0.1650** vs the 0.30 bar (and vs BM25 0.2382, −0.0732). hybrid+judge not measured: the hybrid first stage itself runs 13–26 s/query on the 57,638-doc index ([fiqa-quality-aborted.log](./fiqa-quality-aborted.log)); the FiQA row is measured on the BM25 top-30 shortlist, the same first stage the hosted 0.3638 reference used | **FAIL** |
+| adds ≤ 40 ms p50 for top-30 on CPU | **+0.7 ms** SciFact / **+0.5 ms** NFCorpus / **+0.6 ms** FiQA added p50 (node pinned to 8 cores, client on the other 8); server-side `judged.took_ms` p50 **0 ms** on every dataset | **PASS** |
+
+Full per-run output: `scifact-quality.log`, `nfcorpus-quality.log`,
+`fiqa-quality.log`, `*-latency.log` in this directory; setup, sha256s and core
+pinning in `manifest.txt`; harness is [`judge_gate.py`](../../judge_gate.py).
+
+## Headline numbers (nDCG@10, 3 runs each, size-30 pages)
+
+| Arm | SciFact (300 q) | NFCorpus (323 q) | FiQA (648 q) |
+|---|---:|---:|---:|
+| bm25 top-30 | 0.6572 | 0.3016 (25 empty) | 0.2382 |
+| **hybrid top-30 (the bar)** | **0.7045** | **0.3419** | not measured (26 s/query) |
+| bm25 top-30 + judge | 0.5966 | 0.2827 | 0.1650 |
+| hybrid top-30 + judge | 0.5967 | 0.2924 | n/a (see above) |
+
+Every arm reproduced to the fourth decimal across its 3 runs (spread 0.0000)
+— the post-#940 deterministic path is deterministic on this binary, exactly as
+the gate assumed. The BM25 arms reproduce the 2026-09-18 baseline runs
+bit-for-bit (0.6572 / 0.3016 / 0.2382), which validates the harness against
+the recorded numbers; the hybrid arm on this binary measures 0.7045 / 0.3419
+against the rc.74-era 0.6993–0.7044 / 0.3446–0.3450 (same band on SciFact,
+−0.003 on NFCorpus). The gate is judged against **like-for-like hybrids
+measured in the same runs on the same node** — a stricter comparison than the
+recorded bar, and it loses by more either way.
+
+## Why it loses, plainly
+
+The always-compiled judge is a **lexical scorer** — window-local BM25
+saturation with page-local IDF, no semantic signal (`xerj-rerank/src/judge.rs`
+says so in its own docstring). Both first stages already read those words:
+BM25 ranked by them, and hybrid fused them with MiniLM vectors. Re-reading the
+same words over the page with page-local statistics destroys information the
+first stages had — corpus-level IDF and the vector arm — so the judged order
+is a worse order. The effect is biggest exactly where the first stage is
+strongest: on SciFact the judge gives back 10.8 points of the hybrid's lead;
+on NFCorpus 5.0; even on BM25-only shortlists the judge is a regression
+(−0.0605 SciFact, −0.0189 NFCorpus).
+
+This is the same finding the 2026-09-18 run recorded for "BM25 top-30 →
+reorder by MiniLM" (worse than fusing), one step further: **a second stage
+that re-reads what the first stage already read is not worth running, from
+either direction.** A local judge that ships needs the model arm (the
+`decide-local` cross-encoder head), and it will have to beat these same
+hybrid numbers under this same harness.
+
+## The cost line, measured
+
+The judge adds **+0.7 ms p50** (SciFact) and **+0.5 ms p50** (NFCorpus) to a
+~0.9 s hybrid query on a node pinned to 8 cores — wall-clock, client pinned to
+the other 8, one warmup pass first; the box carried co-tenant load throughout
+(other rc.80 gate agents, and during the FiQA / late-NFCorpus window a runaway
+client of this very run — manifest incident 2), so treat the absolute query
+times as upper bounds (the
+unjudged hybrid alone measured 220–370 ms p50 on an idle 32-thread box in the
+2026-09-18 run). The response's own `judged.took_ms` reports p50 0 ms on
+every dataset: the lexical scorer is sub-millisecond for a top-30 page of
+~150–200-word abstracts. FiQA (longer documents): see `fiqa-latency.log` —
+**+0.6 ms p50** added (BM25 top-30 base 0.8 s, judged 1.4 s wall — the base is dominated by `_source` rendering of 30 long forum posts, not the judge), `judged.took_ms` p50 0 ms.
+
+## What a caller gets for the tokens
+
+The feature's value line is "fewer irrelevant passages enter the context
+window" — that is a threshold story, not a ranking story, and the ranking
+numbers above say nothing about it. For the record, one informational arm with
+`min_p` set (0.5, chosen once, not tuned): hybrid+judge with `min_p: 0.5` scores **0.0767** SciFact (kept 0.1 of 30 hits per page; 274 of 300 queries return an EMPTY page) and **0.1737** NFCorpus (kept 2.8; 176 of 323 empty) — `scifact-minp05.log`, `nfcorpus-minp05.log`. The lexical scale is a share-of-maximum-saturation, not a calibrated probability: on these corpora almost every hit scores below 0.5, so a round-number threshold deletes the page. A caller who wants the pruning behaviour must calibrate `min_p` against their own corpus, and the response's `judged` block is the only honest way to see what a value does.
+
+## Reproduce
+
+```sh
+# datasets: see manifest.txt (sha256s); node on a private port in your band
+taskset -c 0-7 xerj --insecure --embed-mode neural --port <p> -d <throwaway> &
+python3 load.py scifact/corpus.jsonl scifact # + nfcorpus, + fiqa
+XERJ_URL=http://localhost:<p> python3 judge_gate.py scifact scifact quality 3
+XERJ_URL=http://localhost:<p> taskset -c 8-15 python3 judge_gate.py scifact scifact latency
+```
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-latency.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-latency.log
new file mode 100644
index 000000000..2f45270fa
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-latency.log
@@ -0,0 +1,7 @@
+index=fiqa queries=648 mode=latency size=30 url=http://localhost:9642
+docs=57638
+base wall s p50= 0.8 p95= 1.2
+judged wall s p50= 1.4 p95= 1.9
+judge took_ms p50= 0.0 p95= 0.0
+added p50 (judged wall - base wall, per-set p50s) = 0.6 ms
+added p50 (per-query delta distribution) = 0.6 ms
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality-aborted.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality-aborted.log
new file mode 100644
index 000000000..f1138ae2e
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality-aborted.log
@@ -0,0 +1,15 @@
+index=fiqa queries=648 mode=quality size=30 url=http://localhost:9642
+docs=57638
+run 1 bm30 nDCG@10=0.2382 empty= 0
+
+[aborted] Full-arm FiQA run stopped after run 1's bm30 arm: a probe measured
+the hybrid first stage itself at 13.7 / 26.0 / 26.2 s per query on the 57,638-doc
+index (8 pinned cores, box load 2.8/32, judged variant 26.5-27.1 s), so the
+4-arm x 3-run plan was ~28 h of wall. The FiQA gate row is measured on the
+BM25 top-30 shortlist — the same first stage the hosted-Jev 0.3638 reference
+used. Hybrid-vs-judged-hybrid remains measured on SciFact and NFCorpus, the
+two datasets the gate's hybrid bar was recorded on.
+Probe (3 queries, 2026-09-30 ~20:20 local):
+ hybrid 13.7 s hits 30 / hyb+judge 26.51 s took_ms 0
+ hybrid 26.02 s hits 30 / hyb+judge 27.12 s took_ms 0
+ hybrid 26.22 s hits 30 / hyb+judge 26.71 s took_ms 0
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality.log
new file mode 100644
index 000000000..dd8273ac9
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/fiqa-quality.log
@@ -0,0 +1,58 @@
+index=fiqa queries=648 mode=quality size=30 url=http://localhost:9642
+docs=57638
+run 1 bm30 nDCG@10=0.2382 empty= 0
+Traceback (most recent call last):
+ File "/usr/lib/python3.11/urllib/request.py", line 1348, in do_open
+ h.request(req.get_method(), req.selector, req.data, headers,
+ File "/usr/lib/python3.11/http/client.py", line 1302, in request
+ self._send_request(method, url, body, headers, encode_chunked)
+ File "/usr/lib/python3.11/http/client.py", line 1348, in _send_request
+ self.endheaders(body, encode_chunked=encode_chunked)
+ File "/usr/lib/python3.11/http/client.py", line 1297, in endheaders
+ self._send_output(message_body, encode_chunked=encode_chunked)
+ File "/usr/lib/python3.11/http/client.py", line 1057, in _send_output
+ self.send(msg)
+ File "/usr/lib/python3.11/http/client.py", line 995, in send
+ self.connect()
+ File "/usr/lib/python3.11/http/client.py", line 961, in connect
+ self.sock = self._create_connection(
+ ^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/socket.py", line 851, in create_connection
+ raise exceptions[0]
+ File "/usr/lib/python3.11/socket.py", line 836, in create_connection
+ sock.connect(sa)
+ConnectionRefusedError: [Errno 111] Connection refused
+
+During handling of the above exception, another exception occurred:
+
+Traceback (most recent call last):
+ File "/workspace/.claude/worktrees/wf_7ffac925-ac6-3/benchmarks/beir-hybrid/judge_gate.py", line 131, in <module>
+ scores, empties, took, kept, dropped = [], 0, [], [], []
+ ^^^^^^^^^^^^^^^^
+ File "/workspace/.claude/worktrees/wf_7ffac925-ac6-3/benchmarks/beir-hybrid/judge_gate.py", line 108, in <lambda>
+ "hy30": lambda q: (hy30(q), None),
+ ^^^^^^^
+ File "/workspace/.claude/worktrees/wf_7ffac925-ac6-3/benchmarks/beir-hybrid/judge_gate.py", line 85, in hy30
+ return ids(post(f"/{IDX}/_search", {"size": SIZE, "_source": False, "query": HYB(q)}))
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/workspace/.claude/worktrees/wf_7ffac925-ac6-3/benchmarks/beir-hybrid/judge_gate.py", line 45, in post
+ return json.loads(urllib.request.urlopen(r, timeout=300).read())
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 216, in urlopen
+ return opener.open(url, data, timeout)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 519, in open
+ response = self._open(req, data)
+ ^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 536, in _open
+ result = self._call_chain(self.handle_open, protocol, protocol +
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 496, in _call_chain
+ result = func(*args)
+ ^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 1377, in http_open
+ return self.do_open(http.client.HTTPConnection, req)
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ File "/usr/lib/python3.11/urllib/request.py", line 1351, in do_open
+ raise URLError(err)
+urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/manifest.txt b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/manifest.txt
new file mode 100644
index 000000000..537d9d2a4
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/manifest.txt
@@ -0,0 +1,78 @@
+Run manifest — local-judge gate #1060, measured 2026-09-30
+===========================================================
+
+Binary (NOT rebuilt; release binary staged for the rc.80 gate wave)
+ path /tmp/xerj-rc80gates-bin/xerj
+ version "xerj v1.0.0-rc.78" (release binary built from main @ a179e1ef3)
+ sha256 a95ed5f0f91e90fffe2e82a7a1c1057ab9639029ea7f43676cc61eddb88e5f76
+
+Datasets (BEIR canonical mirror, fetched fresh this run; zips sha256)
+ scifact.zip 536e14446a0ba56ed1398ab1055f39fe852686ecad24a6306c80c490fa8e0165
+ corpus.jsonl 5,183 docs (sha256 dec31c8182f3d744c7d2c09423756fd1d17cbef75808db13ba01cc0aab4f1ac6)
+ nfcorpus.zip efe5be03f8c5b86a5870102d0599d227c8c6c2444328e68c6522560385671b0b
+ corpus.jsonl 3,633 docs (sha256 10cc83ef1826b1425e6a87090b5140b39b27755d5a27e48215a88611c899991f)
+ fiqa.zip 32c7df99ed21252fdfb2cf3f5673502a8d245ee0c44c4a133570d92ce2b3ad02
+ corpus.jsonl 57,638 docs (sha256 ff593e4df9933955dc3af83be0c3fa28ac7465f627e08c2e53593e734d506517)
+ URL https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets/<name>.zip
+ test splits scored: queries.jsonl + qrels/test.tsv from each archive, verbatim.
+
+Node
+ xerj --insecure --embed-mode neural --port 9642 -d <throwaway mktemp dir under /tmp>
+ private port band 9640-9659 assigned to this task; :9200 never touched.
+ ALL measured numbers: node pinned to cores 0-7 (taskset -c 0-7).
+ Ingest was done on an unpinned instance of the same binary + data dir
+ (SciFact 4.7 docs/s pinned vs ~30 docs/s unpinned; ingest CPU cannot affect
+ query-time ranking or judge latency, and post-#940 ranking is deterministic
+ across restarts — verified below by 3 identical runs per arm).
+ Latency runs: python client pinned to cores 8-15 so it never competes with
+ the node for the measured cores.
+ Co-tenant load: other rc.80 gate agents were measuring on the same 32-core
+ box during these runs — wall-clock absolute values are upper bounds; the
+ judge-vs-base DELTA is the measurement that matters and is sub-ms.
+
+Index mapping (load.py, unchanged from the hybrid baseline runs)
+ title: text, text: text, body: semantic_text (body = title + ". " + text)
+ Note for reproducers: the judged page carries _source with BOTH `text` and
+ `body` (the semantic field duplicates the prose), so the judge's candidate
+ text contains the document twice, cut at DEFAULT_MAX_DOC_CHARS. That is the
+ shipped behaviour of the stage reading the response as emitted; it was not
+ tuned for this run.
+
+Harness
+ judge_gate.py (new, this directory's parent) — same qrels/nDCG@10 scoring as
+ eval.py; arms bm30 / hy30 / bm30+judge / hy30+judge, size=30, 3 runs with
+ query order shuffled per run (seeds 1001..1003). The judge block carries NO
+ min_p in the gate arms (reorder-only; a threshold can only remove recall).
+ hy30+judge passes judge.query explicitly (a `hybrid` query is not an
+ inferable shape); bm30+judge exercises the inference path (multi_match).
+
+Gate line, verbatim from #1060
+ "BEIR harness on the post-#940 deterministic path beats hybrid 0.699
+ SciFact / 0.345 NFCorpus by more than the 3-run spread, and FiQA >=0.30
+ (hosted Jev rerank got 0.3638). Loses, does not ship, same rule as the
+ cross-encoder."
+ AC cost line: "adds <=40 ms p50 for top-30 on CPU."
+
+Incidents during the run (recorded, none change a gate number)
+ 1. The pinned node received an external SIGTERM at 19:28:31 local, after all
+ quality and latency logs in this directory were already written; it shut
+ down cleanly ("final flush complete in 445ms"). A restarted instance on
+ the same data dir reproduced every SciFact and NFCorpus arm bit-for-bit
+ (scifact-minp05.log / nfcorpus-minp05.log re-measure all four base arms
+ after the restart: 0.6572/0.7045/0.5966/0.5967 and
+ 0.3016/0.3419/0.2827/0.2924) — post-#940 determinism holds across
+ restarts, not just across runs.
+ 2. A first full-arm FiQA run was stopped when the hybrid first stage
+ measured 13-26 s wall per query on the 57,638-doc index (server-side
+ slow-query log: 14.7-15.1 s). Its python client survived the stop and
+ kept issuing queries until it was killed; the FiQA bm25-arm logs were
+ measured on the same node while that runaway was running, so FiQA
+ wall-clock absolutes are upper bounds. nDCG@10 is unaffected (ranking is
+ deterministic and was reproduced identically 3x), and the added-p50
+ delta (+0.6 ms) is a within-request difference measured under the same
+ contention in both arms.
+ 3. An early two-processes-one-data-dir mistake (old pinned node + new
+ unpinned node, lock file removed by hand) lasted ~30 s and was resolved
+ by SIGKILL of the old process + clean restart before ANY measurement;
+ SciFact's index replayed from WAL and counted 5,183 both before and
+ after. No measurement ran against the contended state.
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-latency.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-latency.log
new file mode 100644
index 000000000..716fee86e
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-latency.log
@@ -0,0 +1,7 @@
+index=nfcorpus queries=323 mode=latency size=30 url=http://localhost:9642
+docs=3633
+base wall s p50= 0.9 p95= 1.1
+judged wall s p50= 1.4 p95= 1.7
+judge took_ms p50= 0.0 p95= 0.0
+added p50 (judged wall - base wall, per-set p50s) = 0.5 ms
+added p50 (per-query delta distribution) = 0.5 ms
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-minp05.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-minp05.log
new file mode 100644
index 000000000..3cd972bd6
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-minp05.log
@@ -0,0 +1,26 @@
+index=nfcorpus queries=323 mode=quality size=30 url=http://localhost:9642
+docs=3633
+run 1 bm30 nDCG@10=0.3016 empty= 25
+run 1 hy30 nDCG@10=0.3419 empty= 0
+run 1 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 1 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+run 1 hy30+judge min_p=0.5 nDCG@10=0.1737 empty=176 judge_took_ms_p50=0 kept_avg=2.8 dropped_avg=21.8
+run 2 bm30 nDCG@10=0.3016 empty= 25
+run 2 hy30 nDCG@10=0.3419 empty= 0
+run 2 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 2 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+run 2 hy30+judge min_p=0.5 nDCG@10=0.1737 empty=176 judge_took_ms_p50=0 kept_avg=2.8 dropped_avg=21.8
+run 3 bm30 nDCG@10=0.3016 empty= 25
+run 3 hy30 nDCG@10=0.3419 empty= 0
+run 3 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 3 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+run 3 hy30+judge min_p=0.5 nDCG@10=0.1737 empty=176 judge_took_ms_p50=0 kept_avg=2.8 dropped_avg=21.8
+
+== per-arm means over runs, spread, and head-to-head vs hy30 ==
+bm30 runs=0.3016 0.3016 0.3016 mean=0.3016 spread=0.0000
+hy30 runs=0.3419 0.3419 0.3419 mean=0.3419 spread=0.0000
+bm30+judge runs=0.2827 0.2827 0.2827 mean=0.2827 spread=0.0000
+hy30+judge runs=0.2924 0.2924 0.2924 mean=0.2924 spread=0.0000
+hy30+judge min_p=0.5 runs=0.1737 0.1737 0.1737 mean=0.1737 spread=0.0000
+hy30+judge vs hy30: W/L/T = 60/126/137 mean per-query delta=-0.0495
+bm30+judge vs bm30: W/L/T = 65/97/161 mean per-query delta=-0.0189
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-quality.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-quality.log
new file mode 100644
index 000000000..e144c394e
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/nfcorpus-quality.log
@@ -0,0 +1,22 @@
+index=nfcorpus queries=323 mode=quality size=30 url=http://localhost:9642
+docs=3633
+run 1 bm30 nDCG@10=0.3016 empty= 25
+run 1 hy30 nDCG@10=0.3419 empty= 0
+run 1 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 1 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+run 2 bm30 nDCG@10=0.3016 empty= 25
+run 2 hy30 nDCG@10=0.3419 empty= 0
+run 2 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 2 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+run 3 bm30 nDCG@10=0.3016 empty= 25
+run 3 hy30 nDCG@10=0.3419 empty= 0
+run 3 bm30+judge nDCG@10=0.2827 empty= 25 judge_took_ms_p50=0 kept_avg=22.2 dropped_avg=0.0
+run 3 hy30+judge nDCG@10=0.2924 empty= 0 judge_took_ms_p50=0 kept_avg=24.7 dropped_avg=0.0
+
+== per-arm means over runs, spread, and head-to-head vs hy30 ==
+bm30 runs=0.3016 0.3016 0.3016 mean=0.3016 spread=0.0000
+hy30 runs=0.3419 0.3419 0.3419 mean=0.3419 spread=0.0000
+bm30+judge runs=0.2827 0.2827 0.2827 mean=0.2827 spread=0.0000
+hy30+judge runs=0.2924 0.2924 0.2924 mean=0.2924 spread=0.0000
+hy30+judge vs hy30: W/L/T = 60/126/137 mean per-query delta=-0.0495
+bm30+judge vs bm30: W/L/T = 65/97/161 mean per-query delta=-0.0189
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-latency.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-latency.log
new file mode 100644
index 000000000..46138aeb1
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-latency.log
@@ -0,0 +1,7 @@
+index=scifact queries=300 mode=latency size=30 url=http://localhost:9642
+docs=5183
+base wall s p50= 0.9 p95= 1.3
+judged wall s p50= 1.6 p95= 2.1
+judge took_ms p50= 0.0 p95= 0.0
+added p50 (judged wall - base wall, per-set p50s) = 0.7 ms
+added p50 (per-query delta distribution) = 0.7 ms
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-minp05.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-minp05.log
new file mode 100644
index 000000000..56dcd1c7e
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-minp05.log
@@ -0,0 +1,26 @@
+index=scifact queries=300 mode=quality size=30 url=http://localhost:9642
+docs=5183
+run 1 bm30 nDCG@10=0.6572 empty= 0
+run 1 hy30 nDCG@10=0.7045 empty= 0
+run 1 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 1 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 1 hy30+judge min_p=0.5 nDCG@10=0.0767 empty=274 judge_took_ms_p50=0 kept_avg=0.1 dropped_avg=29.9
+run 2 bm30 nDCG@10=0.6572 empty= 0
+run 2 hy30 nDCG@10=0.7045 empty= 0
+run 2 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 2 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 2 hy30+judge min_p=0.5 nDCG@10=0.0767 empty=274 judge_took_ms_p50=0 kept_avg=0.1 dropped_avg=29.9
+run 3 bm30 nDCG@10=0.6572 empty= 0
+run 3 hy30 nDCG@10=0.7045 empty= 0
+run 3 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 3 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 3 hy30+judge min_p=0.5 nDCG@10=0.0767 empty=274 judge_took_ms_p50=0 kept_avg=0.1 dropped_avg=29.9
+
+== per-arm means over runs, spread, and head-to-head vs hy30 ==
+bm30 runs=0.6572 0.6572 0.6572 mean=0.6572 spread=0.0000
+hy30 runs=0.7045 0.7045 0.7045 mean=0.7045 spread=0.0000
+bm30+judge runs=0.5966 0.5966 0.5966 mean=0.5966 spread=0.0000
+hy30+judge runs=0.5967 0.5967 0.5967 mean=0.5967 spread=0.0000
+hy30+judge min_p=0.5 runs=0.0767 0.0767 0.0767 mean=0.0767 spread=0.0000
+hy30+judge vs hy30: W/L/T = 32/99/169 mean per-query delta=-0.1077
+bm30+judge vs bm30: W/L/T = 28/74/198 mean per-query delta=-0.0605
diff --git a/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-quality.log b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-quality.log
new file mode 100644
index 000000000..1d54e6c56
--- /dev/null
+++ b/benchmarks/beir-hybrid/results/2026-09-30-judge-gate/scifact-quality.log
@@ -0,0 +1,22 @@
+index=scifact queries=300 mode=quality size=30 url=http://localhost:9642
+docs=5183
+run 1 bm30 nDCG@10=0.6572 empty= 0
+run 1 hy30 nDCG@10=0.7045 empty= 0
+run 1 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 1 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 2 bm30 nDCG@10=0.6572 empty= 0
+run 2 hy30 nDCG@10=0.7045 empty= 0
+run 2 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 2 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 3 bm30 nDCG@10=0.6572 empty= 0
+run 3 hy30 nDCG@10=0.7045 empty= 0
+run 3 bm30+judge nDCG@10=0.5966 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+run 3 hy30+judge nDCG@10=0.5967 empty= 0 judge_took_ms_p50=0 kept_avg=30.0 dropped_avg=0.0
+
+== per-arm means over runs, spread, and head-to-head vs hy30 ==
+bm30 runs=0.6572 0.6572 0.6572 mean=0.6572 spread=0.0000
+hy30 runs=0.7045 0.7045 0.7045 mean=0.7045 spread=0.0000
+bm30+judge runs=0.5966 0.5966 0.5966 mean=0.5966 spread=0.0000
+hy30+judge runs=0.5967 0.5967 0.5967 mean=0.5967 spread=0.0000
+hy30+judge vs hy30: W/L/T = 32/99/169 mean per-query delta=-0.1077
+bm30+judge vs bm30: W/L/T = 28/74/198 mean per-query delta=-0.0605