Repository navigation
refactor: migrate every test-file-name detector to autobot_shared.testfile_names (#21078) - #21162
Conversation
…the test-name guard (#21078)
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 24 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Code review (code-reviewer pass) at aa259fdRead-only review against
Verdict: CHANGES. The restoring fix for the degenerate names is one character each in the canonical regex. The rest is documentation of behaviour changes (conftest exemptions, |
… names, pin baseline totals (#21078)
…names # Conflicts: # scripts/python_file_size_known_large.py
|
Code review (code-reviewer pass) at be23b6a Read-only, against Fixed since the last pass, verified in code:
CodeRabbit threads: 0 inline review threads; only the summary comment. Nothing needs an answer. |
|
Review findings addressed in be23b6a (fix commit 657be66, then merged with current main).
Also: |
✅ SSOT Configuration Compliance: Passing🎉 No new hardcoded values of either class — Known backlog in |
|
Second review (comment 6720217071) folded in at 4baf994.
|
|
Code review (code-reviewer pass) at 59a946c Delta review from the previous verdict (reviewed head be23b6a) to 59a946c. Read-only; nothing was checked out or run.
New problems in the delta: none. The only author commit is 4baf994 (docstring only, 4 lines in one file). The rest is the main merge bringing in #15738 content. CodeRabbit threads: 0 inline review threads. The only CodeRabbit comment is a rate-limit notice, so there is nothing to answer. |
Auto-sync: merging
|
| side | commit | subject | issue refs |
|---|---|---|---|
| main | eb0ccc38fc |
Merge main into issue-20761-api-key-compare (auto-sync) [skip ci] | none |
| main | 1fd6964fd3 |
fix(auth): the constant-time compare guard declares its reach floor, scope and roots (#20761) | #20761 |
| this branch | 5d6c08c7eb |
refactor: move the reach scope record to its own module and register the test-name guard (#21078) | #21078 |
|
Delta review at 3d154ec after the main merge: APPROVE. The merge commit has no combined hunks, so every file came cleanly from one side. The own commit routes main's two new test-name rules ( |
|
Merge check at 9ac080a (merges fe97219 and 9ac080a): MERGE-OK.
|
…ays stdlib-only (#21078)
|
Delta review at 39e1e6d (T103 ejection fix): APPROVE. |
Refs #21078
Thinking Path
#21078 asks for one answer to "is this file name a test file?". The canonical predicate landed from #21065 as
autobot_shared/testfile_names.py(is_test_filename(name, *, include_js=True)); the issue and the task name ittest_file_names, but a module calledtest_file_names.pywould itself match the test-name rule, so it istestfile_names. Each site keeps its directory rule and passesinclude_js=Falsewhere JS specs never counted; the helper needed no new variant. Where the helper is stricter or wider than the old rule it is the issue's intent: the old copies had drifted (some missedconftest.pyortests.py, one used a substring match that skippedlatest_x.py).What Changed
Migrated to
is_test_filename(file:symbol):autobot-backend/api/codebase_analytics/api_endpoint_scanner.py(_is_test_file, and the inline.test./.spec.skip in the frontend call scan);autobot-backend/api/codebase_analytics/config_duplication_detector.py(_is_test_or_archive);autobot-backend/code_intelligence/testing_pattern_analyzer.py(is_test_file; caller-suppliedtest_file_patternsstill win, omitted means canonical);autobot-backend/code_analysis/src/testing_coverage_analyzer.py(_is_test_file);autobot-backend/api/analytics_architecture.py(_should_skip_python_file);autobot-backend/services/autoresearch/meta_agent.py(_validate_target);autobot_shared/symbol_forks.py(fork_is_test_file);autobot_shared/api_routing/mount_graph.py(build_graph);autobot_shared/plugin_sdk/loader.py(is_non_production_module).tools/lint/check_no_blocking_io_in_async.py,check_no_src_mock_path.py,check_route_deadlines.py,check_getenv_ssot_drift.py,check_git_toplevel_env_scrubbed.py,check_no_local_schemas.py,check_git_write_env_scrubbed.py,check_ci_system_package_provisioning.py,_env_fork_scan.py;tools/lint/canonical/rules/py_banned_route_path.py,py_duplicate_concept.py,py_hardcoded_url.py,py_banned_suffix_filename.py;scripts/audit_api_wiring.py(both sites).autobot-backend,autobot-slm-backend,autobot_sharedandrepo_testsguards that carried a copy (_isolated_git_detect,_mocked_config_import,_reach_roots,_audit_action_vocabulary_scope,_import_hermeticity_scope,_registry_catalogue, and the guards named in the issue plus the ones the guard found)._reach_roots_record.pyis regenerated.New guard:
repo_tests/test_name_predicate_single_home_21078_test.py(AST detector forendswith("_test.py"),== "conftest.py",".test." in x), with planted controls (a hand-written predicate is flagged, the canonical module and a call to it are not) and a shrink-only baselinerepo_tests/test_name_predicate_baseline_21078.py. Its scope is declared inrepo_tests/_reach_declared_scopes.py, split out ofreach_scope_claim_17844_test.pybecause one more entry took that file past 600 lines.Deferred and left, each in the baseline with its reason:
code_intelligence/python_files.py,problem_dedup.py,problem_query.py,endpoints/stats.py,endpoints/report.py,client_disconnect.py,error_boundaries/, the 21004 test) holds a detector on main.tools/lint/check_no_direct_redis.py: its hook runs on the system interpreter, which theautobot_sharedimport floor refuses.pipeline-scripts/audit_unwired_trackers.py:82,125: deliberately not canonical (TEST_PATH_FRAGMENTSmatches_test./.test.anywhere in a path and excludes/test_for pytesttmp_path); touching the file trips its flake8 hook (bug(scripts): audit_unwired_trackers.py fails the repo's own hooks (print() and line length), blocking any edit #21164), so the reason is recorded in the baseline header instead.tools/lint/prepush_selection.py:137: matches pytestpython_filesglobs, a different question.tools/lint/canonical/rules/py_celery_private_event_loop.py: the rule scansconftest.pytoday and migrating would silently exempt it; nothing in its own test requires that, so the baseline reason says so.conftest.py) and about 120 further hand-written copies the guard found outside the issue's list (100-file ceiling): tracked in refactor: migrate the remaining hand-written test-file-name rules the #21078 guard found #21161.Floor change: none. The
floor=329pin was removed;slm_login_needs_no_users_db_19406_test.pykeepsconftest.pyin scope, so its floor stays 330.conftest.pyscope, per toolis_test_filename(name, include_js=..., include_conftest=True)gained a keyword.include_conftest=Falsekeepsconftest.pyout of the test class. Every site whose old rule did not nameconftestpasses it, so no population, floor or census moves. Decision per tool:conftest.pystays checked (real code: hooks, fixtures, env handling) forcheck_no_blocking_io_in_async,check_getenv_ssot_drift,_env_fork_scan,check_git_toplevel_env_scrubbed,check_git_write_env_scrubbed,check_no_src_mock_path,check_route_deadlines,check_no_local_schemas,check_ci_system_package_provisioning, canonical rulespy_hardcoded_url,py_banned_route_path,py_duplicate_concept,py_banned_suffix_filename,scripts/audit_api_wiring.py(both sites),repo_tests/_reach_roots.py,_registry_catalogue,_audit_action_vocabulary_scope,_import_hermeticity_scope, and the guardsanalytics_metadata_contract_17651,docstring_restatement_17165,embedding_override_19379,enum_hand_copy,no_simulated_command_output_19807,regex_concept_fork_18093,secret_access_check_16982,slm_login_19406,source_scoping_17758,tls_cert_dir_19317,node_roles_declared_producers. Sites whose old rule already exemptedconftest.pykeep the default (symbol_forks,_isolated_git_detect,_mocked_config_import,loader.is_non_production_module, the a2a / chat_workflow / llm_spend / raw_client_session / slm_agent_deploys / import_under_mocked_config / redis_db / api_key_scopes / chunk_identity / fastapi_validation / inline_lazy / kb_construction / one_fake_* / raw_aiohttp / store_authority / upload_routes / stdlib_logging / service_upsert guards).meta_agent._validate_targetalso keeps the default: refusingconftest.pyas an edit target is the safe direction.Behaviour changes
testfile_names:test_.+/.+_testbecametest_.*/.*_test, sotest_.pyand_test.pyare tests again everywhere (the meta-agent target refusal, the plugin loader,mount_graph,api_endpoint_scanner,config_duplication_detector,symbol_forks). Pinned intestfile_names_test.py.plugin_sdk.loader.is_non_production_modulealso skips a submodule namedtestsand ignores case; pinned inplugin_sdk/non_production_module_21078_test.py(notestssubmodule exists today).analytics_architecture._should_skip_python_file: the old"test_" in namesubstring match skippedlatest_x.py,contest.py,attestation_x.pyand similar; only thetest_prefix and_test.py/tests.pynames are skipped now, so those production files enter the architecture analysis and its file and pattern totals can rise. No test pins those totals (the only test touching the module,analytics_architecture_regex_19566_test.py, passed).testing_coverage_analyzer._is_test_file: the oldre.searchon the full path lettest_anywhere in a directory name mark a file as a test; the new rule reads the base name plustests/in the path. Files under directories such aslatest_results/ortest_dir/that are not test files are no longer counted as tests.self.test_patternswas removed with no other reader. No test pins its totals (analyzer_construction_15914_test.pypassed).testing_pattern_analyzer: with no caller patterns the default is now the canonical rule instead of a list:tests.pywas already matched, case-insensitive matching is added;conftest.pyis not a test here.self.test_file_patternsis nowNoneby default (no reader found)..test./.spec.checks (api_endpoint_scanner, therepo_testsfrontend scans): now*.test|spec.(js,jsx,ts,tsx,mjs,cjs,vue).git ls-files | grep -E '\.(test|spec)\.'lists 687 files, none outside that extension list, so the list was not widened. Behaviour change: names the old any-extension substring skipped (x.test.mts,.cts,.test.json,a.test.mock.ts) would now be scanned; none is tracked. The one\.(test|spec)\.ts$site now also skips js, tsx and vue specs.MAX_ENTRIES = 135andMAX_SITES = 169pins; thestartswith("test_")-only shape is a documented limit with a pinned control (it also tests test-function names across the tree); the remaining drift is tracked in refactor: migrate the remaining hand-written test-file-name rules the #21078 guard found #21161.Verification
~/.venv-python-suite/bin/python -m pytest: all passed (a2a, chat_workflow, services, SLM backend, therepo_testsguards,plugin_load_visibility_test,testfile_names_test,tools/linttests).repo_tests/test_name_predicate_single_home_21078_test.py,reach_declarations_test.py,reach_scope_claim_17844_test.py: 1304 passed.repo_tests/lint/canonical/rules/test_py_celery_private_event_loop.pyandreach_roots_record_18808_test.py: 19 passed.Model Used
Claude Sonnet 5.5