Skip to content

Remove verified-redundant tests, preserve two boundary assertions - #690

Merged
anshss merged 1 commit into
mainfrom
test-cull
Aug 4, 2026
Merged

anshss merged 1 commit into
mainfrom
test-cull

Conversation

@anshss

@anshss anshss commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Verified a list of 45 candidate tests flagged by a prior file-level audit as possibly redundant, and deleted only the ones I could prove were fully subsumed elsewhere by comparing exact input/output assertions. 16 of the 45 candidates verified as genuinely redundant and were deleted (21 pytest test-IDs once parametrize expansion is counted); the other 29 did not hold up under verification and were left in place. Two deletions required porting one assertion each into the surviving test first, to avoid losing coverage.

This is a test-only change. No product source under tokenjam/ was touched.

Deleted (16 candidates, 21 test-IDs)

  • tests/unit/test_humanize.py (3): test_format_tokens_sub_thousand_is_raw, test_format_tokens_thousands_use_k, test_format_tokens_millions_use_m — tokenjam/utils/formatting.py re-exports the identical format_tokens function object, already covered by test_formatting.py::TestFormatTokens. Ported: that survivor was missing the k→M upper boundary (999_000 == "999.0k"), so I added TestFormatTokens.test_just_below_million before deleting.
  • tests/integration/test_api.py (3 functions / 6 test-IDs): test_status_framing_reflects_plan_tier (a 4-case parametrize) — the /status and /traces routes wire compute_framing via byte-identical code, the /traces version of this matrix survives, and status_response_includes_framing_block still guards /status's own key presence; test_docs_endpoint_is_accessible — a bare FastAPI /docs 200 check with no product logic; test_optimize_response_includes_framing_block — a strict subset of test_optimize_chain_framing_and_recoverable_fields (identical setup, plus more assertions).
  • tests/integration/test_demos.py (1): test_demo_list_shows_descriptions — strictly weaker than test_demo_list_shows_all_scenarios (same invocation, len(output) > 0 vs. specific substrings).
  • tests/integration/test_tokenmaxx_serve.py (1): test_tokenmaxx_cli_errors_cleanly_without_serve_or_conn — subsumed by tests/unit/test_cmd_tokenmaxx.py::test_requires_direct_db_connection, whose own comment cross-references this file.
  • tests/unit/test_demo_live.py (1): test_build_payload_shape. Ported: its only assertion not covered elsewhere (spans[0]["name"] propagating through _build_payload) was added as a new assertion inside test_live_sink_buffers_and_flushes, which exercises the same payload construction through the real flush() path.
  • tests/unit/test_export_claude_code.py (2): test_render_subscription_user_carries_usd_savings_too, test_render_unknown_plan_carries_usd_savings_too — verified against source that render_claude_code_snippet no longer branches on pricing_mode/plan_tier for which fields appear (product decision); added a short comment documenting the invariant in place of the deleted docstrings.
  • tests/unit/test_export_route_generators.py (2 functions / 4 test-IDs, each parametrized over both renderers): test_subscription_user_carries_usd_savings_too, test_unknown_plan_carries_usd_savings_too — same invariant, verified against both render_ccr_config and render_litellm_config source.
  • tests/unit/test_harness_setup.py (1): test_helper_relpath_is_under_tj — HELPER_RELPATH's exact value is verified more strongly (exact-match, not just prefix) by tests/unit/test_mcp_server.py:409 via a real MCP-tool code path.
  • tests/unit/test_models.py (1): test_alert_type_values — all three asserted enum spellings (cost_budget_daily, retry_loop, drift_detected) are independently verified via real serialization in test_mcp_server.py, test_demo_live.py, and test_demos.py.
  • tests/unit/test_time_parse.py (1): test_hours_large — verified in source that parse_since has no branch on digit count; identical regex path to test_hours.

Skipped as unverifiable (29 candidates)

The verification bar was: prove every assertion is checked elsewhere, or leave the test in place. 29 of the 45 candidates did not clear that bar. Notable findings where the original audit's premise turned out to be factually wrong on inspection:

  • tests/integration/test_cli.py (2): test_doctor_onboarding_signal_info_when_silent / _ok_with_spans are the only tests proving cmd_doctor.py's checks.append(_check_onboarding_first_signal(...)) line is wired into tj doctor --json's output — the claimed unit-test survivors only call the check function directly, never through the CLI's ~20-line manually-maintained checks list.
  • tests/integration/test_summarize_cli.py (5): each "human-output" test exercises a distinct call site of a shared print helper (_print_verdict, _print_amortization) with its own independent wiring; no unit test covers the actual rendered text at all. One candidate (test_prep_via_api_unknown_model_labels_estimate) covers a fallback branch (rates_known=False) that literally no other test reaches.
  • tests/unit/test_drift.py (1): the claimed synthetic-test survivor always registers an explicit AgentConfig for the test agent, so it never exercises drift.py:232's self.config.agents.get(agent_id) or AgentConfig() fallback that the candidate is testing.
  • tests/unit/test_onboard_first_run.py (4): one candidate's own docstring starts with "Regression:" — a hard no-touch per this suite's convention regardless of audit findings — and it uniquely guards four legacy-panel strings. A second candidate's claimed premise ("prompt was permanently removed") is false; I read the source and the guarded code is still live, gated by an if persona == "claude-code": return that this test protects.
  • tests/unit/test_formatting.py (4): the audit's own stated reasoning ("one representative + fallback is enough") contradicts its "drop all 4" instruction, and no other test anywhere references severity_colour.
  • tests/unit/test_models.py (5 of 6): only AlertType's literal spelling is verified elsewhere via real JSON output; Severity, SpanStatus.UNSET, SpanKind, and both isinstance(_, str) checks are only ever compared enum-to-enum elsewhere, never enum-to-literal.

