demoprep / tests /test_research_logging_regression.py
mike boone
feat: add temporary-password onboarding flow
ece9b51
Raw
History Blame Contribute Delete
1.21 kB
"""Regression checks for research-phase session logging."""
import ast
from pathlib import Path
def test_fresh_research_binds_slog_before_use():
"""Catch the UI-only NameError where _slog was referenced before assignment."""
source = Path("chat_interface.py").read_text()
module = ast.parse(source)
target = next(
node
for node in module.body
if isinstance(node, ast.ClassDef) and node.name == "ChatDemoInterface"
)
method = next(
node
for node in target.body
if isinstance(node, ast.FunctionDef) and node.name == "_run_fresh_research"
)
saw_assignment = False
for node in ast.walk(method):
if isinstance(node, ast.Name) and node.id == "_slog" and isinstance(node.ctx, ast.Load):
assert saw_assignment, "_slog is read before it is assigned in _run_fresh_research"
return
if isinstance(node, ast.Assign):
saw_assignment = any(
isinstance(target, ast.Name) and target.id == "_slog"
for target in node.targets
) or saw_assignment
raise AssertionError("_run_fresh_research does not read _slog; regression test needs updating")