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
#!/usr/bin/env python3
"""Fail-closed guard: requirements.in must mirror pyproject [project].dependencies.
This is the guard for the bug class that shipped a broken public installer:
``requirements.in`` (the source for the hash-pinned ``requirements.txt``
lockfile) drifted from ``pyproject.toml [project].dependencies``. It listed
extras-only, native packages (for example ``faster-whisper`` and desktop input
drivers) that pyproject deliberately keeps in the ``[local-voice]`` /
``[desktop]`` extras per the cloud-first doctrine. The lockfile
compiler then baked the multi-GB, GPU-specific CUDA-13 wheel stack (``nvidia-*``) into the
committed lockfile, and the Windows/macOS installer forced every downloader
through it with ``pip install --require-hashes -r requirements.txt`` — which is
unresolvable on a plain-PyPI machine (``nvidia-cufile==1.15.1.6`` does not exist
on PyPI). "Works on my machine" is the defect (AP-23).
``requirements.in`` is the base runtime set ONLY. Every line in it must appear,
byte-for-byte on name + extras + version specifier + environment marker, in
``pyproject.toml [project].dependencies`` and vice-versa. Extras
(``[project.optional-dependencies]``) are intentionally NOT mirrored here — they
are installed separately and never enter the base lockfile.
Exit 0 when in lockstep; exit 1 with a diff otherwise.
"""
from __future__ import annotations
import sys
import tomllib
from pathlib import Path
try:
from packaging.requirements import Requirement
except ImportError: # pragma: no cover - degrade gracefully when packaging is absent
# Fail-open when the guard genuinely cannot run (e.g. a deps-less venv).
# Layer-3 CI installs `packaging` explicitly, so it is the backstop.
print("SKIP: `packaging` not importable; requirements-sync guard cannot run here.")
sys.exit(0)
REPO_ROOT = Path(__file__).resolve().parents[2]
PYPROJECT = REPO_ROOT / "pyproject.toml"
REQUIREMENTS_IN = REPO_ROOT / "requirements.in"
def _canonical(spec: str) -> tuple[str, frozenset[str], str, str]:
"""Normalize a requirement to (name, extras, specifier, marker)."""
req = Requirement(spec)
name = req.name.lower().replace("_", "-")
extras = frozenset(e.lower() for e in req.extras)
# Sort specifier components so ">=1,<2" and "<2,>=1" compare equal.
specifier = ",".join(sorted(str(s) for s in req.specifier))
marker = str(req.marker) if req.marker is not None else ""
return (name, extras, specifier, marker)
def _parse_pyproject(path: Path = PYPROJECT) -> dict[tuple[str, frozenset[str], str, str], str]:
data = tomllib.loads(path.read_text(encoding="utf-8"))
deps = data.get("project", {}).get("dependencies", [])
return {_canonical(d): d for d in deps}
def _parse_requirements_in(
path: Path = REQUIREMENTS_IN,
) -> dict[tuple[str, frozenset[str], str, str], str]:
out: dict[tuple[str, frozenset[str], str, str], str] = {}
for raw in path.read_text(encoding="utf-8").splitlines():
line = raw.split("#", 1)[0].strip()
if not line:
continue
out[_canonical(line)] = line
return out
def check_pair(project_path: Path, requirements_path: Path) -> int:
pyproject = _parse_pyproject(project_path)
req_in = _parse_requirements_in(requirements_path)
only_in_pyproject = sorted(pyproject.keys() - req_in.keys())
only_in_reqin = sorted(req_in.keys() - pyproject.keys())
if not only_in_pyproject and not only_in_reqin:
print(f"OK: {requirements_path.relative_to(REPO_ROOT)} mirrors its project dependencies")
return 0
print(f"FAIL: {requirements_path.relative_to(REPO_ROOT)} has drifted from its project.")
print(" They must mirror each other exactly (name + extras + version + marker).")
print(" Regenerate with the scoped native crypto configuration (install/README.md).")
print()
if only_in_pyproject:
print(" In pyproject.toml but MISSING from requirements.in:")
for key in only_in_pyproject:
print(f" + {pyproject[key]}")
if only_in_reqin:
print(" In requirements.in but NOT a pyproject base dependency")
print(" (is it an extras-only package that belongs in [project.optional-dependencies]?):")
for key in only_in_reqin:
print(f" - {req_in[key]}")
return 1
def main() -> int:
browser = REPO_ROOT / "dodaios" / "assets" / "browser"
base_result = check_pair(PYPROJECT, REQUIREMENTS_IN)
browser_result = check_pair(browser / "pyproject.toml", browser / "requirements.in")
return max(base_result, browser_result)
if __name__ == "__main__":
sys.exit(main())