about summary refs log tree commit diff
path: root/tests/search_parity.rs
AgeCommit message (Collapse)Author
2026-11-09fix: DOL maps again on both engines, and the four stale testsPjotr
DOL (200 individuals, 112 913 markers, one genotype version) failed on R/qtl with "There are missing chromosome IDs" and on GEMMA with a bare wrapper bail-out. Two unrelated causes, both in our own code. **R/qtl: a genotype code collided with a chromosome name.** DOL's header says `@unk:X` -- X is the code for a missing genotype -- and the wrapper passed that to `read.csv(na.strings=...)` for the *whole* file, so every marker on the X chromosome lost its chromosome ID and `read.cross.csv` refused the map. The unknown code now applies to the genotype columns only. DOL scans: 112 913 markers in 42 s, where before it never got past reading the file. Same fix in scripts/qtl_fitqtl.R, which shares the read. **GEMMA: its leave-one-chromosome-out run cannot fit the Y.** With LOCO the DOL panel is scanned per chromosome, and the Y run dies inside BLAS -- `Enforce failed for N>0 in src/fastblas.cpp ... fast_cblas_dgemm` -- taking the whole request with it (a 502 whose detail is the wrapper's banner). The mitochondrial chromosome has the same shape of problem. `prepare` for the GEMMA engine now writes the bimbam pair without the Y and M markers (cached beside the individual subset, line-aligned so the geno and snps stay in step), and the note says what was left out: "46 Y/M markers left out (GEMMA's LOCO cannot fit them)". DOL maps: 106 515 rows in 49 s. **And the four tests that had been failing since before this work**, all stale expectations rather than product bugs: * `benchmark_questions` pinned two traits to "page 2" of a 100-per-page search when they rank ~190th and ~219th of 246 -- one re-index pushes them over. It now walks up to three pages and asserts presence and LOD, not the page; and the helper `search()` pages, because a benchmark row can name a trait that ranks outside the first hundred of its own query. * `no_db_mode_degrades_gracefully` asserted exactly one hit for "alcohol" from the index alone. The index grew; the behaviour under test is that the search still answers, within the limit, with the database-backed fields null. That is what it asserts now. * `search_proxy_scenarios` and `search_parity_replay` never pinned the engine they test, so an ambient `SEARCH_ENGINE=native` made the proxy scenarios answer from the local index: a 200 where a 422 was expected, and "expected 2 upstream calls, got 0" for every replayed query. Both now set `SEARCH_ENGINE=forward`. * src/genotypes.rs: `DEGENERATE_CHROMOSOMES`, `drop_degenerate_chromosomes`, `Prepared.markers_dropped`. * src/routes/gemma.rs: also the 500 that `eb5320d` introduced -- counting parents/F1s from `panel - keep` instead of subtracting the exclusion *set*, whose length can exceed the panel (subtract overflow). * scripts/rqtl_wrapper.R, scripts/qtl_fitqtl.R: na.strings scoped to the genotype columns. * tests/{benchmark,no_db,search,search_parity}.rs: as above. Verified through the API on DOL trait 10003: R/qtl 112 913 rows, GEMMA 106 515 rows. gemma/rqtl/fitqtl suites green (14, 10, 4).
2026-10-08Merge origin/main (54f1388): page, publish annotations, publications route.Alexander_Kabui
Composes the new main above the search engine seam: * src/routes/search.rs (page): parsed and threaded through the seam; the gn3 forwarder passes page to gn3 unsorted (sorted fetches the wide first page), the native engine takes the mset window. Ranked pages slice the sorted list, as before. * src/routes/search.rs (add_publish_annotations): enrichment now fills locus and abbreviation in one PublishXRef/Phenotype lookup. * src/search/mod.rs (Engine::search): page parameter; SearchHit gains abbreviation and pubmed_id (gn3's future fields flow via extra, as before). * src/db.rs (LRS_PER_LOD): 4.604 — lod shifts accordingly everywhere. All 34 test binaries green; parity replay and shape gates pass against the dev index with the new lod constant (grading compares identifier sets, not lod); page disjointness, abbreviation and locus verified live (native engine, dev index, SQL_URI set).
2026-10-07Typed-422 body + Q42 re-baseline (C3.7, ACTIVE — the owner-blessed contract)Alexander_Kabui
One commit, both halves of AMENDMENT E / the 2026-10-06 contract: (i) The 422 invalid_query body gains the blessed typed shape. The SearchError::InvalidQuery payload becomes {message, xapian_error_type}, threaded from every producer: - native parser rejects (parse_query_checked): the ParseError's own class, e.g. QueryParserError for Q51/Q52; - the C3.4 numeric-range guard: QueryParserError ("Unknown range operation", Q52's recorded production diagnostic); - the C3.6 invalid-location guard: InvalidOperationError — the class production actually threw for Q42; - the gn3 forwarder: gn3's error_type field, with the bytes-repr leak normalized (b'QueryParserError' -> QueryParserError — the binding- report R1 / OPEN-16 wrapper-layer normalization), or the exception class name itself for gn3's escaping-exception 500 bodies. The route's engine_error builds the typed body inside the existing ApiError envelope, under "error": {type: "invalid_query", message, param: "query", detail: {xapian_error_type}} — the envelope's existing fields (code, detail, ...) keep their meaning, so every current 422 (Q51/Q52 parser rejects, Q42's invalid-location class, mean:abc..def) emits it and the harness's body["code"] grading is untouched. The forwarder additionally maps gn3's malformed-processor-value 500s (the escaping xapian exceptions — Q42's recorded {"error": "InvalidOperationError", ...} body, the parity-metric amendment's curl-verified ValueError) onto InvalidQuery, scoped to the exception-class shape (a bare CamelCase ...Error name, or "Class: message"): the blessed contract folds all malformed input into 422, while prose 500 diagnostics ("gn3 exploded") keep the 502 backend_error class — pinned by both the rust and python route tests. (ii) The harness comparator's Q42 mapping rule changes: recorded production 500 -> expected 422 invalid_query. The recorded fixture itself stays untouched as production truth (recorded_status 500, served verbatim by the stub); only grade_error_class's Server500 arm re-baselines, with its doc comments and the comparator unit tests. Gate evidence (~/spikes/port-execution-r2/logs/c37-*): production floor 54/54 PASS with the NEW rule — Q42 rec=500 gn4=422 code=invalid_query through the real route + forwarding engine + stub (match200 49/49, clause-b 36/36, min J 1.000, parity-report.json floor PASS); FULL pinned cargo test --release EXIT=0 (30 suites, incl. the re-based comparator unit tests and the route unit tests pinning the typed body's presence for invalid_query and absence for backend errors); shape-class gate 52/52 unchanged; hermetic lib 23 green incl. the typed-payload assertions (Q51 message byte-identical, QueryParserError classification). rustfmt --edition 2024 clean on all nine touched files.
2026-10-07* tests/search_parity.rs (search_parity_replay): grade clause (a)Alexander_Kabui
full-set equality at the ENGINE seam; keep status classes, error bodies and clause (b) top-10 at the ROUTE level (harness v2). The route gained hits.truncate(limit) in e912c87 (documented limit contract: default 20, cap 100), which blocked the floor at 85b63ab: 36 shapes DIFFed with rec=200/<full> gn4=200/20 missing=<full-20>. Root cause was never the route: route-level full-set grading only ever worked because the calibration stub serves the full recorded body regardless of the forwarded per_page — real gn3 caps server-side. The truncate is the route-side piece of the per_page invariant (PORT-DESIGN §5: the engine retrieves the full match set; the route keeps its limit logic), so set-equality moved below it, to the seam. Match200 grading now: replay through the route exactly as before (200 check, top-10 clause (b) off the truncated response — first-ten-in- recorded-order survives the truncate; upstream-call accounting), then call genenetwork4::search::search(q, type, ENGINE_FETCH_LIMIT = 1_000_000) directly, in process, against the same stub gn3, and grade the returned Vec<SearchHit> (dataset, name) identifier set against the fixture for clause (a). A match shape now makes exactly 2 stub requests (route + engine); error/surface shapes are unchanged. replayed_hits reports the engine-level full-set size, so the report line keeps its meaning (Q01: rec=200/1197 gn4=200/1197 missing=0). Floor after the fix: 54/54 PASS — match200 49/49, clause-(b) 36/36, min Jaccard 1.000, report written (target/parity-reports/). Negative controls (fixture mismatch RED/restore GREEN, truncated stub body RED/restore GREEN, top-10-breaking stub order RED/restore GREEN) ran on this commit via a throwaway uncommitted stub hook; evidence in ~/spikes/harness-fix/HARNESS-FIX-REPORT.md and logs/.
2026-10-07tests/search_parity.rs (search parity): re-shape 13 weak shapes toAlexander_Kabui
discriminating values; re-record Q02 (insulin) through a verified pagination walk (50000 + 7632 = 57632 hits, truncation closed). 12 formerly zero-hit shapes now carry real matches so clause (b) bites on 36/36 recorded shapes; Q26 re-shaped from chr:2 (>1.1M matches, unrecordable) to the bounded chr:m (9374 hits), same chr:->XC boolean filter grammar; Q04/Q11/Q12/Q21 retained as documented empty (the deployed index has no positional data and XD is unpopulated). * test/data/parity-fixtures (Q01-Q54, reduced-v1): re-baseline the corpus with the 14 re-recorded fixtures (production snapshot 2026-10-07); parity floor PASS 54/54, clause-(b) 36/36, min Jaccard 1.000. * test/data/parity-fixtures/reduce_fixtures.py (SHAPE_RE): tolerate rustfmt-expanded shape! tuples; the strict regex parsed only 4/54 of the current harness file and would fatal the generator. * test/data/parity-fixtures/README.md: document the re-recording, the truncation closure and the retained-empty shapes.
2026-10-07* tests/search_parity.rs (search parity): add the 54-shape harness.Alexander_Kabui
* test/data/parity-fixtures (Q01-Q54, reduced-v1): commit the corpus. * test/data/parity-fixtures/reduce_fixtures.py: regenerate it from a full recording corpus. Grades any implementation behind /search against 54 recorded production shapes per parity-metric.md: status, full match-set equality, a Jaccard >= 0.8 top-10 floor for sets of 10 or more, error-class mapping (recorded gn3 4xx -> 422 invalid_query, recorded 500 -> 502 backend_error, surface -> 400 invalid_parameter with no upstream call), and exactly-once upstream-call assertions. Hermetic: axum stubs stand in for gn3 and gn-auth, tokens are minted with the committed test key, no network. The committed corpus is reduced-v1: 109 MB of recorded payloads reduced to 6.6 MB of graded essentials (sorted identifier set, the recorded first-ten order, status); the raw corpus stays out of git. The loader sniffs full and reduced files in one directory, and the stub serves reduced bodies reconstructed top-ten-first so grading is identical either way; reduced files also self-verify against the shape table at load time. The generator parses the shape table from this test so the two cannot drift, and fails loudly on any hit lacking (dataset, name). Calibrated 54/54 against the forwarding route on both the full and the reduced corpus; negative controls prove it fails loudly. Runs by default from the committed corpus; GN4_PARITY_FIXTURES overrides for external corpora, GN4_PARITY_REPORTS relocates the report (default target/parity-reports).