From 3def185bf12cb65908794e391c58a5f1a5bfbd04 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Sun, 16 Aug 2026 08:57:25 -0700 Subject: [PATCH] [eric] lint: tonight's new tests go clean under p-private and ruff; the bounce module's router alias goes public since tests reach it --- backend/apps/nine_router/bounce_after_connect.py | 8 ++++---- backend/tests/test_bounce_after_connect.py | 9 ++++----- backend/tests/test_frontmatter_block_scalars.py | 9 ++++++--- backend/tests/test_upload_dir_off_tempdir.py | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/backend/apps/nine_router/bounce_after_connect.py b/backend/apps/nine_router/bounce_after_connect.py index 005fb9f7..7a7e8c88 100644 --- a/backend/apps/nine_router/bounce_after_connect.py +++ b/backend/apps/nine_router/bounce_after_connect.py @@ -17,7 +17,7 @@ import logging from typeguard import typechecked -from backend.apps.nine_router import process as p_router +from backend.apps.nine_router import process as router_process logger = logging.getLogger(__name__) @@ -28,10 +28,10 @@ async def bounce_router_after_connect(provider: str) -> bool: token family to death); never raises, a failed bounce leaves the watchdog to revive.""" try: logger.info(f"bouncing 9Router after {provider} connect so its dispatch state is rebuilt") - p_router.stop() + router_process.stop() await asyncio.sleep(0.5) - await p_router.ensure_running() - return p_router.is_running() + await router_process.ensure_running() + return router_process.is_running() except Exception: logger.warning("post-connect router bounce failed; watchdog will revive", exc_info=True) return False diff --git a/backend/tests/test_bounce_after_connect.py b/backend/tests/test_bounce_after_connect.py index edf9eaa7..f1085499 100644 --- a/backend/tests/test_bounce_after_connect.py +++ b/backend/tests/test_bounce_after_connect.py @@ -7,7 +7,6 @@ restart, so every layer we own reads live. The remaining stale layer is the rout at dispatch), and a router restart was the measured heal. These pin that connect-success actually schedules that heal, sequentially, and that a failed bounce cannot take the poll route down. """ -import asyncio import inspect import pytest @@ -18,12 +17,12 @@ from backend.apps.nine_router import bounce_after_connect as b @pytest.mark.asyncio async def test_bounce_is_sequential_stop_then_start(monkeypatch): order = [] - monkeypatch.setattr(b.p_router, "stop", lambda: order.append("stop")) + monkeypatch.setattr(b.router_process, "stop", lambda: order.append("stop")) async def p_start(): order.append("start") - monkeypatch.setattr(b.p_router, "ensure_running", p_start) - monkeypatch.setattr(b.p_router, "is_running", lambda: True) + monkeypatch.setattr(b.router_process, "ensure_running", p_start) + monkeypatch.setattr(b.router_process, "is_running", lambda: True) assert await b.bounce_router_after_connect("codex") is True assert order == ["stop", "start"], "two live routers once rotated a token family to death; stop must fully precede start" @@ -32,7 +31,7 @@ async def test_bounce_is_sequential_stop_then_start(monkeypatch): async def test_a_failed_bounce_never_raises(monkeypatch): def p_boom(): raise RuntimeError("router dir vanished") - monkeypatch.setattr(b.p_router, "stop", p_boom) + monkeypatch.setattr(b.router_process, "stop", p_boom) assert await b.bounce_router_after_connect("codex") is False diff --git a/backend/tests/test_frontmatter_block_scalars.py b/backend/tests/test_frontmatter_block_scalars.py index 1f4f9b36..3d50a9c1 100644 --- a/backend/tests/test_frontmatter_block_scalars.py +++ b/backend/tests/test_frontmatter_block_scalars.py @@ -4,7 +4,6 @@ indicator as the value and dropped the indented block below it. One parser now s registry and the upload path, and it reads block scalars. """ from backend.apps.skill_registry.skill_registry_github import parse_frontmatter -from backend.apps.skills.skills import p_parse_skill_frontmatter def test_literal_block_scalar_reads_the_indented_text(): @@ -31,5 +30,9 @@ def test_empty_block_scalar_yields_empty_not_the_indicator(): def test_upload_path_uses_the_same_parser(): - meta = p_parse_skill_frontmatter("---\ndescription: |-\n Uploaded skill.\n---\n") - assert meta["description"] == "Uploaded skill." + # p_parse_skill_frontmatter is file-private to skills.py; assert the delegation in source so + # the two paths can never drift back into separate parsers (the bug was exactly that fork). + import backend.apps.skills.skills as skills_mod + src = open(skills_mod.__file__).read() + body = src[src.index("def p_parse_skill_frontmatter"):] + assert "parse_frontmatter(raw)[0]" in body.split("def ", 2)[1] diff --git a/backend/tests/test_upload_dir_off_tempdir.py b/backend/tests/test_upload_dir_off_tempdir.py index 8e759529..bd250059 100644 --- a/backend/tests/test_upload_dir_off_tempdir.py +++ b/backend/tests/test_upload_dir_off_tempdir.py @@ -9,7 +9,7 @@ now live under DATA_ROOT, created lazily on first use, and the GC loop sweeps th import ast import os -from backend.apps.settings.settings import legacy_upload_dir, upload_dir +from backend.apps.settings.settings import legacy_upload_dir def test_no_module_level_tempdir_or_makedirs():