~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
"""Bound the set of test modules shelved by the FastAPI migration.
Test modules that import Flask modules the migration deleted used to skip
themselves at module level with an explicit reason naming their replacement
(e.g. "Live coverage moved to tests/web/routers/. Re-port post-Phase-8."). That
was honest, tracked debt rather than a hidden hole — the underlying behaviour
was checked and enforced by live tests elsewhere.
**The shelf is now empty:** `SHELVED_BY_MIGRATION` below is the empty set. The
immediate snapshot collected 92 unskipped cases (89 re-port cases plus three
same-commit structural controls) and 21 deliberate skips. ADR-0010 retains the
separate historical revisions and measurements; this file stays as the
executable ratchet that keeps the shelf empty.
What was missing is a bound. A module-level skip is invisible in a green run:
`pytest -q` prints a dot-free `s` and the summary says "passed". Nothing stops
this shelf from growing unless CI makes additions an explicit reviewed change.
So this is a RATCHET, not a prohibition:
* the shelf may not GROW without editing this file, which forces the decision
to be conscious and reviewed;
* when a module is re-ported the test fails too, prompting you to delete its
entry — so the list shrinks visibly and progress is recorded.
Why this shape rather than an import-graph guard: the dangerous variant of
this class is the opposite one — a test that survives a merge while its
IMPLEMENTATION is deleted. That does not skip, it FAILS, and CI already
catches it. (It is exactly how a lost egress-policy gate was found on this
branch: the orphaned test went red.) A guard for that would duplicate CI. The
silent failure direction is the one this ratchet guards.
"""
# allow: no-sut-import — a guardian test over the TEST tree, not production
# code. It asserts a property of which test modules skip themselves, so
# importing local_deep_research would prove nothing about what it checks.
import pathlib
import pytest
from tests.migration_evidence_nodes import module_level_blocking_reasons
REPO_ROOT = pathlib.Path(__file__).resolve().parent.parent
TESTS_ROOT = REPO_ROOT / "tests"
_PYTEST_MODULE_PATTERNS = ("test_*.py", "*_test.py")
# Test modules that skip themselves because the FastAPI migration deleted the
# Flask modules they exercise. Each is expected to be re-ported, at which
# point its entry here should be removed.
SHELVED_BY_MIGRATION: set[str] = set()
# (empty on purpose — see below; `{}` would be a dict, not a set)
_SHELF_NOTES = """
THE SHELF IS EMPTY. Every module that was shelved by the migration has
been re-ported; this ratchet has fully turned. It stays in the tree
because its job is now prevention: any NEW module that shelves itself
with a migration-era skip marker will be caught by
test_shelved_set_has_not_grown below.
chat/test_chat_socket_events.py — re-ported
news/test_news_input_validation.py — re-ported
research_scheduler/test_scheduler_edge_cases.py — re-ported
security/test_api_security.py — re-ported
security/test_auth_security.py — re-ported
security/test_cookie_security.py — re-ported
security/test_csrf_protection.py — re-ported
security/test_pagination_bounds.py — re-ported
test_followup_api.py — re-ported
The immediate snapshot collects 92 unskipped pytest cases: 89 re-port cases
plus three same-commit structural controls. Another 21 main-era
`@pytest.mark.skip` placeholders remain skipped, deliberately: they assert
nothing on either branch and recovering them would overstate the coverage
restored. The exact historical revisions and aggregate counts are recorded in
ADR-0010.
news/test_news_input_validation.py was re-ported first, separately: its
7 source-inspection tests became 57 behavioural cases.
web/test_socket_subscribe_ownership.py — REMOVED FROM THE SHELF.
Deleted rather than re-ported: its 7 tests drove the deleted Flask
SocketIOService, and every property they pinned now has a live ASGI-era
equivalent. The two unsubscribe-ownership cases are superseded by
tests/web/services/test_socketio_real_websocket_transport.py, which
exercises the restored gate over the real websocket transport rather
than a mocked Flask request. The remaining _user_owns_research cases are
covered by test_socketio_handshake_auth.py::
TestVerifiedUsernameScopesSubscriptions.
"""
# Substrings identifying a migration-shelving skip, as opposed to the many
# legitimate environment skips (no network, no LLM, optional dependency).
_MIGRATION_SKIP_MARKERS = (
"Pre-FastAPI-migration",
"removed in the migration",
)
def _migration_shelving_reason(source: str) -> str | None:
"""Return a literal migration-shelving reason, if statically visible."""
try:
reasons = module_level_blocking_reasons(source)
except SyntaxError:
return None
for reason in reasons:
if any(marker in reason for marker in _MIGRATION_SKIP_MARKERS):
return reason
return None
def _module_level_skip_reason(path: pathlib.Path) -> str | None:
return _migration_shelving_reason(path.read_text(errors="ignore"))
def _discover_shelved(tests_root: pathlib.Path = TESTS_ROOT) -> set[str]:
found = set()
paths = {
path
for pattern in _PYTEST_MODULE_PATTERNS
for path in tests_root.rglob(pattern)
}
for path in paths:
reason = _module_level_skip_reason(path)
if reason and any(m in reason for m in _MIGRATION_SKIP_MARKERS):
found.add(path.relative_to(tests_root).as_posix())
return found
def test_shelved_set_has_not_grown():
"""No new module may be shelved without updating this list."""
discovered = _discover_shelved()
new = discovered - SHELVED_BY_MIGRATION
assert not new, (
"These test modules newly skip themselves as pre-FastAPI-migration:\n"
+ "\n".join(f" - {p}" for p in sorted(new))
+ "\n\nShelving coverage is a decision, not a fix. If a ported test "
"fails, fix it or the code — do not skip the module. If shelving is "
"genuinely right, add it to SHELVED_BY_MIGRATION with a reason in the "
"commit message."
)
def test_shelved_entries_still_exist_and_are_still_shelved():
"""Re-ported modules must be removed from the list.
Fails when an entry no longer skips, so the list shrinks as work lands
instead of quietly outliving it.
"""
discovered = _discover_shelved()
stale = SHELVED_BY_MIGRATION - discovered
assert not stale, (
"These entries no longer skip as pre-FastAPI-migration:\n"
+ "\n".join(f" - {p}" for p in sorted(stale))
+ "\n\nIf they were re-ported, delete them from SHELVED_BY_MIGRATION "
"— that is the ratchet turning. If a file was deleted outright, "
"remove the entry and say so in the commit message."
)
def test_pytestmark_module_shelving_is_detected():
"""A marker assignment must not bypass the empty-shelf ratchet."""
reason = "Pre-FastAPI-migration module awaiting a committed successor"
source = f"""
import pytest
pytestmark = pytest.mark.skip(reason={reason!r})
"""
assert _migration_shelving_reason(source) == reason
def test_nested_module_scope_and_imported_skip_alias_are_detected():
"""Module-executed control flow and common aliases remain in scope."""
reason = "removed in the migration pending a committed behavior port"
source = f"""
from pytest import mark as test_mark
if True:
try:
pytestmark = test_mark.skip(reason={reason!r})
except RuntimeError:
pass
"""
assert _migration_shelving_reason(source) == reason
@pytest.mark.parametrize(
"mutation",
(
"pytestmark += [pytest.mark.skip(reason={reason})]",
"pytestmark.append(pytest.mark.skip(reason={reason}))",
"pytestmark.extend([pytest.mark.skip(reason={reason})])",
),
)
def test_pytestmark_mutation_cannot_bypass_the_shelf(mutation):
"""Common list mutations must retain their literal shelving reason."""
reason = "removed in the migration pending a committed behavior port"
mutation = mutation.format(reason=repr(reason))
source = f"""
import pytest
pytestmark = []
{mutation}
"""
assert _migration_shelving_reason(source) == reason
def test_import_time_class_body_skip_cannot_bypass_the_shelf():
"""A skip raised while defining a class still shelves the whole module."""
reason = "removed in the migration pending a committed behavior port"
source = f"""
import pytest
class TestShelved:
pytest.skip({reason!r}, allow_module_level=True)
def test_node(self):
pass
"""
assert _migration_shelving_reason(source) == reason
def test_direct_skiptest_raise_cannot_bypass_the_shelf():
"""The unittest spelling is also an import-time collection stop."""
reason = "removed in the migration pending a committed behavior port"
source = f"""
import unittest
raise unittest.SkipTest({reason!r})
"""
assert _migration_shelving_reason(source) == reason
def test_class_local_skip_alias_in_a_default_cannot_bypass_the_shelf():
"""Definition headers execute in the class namespace during import."""
reason = "removed in the migration pending a committed behavior port"
source = f"""
class Helper:
from pytest import skip as stop
def helper(value=stop({reason!r}, allow_module_level=True)):
pass
"""
assert _migration_shelving_reason(source) == reason
def test_class_pytestmark_cannot_bypass_the_shelf():
"""A class marker can silently shelve every test in a module."""
reason = "removed in the migration pending a committed behavior port"
source = f"""
import pytest
class TestShelved:
pytestmark = pytest.mark.skip(reason={reason!r})
def test_node(self):
pass
"""
assert _migration_shelving_reason(source) == reason
def test_direct_skip_aliases_are_resolved_at_the_call_site():
"""Earlier/later bindings must not erase a valid direct import alias."""
reason = "removed in the migration pending a committed behavior port"
after_import = f"""
from pytest import skip as stop
stop({reason!r}, allow_module_level=True)
stop = print
"""
after_rebinding = f"""
stop = print
from pytest import skip as stop
stop({reason!r}, allow_module_level=True)
"""
class_local = f"""
class Helper:
from pytest import skip as stop
def helper(value=stop({reason!r}, allow_module_level=True)):
pass
stop = print
"""
assigned_alias = f"""
import pytest
stop = pytest.skip
stop({reason!r}, allow_module_level=True)
"""
same_line_alias = f"""
import pytest; stop = pytest.skip; stop(
{reason!r}, allow_module_level=True
)
"""
for source in (
after_import,
after_rebinding,
class_local,
assigned_alias,
same_line_alias,
):
assert _migration_shelving_reason(source) == reason
def test_importorskip_positional_reason_uses_the_reason_argument():
"""The dependency name is not the third positional reason argument."""
reason = "removed in the migration pending a committed behavior port"
source = f"pytest.importorskip('missing', None, {reason!r})"
assert _migration_shelving_reason(source) == reason
marker = f"pytestmark = pytest.mark.skipif(True, {reason!r})"
assert _migration_shelving_reason(marker) == reason
def test_pytest_suffix_module_pattern_is_scanned(tmp_path):
"""The ratchet follows both of pytest's default Python file patterns."""
reason = "removed in the migration pending a committed behavior port"
path = tmp_path / "shelved_test.py"
path.write_text(
f"import pytest\npytest.skip({reason!r}, allow_module_level=True)\n",
encoding="utf-8",
)
assert _discover_shelved(tmp_path) == {"shelved_test.py"}
@pytest.mark.parametrize("relpath", sorted(SHELVED_BY_MIGRATION))
def test_each_shelved_module_explains_itself(relpath):
"""A shelved module must name why, so the debt stays auditable."""
path = TESTS_ROOT / relpath
assert path.exists(), f"{relpath} is listed as shelved but does not exist"
reason = _module_level_skip_reason(path)
assert reason, f"{relpath} has no module-level pytest.skip reason"
assert len(reason) > 40, (
f"{relpath} skips with a bare reason ({reason!r}). It should say what "
f"replaced it, or what re-porting it requires."
)