Repository navigation
feat(doctor): the reranker weights are verified against the published digest (#734, slice 3) - #972
Conversation
… digest (#734, slice 3) The FlashRank ONNX sha256 was recorded in every benchmark manifest and compared with nothing (docs/audits/model-identity-inventory-2026-11-06.md): a changed or corrupt file that still loads gave reranker_state "loaded" and no surface said the bytes differed. - core/reranker_identity.py classifies a digest as absent, verified or mismatch against the sha256 every committed result carries (131 entries, one value, cited to benchmarks/results/repro/20261014T232318Z/MANIFEST.json). - cortex doctor gains an optional "Reranker weights identity" check on both backends: it reads the cached file, never downloads, deletes or loads. - Both benchmark manifests record reranker_model_identity next to the digest. Refs #734 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018kyZYtnEGra9C5XdQUC4Xj
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Claude finished @cdeust's task in 2m 36s —— View job Review 1 of 3 (ADR-1119) is done
None of the five reviews found a Blocker. The posted comment has three Notes, no action before merge. Verdict: approve |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9d25ef364a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "CORTEX_RERANKER_OFFLINE" | ||
| ) | ||
| _MISMATCH_FIX = ( | ||
| "Delete {path} and let FlashRank download it again; results measured with " |
There was a problem hiding this comment.
Remove the model directory rather than only the ONNX file
When a cached model has a mismatching digest, following this fix deletes only the ONNX file but leaves its model directory intact. The installed FlashRank 0.2.10 implementation of Ranker._prepare_model_dir downloads only under if not self.model_dir.exists() (also documented in docs/adr/ADR-0244-mcp-server-core-reranker-model.md), so the next load skips downloading and fails on the missing weights. Cortex then disables reranking for the rest of that process. Recommend removing the model's cache directory, or explicitly reprovisioning its complete contents, so the suggested repair actually restores reranking.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Confirmed and fixed in 2df9d02. FlashRank 0.2.10 Ranker._prepare_model_dir downloads only under if not self.model_dir.exists(), so deleting the ONNX file alone would leave reranking disabled. Both hints now name the model directory: remove it on a mismatch, and remove it if present when the file is absent. The doctor tests assert the directory path.
Generated by Claude Code
Review 1 of 3 (ADR-1119) — PR #972, commit 9d25ef3I ran five reviews: code quality, performance, test coverage, documentation accuracy and security. None of them found a Blocker. What I checked:
Notes, no action before merge
Verdict: approve |
…blished digest (#734, slice 3)
|
Claude finished @cdeust's task in 2m 10s —— View job Review 2 of 3 (ADR-1119) — PR #972, commits after 9d25ef3 (
|
…blished digest (#734, slice 3)
|
CI autopilot :
Generated by Claude Code |
|
Claude finished @cdeust's task in 1m 42s —— View job Review 3 of 3 (ADR-1119) is done
None of the five reviews found a Blocker, and the comment has three Notes. The whole PR is accepted: no file or commit has an open Blocker. Verdict: approve |
Review 3 of 3 (ADR-1119) — PR #972, commits after 2df9d02 (
|
…973) * docs(agents): state the CI contract every agent and routine follows The scheduled routines were written before the review contract: on 2026-11-10 they measured branches against the main branch and rebased them with a forced push, commented on approved pull requests (#968) and opened pull requests while another was in flight (#971, #972). Their prompt tells them to read CLAUDE.md and docs/ and to apply the repository's standards, so the rules "Review rounds" does not hold yet are written next to it, and both are said to win over a less restrictive routine prompt. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_018kyZYsWnKSjpX4oNV19PCF Signed-off-by: Claude <[email protected]> * docs(agents): rule 1 names the two merges the verdict does not decide Notes of review 1 of #973, taken in one push because that review's verdict cannot be read by the resolver (its comment does not link the run, fixed for later reviews by ADR-1130, #975): the low-risk Dependabot merge and the "do not merge" title, and what a pull request cut down after its third review waits for. Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_018kyZYsWnKSjpX4oNV19PCF Signed-off-by: Claude <[email protected]> --------- Signed-off-by: Claude <[email protected]> Co-authored-by: Claude <[email protected]>
Summary
reranker_model_sha256was recorded in both benchmark manifests and compared with nothing (docs/audits/model-identity-inventory-2026-11-06.md, "The reranker digest is recorded, never verified"). FlashRank downloads its ONNX file by name. A changed or corrupt file that still loads gavereranker_state: loadedand a different digest, and neithercortex doctornor a manifest said that the bytes differed from the ones the published numbers were measured with. This PR compares the on-disk digest with the digest the committed results carry, and reports the result incortex doctorand in both manifests.mcp_server/core/reranker_identity.py(pure):classify_model_digest(sha256)returnsabsent,verifiedormismatchagainstEXPECTED_MODEL_SHA256=d3dd7b09…41d1. That value is the only digest among the 131reranker_model_sha256entries committed underbenchmarks/results/. Its source isbenchmarks/results/repro/20261014T232318Z/MANIFEST.json(reranker_state: loaded, gitb9d4dd5).core/reranker_model.pygainsmodel_path_under(cache_dir), the existing path join made public, andmodel_identity().core.rerankerre-exportsmodel_identity.mcp_server/doctor_reranker.pyadds a new optional check, Reranker weights identity, to the PostgreSQL and SQLite check lists. It only reads the cached file: it never downloads, deletes or loads a model. An absent or different file gives a warning, because recall still runs without the reranker. An unreadable file is reported, not raised.benchmarks/lib/write_manifest.pyandbenchmarks/_repro.pyrecordreranker_model_identitynext to the digest (unresolvedin the degraded arm).Refs #734 (slice 3; the issue stays open). Remaining slices: one effective manifest returned by
cortex doctorand the benchmarks; a digest check of the embedding snapshot files; a receipt of memory operations run with networking disabled.Type of change
Test plan
pytest tests_py/core/test_reranker_identity.py tests_py/test_doctor_reranker.py tests_py/test_doctor.py tests_py/core/test_reranker.py tests_py/benchmarks/gives 456 passed and 15 skipped. I did not run the full suite locally; CI runs it.tests_py/core/test_reranker_identity.py(4 tests, one checks that the pin equals the digest of the cited manifest) andtests_py/test_doctor_reranker.py(5 tests: absent, verified, mismatch, unreadable, registered on both backends).CORTEX_RERANKER_OFFLINE=1 python -m mcp_server.doctorin this container prints[WARN] Reranker weights identity absent at …/flashrank/ms-marco-MiniLM-L-12-v2/flashrank-MiniLM-L-12-v2_Q.onnx.Audit notes
ruff checkandruff format --check(0.17.3, the version inuv.lock) pass on the changed files.scripts/check_craftsmanship.py: OK.scripts/check_doc_claims.py: OK.verifiedpath is not tested on a real FlashRank download, because this container's proxy does not allow the model download and the tests use synthetic bytes. PostgreSQL runs are not verified. The CI of this PR had not started when the PR was opened.Coding-standards compliance
core/reranker_identity.pyimports nothing outside the standard library, and the doctor composes core with infrastructure.mcp_server/doctor.pywas already over 500 lines (691 before this PR, baseline debt). This PR adds 6 lines to it and puts the check in a new 61-line module.# source:comment.Breaking changes
None. The manifests gain one key, and doctor gains one optional check that does not change the exit code.
Screenshots / logs
Reviewer checklist
docs/module-inventory.md.https://claude.ai/code/session_018kyZYtnEGra9C5XdQUC4Xj
Generated by Claude Code