Full per-file reasoning is in the worker session; ask if you want it broken out further.

Test plan

  • Ran each touched file's tests individually — 270 passed.
  • Ran the full suite (tests/unit/ tests/synthetic/ tests/agents/ tests/integration/, -n auto) before (via git stash) and after: 5196 total test-IDs before, 5176 after — a net of -20, reconciling exactly against the ledger above (21 deleted, 1 ported/added).
  • One pre-existing failure (test_onboard_first_run.py::test_home_when_db_populated_but_no_config_is_set_up) reproduces identically on unmodified main and in a file this PR never touches — confirmed flaky/order-dependent, out of scope here.

🤖 Generated with Claude Code

Culled a candidate list of possibly-redundant tests down to only the ones
individually verified as fully subsumed elsewhere by comparing exact
input/output assertions against their claimed survivors. Two deletions
required porting a missing assertion into the surviving test first
(format_tokens' k->M boundary case, and _build_payload's span-name
propagation) so no coverage was lost. The majority of candidates did not
hold up under verification and were left in place.

Co-Authored-By: Claude <[email protected]>
@anshss
anshss requested a review from anilmurty as a code owner August 4, 2026 13:36
@greptile-apps

greptile-apps Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This test-only PR removes assertions determined to be redundant and ports two boundary checks into stronger surviving tests.

  • Consolidates token-formatting and live replay payload coverage.
  • Removes duplicate API, CLI, export, enum, path, and time-parsing cases.
  • Leaves one non-blocking coverage concern around independently maintained /status framing wiring.

Confidence Score: 4/5

The PR appears safe to merge, with a non-blocking recommendation to retain /status-specific plan-tier coverage because its framing wiring is maintained separately from /traces.

The production code is unchanged and nearly all removed assertions are covered by identical or stronger surviving paths; only the independently wired /status framing matrix loses meaningful regression protection.

Files Needing Attention: tests/integration/test_api.py

Important Files Changed

Filename Overview
tests/integration/test_api.py Removes several API smoke and duplicate framing tests; the /status plan-tier matrix was not fully redundant with the separately wired /traces route.
tests/unit/test_demo_live.py Moves span-name payload coverage into the stronger end-to-end LiveSink.flush() test.
tests/unit/test_formatting.py Adds the missing just-below-million boundary before duplicate humanize tests are removed.
tests/unit/test_export_claude_code.py Removes mode-specific cases whose asserted figure selection is unconditional in the renderer.
tests/unit/test_export_route_generators.py Removes subscription and unknown cases that traverse the same unconditional shared figure-selection helper.
tests/unit/test_time_parse.py Removes a multi-digit-hour case that follows the same regex and conversion path as the surviving hour test.

Comments Outside Diff (1)

  1. tests/integration/test_api.py, line 637-640 (link)

    P2 Preserve status framing coverage

    The removed plan-tier matrix covered /status's independently maintained framing wiring, while this surviving test only checks key presence for an API plan. Retaining a /status pricing-mode assertion protects against status-specific wiring regressions that make the UI frame subscription, local, or unknown costs incorrectly even when the separate /traces matrix passes.

    Prompt To Fix With AI
    This is a comment left during a code review.
    Path: tests/integration/test_api.py
    Line: 637-640
    
    Comment:
    **Preserve status framing coverage**
    
    The removed plan-tier matrix covered `/status`'s independently maintained framing wiring, while this surviving test only checks key presence for an API plan. Retaining a `/status` pricing-mode assertion protects against status-specific wiring regressions that make the UI frame subscription, local, or unknown costs incorrectly even when the separate `/traces` matrix passes.
    
    ---
    
    For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix All With AI
### Issue 1
tests/integration/test_api.py:637-640
**Preserve status framing coverage**

The removed plan-tier matrix covered `/status`'s independently maintained framing wiring, while this surviving test only checks key presence for an API plan. Retaining a `/status` pricing-mode assertion protects against status-specific wiring regressions that make the UI frame subscription, local, or unknown costs incorrectly even when the separate `/traces` matrix passes.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "test: remove verified-redundant test cas..." | Re-trigger Greptile

@anshss
anshss merged commit d2a6acc into main Aug 4, 2026
7 checks passed
@anilmurty
anilmurty deleted the test-cull branch September 18, 2026 21:03
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.

1 participant