Accumulated uncommitted work: GHOST Web backend, WebGL/GPU web layer, web workflow engine and protocol, tooling, docs and task records. Large generated evidence, user-testing archives, build snapshots and imported test assets remain untracked. Co-Authored-By: Claude Code <noreply@anthropic.com>
57 lines
2.8 KiB
Python
57 lines
2.8 KiB
Python
"""Timing scopes keep historical model latency separate from current local work."""
|
|
import json
|
|
from pathlib import Path
|
|
import tempfile
|
|
import unittest
|
|
|
|
from wbv2_timing import timing_report
|
|
|
|
|
|
class TimingScopeTests(unittest.TestCase):
|
|
def setUp(self):
|
|
self.temporary = tempfile.TemporaryDirectory()
|
|
self.addCleanup(self.temporary.cleanup)
|
|
self.directory = Path(self.temporary.name)
|
|
self.events = [
|
|
{"event": "process.finished", "time": "2026-09-08T01:01:00+00:00", "startedAt": "2026-09-08T01:00:00+00:00", "finishedAt": "2026-09-08T01:01:00+00:00", "phase": "model_request", "durationSeconds": 60},
|
|
{"event": "state.changed", "time": "2026-09-08T02:00:00+00:00", "state": "implementing"},
|
|
{"event": "workflow.local", "time": "2026-09-08T02:00:00+00:00"},
|
|
{"event": "process.finished", "time": "2026-09-08T02:00:02+00:00", "startedAt": "2026-09-08T02:00:00+00:00", "finishedAt": "2026-09-08T02:00:02+00:00", "phase": "validation:fixture", "durationSeconds": 2},
|
|
{"event": "timing.span", "time": "2026-09-08T02:00:12+00:00", "startedAt": "2026-09-08T02:00:02+00:00", "finishedAt": "2026-09-08T02:00:12+00:00", "phase": "local_work_wait", "durationSeconds": 10},
|
|
]
|
|
|
|
def write(self):
|
|
(self.directory / "events.jsonl").write_text("\n".join(json.dumps(event) for event in self.events))
|
|
|
|
def test_local_scope_excludes_historical_model_requests(self):
|
|
self.write()
|
|
report = timing_report(self.directory, scope="local")
|
|
self.assertNotIn("model_request", [row["phase"] for row in report["summary"]])
|
|
self.assertEqual(2, report["activeMeasuredSeconds"])
|
|
self.assertEqual(10, report["waitingMeasuredSeconds"])
|
|
|
|
def test_all_scope_retains_full_history(self):
|
|
self.write()
|
|
report = timing_report(self.directory, scope="all")
|
|
self.assertEqual(62, report["activeMeasuredSeconds"])
|
|
|
|
def test_last_run_starts_at_most_recent_attempt(self):
|
|
self.events += [
|
|
{"event": "state.changed", "time": "2026-09-08T03:00:00+00:00", "state": "implementing"},
|
|
{"event": "timing.span", "time": "2026-09-08T03:00:01+00:00", "startedAt": "2026-09-08T03:00:00+00:00", "finishedAt": "2026-09-08T03:00:01+00:00", "phase": "step_cache_lookup", "durationSeconds": 1},
|
|
]
|
|
self.write()
|
|
report = timing_report(self.directory, scope="last-run")
|
|
self.assertEqual(1, report["activeMeasuredSeconds"])
|
|
self.assertEqual(0, report["waitingMeasuredSeconds"])
|
|
|
|
def test_no_local_attempt_does_not_display_model_history_as_local(self):
|
|
self.events = self.events[:1]
|
|
self.write()
|
|
report = timing_report(self.directory, scope="local")
|
|
self.assertEqual([], report["steps"])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|