d83b10f939
The retrieval-mode enum used opaque single letters `Mode { C, A }`;
neither the identifier nor the operator-facing `--mode a` token
conveyed what the mode does. Rename to self-describing names that map
directly onto the glossary definitions:
Mode::C -> Mode::Lexical (BM25 + tag filter, offline, no IONOS)
Mode::A -> Mode::Hybrid (lexical u semantic -> RRF -> rerank)
Decisions taken (the issue's open questions, resolved):
- CLI canonical tokens are now `lexical` / `hybrid`; the default is
`lexical`. The legacy `c` / `a` tokens stay accepted as
case-insensitive input aliases (zero cost; protects hand-typed
invocations). A unit test pins the alias contract.
- The diagnostics `mode` string (Debug-derived) now emits
"Lexical"/"Hybrid". Verified safe: no downstream consumer parses it.
doctate is the future integrator and embeds the library (the `Mode`
enum), not the JSON string (design spec §103).
- The reserved, out-of-scope generative tier (spec's "Mode B") keeps
conceptual room: a future `Mode::Generative` does not collide with
the retrieval-strategy names Lexical/Hybrid.
Surface: enum + FromStr, CLI defaults and `eval --mode both`
expansion, the private `collect_mode_c`/`collect_mode_a` methods (now
`collect_lexical`/`collect_hybrid`) and their comments, the two
pipeline mode test files (renamed), the eval CLI test, the glossary
(old letter forms demoted to Avoid lists), and the spec CLI synopsis.
closes #2
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
38 lines
1.6 KiB
Rust
38 lines
1.6 KiB
Rust
use alpha_id::pipeline::Pipeline;
|
|
use alpha_id::model::{Config, Filter, Mode};
|
|
|
|
fn cfg() -> Config {
|
|
Config::load("config/default.toml").unwrap()
|
|
}
|
|
|
|
#[test]
|
|
fn lexical_end_to_end_real_data() {
|
|
let p = Pipeline::load(&cfg()).unwrap();
|
|
let dictation = "Patient mit Diabetes mellitus Typ 2\n\nArterielle Hypertonie";
|
|
let res = p.suggest(dictation, Mode::Lexical, &Filter::default(), 10);
|
|
assert!(!res.suggestions.is_empty());
|
|
assert!(res.suggestions.len() <= 10);
|
|
assert!(res.suggestions.iter().any(|s| s.icd_code.starts_with("E11")));
|
|
assert!(res.suggestions.iter().any(|s| s.icd_code.starts_with("I10")));
|
|
assert_eq!(res.diagnostics.segment_count, 2);
|
|
assert_eq!(res.diagnostics.mode, "Lexical");
|
|
}
|
|
|
|
#[test]
|
|
fn billable_only_filter_excludes_three_digit_v_codes() {
|
|
let p = Pipeline::load(&cfg()).unwrap();
|
|
let f = Filter { billable_only: true, valid_only: true, chapters: None, exclude_exotic: false };
|
|
let res = p.suggest("Cholera", Mode::Lexical, &f, 10);
|
|
assert!(res.suggestions.iter().all(|s| s.tags.billable && s.tags.valid));
|
|
}
|
|
|
|
#[test]
|
|
fn billable_only_keeps_diabetes_5th_digit_codes() {
|
|
let p = Pipeline::load(&cfg()).unwrap();
|
|
let f = Filter { billable_only: true, valid_only: true, chapters: None, exclude_exotic: false };
|
|
let res = p.suggest("Diabetes mellitus Typ 2", Mode::Lexical, &f, 10);
|
|
assert!(res.suggestions.iter().any(|s| s.icd_code.starts_with("E11") && s.tags.billable),
|
|
"billable E11.x must survive --billable-only; got {:?}",
|
|
res.suggestions.iter().map(|s| (&s.icd_code, s.tags.billable)).collect::<Vec<_>>());
|
|
}
|