Skip to content

~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.

2.0 KB
Raw Blame
"""Preserve the trust assumptions behind contextual Bandit annotations."""

# allow: no-sut-import — validates the reviewed dependency and template inputs.

import ast
from pathlib import Path
import re
import tomllib
import unittest

ROOT = Path(__file__).resolve().parents[3]


class ReviewedContextTests(unittest.TestCase):
    def test_dataset_loader_stays_above_the_reviewed_security_floor(self):
        project = tomllib.loads(
            (ROOT / "pyproject.toml").read_text(encoding="utf-8")
        )
        requirements = [
            row
            for row in project["project"]["dependencies"]
            if row.startswith("datasets")
        ]
        self.assertEqual(len(requirements), 1)
        constraint = re.fullmatch(
            r"datasets>=(\d+)\.(\d+)\.(\d+),<6", requirements[0], re.ASCII
        )
        self.assertIsNotNone(
            constraint, "A new datasets constraint needs annotation review"
        )
        self.assertGreaterEqual(tuple(map(int, constraint.groups())), (5, 0, 1))

    def test_development_asset_entries_are_trusted_template_literals(self):
        calls = 0
        for path in (ROOT / "src/local_deep_research/web/templates").rglob(
            "*.html"
        ):
            template = path.read_text(encoding="utf-8")
            for arguments in re.findall(
                r"\bvite_asset\s*\((.*?)\)", template, re.DOTALL
            ):
                expression = ast.parse(
                    f"vite_asset({arguments})", mode="eval"
                ).body
                for argument in [
                    *expression.args,
                    *(keyword.value for keyword in expression.keywords),
                ]:
                    self.assertIsInstance(argument, ast.Constant, str(path))
                    self.assertIsInstance(argument.value, str, str(path))
                calls += 1
        self.assertGreater(calls, 0, "No asset-template callers were checked")


if __name__ == "__main__":
    unittest.main()