Skip to content

feat(eval): per-query kind targeting infra (opt-in; honest negative on NDCG)#4

Merged
kitfunso merged 1 commit into
masterfrom
feat/per-query-kind-targeting
May 23, 2026
Merged

feat(eval): per-query kind targeting infra (opt-in; honest negative on NDCG)#4
kitfunso merged 1 commit into
masterfrom
feat/per-query-kind-targeting

Conversation

@kitfunso

Copy link
Copy Markdown
Owner

Summary

A2's first remediation candidate (per-query kind targeting from v2-golden.json) is implemented as opt-in infrastructure and ships with an honest negative result: per-query targeting is better than the previously-tested global kind filter (PR #3) but still drops NDCG@3 on both corpora vs no filter.

Approach 434 NDCG@3 10k NDCG@3
No kind filter (A1/A2 baselines) 0.7296 0.3139
Global `kind=tool` (PR #3, rejected) 0.6765 0.2472
Per-query kind targeting (this PR, opt-in) 0.7062 0.2844

Why it drops (the structural issue)

A1's relevance maps were graded without kind awareness. Some queries' relevance maps include skills/subagents at rel=1 or rel=2 — judges rated cross-kind candidates as "related" or "acceptable". Any kind-restrictive retrieval excludes those incidental hits and loses NDCG points.

What ships

  • `tests/fixtures/v2-golden.json` — `expected_kind` field added to every query (90 tool / 4 skill / 3 subagent / 3 no-kind for adversarial)
  • `tests/schemas/v2-golden.schema.json` — enum extension
  • `scripts/smoke/v2-golden-v2native.ts` — `--per-query-kind` flag (opt-in; default off preserves A1's 0.7296 baseline byte-identically)
  • `docs/perf/10k-benchmark.md` — comparison table + structural-issue explanation + next-remediation pointer

Backward compatibility verified: `npm run eval:golden` against 434 corpus = 0.7296 unchanged. A1 CI gate unaffected.

What this enables for future episodes

The infrastructure is the prerequisite for the real fix path: re-grade the relevance maps with kind-restricted candidate pools so each query's relevance map only contains entries of `expected_kind`. That episode is bigger (re-run the judge ensemble) but with the schema + runner already in place, it's mechanical.

Independent next candidate

`reliability_score` post-filter or third RRF arm (A2 open item #2). Doesn't depend on kind. Addresses the synthetic-tool dilution half of the scale-break.

Test plan

  • CI green (`golden` workflow schema-lints the v2-golden.json with the new enum field; should pass)
  • Locally: `npm run typecheck` clean
  • Locally: `npm run eval:golden` against 434 corpus still produces 0.7296 (backward-compat)
  • Locally: `npm run eval:golden -- --per-query-kind` produces 0.7062 (documented behavior)

🤖 Generated with Claude Code

…egative result)

Adds expected_kind field to every v2-golden.json query (90 tool, 4 skill, 3
subagent, 3 no-kind for adversarial), extends the schema enum, and supports
passing q.expected_kind to discover() in the runner — gated behind a new
--per-query-kind flag so default behaviour (and A1's CI gate) is unchanged.

Result documented in docs/perf/10k-benchmark.md: per-query kind targeting
is better than a global kind=tool filter but still drops NDCG@3 on both
corpora vs no filter:

  434 corpus: 0.7296 → 0.7062 (still trips A1 CI floor)
  10k corpus: 0.3139 → 0.2844

Why it drops: A1's relevance maps include cross-kind incidental grades
(judges rated some skills/subagents as rel=1 or rel=2 for tool-targeted
queries). Any kind filter excludes those hits and loses NDCG points.

The infrastructure is correct and ships; making per-query kind targeting
a positive remediation requires re-grading the relevance maps with
kind-restricted candidate pools — a larger follow-up episode (re-run the
judge ensemble with kind-aware candidate sourcing).

Default eval:golden behavior unchanged: 434 corpus produces 0.7296,
matches v2-baseline-native.json byte-identically. CI gate unaffected.

Next remediation candidate (independent of kind):
  - reliability_score post-filter or third RRF arm (A2 open item #2)
  - Phase 2 D (Postgres + pgvector) with HNSW + filter-pushdown

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kitfunso kitfunso merged commit 5257ee9 into master May 23, 2026
1 check passed
@kitfunso kitfunso deleted the feat/per-query-kind-targeting branch May 23, 2026 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant