2026-03-05 21:54:24 -05:00
|
|
|
import os
|
|
|
|
|
import shutil
|
2026-03-08 12:50:44 -04:00
|
|
|
import subprocess
|
2026-03-05 21:54:24 -05:00
|
|
|
import time
|
2026-03-08 12:50:44 -04:00
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
import pytest
|
2026-03-05 21:54:24 -05:00
|
|
|
|
|
|
|
|
# Production-like paths for functional testing
|
|
|
|
|
PROD_PROJECT_DIR = Path("/home/ubuntu/prod-sovereign-stack")
|
|
|
|
|
PROD_VAULT_DIR = PROD_PROJECT_DIR / "TimmyVault"
|
|
|
|
|
SETUP_SCRIPT_PATH = Path("/home/ubuntu/setup_timmy.sh")
|
|
|
|
|
|
2026-03-06 13:21:05 -05:00
|
|
|
pytestmark = pytest.mark.skipif(
|
|
|
|
|
not SETUP_SCRIPT_PATH.exists(),
|
|
|
|
|
reason=f"Setup script not found at {SETUP_SCRIPT_PATH}",
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
@pytest.fixture(scope="module", autouse=True)
|
|
|
|
|
def setup_prod_env():
|
|
|
|
|
"""Ensure a clean environment and run the full installation."""
|
|
|
|
|
if PROD_PROJECT_DIR.exists():
|
|
|
|
|
shutil.rmtree(PROD_PROJECT_DIR)
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Run the actual install command
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
env["PROJECT_DIR"] = str(PROD_PROJECT_DIR)
|
|
|
|
|
env["VAULT_DIR"] = str(PROD_VAULT_DIR)
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
result = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH), "install"], capture_output=True, text=True, env=env
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
assert result.returncode == 0, f"Install failed: {result.stderr}"
|
|
|
|
|
yield
|
|
|
|
|
# Cleanup after all tests in module
|
|
|
|
|
# shutil.rmtree(PROD_PROJECT_DIR)
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_prod_directory_structure():
|
|
|
|
|
"""Verify the directory structure matches production expectations."""
|
|
|
|
|
assert PROD_PROJECT_DIR.exists()
|
|
|
|
|
assert (PROD_PROJECT_DIR / "paperclip").exists()
|
|
|
|
|
assert (PROD_PROJECT_DIR / "agents/hello-timmy").exists()
|
|
|
|
|
assert PROD_VAULT_DIR.exists()
|
|
|
|
|
assert (PROD_PROJECT_DIR / "logs").exists()
|
|
|
|
|
assert (PROD_PROJECT_DIR / "pids").exists()
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_prod_paperclip_dependencies():
|
|
|
|
|
"""Verify that Paperclip dependencies were actually installed (node_modules exists)."""
|
|
|
|
|
node_modules = PROD_PROJECT_DIR / "paperclip/node_modules"
|
|
|
|
|
assert node_modules.exists(), "Paperclip node_modules should exist after installation"
|
|
|
|
|
# Check for a common package to ensure it's not just an empty dir
|
2026-03-08 12:50:44 -04:00
|
|
|
assert (
|
|
|
|
|
(node_modules / "typescript").exists()
|
|
|
|
|
or (node_modules / "vite").exists()
|
|
|
|
|
or (node_modules / "next").exists()
|
|
|
|
|
or any(node_modules.iterdir())
|
|
|
|
|
)
|
|
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
|
|
|
|
|
def test_prod_openfang_config():
|
|
|
|
|
"""Verify OpenFang agent configuration."""
|
|
|
|
|
agent_toml = PROD_PROJECT_DIR / "agents/hello-timmy/agent.toml"
|
|
|
|
|
assert agent_toml.exists()
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
with open(agent_toml) as f:
|
2026-03-05 21:54:24 -05:00
|
|
|
content = f.read()
|
|
|
|
|
assert 'name = "hello-timmy"' in content
|
|
|
|
|
assert 'model = "default"' in content
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_prod_obsidian_vault_content():
|
|
|
|
|
"""Verify the initial content of the Obsidian vault."""
|
|
|
|
|
hello_note = PROD_VAULT_DIR / "Hello World.md"
|
|
|
|
|
soul_note = PROD_VAULT_DIR / "SOUL.md"
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
assert hello_note.exists()
|
|
|
|
|
assert soul_note.exists()
|
2026-03-08 12:50:44 -04:00
|
|
|
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
with open(hello_note) as f:
|
2026-03-05 21:54:24 -05:00
|
|
|
content = f.read()
|
|
|
|
|
assert "# Hello World" in content
|
|
|
|
|
assert "Paperclip" in content
|
|
|
|
|
assert "OpenFang" in content
|
|
|
|
|
|
ruff (#169)
* polish: streamline nav, extract inline styles, improve tablet UX
- Restructure desktop nav from 8+ flat links + overflow dropdown into
5 grouped dropdowns (Core, Agents, Intel, System, More) matching
the mobile menu structure to reduce decision fatigue
- Extract all inline styles from mission_control.html and base.html
notification elements into mission-control.css with semantic classes
- Replace JS-built innerHTML with secure DOM construction in
notification loader and chat history
- Add CONNECTING state to connection indicator (amber) instead of
showing OFFLINE before WebSocket connects
- Add tablet breakpoint (1024px) with larger touch targets for
Apple Pencil / stylus use and safe-area padding for iPad toolbar
- Add active-link highlighting in desktop dropdown menus
- Rename "Mission Control" page title to "System Overview" to
disambiguate from the chat home page
- Add "Home — Timmy Time" page title to index.html
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* fix(security): move auth-gate credentials to environment variables
Hardcoded username, password, and HMAC secret in auth-gate.py replaced
with os.environ lookups. Startup now refuses to run if any variable is
unset. Added AUTH_GATE_SECRET/USER/PASS to .env.example.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
* refactor(tooling): migrate from black+isort+bandit to ruff
Replace three separate linting/formatting tools with a single ruff
invocation. Updates tox.ini (lint, format, pre-push, pre-commit envs),
.pre-commit-config.yaml, and CI workflow. Fixes all ruff errors
including unused imports, missing raise-from, and undefined names.
Ruff config maps existing bandit skips to equivalent S-rules.
https://claude.ai/code/session_015uPUoKyYa8M2UAcyk5Gt6h
---------
Co-authored-by: Claude <noreply@anthropic.com>
2026-03-11 12:23:35 -04:00
|
|
|
with open(soul_note) as f:
|
2026-03-05 21:54:24 -05:00
|
|
|
content = f.read()
|
|
|
|
|
assert "I am Timmy" in content
|
|
|
|
|
assert "sovereign AI agent" in content
|
|
|
|
|
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
def test_prod_service_lifecycle():
|
|
|
|
|
"""Verify that services can be started, checked, and stopped."""
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
env["PROJECT_DIR"] = str(PROD_PROJECT_DIR)
|
|
|
|
|
env["VAULT_DIR"] = str(PROD_VAULT_DIR)
|
|
|
|
|
|
|
|
|
|
# Start services
|
|
|
|
|
start_result = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH), "start"], capture_output=True, text=True, env=env
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
|
|
|
|
assert start_result.returncode == 0
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Wait a moment for processes to initialize
|
|
|
|
|
time.sleep(2)
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Check status
|
|
|
|
|
status_result = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH), "status"], capture_output=True, text=True, env=env
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
|
|
|
|
assert "running" in status_result.stdout
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Stop services
|
|
|
|
|
stop_result = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH), "stop"], capture_output=True, text=True, env=env
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
|
|
|
|
assert stop_result.returncode == 0
|
2026-03-08 12:50:44 -04:00
|
|
|
|
2026-03-05 21:54:24 -05:00
|
|
|
# Final status check
|
|
|
|
|
final_status = subprocess.run(
|
2026-03-08 12:50:44 -04:00
|
|
|
[str(SETUP_SCRIPT_PATH), "status"], capture_output=True, text=True, env=env
|
2026-03-05 21:54:24 -05:00
|
|
|
)
|
|
|
|
|
assert "stopped" in final_status.stdout
|