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): re-arm the distribution denylist as a pre-commit gate
Ruben Lütked7dbc53c578c
diff --git a/.githooks/pre-commit b/.githooks/pre-commitindex 05ab5e38d3..4648bbff59 100755--- a/.githooks/pre-commit+++ b/.githooks/pre-commit@@ -123,4 +123,24 @@ if [ -f "$privkey" ]; thenfifi+# --- DISTRIBUTION-DENYLIST gate (FAIL-CLOSED on NEW additions) ----------------+# The denylist withholds paths that must never ship: live-vault captures,+# internal process docs, personal scratch. It lost its enforcement when the+# snapshot build was retired (2026-07-17, keys-only), and ~600 withheld files+# went public unnoticed. This blocks a withheld path the moment it is ADDED —+# the backlog is deliberately not checked here (see --report for that), so the+# gate stays quiet on normal work. rc 1 = confirmed block.+denylist="scripts/ci/check_denylist_not_tracked.py"+if [ -f "$denylist" ]; then+ "$PY" "$denylist" --staged </dev/null+ if [ "$?" -eq 1 ]; then+ echo ""+ echo "pre-commit BLOCKED: DENYLIST gate — this change tracks a withheld path."+ echo " Keep the file untracked (add it to .gitignore), or edit the denylist"+ echo " in the SAME commit if the entry is genuinely wrong."+ echo " Bypass once with: git commit --no-verify"+ exit 1+ fi+fi+exit 0diff --git a/scripts/ci/check_denylist_not_tracked.py b/scripts/ci/check_denylist_not_tracked.pynew file mode 100644index 0000000000..b0c9a3e3b8--- /dev/null+++ b/scripts/ci/check_denylist_not_tracked.py@@ -0,0 +1,170 @@+#!/usr/bin/env python3+"""CI gate: block NEWLY TRACKED files that the distribution denylist withholds.++``privacy_gate/references/distribution-denylist.txt`` is a curated register of+paths that must never reach the public repo — live-vault captures, internal+process docs, key material, personal scratch — each with a written rationale.+It used to be enforced by the depersonalized-snapshot build, which was retired+on 2026-07-17 in favour of keys-only protection. Keys-only does not cover PII,+so the register kept its rationales but lost its teeth, and ~460 withheld files+became public without anyone noticing.++This gate gives it teeth again at the only moment that scales: the instant a+file is ADDED. Like the sibling ``check_no_new_german.py`` it is deliberately+blind to the backlog — the denylisted files already tracked are a cleanup task,+not a reason to block every commit — so it inspects only what the staged change+introduces. That keeps the gate quiet on normal work and loud exactly when a+withheld path is about to become permanent.++Modes:+ ``--staged`` inspect files the staged change ADDS; rc 1 on a match (hook use)+ ``--report`` list every tracked file the denylist withholds (the backlog); rc 0+ ``--check`` like ``--report`` but rc 1 if the backlog is non-empty (release use)++The denylist and its glob semantics are loaded from the privacy-gate module+itself rather than reimplemented, so the two can never drift apart. When that+module is absent — a fork that never had it — this exits 0 with a note: a+missing personal register is not a fork's problem to solve.+"""+from __future__ import annotations++import argparse+import importlib.util+import re+import subprocess+import sys+from pathlib import Path++_HERE = Path(__file__).resolve().parent+_GATE_DIR = _HERE / "privacy_gate"+_ENGINE = _GATE_DIR / "scripts" / "strip_and_scan.py"+++def _load_engine():+ """Import the privacy-gate module by path, or None when it is not present."""+ if not _ENGINE.is_file():+ return None+ spec = importlib.util.spec_from_file_location("_privacy_gate_engine", _ENGINE)+ if spec is None or spec.loader is None:+ return None+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module+++def _git(*args: str) -> list[str]:+ out = subprocess.run(+ ["git", *args], capture_output=True, text=True, encoding="utf-8", check=False+ )+ if out.returncode != 0:+ return []+ return [ln for ln in out.stdout.splitlines() if ln.strip()]+++def _added_paths() -> list[str]:+ """Repo-relative posix paths the staged change ADDS (A) or renames in (R)."""+ staged = _git("diff", "--cached", "--name-only", "--diff-filter=AR")+ return [p.replace("\\", "/") for p in staged]+++def _tracked_paths() -> list[str]:+ return [p.replace("\\", "/") for p in _git("ls-files")]+++def _rationale_for(pattern: str, denylist_text: str) -> str:+ """The comment block directly above ``pattern`` — why it was withheld.++ The register's value is its reasoning, so surface it at the block instead of+ making the author go read the file. Returns '' when a line carries no+ preceding comment.+ """+ lines = denylist_text.splitlines()+ try:+ idx = next(i for i, ln in enumerate(lines) if ln.strip() == pattern)+ except StopIteration:+ return ""+ comment: list[str] = []+ for ln in reversed(lines[:idx]):+ stripped = ln.strip()+ if not stripped.startswith("#"):+ break+ text = stripped.lstrip("#").strip(" -")+ if text:+ comment.append(text)+ return " ".join(reversed(comment))+++def _violations(paths: list[str], engine, denylist_text: str) -> list[tuple[str, str, str]]:+ """(path, pattern, rationale) for every path a denylist entry withholds."""+ patterns = [+ ln.strip()+ for ln in denylist_text.splitlines()+ if ln.strip() and not ln.lstrip().startswith("#")+ ]+ compiled: list[tuple[str, re.Pattern[str]]] = [+ (p, engine._compile_glob(p)) for p in patterns+ ]+ hits: list[tuple[str, str, str]] = []+ for path in paths:+ for pattern, rx in compiled:+ if rx.match(path):+ hits.append((path, pattern, _rationale_for(pattern, denylist_text)))+ break+ return hits+++def main(argv: list[str] | None = None) -> int:+ ap = argparse.ArgumentParser(description=__doc__)+ mode = ap.add_mutually_exclusive_group()+ mode.add_argument("--staged", action="store_true", help="check what the staged change adds")+ mode.add_argument("--report", action="store_true", help="list the tracked backlog")+ mode.add_argument("--check", action="store_true", help="like --report, but rc 1 if non-empty")+ args = ap.parse_args(argv)++ engine = _load_engine()+ denylist_path = _GATE_DIR / "references" / "distribution-denylist.txt"+ if engine is None or not denylist_path.is_file():+ print("check_denylist_not_tracked: SKIP - no privacy-gate register in this tree.")+ return 0++ denylist_text = denylist_path.read_text(encoding="utf-8")+ staged = args.staged or not (args.report or args.check)+ paths = _added_paths() if staged else _tracked_paths()+ hits = _violations(paths, engine, denylist_text)++ if not hits:+ scope = "staged additions" if staged else "tracked tree"+ print(f"check_denylist_not_tracked: OK - no withheld paths in the {scope}.")+ return 0++ if staged:+ print("")+ print("DISTRIBUTION DENYLIST - this change tracks a path meant to stay private:")+ print("")+ for path, pattern, why in hits:+ print(f" {path}")+ print(f" withheld by: {pattern}")+ if why:+ print(f" reason: {why}")+ print("")+ print(" Committing it makes it permanent and world-readable. Either keep the")+ print(" file untracked (add it to .gitignore), or - if the register is wrong -")+ print(" edit distribution-denylist.txt in the SAME commit so the decision is")+ print(" recorded rather than bypassed.")+ return 1++ by_pattern: dict[str, int] = {}+ for _, pattern, _why in hits:+ by_pattern[pattern] = by_pattern.get(pattern, 0) + 1+ print(f"check_denylist_not_tracked: {len(hits)} tracked files are withheld by the register.")+ for pattern, count in sorted(by_pattern.items(), key=lambda kv: -kv[1]):+ print(f" {count:>5} {pattern}")+ print("")+ print(" These predate the gate. Untrack them with `git rm --cached` (the files stay")+ print(" on disk) and gitignore them, or retire the entry if it no longer applies.")+ print(" Note: untracking does not remove them from history - that needs filter-repo.")+ return 1 if args.check else 0+++if __name__ == "__main__":+ sys.exit(main())diff --git a/tests/unit/ci/test_check_denylist_not_tracked.py b/tests/unit/ci/test_check_denylist_not_tracked.pynew file mode 100644index 0000000000..f94eb00508--- /dev/null+++ b/tests/unit/ci/test_check_denylist_not_tracked.py@@ -0,0 +1,134 @@+"""Tests for the CI distribution-denylist gate.++The gate lives in scripts/ci/ (not an importable package), so we add that+directory to sys.path before importing — mirroring how CI runs the scripts+directly with `python scripts/ci/<name>.py`.++The behaviour worth pinning is the split the gate exists for: it must BLOCK a+withheld path the moment a change adds it, while staying silent about the+withheld files already tracked. A gate that also failed on the backlog would+block every commit and be disabled within the hour — which is exactly how the+register lost its teeth the first time.+"""+from __future__ import annotations++import sys+from pathlib import Path++import pytest++_SCRIPTS_CI = Path(__file__).resolve().parents[3] / "scripts" / "ci"+sys.path.insert(0, str(_SCRIPTS_CI))++import check_denylist_not_tracked as gate # noqa: E402++DENYLIST = """\+# --- Internal scratch scripts (underscore-prefixed convention) --------------+scripts/_*.py++# Captures of the maintainer's LIVE vault: relocation planning, finances,+# named third parties.+video/qa-wiki/**+assets/screenshots/view-wiki.png+"""+++def engine():+ eng = gate._load_engine()+ if eng is None:+ pytest.skip("privacy-gate module not present in this tree")+ return eng+++class TestMatching:+ def test_flags_a_withheld_path(self, engine):+ hits = gate._violations(["scripts/_scratch.py"], engine, DENYLIST)+ assert [h[0] for h in hits] == ["scripts/_scratch.py"]+ assert hits[0][1] == "scripts/_*.py"++ def test_subtree_glob_matches_at_any_depth(self, engine):+ paths = ["video/qa-wiki/map.png", "video/qa-wiki/frames/t01.jpg"]+ assert [h[0] for h in gate._violations(paths, engine, DENYLIST)] == paths++ def test_exact_path_entry(self, engine):+ assert gate._violations(["assets/screenshots/view-wiki.png"], engine, DENYLIST)++ def test_ordinary_paths_are_clean(self, engine):+ clean = [+ "scripts/preflight.ps1",+ "scripts/ci/check_denylist_not_tracked.py", # no leading underscore+ "video/src/intro/scenes/Integrations.tsx", # video/, but not qa-wiki+ "assets/screenshots/app-home.png",+ "jarvis/core/bus.py",+ ]+ assert gate._violations(clean, engine, DENYLIST) == []++ def test_each_path_reported_once(self, engine):+ """A path matching several entries yields one hit, not one per entry."""+ overlapping = DENYLIST + "\nscripts/**\n"+ hits = gate._violations(["scripts/_scratch.py"], engine, overlapping)+ assert len(hits) == 1+++class TestRationale:+ def test_surfaces_the_comment_block_above_the_entry(self):+ why = gate._rationale_for("scripts/_*.py", DENYLIST)+ assert "Internal scratch scripts" in why++ def test_joins_a_multi_line_comment_block(self):+ why = gate._rationale_for("video/qa-wiki/**", DENYLIST)+ assert "LIVE vault" in why and "named third parties" in why++ def test_entry_without_a_preceding_comment(self):+ assert gate._rationale_for("assets/screenshots/view-wiki.png", DENYLIST) == ""++ def test_unknown_entry_does_not_raise(self):+ assert gate._rationale_for("nope/**", DENYLIST) == ""+++class TestModes:+ def test_staged_mode_blocks_on_an_added_withheld_path(self, engine, monkeypatch, capsys):+ monkeypatch.setattr(gate, "_load_engine", lambda: engine)+ monkeypatch.setattr(gate, "_added_paths", lambda: ["scripts/_scratch.py"])+ monkeypatch.setattr(gate, "_tracked_paths", lambda: [])+ monkeypatch.setattr(+ Path, "read_text", lambda self, **kw: DENYLIST, raising=False+ )+ assert gate.main(["--staged"]) == 1+ out = capsys.readouterr().out+ assert "scripts/_scratch.py" in out+ assert "Internal scratch scripts" in out # the reason, not just the path++ def test_staged_mode_ignores_the_tracked_backlog(self, engine, monkeypatch):+ """The whole point: a dirty tree must not make every commit fail."""+ monkeypatch.setattr(gate, "_load_engine", lambda: engine)+ monkeypatch.setattr(gate, "_added_paths", lambda: ["jarvis/core/bus.py"])+ monkeypatch.setattr(gate, "_tracked_paths", lambda: ["scripts/_old_scratch.py"])+ monkeypatch.setattr(+ Path, "read_text", lambda self, **kw: DENYLIST, raising=False+ )+ assert gate.main(["--staged"]) == 0++ def test_report_mode_lists_the_backlog_without_failing(self, engine, monkeypatch, capsys):+ monkeypatch.setattr(gate, "_load_engine", lambda: engine)+ monkeypatch.setattr(gate, "_tracked_paths", lambda: ["scripts/_old_scratch.py"])+ monkeypatch.setattr(+ Path, "read_text", lambda self, **kw: DENYLIST, raising=False+ )+ assert gate.main(["--report"]) == 0+ assert "scripts/_*.py" in capsys.readouterr().out++ def test_check_mode_fails_on_the_same_backlog(self, engine, monkeypatch):+ monkeypatch.setattr(gate, "_load_engine", lambda: engine)+ monkeypatch.setattr(gate, "_tracked_paths", lambda: ["scripts/_old_scratch.py"])+ monkeypatch.setattr(+ Path, "read_text", lambda self, **kw: DENYLIST, raising=False+ )+ assert gate.main(["--check"]) == 1++ def test_skips_cleanly_when_the_register_is_absent(self, monkeypatch, capsys):+ """A fork without the personal privacy gate must not be blocked by it."""+ monkeypatch.setattr(gate, "_load_engine", lambda: None)+ assert gate.main(["--staged"]) == 0+ assert "SKIP" in capsys.readouterr().out