fix(cli): an untouched session leaves [search] in force, and .bench runs at the quality it prints (#2303) - #2401
Merged
Conversation
…uns at the quality it prints (#2303) A session nobody \set injected mode = 'balanced' into every query, overriding velesdb.toml [search] against the documented priority order. Its mode is now unset until \set, and \show prints the configured default. .bench printed the session mode but searched at the collection default, and dropped failed queries; it now searches at the session quality (ef_search over mode) or the configured default, and the first failure ends it.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…L fixtures \show and .bench now read the configured default through helpers the tests call on a database opened with [search] default_mode = "fast" (shown_settings, bench_quality); hard-coding balanced in either fails a test. The seeded databases move to a test_fixtures module both test files use, and repl_execute_tests is private again. The docs say an unset mode takes the [search] of the --config file until #2400 lands.
…ours-session-search
… the bench test pins Until #2400 lands, ./velesdb.toml is not read without --config, so the CHANGELOG and the comments say the [search] of the --config file. The bench test is named for what it pins, the printed default.
check_prod_unwraps.py reads only *_tests.rs files as test code, so the fixtures' expect() calls failed Lint & Format under test_fixtures.rs.
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.
Fixes #2303
Both items ship together because they are one rule. Item 1 decides what an untouched session searches at, and
.bench(item 2) has to search at that same quality. Landing item 2 alone would have made.benchforcebalancedtoo.Item 1: an untouched session leaves
[search]in forceDecision. The configuration priority order documented in
docs/guides/CONFIGURATION.mdwins: file < runtime override, where the runtime override is "REPL\set, VelesQLWITH, API params". A session default nobody chose is not a\set.The investigation comment on #2303 notes that
repl_execute_tests.rsasserted the opposite on purpose (an untouched session injectsmode = 'balanced') and asks that a change to it be deliberate. This PR is that change. The test and its doc comment are rewritten, with the documented priority order as the reason.SessionSettings.modeis nowOption<SearchQuality>.Nonemeans never\set.search_quality()returns the session'sef_search(asCustom, which is exactly what core'ssearch_with_efruns), else itsmode, elseNone.mode_str()returns anOption.\reset modeand\resetgo back toNonerather than tobalanced.mode()and test-onlyeffective_ef_search()getters are gone. Tests readsearch_quality()andget(...).inject_session_with_options) adds the session's quality only when it holds one. When it holds none it adds nothing, not even an emptyWITH, so the search reachesself.searchand the collection's runtime quality.\showtakes the database and prints the configured default for an unset mode, asfast (configured default), usingdb.config().search.resolved_quality().ef_searchshowsauto (…)for the mode in force..help,CLI_REPL_REFERENCE.mdandCONFIGURATION.mdsay so.Item 2:
.benchruns at the quality it prints.benchprintedmode={:?}but calledcol.search(&query, k). It now searches withcol.search_with_quality(q, k, quality)when the session sets a quality, and withcol.search(q, k)otherwise, which applies the configured default. It prints the quality it runs at. It also used to drop every failed query (if let Ok), so a bench whose queries were all refused still reported a throughput. The first error now ends it withquery i of n failed: ….Red first
.bench: with the new tests run against the old.benchcode,bench_runs_at_the_session_mode_and_reports_the_refusalfailed with ".benchat mode perfect ran past the Perfect-mode cap", onseed_docs_refusing_perfect:max_perfect_mode_vectors = 1, 3 points.test_session_ef_search_reaches_the_searchpinned[("mode", "balanced")]for an untouched session. It now pins[]. The newtest_an_untouched_session_leaves_the_configured_quality_in_forceasserts that the parsed query keeps noWITHclause.mode = 'balanced'again failstest_an_untouched_session_leaves_the_configured_quality_in_forceandtest_session_ef_search_reaches_the_search.search_quality()that returns the mode alone, ignoringef_search, failsbench_runs_at_the_session_ef_search_over_its_mode("the session ef_search was ignored"), plus two session tests.Review round 1
\showand.benchread the configured default untested. Hard-codingbalancedin either left every test green. Both now go through a helper,shown_settings(db, session, key)for\showandbench_quality(db, session)for.bench. Each helper returns what the command prints, and the new tests call it on a database opened through the CLI's--configpath with[search] default_mode = "fast". Two mutations each fail their test:show_prints_the_configured_default_for_an_unset_modeandbench_at_an_untouched_session_prints_the_configured_default. That second test replacesbench_at_an_untouched_session_runs_every_query, which also passed on develop's.bench..benchon an untouched session still callscol.search. That is the same call a query from an untouched session makes, andsearch_with_optsfalls back to it. It uses the PQ/ADC path, andsearch_with_qualitydoes not, so routing throughsearch_with_quality(resolved_quality())would change what a bench measures on a PQ collection. Which qualitycol.searchruns at is the collection's runtime quality, pushed from[search].resolved_quality(). The bench prints that same value, and a test pins it. No test-sized collection can tellcol.searchapart from abalancedsearch at that point: a configuredperfectdefault is applied asaccurate, so the Perfect cap never shows.--config, the CLI does not read./velesdb.toml(cli: ./velesdb.toml is not read without --config, although CONFIGURATION.md says it is #2400). So.helpandCLI_REPL_REFERENCE.mdnow say an unset mode takes the[search]of the--config/VELESDB_CONFIGfile. The.benchrow names the configured default as its last fallback.seed_docs,seed_docs_refusing_perfectand the newseed_docs_configuredmove to a#[cfg(test)] mod test_fixtures, which the three REPL test files use (repl_execute_tests.rs,repl_data_cmds_tests.rs,repl_config_cmds_tests.rs). It lives inrepl_fixtures_tests.rs. CI'scheck_prod_unwraps.pyexempts test-named paths (*_tests.rs,*_test.rs,tests/,benches/), and#[test]functions and#[cfg(test)]items inside the file it scans. It checks each file on its own, so a file whose only test gate is itsmodline inmain.rscounts as production. That is why it failed Lint & Format on ff7ff59, while the file was namedtest_fixtures.rs.repl_execute_testsis private again.Review round 2
inject_session_with_optionsandSessionSettings.modenow name the--config/VELESDB_CONFIGfile and cli: ./velesdb.toml is not read without --config, although CONFIGURATION.md says it is #2400, as.helpand the reference already do.bench_at_an_untouched_session_prints_the_configured_default, and its doc says that it leaves the search arm unpinned on purpose.Found on the way, filed rather than widened
rerankruns atBalanced, not the configured default (SearchOptions::resolved_quality)../velesdb.tomlwithout--config, althoughCONFIGURATION.mdsays it does. Until that is fixed, item 1 only helps a user whose file is loaded through--config/VELESDB_CONFIG.Gates (local, aarch64; reduced to the changed crate to spare the machine, CI runs the whole workspace)
cargo fmt --all -- --check;cargo clippy -p velesdb-cli --all-targets -- -D warnings -D clippy::pedanticcargo test -p velesdb-cli --bin velesdb: all passcheck-inline-tests,check-file-budgets,check-doc-freshness,check-feature-claims,check-ai-attribution