forked from Rockachopa/Timmy-time-dashboard
* 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>
111 lines
3.9 KiB
Python
111 lines
3.9 KiB
Python
"""Tests for Spark engine tool-level and creative pipeline event capture.
|
|
|
|
Covers the new on_tool_executed() and on_creative_step() methods added
|
|
in Phase 6.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
from spark.engine import SparkEngine
|
|
from spark.memory import count_events, get_events
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def tmp_spark_db(tmp_path, monkeypatch):
|
|
db_path = tmp_path / "spark.db"
|
|
monkeypatch.setattr("spark.memory.DB_PATH", db_path)
|
|
monkeypatch.setattr("spark.eidos.DB_PATH", db_path)
|
|
yield db_path
|
|
|
|
|
|
class TestOnToolExecuted:
|
|
def test_captures_tool_event(self):
|
|
engine = SparkEngine(enabled=True)
|
|
eid = engine.on_tool_executed("agent-a", "git_commit", task_id="t1")
|
|
assert eid is not None
|
|
events = get_events(event_type="tool_executed")
|
|
assert len(events) == 1
|
|
assert "git_commit" in events[0].description
|
|
|
|
def test_captures_tool_failure(self):
|
|
engine = SparkEngine(enabled=True)
|
|
eid = engine.on_tool_executed("agent-a", "generate_image", success=False)
|
|
assert eid is not None
|
|
events = get_events(event_type="tool_executed")
|
|
assert len(events) == 1
|
|
assert "FAIL" in events[0].description
|
|
|
|
def test_captures_duration(self):
|
|
engine = SparkEngine(enabled=True)
|
|
engine.on_tool_executed("agent-a", "generate_song", duration_ms=5000)
|
|
events = get_events(event_type="tool_executed")
|
|
assert len(events) == 1
|
|
|
|
def test_disabled_returns_none(self):
|
|
engine = SparkEngine(enabled=False)
|
|
result = engine.on_tool_executed("agent-a", "git_push")
|
|
assert result is None
|
|
|
|
def test_multiple_tool_events(self):
|
|
engine = SparkEngine(enabled=True)
|
|
engine.on_tool_executed("agent-a", "git_add")
|
|
engine.on_tool_executed("agent-a", "git_commit")
|
|
engine.on_tool_executed("agent-a", "git_push")
|
|
assert count_events("tool_executed") == 3
|
|
|
|
|
|
class TestOnCreativeStep:
|
|
def test_captures_creative_step(self):
|
|
engine = SparkEngine(enabled=True)
|
|
eid = engine.on_creative_step(
|
|
project_id="proj-1",
|
|
step_name="storyboard",
|
|
agent_id="pixel-001",
|
|
output_path="/data/images/frame.png",
|
|
)
|
|
assert eid is not None
|
|
events = get_events(event_type="creative_step")
|
|
assert len(events) == 1
|
|
assert "storyboard" in events[0].description
|
|
|
|
def test_captures_failed_step(self):
|
|
engine = SparkEngine(enabled=True)
|
|
engine.on_creative_step(
|
|
project_id="proj-1",
|
|
step_name="music",
|
|
agent_id="lyra-001",
|
|
success=False,
|
|
)
|
|
events = get_events(event_type="creative_step")
|
|
assert len(events) == 1
|
|
assert "FAIL" in events[0].description
|
|
|
|
def test_disabled_returns_none(self):
|
|
engine = SparkEngine(enabled=False)
|
|
result = engine.on_creative_step("p1", "storyboard", "pixel-001")
|
|
assert result is None
|
|
|
|
def test_full_pipeline_events(self):
|
|
engine = SparkEngine(enabled=True)
|
|
steps = ["storyboard", "music", "video", "assembly"]
|
|
agents = ["pixel-001", "lyra-001", "reel-001", "reel-001"]
|
|
for step, agent in zip(steps, agents, strict=False):
|
|
engine.on_creative_step("proj-1", step, agent)
|
|
assert count_events("creative_step") == 4
|
|
|
|
|
|
class TestSparkStatusIncludesNewTypes:
|
|
def test_status_includes_tool_executed(self):
|
|
engine = SparkEngine(enabled=True)
|
|
engine.on_tool_executed("a", "git_commit")
|
|
status = engine.status()
|
|
assert "tool_executed" in status["event_types"]
|
|
assert status["event_types"]["tool_executed"] == 1
|
|
|
|
def test_status_includes_creative_step(self):
|
|
engine = SparkEngine(enabled=True)
|
|
engine.on_creative_step("p1", "storyboard", "pixel-001")
|
|
status = engine.status()
|
|
assert "creative_step" in status["event_types"]
|
|
assert status["event_types"]["creative_step"] == 1
|