Repository navigation
fix(server): the score-band filter read query names the BFF never sent - #273
Merged
Merged
Conversation
`match_scores_list` read `min`/`max`, while the BFF forwards `band_low`/`band_high` (`src/app/api/orgs/[org]/match-scores/route.ts:5`). The bounds were dropped on every request and the endpoint returned the first page of *all* active pairs, so the "By score" tab on the duplicates screen has never filtered against a real backend. Three layers each agreed with one side, and nothing compared them: - the Playwright mock honours `band_low`/`band_high` (`frontend/tests/mock-erserver/server.mjs`) and the functional tier asserts against the mock — so the frontend tier only confirmed the frontend's belief; - `pg_golden_read.rs` *did* cover the band, but requested `?min=0.95` — the server's own spelling rather than the contract the product speaks. A real test, green, asserting the wrong half; - `mock_contract.rs` compares route and method only, so a query-param rename is outside what it can detect at all. Rename both reads and move the test onto the forwarded names. That test's `hi.len() <= pairs.len()` assertion was itself unfalsifiable — an ignored band returns the full set, which satisfies `<=` — so it is replaced with a distribution-independent check: a band above every observed score must return an empty page. Adds the first coverage of `band_high`. The other `min`/`max` site (the review queue, `lib.rs:3398`) is deliberately untouched: its BFF route forwards neither name and it defaults to the full range, so it is unused rather than wrong. Changing it would be an unrequested behaviour change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
match_scores_listreadmin/max; the BFF forwardsband_low/band_high(frontend/src/app/api/orgs/[org]/match-scores/route.ts:5). The bounds were dropped on every request, so the endpoint returned the first page of all active pairs and the "By score" tab on the duplicates screen has never filtered against a real backend. Pre-existing onmain.Why three layers of tests all stayed green
Each agreed with one side of the mismatch, and nothing compared them:
band_low/band_high(frontend/tests/mock-erserver/server.mjs:1533-1534) and the functional tier asserts against the mock — so that tier only ever confirmed the frontend's own belief;pg_golden_read.rs:418did cover the band, and its>= 0.95assertion was sound — but it requested?min=0.95, the name the handler read rather than the one the product sends. It passed legitimately while testing a parameter no caller used;mock_contract.rscompares route + method only, so a query-param rename is outside what it can see at all.One assertion was also unfalsifiable
assert!(hi.len() <= pairs.len(), "band narrows the set")— an ignored band returns the full set, which satisfies<=. Replaced with a distribution-independent backstop: take the maximum observed probability, request a band above it, require an empty page. That holds regardless of how a fixture's scores cluster. Also adds the first coverage ofband_high(both bounds inclusive —>= $min_prob/<= $max_probinentities/match_score/read/active_page.sql).Verification
make checkgreen locally — fmt,clippy --workspace --all-targets -D warnings,er-entity verify, skills-check,cargo test --workspace.make checkdoes NOT exercise the band assertions.pg_golden_read.rsis gated on bothER_TEST_PG_DSNandDEDUPE_E2E_DUCKLAKE=1; on a miss it prints to stderr andreturns, reportingtest golden_records_read_over_ducklake ... okhaving run nothing (0.00s). Noting it because that line is actively misleading.1 passed, 8.58s.min/maxwhile keeping the new test:FAILED. 0 passed; 1 failed, panicking atpg_golden_read.rs:432. So the test now genuinely locks the contract rather than restating the handler's own spelling.DuckLake + extensions e2ejob (rust.yml:486-498) sets all three vars and runs on this PR, so the assertions are covered in the PR tier.Scope
The other
min/maxsite (lib.rs:3398, the review queue) is deliberately untouched: its BFF route forwards neither name and it defaults to the full range, so it is unused rather than wrong.No OpenAPI regeneration —
match-scoresis not in the document.Follow-up, not in this PR
Extending
mock_contract.rsto compare query-param names between each BFFPASSTHROUGHlist and its handler'sparams.getcalls would catch this class in the fast tier. Left out deliberately: a new static analysis over delicate parsing — that file already documents a regex that silently dropped every route — and worth its own review.🤖 Generated with Claude Code