Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
feat(ci): startup-budget regression guard - cold-boot TTU must stay in budget
Ruben Lütke68e3f8d34341
diff --git a/docs/diagnostics/BOOT-TTU-NOTES.md b/docs/diagnostics/BOOT-TTU-NOTES.mdindex 39bac58ac3..64e4427385 100644--- a/docs/diagnostics/BOOT-TTU-NOTES.md+++ b/docs/diagnostics/BOOT-TTU-NOTES.md@@ -139,15 +139,31 @@ custom_onnx engine had hidden.## Next (iteration 5+)-1. Regression guard: budget check against desktop-ttu-baseline.json (e.g.- scripts/ci/check_boot_budget.py or a slow-marked test running- `--voice --runs 1`), so features cannot silently regress TTU.+1. ~~Regression guard~~ DONE (iteration 5): `scripts/ci/check_boot_budget.py`+ (one isolated cold boot; window budget 8 s, voice-TTU budget 30 s, env-+ overridable; ~4x the measured medians so variance never flakes but every+ seen regression class blows through) + pytest wrapper+ `tests/integration/test_boot_budget.py` (slow-marked, self-skips when the+ host cannot measure). Headless boxes check the window anchor and skip the+ voice anchor honestly.2. Attack the live delta: profile a LIVE boot (env flag on the relauncher orlog-timeline) and defer the data/integration blocks (autostart reconcile,board init, telegram/MCP starts) behind voice-ready.3. Cross-OS: headless python:3.11-slim (Docker/WSL) for Linux, document amacOS method (CI matrix) — measure, not assume.+## How to add a feature WITHOUT slowing boot (doctrine)++- Nothing new runs before VOICE_READY. New subsystems hook into+ `_heavy_backend_bg` (desktop_app), a deferred registry scan, or a+ fire-and-forget task created AFTER voice-ready — never into the module+ import path, the WebServer ctor, or `_start_speech_and_orb`.+- Heavy imports: lazy-import inside the function (the repo pattern), or add a+ prefetch thread like `warmup_prefetch.py` if the import must be warm early.+- Verify before merging: `scripts/measure_desktop_boot.py --voice --runs 3`+ before/after; the budget guard (`scripts/ci/check_boot_budget.py`) is the+ enforcement backstop.+## Lessons (do not repeat)- The unit-test suite fast-forwards SMALL asyncio sleeps (a sleep accelerator;diff --git a/scripts/ci/check_boot_budget.py b/scripts/ci/check_boot_budget.pynew file mode 100644index 0000000000..26cb148731--- /dev/null+++ b/scripts/ci/check_boot_budget.py@@ -0,0 +1,150 @@+#!/usr/bin/env python+"""Startup-budget regression guard (TTU) — fail when boot gets slow again.++Why this exists (TTU forensic 2026-07-02, docs/diagnostics/BOOT-TTU-NOTES.md):+boot regressions land silently — a stale custom wake model put a 114.7 s+model-load cascade on the critical path and nobody noticed until the user did.+This guard runs ONE isolated cold boot through the committed harness+(``scripts/measure_desktop_boot.py``) and fails when a measured anchor exceeds+its budget, so a feature that sneaks heavy work onto the startup path breaks+CI/pre-push instead of the user's day.++Anchors and budgets (override via env for slower CI boxes):+- window: spawn -> the UI shell serves (``median_wall_ms``).+ Budget ``JARVIS_BOOT_BUDGET_WINDOW_MS`` (default 8000; measured median on+ the reference box: ~1.2-2.2 s).+- voice TTU: spawn -> ``VOICE_READY_MS`` (wake armed + speech pipeline live).+ Budget ``JARVIS_BOOT_BUDGET_VOICE_MS`` (default 30000; measured median on+ the reference box: ~8.0 s). Checked only when the host can run the voice+ stack (audio device present) — a headless CI box checks the window anchor+ and skips voice honestly instead of faking a pass.++Budgets are deliberately ~4x the measured medians: loose enough that machine+variance never flakes, tight enough that every regression class we have+actually seen (114.7 s load cascade, 12 s gate timeout, 60 s overlay fallback)+blows through them.++Exit codes: 0 = within budget, 1 = budget exceeded, 78 = skipped (no python /+harness prerequisites) so callers can treat "could not measure" as neutral.++How to keep a feature off the critical startup path (the doctrine this guard+enforces): do NOT add work before the speech pipeline / VOICE_READY. New+subsystems belong behind ``_heavy_backend_bg`` (desktop_app), a deferred+registry scan, or a fire-and-forget task AFTER voice-ready. When in doubt run+``scripts/measure_desktop_boot.py --voice --runs 3`` before/after your change.+"""+from __future__ import annotations++import json+import os+import subprocess+import sys+from pathlib import Path++REPO_ROOT = Path(__file__).resolve().parents[2]+HARNESS = REPO_ROOT / "scripts" / "measure_desktop_boot.py"+TTU_LATEST = REPO_ROOT / "desktop-ttu-latest.json"+LATEST = REPO_ROOT / "desktop-boot-latest.json"++SKIP_EXIT = 78 # EX_CONFIG-ish: "could not measure" — neutral, not a failure++DEFAULT_WINDOW_BUDGET_MS = 8_000.0+DEFAULT_VOICE_BUDGET_MS = 30_000.0+++def _audio_capable() -> bool:+ """True when the host can plausibly run the voice stack (mic present)."""+ try:+ import sounddevice # noqa: PLC0415++ devices = sounddevice.query_devices()+ return any(int(d.get("max_input_channels", 0)) > 0 for d in devices)+ except Exception: # noqa: BLE001 — no PortAudio / headless box+ return False+++def main() -> int:+ window_budget = float(+ os.environ.get("JARVIS_BOOT_BUDGET_WINDOW_MS", DEFAULT_WINDOW_BUDGET_MS)+ )+ voice_budget = float(+ os.environ.get("JARVIS_BOOT_BUDGET_VOICE_MS", DEFAULT_VOICE_BUDGET_MS)+ )+ if not HARNESS.exists():+ print(f"boot-budget: harness missing ({HARNESS}) — skipping", flush=True)+ return SKIP_EXIT++ voice = _audio_capable()+ args = [+ sys.executable,+ str(HARNESS),+ "--runs",+ "1",+ "--warmup",+ "0",+ ]+ if voice:+ args.append("--voice")+ print(+ f"boot-budget: measuring one isolated cold boot (voice={voice}) ...",+ flush=True,+ )+ proc = subprocess.run( # noqa: S603 — our own harness, fixed argv+ args, cwd=str(REPO_ROOT), capture_output=True, text=True, timeout=420+ )+ if proc.returncode != 0:+ print(proc.stdout[-2000:], flush=True)+ print(proc.stderr[-2000:], flush=True)+ print("boot-budget: harness run FAILED — treating as budget failure", flush=True)+ return 1++ latest = TTU_LATEST if voice else LATEST+ summary = json.loads(latest.read_text(encoding="utf-8"))++ failures: list[str] = []+ window_ms = summary.get("median_wall_ms")+ if window_ms is None:+ failures.append("window anchor missing from harness output")+ elif window_ms > window_budget:+ failures.append(+ f"window anchor {window_ms:.0f} ms > budget {window_budget:.0f} ms"+ )++ if voice:+ voice_ms = summary.get("median_voice_ready_wall_ms")+ if voice_ms is None:+ failures.append("VOICE_READY anchor missing from harness output")+ elif voice_ms > voice_budget:+ failures.append(+ f"voice TTU {voice_ms:.0f} ms > budget {voice_budget:.0f} ms"+ )+ else:+ print(+ f"boot-budget: voice TTU {voice_ms:.0f} ms <= "+ f"{voice_budget:.0f} ms OK",+ flush=True,+ )+ else:+ print("boot-budget: no audio input device — voice anchor skipped (honest)", flush=True)++ if window_ms is not None and window_ms <= window_budget:+ print(+ f"boot-budget: window {window_ms:.0f} ms <= {window_budget:.0f} ms OK",+ flush=True,+ )++ if failures:+ for f in failures:+ print(f"boot-budget FAILED: {f}", flush=True)+ print(+ "A change put work on the critical startup path. Keep new features "+ "behind _heavy_backend_bg / deferred scans (see the module docstring "+ "and docs/diagnostics/BOOT-TTU-NOTES.md).",+ flush=True,+ )+ return 1+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/tests/integration/test_boot_budget.py b/tests/integration/test_boot_budget.pynew file mode 100644index 0000000000..e5ffb62ec2--- /dev/null+++ b/tests/integration/test_boot_budget.py@@ -0,0 +1,40 @@+"""Startup-budget regression guard as a pytest entry point.++Wraps ``scripts/ci/check_boot_budget.py`` (one isolated cold boot through the+committed harness) so the TTU budget is enforceable from the test suite:++ pytest tests/integration/test_boot_budget.py -m slow++Marked slow + integration: it spawns a real cold boot (~10-40 s), so it never+runs in the fast unit sweep. Self-skips when the guard reports it could not+measure (exit 78, e.g. missing interpreter prerequisites) — a box that cannot+measure must not fake a pass OR a failure.+"""+from __future__ import annotations++import subprocess+import sys+from pathlib import Path++import pytest++REPO_ROOT = Path(__file__).resolve().parents[2]+GUARD = REPO_ROOT / "scripts" / "ci" / "check_boot_budget.py"++pytestmark = [pytest.mark.integration, pytest.mark.slow]+++def test_cold_boot_stays_within_ttu_budget() -> None:+ proc = subprocess.run( # noqa: S603 — our own guard, fixed argv+ [sys.executable, str(GUARD)],+ cwd=str(REPO_ROOT),+ capture_output=True,+ text=True,+ timeout=480,+ )+ if proc.returncode == 78:+ pytest.skip("boot-budget guard could not measure on this host")+ assert proc.returncode == 0, (+ "startup budget exceeded — a change put work on the critical boot "+ f"path:\n{proc.stdout[-2000:]}\n{proc.stderr[-1000:]}"+ )