Skip to content

docs(openspec): plan #1928 Rank the benchmark with numpy and pytrec_eval - #5422

Merged
dan-petty merged 3 commits into
mainfrom
refactor/1928-rank-the-benchmark-with-numpy-and
Nov 13, 2026
Merged

dan-petty merged 3 commits into
mainfrom
refactor/1928-rank-the-benchmark-with-numpy-and

Conversation

@devops-cli-service

Copy link
Copy Markdown
Contributor

Plans #1928

The embedding benchmark ranks every query against every chunk with one cosine_similarity call per pair and its own recall, MRR and nDCG code. This plan replaces that loop with one numpy matrix product over row-normalized vectors and takes recall at 1, 3 and 5, MRR and nDCG at 5 from pytrec_eval. It deletes compute_ndcg_at_k and the C901 marker, declares numpy and pytrec-eval-terrier in pyproject.toml and uv.lock, and types pytrec_eval with a stub under typings, so no mypy override and no higher suppression ceiling are needed. A new invariant test asserts a resolved entry and a linux x86_64 wheel of each library in the lock. The Service Image smoke probe of both workflows imports both libraries. Corpus embedding still dominates a run.

Change: openspec/changes/1928-rank-the-benchmark-with-numpy-and/

@devops-cli-service devops-cli-service Bot added type/docs Type docs: a change to the documents scope/openspec OpenSpec changes, specs and their checks verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix labels Nov 13, 2026
@dan-petty
dan-petty force-pushed the refactor/1928-rank-the-benchmark-with-numpy-and branch from 713337a to 0c4acff Compare November 13, 2026 17:28
@dan-petty

Copy link
Copy Markdown
Owner

Bottom line: Head 0c4acfff6 resolves the one open review finding and the one advisory point that was still open. The plan check, the stage gates and openspec validate --strict pass on that head, and all checks of the pull request pass. The label plan/needs-fix stays until an independent review of this revision. The pull request stays a draft.

Checks on the pushed head 0c4acfff6

  • uv run devops roadmap plan-check 5422: no problem.
  • uv run devops roadmap plan-recheck --branch HEAD (plan reader, stage gates, openspec validate --strict): folder 1928-rank-the-benchmark-with-numpy-and has the result ok and no refusal.
  • Check runs of the head: all pass, Plan Check and Semantic PR title included.
  • The branch is rebased on origin/main at 3f0d0f061. Release 0.129.0 (192ca69) changed only the version lines of pyproject.toml and uv.lock. Each path:line:text citation of the plan still points to the quoted line.

Open finding

  1. criterion_dropped at group 3 and the requirement "Remove compute_ndcg_at_k": the guard test test_benchmark_module_defines_no_compute_ndcg_at_k kept the helper name in tests, so the check of the issue, rg compute_ndcg_at_k src tests with no match, could not pass. The spec delta also replaced that check with "no test imports it".
    Resolution: The plan has no guard test now. Task 3.2 has the verification ! git grep -n compute_ndcg_at_k -- src tests. This is the check of the issue in the negative-search form that the implement step runs (rg is not a program of the step). Task 3.2 removes each line that names the helper in the three test files: the imports, the assertions, the comments, and the docstring of test_compute_ndcg_and_report_rendering. The report part of that test stays as test_report_rendering. The scenario "No remaining reference" states the check of the issue again: git grep -n compute_ndcg_at_k -- src tests finds no match, and the benchmark test suite passes. design.md records the decision and the rejected guard test.

Points for a person

Point Status
other at group 2: rank_corpus returns only the ranked indices, but score_retrieval needs the pair scores for the margins, the separation and the target scores Resolved in this revision. rank_corpus returns the score matrix and the ranked indices. score_retrieval takes both, with the target and the category of each query. It reads the margins and the separation from the score matrix. The run that it gives pytrec_eval holds a score that falls as the rank goes up, so trec_eval does not sort equal scores by document identifier. The scenario "Ranking matches pairwise cosine" names both return values, and a new case asserts the margins and the separation.
other at group 3: test_embedding_benchmark.py keeps its import of cosine_similarity from the runner Resolved at 713337a: task 3.2 changes that import in all three test files.
other and spec_delta_wrong: fractions in the scenario, percentages in group 2 Resolved at 713337a: the scenario asserts 100/3 and 200/3 percent, and the design returns percentages.
verify_form at group 1: the verify passes on the base Resolved at 713337a: the verify is the new tests/invariants/test_declared_dependencies.py, which reads pyproject.toml, uv.lock and the stub.
false_premise at references: the qdrant fake Resolved at 713337a: "Unchanged references" says that the fake has its own _cosine_similarity (tests/support/fakes/qdrant.py:25, :194).
other at specs and criterion_dropped at group 1: a wheel for numpy only Resolved at 713337a: the requirement and the invariant test assert a linux x86_64 wheel for each of the two libraries.
missing_path at group 5: release.yml and the parity test Resolved at 713337a: group 5 changes ci.yml, release.yml and tests/commands/test_ci.py, and its verify runs tests/commands/test_ci.py.
other at feasibility: ci.yml:471, :472, :497 Resolved at 713337a: the plan does not cite those lines. It cites the probe at ci.yml:489 and release.yml:388.

