Files
timmy-home/tests/test_source_distinction.py
Alexander Whitestone 1f92fb0480
Some checks failed
Agent PR Gate / gate (pull_request) Failing after 18s
Self-Healing Smoke / self-healing-smoke (pull_request) Failing after 17s
Smoke Test / smoke (pull_request) Failing after 18s
Agent PR Gate / report (pull_request) Has been cancelled
feat: source distinction - I think vs I know (#793)
SOUL.md compliance: 'Every claim I make comes from one of two places:
a verified source I can point to, or my own pattern-matching.'

scripts/source_distinction.py:
  SourceType enum: VERIFIED, INFERRED, STATED, UNKNOWN
  Claim dataclass with source_type, source_ref, confidence, hedging
  AnnotatedResponse with render() and format_for_display()
  Helper functions: verified(), inferred(), stated()
  source_distinction_check() - hedging word detection

Tests: 9 passing
2026-04-17 01:44:06 -04:00

62 lines
2.6 KiB
Python

"""Tests for source distinction - SOUL.md compliance."""
import pytest
class TestSourceDistinction:
def test_verified_claim(self):
from scripts.source_distinction import verified, SourceType
claim = verified("Paris is the capital", "web_search:Paris")
assert claim.source_type == SourceType.VERIFIED
assert claim.source_ref == "web_search:Paris"
assert claim.confidence == 0.95
def test_inferred_claim(self):
from scripts.source_distinction import inferred, SourceType
claim = inferred("this approach is better")
assert claim.source_type == SourceType.INFERRED
assert claim.hedging == "I think"
def test_stated_claim(self):
from scripts.source_distinction import stated, SourceType
claim = stated("my name is Alexander")
assert claim.source_type == SourceType.STATED
assert claim.confidence == 1.0
def test_render_verified(self):
from scripts.source_distinction import annotate_response, verified
resp = annotate_response("test", [verified("Paris is capital", "web")])
rendered = resp.render()
assert "[verified: web]" in rendered
def test_render_inferred(self):
from scripts.source_distinction import annotate_response, inferred
resp = annotate_response("test", [ inferred("this is better")])
rendered = resp.render()
assert "I think" in rendered
def test_counts(self):
from scripts.source_distinction import annotate_response, verified, inferred
resp = annotate_response("test", [
verified("a", "src"), verified("b", "src"), inferred("c"),
])
assert resp.verified_count == 2
assert resp.inferred_count == 1
def test_hedging_detection(self):
from scripts.source_distinction import source_distinction_check
result = source_distinction_check("I think this is probably right, but I believe it could be different")
assert result["has_hedging"]
assert result["hedging_count"] >= 3
def test_no_hedging(self):
from scripts.source_distinction import source_distinction_check
result = source_distinction_check("The capital of France is Paris.")
assert not result["has_hedging"]
def test_format_for_display(self):
from scripts.source_distinction import format_for_display, annotate_response, verified, inferred
resp = annotate_response("test", [verified("a", "src"), inferred("b")])
output = format_for_display(resp)
assert "=" in output # verified icon
assert "~" in output # inferred icon