diff options
| author | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 23:12:27 +0300 |
|---|---|---|
| committer | Alexander_Kabui <alexanderkabua@gmail.com> | 2026-10-07 23:12:27 +0300 |
| commit | 3dfe9ff07c229d2813edcdd9606884c38f93dd19 (patch) | |
| tree | 15ea452c2e141704ec5e8739b933ea67569ccc2f /tests | |
| parent | 9a76f1c7b855ace11de51d1e625fe4205f0096af (diff) | |
| download | genenetwork4-3dfe9ff07c229d2813edcdd9606884c38f93dd19.tar.gz | |
src/search/native.rs (native engine): register the Hs/Mm location processors (C3.6)
gn3's species-location shorthands (search.py:246-272), WITHOUT the Hs liftover OR-branch (OPEN-4, owner-decided; a C3.6b commit would add it): `Hs:chr<N>:<pos>` / `Mm:...` expand to the gn3 triplet (search.py: 185-193) — AND of the species boolean term (XShuman / XSmouse), the chromosome term (XC + chromosome number, value lowercased before the split exactly like gn3's split_query, search.py:178-183) and the slot-2 position range (the C3.5 machinery: SI suffixes, point +/-50 kb clamp, one-sided VALUE_GE/VALUE_LE, bases->megabases). THE INVALID LEAF (Q42, AMENDMENT E): every condition where gn3 raises ValueError (search.py:179-180, 197-201) — a value not splitting into exactly chr<chromosome>:<position-spec>, a chromosome not starting with "chr", or an unparseable position spec — emits the sentinel term GN4InvalidLocationLeaf (verified absent from the dev index; untypeable as free text under STEM_ALL_Z). The engine then detects the sentinel in the parsed query's unique terms and reports SearchError::InvalidQuery BEFORE the index is opened and any mset call — the blessed 422 for the recorded production mset crash (Q42's 500 InvalidOperationError), via the app-level guard (evidence-backed option (b), PORT-DESIGN C3.6, OPEN-31 closed by AMENDMENT E). The C++ try/catch shim is deliberately NOT extended; no crash-mimicry. An invalid leaf anywhere in the tree poisons the whole query, exactly as gn3's mset-time OP_INVALID rejection did (search.py:293-301 has no try/except). Gate evidence (~/spikes/port-execution-r2/logs/c36-*): hermetic pins green (23 lib tests: Q40/Q41 triplet forms XShuman+XC2 / XSmouse+XC1 + slot-2 VALUE_RANGE, value lowercasing, the 7-case invalid matrix, OR-combined poisoning, and the guard firing InvalidQuery with NO index configured — gn3's parse-before-open order preserved); shape-CLASS gate 52/52 cumulative vs the dev index (Q40/Q41 parse Ok with dev count 0 — REFERENCE ONLY per AMENDMENT B; probe evidence the triplet machinery is live: species:mouse AND chr:1 AND mb:1..200 matches, the 4.95..5.05 Mb chr1 window is genuinely empty in the 2025-02 dev data; Q42 -> InvalidQuery); route-level scenarios: Q52 AND Q42 both 422 invalid_query through the real app with SEARCH_ENGINE=native. rustfmt --edition 2024 clean on the touched files.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/search_native_route.rs | 14 | ||||
| -rw-r--r-- | tests/search_native_shapes.rs | 15 |
2 files changed, 26 insertions, 3 deletions
diff --git a/tests/search_native_route.rs b/tests/search_native_route.rs index 399e3ec..ecc5ade 100644 --- a/tests/search_native_route.rs +++ b/tests/search_native_route.rs @@ -109,7 +109,17 @@ async fn native_engine_route_level_error_and_match_classes() { assert_eq!(body["detail"], "Unknown range operation"); eprintln!(" Q52 mean:abc..def -> 422 invalid_query (route-level)"); - // 2. A valid range query serves: 200 with hits (dev count printed as + // 2. Q42's status class, route-level (AMENDMENT E): the recorded + // production 500 (mset-time InvalidOperationError on the invalid + // Hs location) is re-baselined to the blessed 422 invalid_query; + // the native engine's app-level guard detects the invalid leaf + // before any mset call — no crash, no crash-mimicry. + let (status, body) = get_json("/search?q=Hs%3Afoo%3A1M&type=phenotype", &token).await; + assert_eq!(status, StatusCode::UNPROCESSABLE_ENTITY, "Q42 class"); + assert_eq!(body["code"], "invalid_query"); + eprintln!(" Q42 Hs:foo:1M -> 422 invalid_query (route-level)"); + + // 3. A valid range query serves: 200 with hits (dev count printed as // REFERENCE ONLY, AMENDMENT B — never compared to production). let (status, body) = get_json("/search?q=mean%3A10..20&type=phenotype", &token).await; assert_eq!(status, StatusCode::OK, "mean:10..20 class"); @@ -119,7 +129,7 @@ async fn native_engine_route_level_error_and_match_classes() { hits.len() ); - // 3. Free text still serves through the same configuration. + // 4. Free text still serves through the same configuration. let (status, body) = get_json("/search?q=alcohol&type=phenotype", &token).await; assert_eq!(status, StatusCode::OK, "alcohol class"); let hits = body["data"].as_array().cloned().unwrap_or_default(); diff --git a/tests/search_native_shapes.rs b/tests/search_native_shapes.rs index d97cdbe..71fb918 100644 --- a/tests/search_native_shapes.rs +++ b/tests/search_native_shapes.rs @@ -37,6 +37,11 @@ //! bridge end-to-end: `position:abc` must parse and serve 200 with //! 0 hits (the parity-metric amendment's safe default — never an //! <INVALID> leaf, never a process abort). +//! - stage C3.6: + the Hs/Mm location processors (no liftover, OPEN-4) +//! and Q42's re-baselined class: an invalid location leaf (bad +//! chromosome form per search.py:179-201) surfaces as the engine's +//! InvalidQuery — the blessed 422 contract, detected by an app-level +//! guard BEFORE the mset call (no crash-mimicry, per AMENDMENT E). //! //! Env: `XAPIAN_DB_PATH` must point at the dev index (the gate runs //! set it to ~/spikes/index-self-build/xapian-index); the test skips @@ -190,6 +195,14 @@ const SHAPES: &[(&str, &str, &str, Class)] = &[ // MatchNothing and serves 200 with 0 hits (parity-metric // amendment; fork commit aa915af verified end-to-end). ("POSABC", "position:abc", "phenotype", Class::Match200Empty), // parity-metric.md amendment 2026-10-06 + // ---- stage C3.6: Hs/Mm location processors, no liftover (OPEN-4) ---- + ("Q40", "Hs:chr2:1M..1.2M", "gene", Class::Match200), // parity.rs:435 + ("Q41", "Mm:chr1:5M", "gene", Class::Match200), // parity.rs:442 + // Q42's class: the recorded production 500 (mset-time + // InvalidOperationError) is re-baselined to the blessed 422 — the + // engine's app-level guard detects the invalid location leaf + // before any mset call and reports InvalidQuery (AMENDMENT E). + ("Q42", "Hs:foo:1M", "phenotype", Class::InvalidQuery), // parity.rs:444 ]; #[tokio::test(flavor = "multi_thread", worker_threads = 2)] @@ -249,7 +262,7 @@ async fn native_engine_shape_class_gate() { } let summary = if failed.is_empty() { - "stages C3.1 + C3.2 + C3.3 + C3.4 + C3.5".to_string() + "stages C3.1 + C3.2 + C3.3 + C3.4 + C3.5 + C3.6".to_string() } else { format!("FAILED: {failed:?}") }; |