One more change: task 2.2 tells the implement step to import the new module inside each test function. The runner of the closed plan #5140 needed one repair round for this fault.

Before the push

Note: the record of #1928 still holds implement.job devops-cli-runner-20261112-163430-77e5 with the state failed. That Job was the runner of #5140, and it does not exist now. The row stage_ready skips an item whose record holds implement.job, so the Service does not read this draft.

devops-cli-service Bot and others added 3 commits November 13, 2026 18:00
The issue proves the removal of compute_ndcg_at_k with a search of src and tests that finds no match. The plan named the helper in a guard test, so that search could not pass. The plan now runs the negative search in group 3 and names the helper in no test. rank_corpus also returns the score matrix, because score_retrieval needs the pair scores for the margins and the separation.
@dan-petty
dan-petty force-pushed the refactor/1928-rank-the-benchmark-with-numpy-and branch from 0c4acff to db99ac2 Compare November 13, 2026 18:01
@dan-petty

dan-petty commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Bottom line: every review finding is resolved at db99ac2. All checks pass. I remove plan/needs-fix and mark this pull request ready. A person merges it.

Revision db99ac2 (rebased onto main 2bdc9a2) resolves the findings of the independent review of 0c4acff:

  1. Blocking: the test rename had no ## Weakened checks entry. Task 3.2 renames tests/ai/benchmark/test_embedding_benchmark.py::test_compute_ndcg_and_report_rendering to test_report_rendering. The step guard (lost_since and unrecorded_tests in src/devops_cli/roadmap/implement/implement_test_names.py) compares test names only, so the runner stopped group 3 with tests_lost, as it stopped fix(ci): a narrowed ci test runs many slow tests serially #4472. Resolution: proposal.md now has ## Weakened checks between ## Impact and ## Feasibility, with one entry for that test. The safeguard names test_report_rendering and tests/ai/benchmark/test_retrieval_metrics.py::test_metrics_match_fixed_expected_values, which asserts ndcg_at_5 from pytrec_eval on a fixed fixture. plan_read.weakened_checks reads 1 entry, and recorded_tests gives the right path::name. No other test of the plan is removed or renamed.
  2. Major: the stale check-out of refactor(ai): rank the benchmark with numpy and pytrec-eval #1928. The record of refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 holds implement.job=devops-cli-runner-20261112-163430-77e5 with implement.job_state=failed and implement.pr=5140 (a closed plan). That Job is not in the cluster. _recorded_pull (src/devops_cli/roadmap/stage/stage_ready.py:96) and the fix-plan filter (src/devops_cli/roadmap/steps/fix_plan.py:432) skip an item that holds implement.job, so the Service does not read this draft. Resolution: I did not edit the record by hand. I mark this pull request ready by hand, and feat(roadmap): the poll frees the check-out of a gone job #5524 tracks the cause: the poll frees the check-out of a gone or failed Job.
  3. Earlier findings (criterion_dropped at group 3, rank_corpus scores, and the advisory points): resolved at 0c4acff and 713337a, as the comment docs(openspec): plan #1928 Rank the benchmark with numpy and pytrec_eval #5422 (comment) lists.

Checks on db99ac2:

  • uv run devops roadmap plan-check 5422 --json: []
  • CI Plan Check: success. All other CI checks that ran pass. Dependency Freshness, Test Job Duration and Tests on Main are skipped by their triggers.
  • uv run openspec validate 1928-rank-the-benchmark-with-numpy-and --strict: valid
  • uv run devops roadmap plan-recheck --branch HEAD: 0 new refusals
  • Each path:line:text citation still matches after the rebase. The release changed only the version lines of pyproject.toml and uv.lock.
  • Guards before the push: no active Job for refactor(ai): rank the benchmark with numpy and pytrec-eval #1928, no stage.pending and no fix_plan.* marks in its record, and no stage line for refactor(ai): rank the benchmark with numpy and pytrec-eval #1928 in Loki for the last 30 minutes. Push with --force-with-lease against 0c4acff.

@dan-petty dan-petty removed the verdict/fix-plan Verdict Needs fix of a plan: an open finding keeps the plan in draft until a fix label Nov 13, 2026
@dan-petty
dan-petty marked this pull request as ready for review November 13, 2026 18:15
@dan-petty
dan-petty self-requested a review as a code owner November 13, 2026 18:15
@dan-petty
dan-petty merged commit 054cee2 into main Nov 13, 2026
22 checks passed
@dan-petty
dan-petty deleted the refactor/1928-rank-the-benchmark-with-numpy-and branch November 13, 2026 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/openspec OpenSpec changes, specs and their checks type/docs Type docs: a change to the documents

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant