Repository navigation
Open
Labels
ai-taskenhancementNew feature or requestpriority: laterUseful improvement, lower sequencing pressuretooling
Description
Priority / sequencing
P2 / priority: later
Suggested labels
- documentation
- ux
- compatibility
- distribution
Roadmap fields
Status: Backlog; Priority: P2; Size: XL; Order: (unset); Depends on: (none)
Problem
A repo-wide over-engineering audit (grep-verified) found about 1,000 lines of removable excess in src/ and scripts/, plus test-suite excess in tests/:
- Copy-pasted helpers. The same logic is hand-written 2 to 5 times across modules, so a fix in one copy silently misses the others.
- A test harness shipping in the wheel.
src/sumo_qa/conformance.py(~761 lines) is a test and eval harness. Onlytests/imports it. - An over-grown test suite.
tests/has 4,746 collected tests, but line coverage ofsrc/needs only 641 of them. Per-item parametrize fan-outs, copy-pasted helpers and per-test subprocess/git setup inflate both the count and the maintenance cost (Scope D).
Expected outcome
- Every duplicated helper listed in Scope exists once and every former copy calls it.
conformance.pylives undertests/and is absent from the built wheel.- Public MCP tool names, docstrings, schemas and CLI behaviour are unchanged.
- The test suite keeps every check it has today with far fewer collected tests and lines, and shared test helpers live once in
tests/conftest.py.
Scope
0. Refresh the audit first (before any edit)
- Re-run the ponytail over-engineering audit (
/ponytail-audit) on currentmain, coveringsrc/,scripts/,tests/evals/andtests/. This issue may sit in the backlog for a while, so the list below is a snapshot ofmainatec7db3b. Grep-verify each item in Scopes B, C and D against currentmain: tick and annotate an item that is already gone, and drop one that no longer applies. Add every new finding to Scope B, C or D. Post the refreshed list as a comment on this issue before implementing. Ad-hoc ponytail reviews are not run while this issue is open, so this audit is where anything that landed sinceec7db3bgets caught.
A. Decisions (recorded)
analysis/(~1,305 lines, [Task]: Add semantic code analysis adapters for QA recommendations #212): keep. It has no production caller yet, but it is the planned base layer for epic [Epic]: Expose semantic change-impact intelligence to users and workflows #622 ([Task]: Define user-facing semantic impact model and QA workflow integration #623, [Task]: Add semantic impact evidence to QA reports and risk context #629). Its adapter registry stays as the extension point for more languages.gate_evidence_*(~419 lines, [Task]: Add evidence-backed gate reporting for QA workflow claims #213): keep. It is the base for [Task]: Introduce provenance-bound evidence receipts and serve gate evidence #514 (P1, serve gate evidence), [Task]: define evidence-gated TDD behavior for explicitly delegated workers #470 and [Task]: bring gate-evidence decision logic under the strict mutation gate #488.-
conformance.py: move undertests/so it stops shipping in the wheel.
B. Collapse duplicates (largest first)
- JSON-RPC
initialize/tools/listhandshake written 4 times:installer.py:1301,doctor.py:227,scripts/uvx_smoke_handshake.py:54,scripts/regen_tools_list_snapshot.py:48. One helper insrc/sumo_qa/. Callers classify the result. - Load-envelope boilerplate (error class,
_classifyif-chain, schema_version pre-check,locjoin) inledger_validation.py,export_validation.py,context_bundle_validation.py,scorecard_validation.py,gate_evidence_validation.py,coverage_models.py. Oneload_envelope(data, model, version, err_cls)plus a dict lookup for the error kind. Keep each public*ValidationErrorname and itskindvalues. - Per-host setup/uninstall pairs in
installer.py:855-1020share one shape. Drive them from a(name, path_fn, container_key)table. - Markdown cell escaper copied 4 times and table builder 3 times across
ledger_format.py,export_format.py,scorecard_format.py,context_bundle_format.py. Onemd_cell()and onemd_table(). - JetBrains IDE-dir detection (
jb_rootOS branch) atinstaller.py:972,installer.py:1138,doctor.py:1002. One_jetbrains_ide_dirs(home, system). - Claude Code
config_dirresolution duplicated ininstaller._setup_claude_code,installer._uninstall_claude_code,doctor._claude_code_config_path. - Heading scanner, fence/heading regexes,
_dedupe, slugify duplicated betweenskill_manifest.py:67-134andknowledge_loaders.py:175-235. Also_approx_tokensand_FRONTMATTER_REduplicated inskill_prompts.py/skill_manifest.py. - Four pass-through knowledge-loader tools in
server.py:914-995. Register from a table (names and docstrings unchanged). - "Read config, warn unreadable, parse, warn malformed" repeated in
repo_map_resolvers/{rust,php,typescript,csharp}.py. OneScanContext.read_parsed()inbase.py. - Dot-segment join loop copied in
cpp.py:154,typescript.py:354,ruby.py:188. Useposixpath.normpath(posixpath.join(...))plus a..check, as csharp/php already do. Replace the 8rsplit("/", 1)[0] if "/" in x else ""sites withposixpath.dirname. - Path-resolution ladder hand-rolled in
knowledge_loaders._standards_dir/_rules_path. One_first_existing(candidates). -
git rev-parse --show-toplevelblock x3 (repo_map_scanner.py:298,:619,repo_map_impact.py:188) and_git_envx2. One helper each.
C. Small deletions
-
LanguageConfig.extensionsis never read. Drop the field and everyextensions=(...). Drop explicitbarrels=()that repeats the default. -
PreparableResolverProtocol (repo_map_resolvers/base.py:198) exists for oneisinstancecheck. Usegetattr(resolver, "prepare", None). -
TestDataValidatorProtocol (tdm_validation.py:17) has one implementation. Annotate withMockValidator. - Dead
_NON_SLUG_REatknowledge_loaders.py:175. - Single-use wrappers:
typescript._is_out_of_repo_target,skill_manifest._public_section/_public_module(identical). -
tests/evals/promptfoo/recall.py(from the PR test(evals): add a review-recall corpus of real past misses and a recall reporter #770 ponytail review, about -6 lines; outside thesrc/+scripts/line count):_casereturns(identity, caught)instead of a 5-tuple that repeats the identity fields; the controls counter uses_bucket()like every other bucket; the per-runidentities/sourcebookkeeping moves to a list besidefile_runs, sosummariseno longer deletes keys before returning.tests/test_eval_recall_report.pystays green unchanged, andrecall.pyoutput on a real recall report is identical before and after.
D. Test suite (tests/, excluding tests/evals/): from the 2026-10-01 audit of 7abc919
The suite has 4,746 collected tests from 2,791 test functions. Line coverage of src/ needs only 641 of them. The audit estimate is about -1,140 tests and -3,800 lines. Every change keeps the same checks: a merged fan-out must still fail on every offender and name each one.
- Merge per-item fan-outs into one test that collects offenders and asserts the list is empty (about -950 tests):
test_mutmut_subprocess_exclusions.py:158: 150 copies, one per test file. Also hoist its twotomllibparses.test_eval_runner_defaults.py:96-122: candidate / judge / no-openai checks, 65 copies each. Parse each config once.test_review_skill_modules.py: the load-bearing rule check (95 copies,:856) plus the per-module and per-pinned-marker families (:814,:868,:877,:955,:1096,:1126,:1194). Cache_all_skill_text(), which is re-read on every call.test_skill_conformance.py: the structure checks (:24-90, 126 items), the host-phrase denylists (:98-125, 126 items) and the contract-doc check (:128-157).test_repo_map_resolver_scanner_contract.py:96-133: 62 items.- Also the smaller fan-outs:
test_eval_recall_corpus.py:99-160,test_check_no_em_dashes.py:174-186(also drop itsgit ls-filesat collection time),test_skill_md_token_budget.py:111-123,test_skill_md_description_vs_body.py:172-181,test_skill_modules.py:131-140and:242-265,test_skill_triggering.py:36-186(also reuse one server instead of rebuilding it per row).
- Widen fixture scope for expensive setup (the part that saves time):
test_session_start_hook.py: one module-scoped hook run per env variant, and fold the tests that read the same payload. About -20s.- Real git repos per test in
test_report_builder.py(18 callers),test_repo_map_scanner.py(10),test_check_mutation_gate.py:673(8): copy a session-scoped template repo. - Node assert harness spawned per row in the four
test_eval_*_assert.pyfiles: batch each table through one_gradecall. - MCP server subprocess per test in
test_e2e_mcp_initialize.py:111-166andtest_tools_list_contract.py: once per module. test_repo_map_resolvers_java.py:46-94: replace the interpreter spawn with an in-processsys.modulescheck.
- Fold near-duplicate tests into tables:
test_doctor.py: per-host config checks,run_mcp_probeerror shapes, registry variants, colour and exit-code renderer tests.test_claude_hooks.py: slug-prior resolution (:1166-1700) and path validation (:455-655).- Pure-resolve cases in
test_repo_map_resolvers_{rust,ruby,go,typescript,php,python,java,cpp}.py, and the 8*_resolver_is_registeredtests (covered by the scanner contract). test_cli.pyhuman/--json/missing-repo clusters;test_installer_idempotency.py;test_claude_cli_provider.py:74-312tables;test_server_schemas.pyper-modelrejects_unknown_field; per-tool metadata trio intest_server_*_tool.py;test_report_html.py:82-120;test_knowledge_loaders_entries.py:161-186,:286-307,:357-430;test_eval_mirror_gate_assert.py:104-380;test_toolchain_pin_lockstep.py:380-660withtest_treesitter_pins.py.
- One shared
tests/conftest.py(none exists today) replacing the copies:_repo_root()(8), git-repo setup (about 6),_FakeStream/_FakeProc/_okPopen fakes (4 files),_needs_tsskip marker (13),_writefile helper (6), the node assert harness (4), a sharedserverfixture. - Delete tautology and dead tests:
test_installer_uses_plugin_metadata.py:19-49(greps installer source).test_bin_wrapper.py(prose greps).test_doctor.pyhasattr/dataclass/version meta-tests (:116-150,:1046-1049) andtest_doctor_module_form_help_is_path_independent.test_token_weight_regression.py:112-130(permanentxfail) and the subsumed loop at:189-265.test_error_envelope.py:48-86: drop the duplicate hint test and tighten the always-trueorassert.- Five weak loader tests in
test_knowledge_loaders.py:273-352subsumed bytest_knowledge_loaders_strengthening.py. test_report_builder.py:522(duplicates the HTML tracker-leak guard).TestNpmScriptsintest_eval_runner_defaults.py:129-150, and the per-config wiring greps in the threetest_eval_*_assert.pyfiles.
- Mutation-gated modules need care. Tests that kill mutants in
tdm_validation,report_builderandknowledge_loadersmay only move or merge if the mutation gate stays at no new survivors. Do not deletetest_tdm_validation_strengthening.pywholesale. Replace the encoding/indent spy tests intest_report_builder.py:1179,:1198,:1245with# pragma: no mutateonly if the mutation-survivor triage classes those mutants as equivalent.
Acceptance criteria
- A refreshed audit of current
mainis posted on this issue before implementation, and Scopes B, C and D match it (stale items removed, new findings added). -
conformance.pyis undertests/, all its importers are updated, and it is absent from the built wheel. -
analysis/andgate_evidence_*keep their public API. They change only to adopt shared helpers from Scope B. - Each Scope B item:
git grepshows one definition and no remaining copy. - Each Scope C item is removed, or the PR states why it was kept.
- No public MCP tool name, schema or docstring changes. The tools/list snapshot test passes unchanged.
- Mutation gate holds on every touched file (no new survivors).
- Net line count in
src/+scripts/goes down. The PR states the before/afterwc -l. - Each Scope D item is done, or the PR states why it was kept. The PR states before/after collected-test count,
tests/line count and local full-suite time. - The 100% coverage gate still passes, and a merged fan-out still fails on a seeded offender and names it.
Test plan
uv run pytest(full suite) green.uv run mutmut runon the touched modules, with the mutation gate passing.- Install smoke:
python -m sumo_qa.installer --skip-mcp-installin a scratch workspace plussumo-qa doctor, to confirm the shared handshake and host-table refactors behave the same. - Build the wheel and confirm
conformance.pyis absent from it. - For each merged fan-out, seed one offender locally and confirm the merged test fails and names it.
uv run pytest --collect-only -q | tail -1and the full-suite time, before and after.
Context
- Source: ponytail over-engineering audit of
mainatec7db3b(0.67.0). Every item was grep-verified for callers before listing. analysis/andgate_evidence_*were reviewed and kept as foundations for open planned work ([Epic]: Expose semantic change-impact intelligence to users and workflows #622, [Task]: Introduce provenance-bound evidence receipts and serve gate evidence #514). They are not dead code.- Out of scope: correctness, security and performance findings.
- Rejected: replacing the stdlib PNG code in
scripts/generate_marketplace_assets.pywith Pillow (adds a dependency, and the script is stdlib-only on purpose). Droppingtomlionly applies ifrequires-pythonmoves to 3.11 or later, which is a separate decision. - Likely splits into 3 PRs: (1) installer/doctor/scripts plus the conformance move, (2) validation/format/resolver dedupe, (3) the Scope D test-suite cleanup.
- CI matrix size and pre-push suite runs are tracked in [Task]: cut CI and pre-push test time (matrix size, per-push suite runs) #787, not here.
Metadata
Metadata
Assignees
Labels
ai-taskenhancementNew feature or requestpriority: laterUseful improvement, lower sequencing pressuretooling
Activity
[-][Task]: remove duplicated helpers and decide the fate of unwired subsystems (over-engineering audit)[/-][+][Task]: remove duplicated helpers and stop shipping the conformance harness (over-engineering audit)[/+][-][Task]: remove duplicated helpers and stop shipping the conformance harness (over-engineering audit)[/-][+][Task]: remove duplicated helpers, stop shipping the conformance harness, slim the test suite (over-engineering audit)[/+]feat(cli): add a side-effect-free sumo-qa check readiness gate with e…