Files
rune/tests/test_research_router.py
T
Nick b6d1a08750
CI Pipeline / canary (push) Successful in 28s
CI Pipeline / best-practices (push) Successful in 3s
CI Pipeline / lint (push) Failing after 32s
CI Pipeline / documentation (push) Successful in 3s
CI Pipeline / unit-tests (push) Successful in 49s
CI Pipeline / gitea-offline (push) Successful in 13s
CI Pipeline / type-check (push) Successful in 25s
CI Pipeline / required-checks (push) Successful in 1s
feat(research): R1-R5 — event-driven coordinator, stage-scoped methodology, OUTWARD router, structured artifact gate, MORE_RESEARCH immediate re-dispatch
R1: disposition routing wired into the research stage workflow — PROCEED
lets research-clear fire, MORE_RESEARCH dispatches round+1 immediately
(no sweep wait). The workflow completion IS the event.

R2: 8 stage-scoped prompt templates (DEFINE through QUALIFY) — each gets
a narrow prompt, frozen prior artifacts, explicit MUST NOT constraints.

R3: research_router.py — classifies questions (academic/software/web),
routes to OpenAlex/SemanticScholar/arXiv/GitHub/DuckDuckGo, doctrine
queries include limitations/alternatives/failures.

R4: structured artifact validated in the stage workflow before commit —
receipt + URLs + code paths + disposition all checked.

R5: MORE_RESEARCH dispatches round+1 from the workflow (no sweep wait);
blocking unknowns passed to the next round.

R0 red reproduction recorded: foreground slept 300s×N while child mimo
worker was productive (18.6% CPU, 547MB, 8min CPU). Anti-pattern confirmed.
2026-09-08 12:31:53 +01:00

36 lines
1.4 KiB
Python

"""Red-first tests for scripts/research_router.py — R3 OUTWARD source routing."""
from __future__ import annotations
import importlib.util
from pathlib import Path
ROOT = Path(__file__).resolve().parent.parent
SPEC = importlib.util.spec_from_file_location("research_router", ROOT / "scripts" / "research_router.py")
rr = importlib.util.module_from_spec(SPEC)
SPEC.loader.exec_module(rr)
def test_academic_question_routes_to_academic():
r = rr.route("what does the latest research say about attention mechanisms in transformers")
assert r["question_type"] == "academic"
assert any(p["name"] in ("OpenAlex", "Semantic Scholar", "arXiv") for p in r["providers"])
def test_software_question_routes_to_software():
r = rr.route("how to configure sqlite WAL mode for better performance")
assert r["question_type"] == "software"
assert any("GitHub" in p["name"] or "docs" in p["name"].lower() for p in r["providers"])
def test_general_question_routes_to_web():
r = rr.route("what are the best practices for TUI performance optimization")
assert r["question_type"] in ("web", "software")
assert len(r["queries"]) >= 3
def test_doctrine_queries_include_limitations():
r = rr.route("textual reactive performance")
assert any("limitations" in q for q in r["queries"])
assert any("alternatives" in q or "vs" in q for q in r["queries"])