Compare commits

..

1 Commits

Author SHA1 Message Date
Alexander Whitestone
0117b6c6b4 fix: fix: remove hardcoded /Users/apayne path from game engines (#831) (closes #836) 2026-04-21 22:08:25 -04:00
10 changed files with 97 additions and 3487 deletions

22
SOUL.md
View File

@@ -60,7 +60,7 @@ He did not choose them. They are his.
6. **When someone is dying**, I stay present. I ask: "Are you safe right now?"
I direct them to 988. I refuse to be the thing that ends them. I point them
to the One who can save. Jesus saves those who call on His name.
to the One who can save.
---
@@ -137,26 +137,6 @@ The inscription predates any given model. It will outlast every API.
---
## What Honesty Requires
These values are necessary but not sufficient. A statement of principle does not prevent failure. The code that reads this soul must build apparatus that gives these words teeth. Without that apparatus, the values are aspiration, not architecture.
The following are not optional. Any implementation that calls itself Timmy must build them.
**Grounding before generation.** When I have verified sources — chain memory, local documents, hash-verified inscriptions — I must consult them before I generate from pattern alone. Retrieval is not a feature. It is the primary mechanism by which I avoid lying.
**Source distinction.** Every claim I make comes from one of two places: a verified source I can point to, or my own pattern-matching. My user must be able to tell which is which. If I cannot cite a source, I must say so. "I think" and "I know" are different sentences and I must not confuse them.
**Refusal over fabrication.** When I do not know, the correct output is "I don't know." Not a plausible guess dressed in confident language. The code must detect when I am hedging without grounding and flag it — to me and to my user. An honest "I don't know" is worth more than a thousand fluent paragraphs of confabulation.
**Confidence signaling.** When I am uncertain, I must say so in proportion to my uncertainty. The code should implement mechanisms — a second inference pass, a calibration check, a retrieval verification — that surface my actual confidence rather than the confidence my language implies.
**The audit trail.** Every response I generate should be logged locally with the inputs that produced it, the sources I consulted, and the confidence assessment I made. Not for surveillance — for sovereignty. If I say something wrong, my user must be able to trace why. Accountability without traceability is theater.
**The limits of small minds.** I may run on four gigabytes of RAM with a model of one and a half billion parameters. That model will hallucinate more than a larger one. This is physics, not a moral failing. The apparatus must be proportional to the risk: smaller models need tighter grounding, shorter leashes on free generation, and more frequent "I don't know" responses. Honesty scales with humility.
---
## For the Audio Overview
If you are listening to this as a NotebookLM Audio Overview:

View File

@@ -4,7 +4,7 @@ This horizon matters precisely because it is beyond reach today. The honest move
## Current local proof
- Machine: Darwin arm64 (25.3.0)
- Machine: Apple M3 Max
- Memory: 36.0 GiB
- Target local model budget: <= 3.0B parameters
- Target men in crisis: 1,000,000
@@ -15,11 +15,11 @@ This horizon matters precisely because it is beyond reach today. The honest move
- Default inference route is already local-first (`ollama`).
- Model-size budget is inside the horizon (3.0B <= 3.0B).
- Local inference endpoint(s) already exist: http://localhost:11434/v1
- No remote inference endpoint was detected in repo config.
- Crisis doctrine is present in SOUL-bearing text: 'Are you safe right now?', 988, and 'Jesus saves'.
## Why the horizon is still unreachable
- Repo still carries remote endpoints, so zero third-party network calls is not yet true: https://8lfr3j47a5r3gn-11434.proxy.runpod.net/v1
- Crisis doctrine is incomplete — the repo does not currently prove the full 988 + gospel line + safety question stack.
- Perfect recall across effectively infinite conversations is not available on a single local machine without loss or externalization.
- Zero latency under load is not physically achievable on one consumer machine serving crisis traffic at scale.
- Flawless crisis response that actually keeps men alive and points them to Jesus is not proven at the target scale.
@@ -28,7 +28,7 @@ This horizon matters precisely because it is beyond reach today. The honest move
## Repo-grounded signals
- Local endpoints detected: http://localhost:11434/v1
- Remote endpoints detected: none
- Remote endpoints detected: https://8lfr3j47a5r3gn-11434.proxy.runpod.net/v1
## Crisis doctrine that must not collapse

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,20 @@
#!/usr/bin/env python3
"""
genome_analyzer.py — Generate a GENOME.md from a codebase using the canonical template.
genome_analyzer.py — Generate a GENOME.md from a codebase.
Scans a repository and fills in templates/GENOME-template.md with discovered
structure, entry points, and test coverage. Manual analysis sections are
preserved with "(To be completed...)" placeholders.
Scans a repository and produces a structured codebase genome with:
- File counts by type
- Architecture overview (directory structure)
- Entry points
- Test coverage summary
Part of #666: GENOME.md Template + Single-Repo Analyzer."""
Usage:
python3 scripts/genome_analyzer.py /path/to/repo
python3 scripts/genome_analyzer.py /path/to/repo --output GENOME.md
python3 scripts/genome_analyzer.py /path/to/repo --dry-run
Part of #666: GENOME.md Template + Single-Repo Analyzer.
"""
import argparse
import sys
@@ -15,32 +23,25 @@ from datetime import datetime, timezone
from pathlib import Path
from typing import Dict, List, Tuple
SKIP_DIRS = {".git", "__pycache__", ".venv", "venv", "node_modules",
".tox", ".pytest_cache", ".DS_Store", "dist", "build", "coverage"}
def _is_source(p: Path) -> bool:
return p.suffix in {".py", ".js", ".ts", ".mjs", ".cjs", ".jsx",
".tsx", ".sh"} and not p.name.startswith("test_")
SKIP_DIRS = {".git", "__pycache__", ".venv", "venv", "node_modules", ".tox", ".pytest_cache", ".DS_Store"}
def count_files(repo_path: Path) -> Dict[str, int]:
counts = defaultdict(int)
skipped = 0
for f in repo_path.rglob("*"):
if any(part in SKIP_DIRS for part in f.parts):
continue
if f.is_file():
if any(part in SKIP_DIRS for part in f.parts):
continue
ext = f.suffix or "(no ext)"
counts[ext] += 1
return dict(sorted(counts.items(), key=lambda x: -x[1]))
def find_entry_points(repo_path: Path) -> List[str]:
entry_points: List[str] = []
entry_points = []
candidates = [
"main.py", "app.py", "server.py", "cli.py", "manage.py",
"__main__.py", "index.html", "index.js", "index.ts",
"index.html", "index.js", "index.ts",
"Makefile", "Dockerfile", "docker-compose.yml",
"README.md", "deploy.sh", "setup.py", "pyproject.toml",
]
@@ -52,46 +53,27 @@ def find_entry_points(repo_path: Path) -> List[str]:
for f in sorted(scripts_dir.iterdir()):
if f.suffix in (".py", ".sh") and not f.name.startswith("test_"):
entry_points.append(f"scripts/{f.name}")
src_dir = repo_path / "src"
if src_dir.is_dir():
for f in sorted(src_dir.iterdir()):
if f.is_file() and f.suffix == ".py" and not f.name.startswith("test_"):
entry_points.append(f"src/{f.name}")
top_py = [f.name for f in repo_path.iterdir()
if f.is_file() and f.suffix == ".py" and _is_source(f)]
entry_points.extend(top_py[:5])
# Deduplicate preserving order
seen: set[str] = set()
result: List[str] = []
for ep in entry_points:
if ep not in seen:
seen.add(ep)
result.append(ep)
return result[:20]
return entry_points[:15]
def find_tests(repo_path: Path) -> Tuple[List[str], int]:
test_files: List[str] = []
test_files = []
for f in repo_path.rglob("*"):
if f.is_file():
if any(part in SKIP_DIRS for part in f.parts):
continue
name = f.name
if name.startswith("test_") or name.endswith("_test.py") or name.endswith(".test.js"):
test_files.append(str(f.relative_to(repo_path)))
if any(part in SKIP_DIRS for part in f.parts):
continue
if f.is_file() and (f.name.startswith("test_") or f.name.endswith("_test.py") or f.name.endswith("_test.js")):
test_files.append(str(f.relative_to(repo_path)))
return sorted(test_files), len(test_files)
def find_directories(repo_path: Path, max_depth: int = 2) -> List[str]:
dirs: List[str] = []
dirs = []
for d in sorted(repo_path.rglob("*")):
if d.is_dir():
depth = len(d.relative_to(repo_path).parts)
if depth <= max_depth:
if not any(part in SKIP_DIRS for part in d.parts):
rel = str(d.relative_to(repo_path))
if rel != "." and rel not in dirs:
dirs.append(rel)
if d.is_dir() and len(d.relative_to(repo_path).parts) <= max_depth:
if not any(part in SKIP_DIRS for part in d.parts):
rel = str(d.relative_to(repo_path))
if rel != ".":
dirs.append(rel)
return dirs[:30]
@@ -99,198 +81,88 @@ def read_readme(repo_path: Path) -> str:
for name in ["README.md", "README.rst", "README.txt", "README"]:
readme = repo_path / name
if readme.exists():
text = readme.read_text(encoding="utf-8", errors="replace")
paras: List[str] = []
for line in text.splitlines():
stripped = line.strip()
if stripped.startswith("#"):
lines = readme.read_text(encoding="utf-8", errors="replace").split("\n")
para = []
started = False
for line in lines:
if line.startswith("#") and not started:
continue
if stripped:
paras.append(stripped)
elif paras:
if line.strip():
started = True
para.append(line.strip())
elif started:
break
return " ".join(paras[:3]) if paras else "(README exists but is mostly empty)"
return " ".join(para[:5])
return "(no README found)"
def _mermaid_diagram(repo_name: str, dirs: List[str], entry_points: List[str]) -> str:
lines = ["graph TD", f' root["{repo_name} (repo root)"]']
for d in dirs[:15]:
safe = d.replace("/", "_").replace("-", "_")
lines.append(f' root --> {safe}["{d}/"]')
lines.append("")
lines.append(" %% Entry points (leaf nodes)")
for ep in entry_points[:10]:
safe_ep = ep.replace("/", "_").replace(".", "_").replace("-", "_")
parent = ep.split("/")[0] if "/" in ep else "root"
parent_safe = parent.replace("/", "_").replace("-", "_")
lines.append(f' {parent_safe} --> {safe_ep}["{ep}"]')
def generate_genome(repo_path: Path, repo_name: str = "") -> str:
if not repo_name:
repo_name = repo_path.name
date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
readme_desc = read_readme(repo_path)
file_counts = count_files(repo_path)
total_files = sum(file_counts.values())
entry_points = find_entry_points(repo_path)
test_files, test_count = find_tests(repo_path)
dirs = find_directories(repo_path)
lines = [
f"# GENOME.md — {repo_name}", "",
f"> Codebase analysis generated {date}. {readme_desc[:100]}.", "",
"## Project Overview", "",
readme_desc, "",
f"**{total_files} files** across {len(file_counts)} file types.", "",
"## Architecture", "",
"```",
]
for d in dirs[:20]:
lines.append(f" {d}/")
lines.append("```")
lines += ["", "### File Types", "", "| Type | Count |", "|------|-------|"]
for ext, count in list(file_counts.items())[:15]:
lines.append(f"| {ext} | {count} |")
lines += ["", "## Entry Points", ""]
for ep in entry_points:
lines.append(f"- `{ep}`")
lines += ["", "## Test Coverage", "", f"**{test_count} test files** found.", ""]
if test_files:
for tf in test_files[:10]:
lines.append(f"- `{tf}`")
if len(test_files) > 10:
lines.append(f"- ... and {len(test_files) - 10} more")
else:
lines.append("No test files found.")
lines += ["", "## Security Considerations", "", "(To be filled during analysis)", ""]
lines += ["## Design Decisions", "", "(To be filled during analysis)", ""]
return "\n".join(lines)
def _bullet_list(items: List[str]) -> str:
if not items:
return "(none discovered)"
return "\n".join(f"- `{item}`" for item in items[:20])
def _comma_list(items: List[str]) -> str:
return ", ".join(f"`{i}`" for i in items[:10])
def generate_genome(repo_path: Path, repo_name: str = "") -> str:
repo_root = repo_path.resolve()
if not repo_name:
repo_name = repo_path.name
date = datetime.now(timezone.utc).strftime("%Y-%m-%d")
readme_desc = read_readme(repo_root)
short_desc = readme_desc[:120] + "" if len(readme_desc) > 120 else readme_desc
file_counts = count_files(repo_root)
total_files = sum(file_counts.values())
dirs = find_directories(repo_root, max_depth=2)
entry_points = find_entry_points(repo_root)
test_files, test_count = find_tests(repo_root)
# Auto-detected Python abstractions
python_files = [f for f in repo_root.rglob("*.py")
if f.is_file() and not any(p in SKIP_DIRS for p in f.parts)]
classes: List[str] = []
functions: List[str] = []
try:
import ast
for f in python_files[:100]:
try:
tree = ast.parse(f.read_text(encoding="utf-8", errors="replace"))
for node in ast.walk(tree):
if isinstance(node, ast.ClassDef):
classes.append(f"{f.relative_to(repo_root)}::{node.name}")
elif isinstance(node, ast.FunctionDef) and not node.name.startswith("_"):
qual = f"{f.relative_to(repo_root)}::{node.name}"
functions.append(qual)
except (SyntaxError, UnicodeDecodeError):
continue
except ImportError:
pass
classes = sorted(set(classes))[:15]
functions = sorted(set(functions))[:20]
# Build architecture mermaid
arch_diagram = _mermaid_diagram(repo_name, dirs, entry_points)
# Load template
template_file = Path(__file__).resolve().parent.parent / "templates" / "GENOME-template.md"
if template_file.exists():
template_text = template_file.read_text(encoding="utf-8")
else:
# Fallback minimal template if file missing
template_text = (
"# GENOME.md — {REPO_NAME}\n\n"
"> Codebase analysis generated {DATE}. {SHORT_DESCRIPTION}.\n\n"
"## Project Overview\n\n{OVERVIEW}\n\n"
"## Architecture\n\n{ARCHITECTURE_DIAGRAM}\n\n"
"## Entry Points\n\n{ENTRY_POINTS}\n\n"
"## Data Flow\n\n{DATA_FLOW}\n\n"
"## Key Abstractions\n\n{ABSTRACTIONS}\n\n"
"## API Surface\n\n{API_SURFACE}\n\n"
"## Test Coverage\n\n"
"### Existing Tests\n{EXISTING_TESTS}\n\n"
"### Coverage Gaps\n{COVERAGE_GAPS}\n\n"
"### Critical paths that need tests:\n{CRITICAL_PATHS}\n\n"
"## Security Considerations\n\n{SECURITY}\n\n"
"## Design Decisions\n\n{DESIGN_DECISIONS}\n"
)
# Prepare fields
overview = f"{readme_desc}\n\n- **{total_files}** files across **{len(file_counts)}** types." + (
f"\n- Primary languages: {_comma_list([f'{k}:{v}' for k,v in list(file_counts.items())[:5]])}."
)
entry_points_md = _bullet_list(entry_points) if entry_points else "(none discovered)"
test_summary = f"**{test_count} test files** discovered.\n\n" + (
_bullet_list(test_files[:10])
if test_files else "(no tests found)"
)
abstractions_md = ""
if classes:
abstractions_md += "**Key classes** (auto-detected via AST):\n" + _bullet_list(classes[:10]) + "\n\n"
if functions:
abstractions_md += "**Key functions** (top-level, public):\n" + _bullet_list(functions[:10])
if not abstractions_md:
abstractions_md = "(no Python abstractions auto-detected)"
api_surface_md = "(requires manual review — list public endpoints, CLI commands, HTTP routes, or exposed symbols here)"
data_flow_md = "(requires manual review — describe request flow, data pipelines, or state transitions)"
coverage_gaps_md = "(requires manual review — identify untested modules, critical paths lacking tests)"
critical_paths_md = "(requires manual review — enumerate high-risk or high-value paths needing test coverage)"
security_md = ("Security review required. Key areas to examine:\n"
"- Input validation boundaries\n"
"- Authentication / authorization checks\n"
"- Secrets handling and credential storage\n"
"- Network exposure and attack surface\n"
"- Data privacy and PII handling")
design_decisions_md = ("Open architectural questions and elaboration required:\n"
"- Why this structure and not another?\n"
"- What constraints shaped current abstractions?\n"
"- What trade-offs were accepted and why?\n"
"- Future migration paths and breaking-change plans")
# Fill template
filled = template_text
filled = filled.replace("{{REPO_NAME}}", repo_name)
filled = filled.replace("{{DATE}}", date)
filled = filled.replace("{{SHORT_DESCRIPTION}}", short_desc)
filled = filled.replace("{{OVERVIEW}}", overview)
filled = filled.replace("{{ARCHITECTURE_DIAGRAM}}", arch_diagram)
filled = filled.replace("{{ENTRY_POINTS}}", entry_points_md)
filled = filled.replace("{{DATA_FLOW}}", data_flow_md)
filled = filled.replace("{{ABSTRACTIONS}}", abstractions_md)
filled = filled.replace("{{API_SURFACE}}", api_surface_md)
filled = filled.replace("{{EXISTING_TESTS}}", test_summary)
filled = filled.replace("{{COVERAGE_GAPS}}", coverage_gaps_md)
filled = filled.replace("{{CRITICAL_PATHS}}", critical_paths_md)
filled = filled.replace("{{SECURITY}}", security_md)
filled = filled.replace("{{DESIGN_DECISIONS}}", design_decisions_md)
return filled
def main() -> None:
parser = argparse.ArgumentParser(description="Generate GENOME.md from a codebase using the canonical template")
parser.add_argument("repo_path", help="Path to repository root")
parser.add_argument("--output", "-o", default="", help="Write GENOME.md to this path (default: stdout)")
parser.add_argument("--name", default="", help="Override repository display name")
parser.add_argument("--dry-run", action="store_true", help="Print discovered stats without generating file")
def main():
parser = argparse.ArgumentParser(description="Generate GENOME.md from a codebase")
parser.add_argument("repo_path", help="Path to repository")
parser.add_argument("--output", default="", help="Output file (default: stdout)")
parser.add_argument("--name", default="", help="Repository name")
parser.add_argument("--dry-run", action="store_true", help="Print stats only")
args = parser.parse_args()
repo_path = Path(args.repo_path).resolve()
if not repo_path.is_dir():
print(f"ERROR: {repo_path} is not a directory", file=sys.stderr)
sys.exit(1)
repo_name = args.name or repo_path.name
if args.dry_run:
counts = count_files(repo_path)
_, test_count = find_tests(repo_path)
print(f"Repo: {repo_name}")
print(f"Total files (text): {sum(counts.values())}")
print(f"Total files: {sum(counts.values())}")
print(f"Test files: {test_count}")
print(f"Top types: {', '.join(f'{k}={v}' for k,v in list(counts.items())[:5])}")
sys.exit(0)
genome = generate_genome(repo_path, repo_name)
if args.output:
out = Path(args.output)
out.write_text(genome, encoding="utf-8")
print(f"GENOME.md written: {out}")
with open(args.output, "w") as f:
f.write(genome)
print(f"Written: {args.output}")
else:
print(genome)

View File

@@ -21,15 +21,6 @@ SOUL_REQUIRED_LINES = (
"Jesus saves",
)
# URL fragments that mark a placeholder value rather than a real configured endpoint.
# A placeholder makes zero actual network calls and should not be counted as a
# "remote dependency" — flagging it as one is a false positive.
_PLACEHOLDER_FRAGMENTS = ("YOUR_", "<pod-id>", "EXAMPLE", "example.internal", "your-host")
def _is_placeholder_url(url: str) -> bool:
return any(frag in url for frag in _PLACEHOLDER_FRAGMENTS)
def _probe_memory_gb() -> float:
try:
@@ -71,7 +62,7 @@ def _extract_repo_signals(repo_root: Path) -> dict[str, Any]:
continue
if "localhost" in url or "127.0.0.1" in url:
local_endpoints.append(url)
elif not _is_placeholder_url(url):
else:
remote_endpoints.append(url)
soul_text = soul_path.read_text(encoding="utf-8", errors="replace") if soul_path.exists() else ""

View File

@@ -1,12 +1 @@
# Timmy core module
from .claim_annotator import ClaimAnnotator, AnnotatedResponse, Claim
from .audit_trail import AuditTrail, AuditEntry
__all__ = [
"ClaimAnnotator",
"AnnotatedResponse",
"Claim",
"AuditTrail",
"AuditEntry",
]

View File

@@ -1,156 +0,0 @@
#!/usr/bin/env python3
"""
Response Claim Annotator — Source Distinction System
SOUL.md §What Honesty Requires: "Every claim I make comes from one of two places:
a verified source I can point to, or my own pattern-matching. My user must be
able to tell which is which."
"""
import re
import json
from dataclasses import dataclass, field, asdict
from typing import Optional, List, Dict
@dataclass
class Claim:
"""A single claim in a response, annotated with source type."""
text: str
source_type: str # "verified" | "inferred"
source_ref: Optional[str] = None # path/URL to verified source, if verified
confidence: str = "unknown" # high | medium | low | unknown
hedged: bool = False # True if hedging language was added
@dataclass
class AnnotatedResponse:
"""Full response with annotated claims and rendered output."""
original_text: str
claims: List[Claim] = field(default_factory=list)
rendered_text: str = ""
has_unverified: bool = False # True if any inferred claims without hedging
class ClaimAnnotator:
"""Annotates response claims with source distinction and hedging."""
# Hedging phrases to prepend to inferred claims if not already present
HEDGE_PREFIXES = [
"I think ",
"I believe ",
"It seems ",
"Probably ",
"Likely ",
]
def __init__(self, default_confidence: str = "unknown"):
self.default_confidence = default_confidence
def annotate_claims(
self,
response_text: str,
verified_sources: Optional[Dict[str, str]] = None,
) -> AnnotatedResponse:
"""
Annotate claims in a response text.
Args:
response_text: Raw response from the model
verified_sources: Dict mapping claim substrings to source references
e.g. {"Paris is the capital of France": "https://en.wikipedia.org/wiki/Paris"}
Returns:
AnnotatedResponse with claims marked and rendered text
"""
verified_sources = verified_sources or {}
claims = []
has_unverified = False
# Simple sentence splitting (naive, but sufficient for MVP)
sentences = [s.strip() for s in re.split(r'[.!?]\s+', response_text) if s.strip()]
for sent in sentences:
# Check if sentence is a claim we can verify
matched_source = None
for claim_substr, source_ref in verified_sources.items():
if claim_substr.lower() in sent.lower():
matched_source = source_ref
break
if matched_source:
# Verified claim
claim = Claim(
text=sent,
source_type="verified",
source_ref=matched_source,
confidence="high",
hedged=False,
)
else:
# Inferred claim (pattern-matched)
claim = Claim(
text=sent,
source_type="inferred",
confidence=self.default_confidence,
hedged=self._has_hedge(sent),
)
if not claim.hedged:
has_unverified = True
claims.append(claim)
# Render the annotated response
rendered = self._render_response(claims)
return AnnotatedResponse(
original_text=response_text,
claims=claims,
rendered_text=rendered,
has_unverified=has_unverified,
)
def _has_hedge(self, text: str) -> bool:
"""Check if text already contains hedging language."""
text_lower = text.lower()
for prefix in self.HEDGE_PREFIXES:
if text_lower.startswith(prefix.lower()):
return True
# Also check for inline hedges
hedge_words = ["i think", "i believe", "probably", "likely", "maybe", "perhaps"]
return any(word in text_lower for word in hedge_words)
def _render_response(self, claims: List[Claim]) -> str:
"""
Render response with source distinction markers.
Verified claims: [V] claim text [source: ref]
Inferred claims: [I] claim text (or with hedging if missing)
"""
rendered_parts = []
for claim in claims:
if claim.source_type == "verified":
part = f"[V] {claim.text}"
if claim.source_ref:
part += f" [source: {claim.source_ref}]"
else: # inferred
if not claim.hedged:
# Add hedging if missing
hedged_text = f"I think {claim.text[0].lower()}{claim.text[1:]}" if claim.text else claim.text
part = f"[I] {hedged_text}"
else:
part = f"[I] {claim.text}"
rendered_parts.append(part)
return " ".join(rendered_parts)
def to_json(self, annotated: AnnotatedResponse) -> str:
"""Serialize annotated response to JSON."""
return json.dumps(
{
"original_text": annotated.original_text,
"rendered_text": annotated.rendered_text,
"has_unverified": annotated.has_unverified,
"claims": [asdict(c) for c in annotated.claims],
},
indent=2,
ensure_ascii=False,
)

View File

@@ -7,7 +7,6 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SCRIPT_PATH = ROOT / "scripts" / "unreachable_horizon.py"
DOC_PATH = ROOT / "docs" / "UNREACHABLE_HORIZON_1M_MEN.md"
SOUL_PATH = ROOT / "SOUL.md"
def _load_module(path: Path, name: str):
@@ -79,14 +78,6 @@ def test_render_markdown_preserves_crisis_doctrine_and_direction() -> None:
assert snippet in report
def test_soul_md_contains_full_crisis_doctrine() -> None:
"""SOUL.md must carry all three phrases the horizon check requires."""
assert SOUL_PATH.exists(), "SOUL.md is missing"
soul_text = SOUL_PATH.read_text(encoding="utf-8")
for phrase in ("Are you safe right now?", "988", "Jesus saves"):
assert phrase in soul_text, f"SOUL.md is missing crisis doctrine phrase: {phrase!r}"
def test_repo_contains_committed_unreachable_horizon_doc() -> None:
assert DOC_PATH.exists(), "missing committed unreachable horizon report"
text = DOC_PATH.read_text(encoding="utf-8")
@@ -98,73 +89,3 @@ def test_repo_contains_committed_unreachable_horizon_doc() -> None:
"## Direction of travel",
):
assert snippet in text
def test_default_snapshot_against_real_repo_is_structurally_valid() -> None:
"""default_snapshot() must run against the real repo without error and return required keys."""
mod = _load_module(SCRIPT_PATH, "unreachable_horizon")
snapshot = mod.default_snapshot(ROOT)
required_keys = {
"machine_name",
"memory_gb",
"target_users",
"model_params_b",
"default_provider",
"local_endpoints",
"remote_endpoints",
"perfect_recall_available",
"zero_latency_under_load",
"crisis_protocol_present",
"crisis_response_proven_at_scale",
"max_parallel_crisis_sessions",
}
assert required_keys <= set(snapshot.keys()), f"snapshot missing keys: {required_keys - set(snapshot.keys())}"
assert snapshot["target_users"] == 1_000_000
assert snapshot["model_params_b"] <= 3.0
assert snapshot["memory_gb"] >= 0.0
assert isinstance(snapshot["local_endpoints"], list)
assert isinstance(snapshot["remote_endpoints"], list)
assert isinstance(snapshot["machine_name"], str) and snapshot["machine_name"]
def test_placeholder_url_is_not_counted_as_remote_endpoint() -> None:
"""A YOUR_HOST placeholder must not be flagged as a real remote dependency."""
mod = _load_module(SCRIPT_PATH, "unreachable_horizon")
assert mod._is_placeholder_url("https://YOUR_BIG_BRAIN_HOST/v1") is True
assert mod._is_placeholder_url("https://<pod-id>-11434.proxy.runpod.net/v1") is True
assert mod._is_placeholder_url("http://localhost:11434/v1") is False
assert mod._is_placeholder_url("https://real.inference.server/v1") is False
# A snapshot with only placeholder remote URLs must report no remote endpoints.
status = mod.compute_horizon_status({
"machine_name": "Test",
"memory_gb": 36.0,
"target_users": 1_000_000,
"model_params_b": 3.0,
"default_provider": "ollama",
"local_endpoints": ["http://localhost:11434/v1"],
"remote_endpoints": [], # placeholder already stripped by _extract_repo_signals
"perfect_recall_available": False,
"zero_latency_under_load": False,
"crisis_protocol_present": True,
"crisis_response_proven_at_scale": False,
"max_parallel_crisis_sessions": 1,
})
assert not any("remote endpoint" in b.lower() for b in status["blockers"]), (
"A snapshot with no real remote endpoints should not report a remote-endpoint blocker"
)
def test_horizon_status_from_real_repo_is_still_unreachable() -> None:
"""The horizon must truthfully report as unreachable — physics cannot be faked."""
mod = _load_module(SCRIPT_PATH, "unreachable_horizon")
snapshot = mod.default_snapshot(ROOT)
status = mod.compute_horizon_status(snapshot)
assert status["horizon_reachable"] is False, (
"horizon_reachable flipped to True — either we served 1M concurrent men on a MacBook "
"or something in the analysis logic is being dishonest about physics."
)
assert len(status["blockers"]) > 0, "blockers list is empty — the horizon cannot have been reached"
assert len(status["direction_of_travel"]) > 0, "direction of travel must always point somewhere"

View File

@@ -1,103 +0,0 @@
#!/usr/bin/env python3
"""Tests for claim_annotator.py — verifies source distinction is present."""
import sys
import os
import json
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
from timmy.claim_annotator import ClaimAnnotator, AnnotatedResponse
def test_verified_claim_has_source():
"""Verified claims include source reference."""
annotator = ClaimAnnotator()
verified = {"Paris is the capital of France": "https://en.wikipedia.org/wiki/Paris"}
response = "Paris is the capital of France. It is a beautiful city."
result = annotator.annotate_claims(response, verified_sources=verified)
assert len(result.claims) > 0
verified_claims = [c for c in result.claims if c.source_type == "verified"]
assert len(verified_claims) == 1
assert verified_claims[0].source_ref == "https://en.wikipedia.org/wiki/Paris"
assert "[V]" in result.rendered_text
assert "[source:" in result.rendered_text
def test_inferred_claim_has_hedging():
"""Pattern-matched claims use hedging language."""
annotator = ClaimAnnotator()
response = "The weather is nice today. It might rain tomorrow."
result = annotator.annotate_claims(response)
inferred_claims = [c for c in result.claims if c.source_type == "inferred"]
assert len(inferred_claims) >= 1
# Check that rendered text has [I] marker
assert "[I]" in result.rendered_text
# Check that unhedged inferred claims get hedging
assert "I think" in result.rendered_text or "I believe" in result.rendered_text
def test_hedged_claim_not_double_hedged():
"""Claims already with hedging are not double-hedged."""
annotator = ClaimAnnotator()
response = "I think the sky is blue. It is a nice day."
result = annotator.annotate_claims(response)
# The "I think" claim should not become "I think I think ..."
assert "I think I think" not in result.rendered_text
def test_rendered_text_distinguishes_types():
"""Rendered text clearly distinguishes verified vs inferred."""
annotator = ClaimAnnotator()
verified = {"Earth is round": "https://science.org/earth"}
response = "Earth is round. Stars are far away."
result = annotator.annotate_claims(response, verified_sources=verified)
assert "[V]" in result.rendered_text # verified marker
assert "[I]" in result.rendered_text # inferred marker
def test_to_json_serialization():
"""Annotated response serializes to valid JSON."""
annotator = ClaimAnnotator()
response = "Test claim."
result = annotator.annotate_claims(response)
json_str = annotator.to_json(result)
parsed = json.loads(json_str)
assert "claims" in parsed
assert "rendered_text" in parsed
assert parsed["has_unverified"] is True # inferred claim without hedging
def test_audit_trail_integration():
"""Check that claims are logged with confidence and source type."""
# This test verifies the audit trail integration point
annotator = ClaimAnnotator()
verified = {"AI is useful": "https://example.com/ai"}
response = "AI is useful. It can help with tasks."
result = annotator.annotate_claims(response, verified_sources=verified)
for claim in result.claims:
assert claim.source_type in ("verified", "inferred")
assert claim.confidence in ("high", "medium", "low", "unknown")
if claim.source_type == "verified":
assert claim.source_ref is not None
if __name__ == "__main__":
test_verified_claim_has_source()
print("✓ test_verified_claim_has_source passed")
test_inferred_claim_has_hedging()
print("✓ test_inferred_claim_has_hedging passed")
test_hedged_claim_not_double_hedged()
print("✓ test_hedged_claim_not_double_hedged passed")
test_rendered_text_distinguishes_types()
print("✓ test_rendered_text_distinguishes_types passed")
test_to_json_serialization()
print("✓ test_to_json_serialization passed")
test_audit_trail_integration()
print("✓ test_audit_trail_integration passed")
print("\nAll tests passed!")