IDCG
# grade this stage (from your course directory)
npx theinference test --stage idcg --watchIDCG is the DCG of the ideal ranking — all relevant docs sorted to the very top. It is the largest DCG you could achieve, and it's what you divide by to turn a raw DCG into a 0–1 score (next step). Compute it by sorting the relevance values descending and DCG-ing them.
What to build
Implement idcgAtK
Implement idcgAtK(rels, k) in src/metrics.ts — rels is the multiset of all relevant docs' relevance values; sort it descending and dcgAtK it.
export function idcgAtK(rels: number[], k: number): number {
// dcgAtK(rels sorted descending, k)
}
adapter — allclose vs reference on a hand-built relevance list, atol=1e-6. Reuse the dcgAtK you just wrote on the sorted list.
With binary relevance (every relevant doc has value 1), sorting descending just front-loads all the 1s. So IDCG@k for a query with m relevant docs is Σ_{i=0..min(m,k)-1} 1/log₂(i+2) — the best you could possibly score.