Skip to content

test(bot-core): catch the missed mutants from the weekly run - #549

Draft
astrovm wants to merge 4 commits into
mainfrom
test/mutants-533
Draft

astrovm wants to merge 4 commits into
mainfrom
test/mutants-533

Conversation

@astrovm

@astrovm astrovm commented Nov 29, 2026 •

Copy link
Copy Markdown
Owner

The weekly mutation run listed 127 missed or timed-out mutants in Issue #533. This PR adds tests for the real gaps, rewrites code where a mutant cannot change behavior, and excludes the mutants that only hang.

Closes #533

How each finding is handled

Findings File Fix
+= → *= in tokenize (number start) ai_calculator.rs Removed the extra step: the loop after it takes the first digit too.
> → ==, >= in tokenize ai_calculator.rs New test: exactly 200 tokens pass and 201 fail. == is excluded: the list grows one token at a time, so > and == first fail at the same token.
+= → *= in tokenize, += → -= in the parser, || → && in power, /= → *= in convert_base ai_calculator.rs, base_conversion.rs Excluded in .cargo/mutants.toml: each one only makes a loop run forever (or a power run until the timeout), so a test can only hang.
< → <= in floor_divide and modulo ai_calculator.rs Uses num_integer::Integer::div_floor and mod_floor (Python's // and %) instead of hand-written sign checks.
+ → - and < → <= in parse_creditlog_limit admin_reports.rs The "next byte is a digit" check is gone: the number parse already fails on any non-digit. The limits use clamp. New cases: 1, 25, 26 and 1_a.
delete arm Value::Null in optional_id admin_commands.rs Removed: python_string already turns a null into "None".
date math in civil_from_days, days_from_civil charge_history.rs, bcra.rs One copy in the new bot_core::calendar module, also used by bot-adapters (it had two more copies). A test compares every day from year -500 to 4980 with chrono.
> → >= in estimate_transcription_reserve_credit_units ai_reserve.rs Removed the check: as saturates, and credit_units_from_usd_micros already returns Overflow for a value that large.
|| → && in strip_leading_context ai_response_cleanup.rs Removed the first early return: an empty response or empty context list gives the same result without it.
< → <= in parse_date, > → >= in render_bcra bcra.rs New tests: 99 is 2099 and 100 stays 100; the title shows a date only when more than half of the variables share it. The sign of the country-risk change uses is_sign_negative, because it is never 0 there.
> → >=, || → && in raw_components and allocate_components charge_history.rs Free parts were dropped twice. Now only allocate_components drops them, and a new test checks it.
< → <= in render_chat_members chat_members.rs New test: ages 59, 60, 3599 and 3600 seconds start the right band.
delete - and < → <= in evaluate_creditless, == → != in plan_config_callback config_callbacks.rs Decrease is written as "minus 1 above 0, else unchanged". New test: a limit of 0 moves like any other number, and increase adds 1.
&& → || in evaluate_compaction compaction_policy.rs New test: a result needs both the summary and the marker.
|| → && in transliterate_remaining_scripts command_normalization.rs Every ASCII character skips deunicode (it drops control characters such as \n), so the ñ arm was not needed. New test: all 128 ASCII characters stay unchanged.
|| → && in utf16_slice links.rs Removed the early return: empty text or a length of 0 or less already gives an empty range. New case: a length of -1.
|| → && in readable_number output_format.rs New unchanged cases: 1234. and 1234.5a.
link_mode_text arms and return value, < → <= in creditless_text config_command.rs New test: each link mode marks its own button, and a limit of 0 shows as 0.
delete arms (Locale::En, "Mayorista") and "Tarjeta" in render_dollar_rates dollar.rs New test for the wholesale and card names.
< → ==, >, <= in render_elections polymarket.rs New test: 5.12% keeps two decimals and 12.3% keeps one. At exactly 10% both forms print "10", so that mutant is excluded.
explicit_slug_requests, merge_asset, merge_assets, missing_usable_tokens, retain_requested_slugs, stock_fallback_query market_prices.rs New tests: slug lists split on commas and spaces, a usable quote is not missing, a merge keeps a usable price and keeps other ids and other slugs apart, slug quotes keep only the requested slugs, and several unknown words go to stocks as typed.
format_signal_caption_for_period_with_candles, candle_change_for_span, format_percentage, has_usable_chart, delete arm ("expired", Locale::En) in callback_text token_signals.rs The ATH line exists only for a positive ATH, and the live price goes to ath directly (is_usable_chart_candle ignores a price that is not positive). The span change returns a value only for a positive close. The English "expired" arm is gone: the default text is the same. New tests cover the ATH age in days, history far from the live price, a zero supply, a zero close, rounding near zero, and exactly 5 candles.
> → >= in payer_order, delete - in evaluate_pre_checkout telegram_payments.rs The cap text is built only for a limit that fits in u64. The amount check compares an Option, so a missing amount never matches.
/ → % in truncate_text telegram_actions.rs New case: a newline near the start does not cut the text.
|| → && and > → >= in parse_conversion_amount price_queries.rs New cases: both give no amount. > → >= in parse_conversion_amount is excluded: the last dot and the last comma are never at the same index.
> → >= in positive_float and positive_integer provider_runtime_policy.rs New asserts: 0.0, 0.5 and "0" are not positive.
< → <= in best_ask, > → >= in best_bid, / → * in evaluate_rulo rulo.rs New test: of two equal quotes the first wins, the buy uses the ask, and a zero bid gives no USDT route.
> → >= in render_task_page task_commands.rs New test: a 28-character task keeps its text on one page.
+= → *= in romanize_japanese command_normalization.rs Excluded: it only hangs.
> → >= in render_bcra (one date) bcra.rs New case: one dated variable is not a shared date.

All changes

  1. Cargo.toml, crates/bot-core/Cargo.toml: num-integer 0.1.47 as a direct dependency. It was already in Cargo.lock through num-bigint. osv-scanner finds no advisory for it.
  2. crates/bot-core/src/calendar.rs: new module with the only days_from_civil and civil_from_days.
  3. crates/bot-core/src/bcra.rs, charge_history.rs, crates/bot-adapters/src/bcra.rs, crates/bot-adapters/src/weather.rs: use calendar instead of their own copies.
  4. crates/bot-core/src/ai_calculator.rs: floor division and modulo through num-integer; one step less in tokenize; a 200-token test.
  5. crates/bot-core/src/admin_reports.rs, admin_commands.rs, ai_reserve.rs, ai_response_cleanup.rs: remove checks that cannot change the result; new limit cases.
  6. .cargo/mutants.toml: exclusions for the equivalent and hanging mutants, each with its reason.
  7. crates/bot-core/src/command_normalization.rs, config_callbacks.rs, links.rs, telegram_payments.rs, token_signals.rs: the small rewrites in the table above.
  8. New tests in chat_members.rs, compaction_policy.rs, config_callbacks.rs, config_command.rs, dollar.rs, market_prices.rs, output_format.rs, polymarket.rs, price_queries.rs, provider_runtime_policy.rs, rulo.rs, task_commands.rs, telegram_actions.rs, token_signals.rs and bcra.rs.

Done when

  • cargo clippy -D warnings and cargo test -p bot-core (736 pass) on 6cc06a1.
  • cargo-mutants on every row of Issue Missed mutants #533: no missed or timed-out mutant left, except the exclusions above. A run of all reported rows on 6d767a4 caught 140 of 143 mutants. The 3 left are fixed in 6cc06a1, and a rerun of those rows caught all 10 matching mutants.
  • scripts/check-container.sh passes on 6cc06a1 (the full suite with its ffmpeg and PostgreSQL), with coverage.
  • CI passes on 6cc06a1 (required checks, coverage, fuzz, image, CodeQL).
  • Agent review.

Review

Pending.

@astrovm astrovm changed the title test: catch the missed mutants from the weekly run test(bot-core): catch the missed mutants from the weekly run Nov 29, 2026
@github-actions

Copy link
Copy Markdown

Mutation testing: 219 of 220 changes caught by a test.

crates/bot-core/src/bcra.rs:333:52: replace < with <= in render_bcra

Each one is a change to the code no test noticed. Not a blocker: real gaps get their own PR. Full report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missed mutants

1 participant