Skip to content

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.

perf(hooks): cut pre-push down to the two credential gates

rubenluetke10-beepca147960542f
diff --git a/.githooks/pre-push b/.githooks/pre-push
index 0fd9e666b6..2b23ca4613 100755
--- a/.githooks/pre-push
+++ b/.githooks/pre-push
@@ -1,19 +1,40 @@
#!/bin/sh
-# pre-push: versioned local mirror of the credential + language CI gates.
+# pre-push: credential protection only. Everything else is CI's job.
#
-# Direct pushes to the public repo are the NORMAL flow (CLAUDE.md rule 2,
-# standard shared-history workflow since 2026-07-18). What stays fail-closed
-# is credential protection, never a raw-push block.
+# WHY THIS HOOK IS SMALL (rewritten 2026-08-05)
+# --------------------------------------------
+# This hook used to run fifteen gates, thirteen of which scanned the WHOLE tree
+# rather than the change being pushed. Two consequences made ordinary pushing
+# unaffordable:
#
-# 1. CREDENTIAL gate (FAIL-CLOSED on positive findings) — scripts/ci/privacy_pre_push.py
+# 1. Every push inherited whatever was already broken anywhere in the repo, so
+# a one-line fix was blocked by findings in files nobody had touched. The
+# fix-the-unrelated-thing loop, not the push, was the actual cost.
+# 2. The boot-budget gate booted the entire application on every push (420 s
+# timeout) and counted a failed boot — the normal outcome in a fresh
+# worktree without installed deps — as a budget violation.
+#
+# Those gates did not disappear: .github/workflows/ci.yml runs every one of them
+# on GitHub's runners, where a red result is a report instead of a roadblock.
+# The pre-commit hook keeps the cheap diff-scoped checks (language, dist
+# consistency, private keys, denylist) at the moment the change is authored.
+#
+# What stays HERE is only what must never leave the machine, and only what can
+# be judged from the pushed commits alone:
+#
+# 1. CREDENTIAL gate (FAIL-CLOSED) — scripts/ci/privacy_pre_push.py
# (A) logs a heads-up when the target is the public repo (never blocks);
-# (B) blocks a commit carrying a private maintainer email (author/committer);
+# (B) blocks a commit carrying a private maintainer email;
# (C) blocks a real secret / forbidden secret file in the pushed files.
-# The gate itself fails OPEN only when it genuinely cannot run (no python,
-# scanner import fails, diff range unknown) — layer-3 CI is the backstop.
+# Fails OPEN only when it genuinely cannot run (no python, scanner import
+# fails, diff range unknown) — layer-3 CI is the backstop.
#
-# 2. LANGUAGE gate (FAIL-OPEN) — scripts/ci/check_no_new_german.py
-# aborts only on a CONFIRMED newly-added German hit (Output Language Policy).
+# 2. PRIVATE-KEY gate (FAIL-CLOSED) — scripts/ci/check_no_private_keys.py
+# Signing private keys live ONLY in GitHub Actions secrets (AP-29). A
+# leaked key is permanent and unrecoverable, which is why this one is worth
+# its ~1.5 s even though CI also runs it.
+#
+# Together: under two seconds. A push is a push again.
#
# This hook is VERSIONED in .githooks/; the orchestrator wires it via
# `git config core.hooksPath .githooks` (this hook never sets that itself).
@@ -27,7 +48,7 @@
remote_name="$1"
remote_url="$2"
-# Prefer the repository venv because several gates import the project's dev
+# Prefer the repository venv because the gates import the project's dev
# dependencies. Cover POSIX and Windows layouts, then retain the historical
# known-good Windows interpreter before falling back to PATH. No Python at all
# -> fail OPEN.
@@ -45,11 +66,11 @@ cat > "$refs_file"
status=0
privacy_hit=0
-language_hit=0
+privkey_hit=0
-# --- 1) PRIVACY gate (FAIL-CLOSED) --------------------------------------------
+# --- 1) CREDENTIAL gate (FAIL-CLOSED) -----------------------------------------
# Feed the buffered refs to the privacy gate on stdin; it reads remote name/url
-# from argv. A non-zero exit means a CONFIRMED privacy block.
+# from argv. A non-zero exit means a CONFIRMED credential block.
privacy_gate="scripts/ci/privacy_pre_push.py"
if [ -f "$privacy_gate" ]; then
"$PY" "$privacy_gate" "$remote_name" "$remote_url" < "$refs_file"
@@ -59,149 +80,13 @@ if [ -f "$privacy_gate" ]; then
fi
fi
-# --- 2) LANGUAGE gate (FAIL-OPEN) ---------------------------------------------
-# rc == 1 means confirmed newly-added German; any other rc is fail-open.
-language_gate="scripts/ci/check_no_new_german.py"
-if [ -f "$language_gate" ]; then
- while read -r local_ref local_sha remote_ref remote_sha; do
- # Skip branch deletions (local_sha all zeros).
- case "$local_sha" in *[!0]*) : ;; *) continue ;; esac
-
- # Diff base = what the remote already has; new branch -> main.
- case "$remote_sha" in
- *[!0]*) base="$remote_sha" ;;
- *) base="origin/main" ;;
- esac
-
- # </dev/null keeps the gate from touching the hook's stdin; rc captured.
- "$PY" "$language_gate" "$base" </dev/null
- rc=$?
- if [ "$rc" -eq 1 ]; then
- status=1
- language_hit=1
- fi
- done < "$refs_file"
-fi
-
-# --- 3) CLI COVERAGE gate (FAIL-CLOSED) ---------------------------------------
-# Every jarvis/ui/web/*_routes.py router must be mounted in server.py, so every
-# WebUI action stays reachable from the `jarvis` CLI (catches the unmounted-router
-# / dead-command bug class). Static + stdlib-only; safe to run on every push.
-cli_gate="scripts/ci/check_cli_coverage.py"
-if [ -f "$cli_gate" ]; then
- "$PY" "$cli_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- cli_coverage_hit=1
- fi
-fi
-
-# --- 3b) DANGER METADATA gate (FAIL-CLOSED) ------------------------------------
-# A mutating route whose path matches a destructive marker (/restart, /kill,
-# /outbound, ...) must declare openapi_extra x-jarvis-dangerous, so the CLI's
-# dynamic layer and the Command Registry demand an explicit --yes/confirmation.
-# Static + stdlib-only; safe to run on every push.
-danger_gate="scripts/ci/check_danger_metadata.py"
-if [ -f "$danger_gate" ]; then
- "$PY" "$danger_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- danger_meta_hit=1
- fi
-fi
-
-# --- 3c) DEAD CONFIG SWITCH gate (FAIL-CLOSED) ---------------------------------
-# Every field on a config model must be read by some shipped code. A switch the
-# user can set that nothing reads is a lie told by the settings screen — a whole
-# [jarvis_agents] section and both [phase6.safety] flags shipped that way. The
-# known backlog is recorded in dead-config-switches-baseline.json, so this only
-# fails on a NEW one. Static + stdlib-only (~4 s).
-deadcfg_gate="scripts/ci/check_config_switches_wired.py"
-if [ -f "$deadcfg_gate" ]; then
- "$PY" "$deadcfg_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- deadcfg_hit=1
- fi
-fi
-
-# --- 3d) SILENT EXCEPTION gate (FAIL-CLOSED, ratchet) --------------------------
-# An except block that neither logs, nor re-raises, nor explains itself makes a
-# failure invisible — the largest single source of "it only half works" here.
-# Per-file baseline in silent-handlers-baseline.json; fails only when a file
-# GAINS one. Static + stdlib-only (~3 s).
-silentexc_gate="scripts/ci/check_silent_exception_handlers.py"
-if [ -f "$silentexc_gate" ]; then
- "$PY" "$silentexc_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- silentexc_hit=1
- fi
-fi
-
-# --- 4) CLI DOCGEN drift gate (FAIL-CLOSED) -----------------------------------
-# docs/jarvis-cli-reference.md is generated from the curated command tree; this
-# fails the push if a command was added/changed without regenerating it. Static
-# (imports the Typer app only, no live server). Run
-# `python scripts/ci/gen_cli_reference.py` to fix a drift.
-docgen_gate="scripts/ci/gen_cli_reference.py"
-if [ -f "$docgen_gate" ]; then
- "$PY" "$docgen_gate" --check </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- docgen_hit=1
- fi
-fi
-
-# --- 4b) COMMANDS DOCGEN drift gate (FAIL-CLOSED) -------------------------------
-# docs/commands-reference.md is generated from the Command Registry; this fails
-# the push if a registry command was added/changed without regenerating it.
-# Run `python scripts/ci/gen_commands_reference.py` to fix a drift.
-cmddocs_gate="scripts/ci/gen_commands_reference.py"
-if [ -f "$cmddocs_gate" ]; then
- "$PY" "$cmddocs_gate" --check </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- cmddocs_hit=1
- fi
-fi
-
-# --- 5) DOCS PRIVACY gate (FAIL-CLOSED) ---------------------------------------
-# Personal data must never leave the machine inside a documentation file:
-# the maintainer's real name, private email/handle, personal Windows paths,
-# machine/account ids. This is the docs-content half the privacy_pre_push gate
-# above does NOT cover (it checks commit author emails + real secrets, not the
-# name/path text inside docs/). Same canonical manifest the public-release
-# scrub uses (scripts/ci/privacy_gate/references/pii-scrub.tsv), so the two
-# never drift. Read-only scan over tracked docs/; exit 1 on any hit.
-docs_privacy_gate="scripts/ci/docs_privacy_scan.py"
-if [ -f "$docs_privacy_gate" ]; then
- "$PY" "$docs_privacy_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- docs_privacy_hit=1
- fi
-fi
-
-# --- 5a) PUBLIC DOCS contract (FAIL-CLOSED) ----------------------------------
-# Reader-facing pages must stay complete, cross-linked, short-exampled, and
-# free of secret/PII shapes even when the wider engineering archive changes.
-public_docs_gate="scripts/ci/check_public_docs.py"
-if [ -f "$public_docs_gate" ]; then
- "$PY" "$public_docs_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- public_docs_hit=1
- fi
-fi
-
-# --- 5b) PRIVATE-KEY gate (FAIL-CLOSED) ---------------------------------------
+# --- 2) PRIVATE-KEY gate (FAIL-CLOSED) ----------------------------------------
# Signing private keys (and the retired signing passphrase) must NEVER enter the
# repo — they live ONLY in GitHub Actions secrets (WAVE2_OFFLINE_KEY_B64 /
# WAVE4_MLDSA65_KEY_B64). Blocks a full PEM PRIVATE KEY block, a tracked
# *.key/*.key.enc file, or a WAVE2_CEREMONY_PASSPHRASE=<value> line. The demo
-# passphrase once leaked into 14 public snapshots; this guards that class.
-# Public keys are fine. Stdlib + git only, so it runs anywhere the hook does.
+# passphrase once leaked into 14 permanent public snapshots; this guards that
+# class. Public keys are fine. Stdlib + git only, so it runs anywhere.
privkey_gate="scripts/ci/check_no_private_keys.py"
if [ -f "$privkey_gate" ]; then
"$PY" "$privkey_gate" </dev/null
@@ -211,90 +96,6 @@ if [ -f "$privkey_gate" ]; then
fi
fi
-# --- 5c) DIST CONSISTENCY gate (FAIL-CLOSED on a confirmed broken bundle) ------
-# The shipped frontend bundle must be self-consistent IN GIT: dist/index.html
-# and every chunk reachable from it (dynamic imports included) must resolve to
-# tracked files, or every fresh clone boots to a blank spinner while the
-# builder's machine looks fine (cloud review 2026-07-18, AP-23). Checks HEAD,
-# so it also catches breakage a parallel session committed. rc 1 = confirmed
-# missing chunk; any other rc fails OPEN. Stdlib + git only, sub-second.
-dist_gate="scripts/ci/check_dist_consistency.py"
-if [ -f "$dist_gate" ]; then
- "$PY" "$dist_gate" </dev/null
- if [ "$?" -eq 1 ]; then
- status=1
- dist_hit=1
- fi
-fi
-
-# --- 5d) BRAND-LOGO gate (FAIL-CLOSED) ----------------------------------------
-# The bundled plugin marks come from outside the project, and an SVG is
-# executable content — a script or a remote reference would run on render.
-# Also catches a mark with no provenance row (a licence gap nobody can
-# reconstruct later) and a wordmark squeezed into a 40 px square (unreadable).
-# rc 1 = confirmed finding; any other rc fails OPEN. Stdlib only, sub-second.
-brandlogo_gate="scripts/ci/check_brand_logos.py"
-if [ -f "$brandlogo_gate" ]; then
- "$PY" "$brandlogo_gate" </dev/null
- if [ "$?" -eq 1 ]; then
- status=1
- fi
-fi
-
-# --- 6) REQUIREMENTS SYNC gate (FAIL-CLOSED) ----------------------------------
-# requirements.in (source for the hash-pinned requirements.txt lockfile) must
-# mirror pyproject.toml [project].dependencies exactly. When they drift, an
-# extras-only, torch-pulling package (silero-vad, sentence-transformers, …) can
-# leak into the base lockfile, baking the multi-GB GPU CUDA wheel stack into the
-# installer and bricking `pip install --require-hashes -r requirements.txt` for
-# every non-maintainer machine (nvidia-cufile unresolvable on plain PyPI). This
-# is the guard for that "works on my machine" class (AP-23). The script itself
-# fails OPEN when `packaging` is unavailable; CI is the backstop.
-reqsync_gate="scripts/ci/check_requirements_sync.py"
-if [ -f "$reqsync_gate" ]; then
- "$PY" "$reqsync_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- reqsync_hit=1
- fi
-fi
-
-# --- 6b) LOCKFILE UNIVERSAL + GPU-FREE gate (FAIL-CLOSED) ----------------------
-# Companion to the sync gate above: inspects the compiled requirements.txt itself
-# and blocks a lockfile that was regenerated the wrong way — one missing the
-# `uv pip compile --universal` marker (pins a single OS) or one that re-baked the
-# maintainer's nvidia-*/torch/CUDA wheels into the base file every downloader
-# installs (AP-23). Stdlib only, so it runs anywhere the hook does.
-lockfile_gate="scripts/ci/check_lockfile_universal.py"
-if [ -f "$lockfile_gate" ]; then
- "$PY" "$lockfile_gate" </dev/null
- if [ "$?" -ne 0 ]; then
- status=1
- lockfile_hit=1
- fi
-fi
-
-# --- 7) BOOT BUDGET gate (FAIL-CLOSED on a measured overrun) --------------------
-# A feature that sneaks heavy work onto the startup critical path must fail the
-# push, not the user's day (TTU forensic 2026-07-02: a wake-model change put a
-# 114.7 s load cascade on boot unnoticed). Runs ONE isolated cold boot via the
-# committed harness and enforces the budgets: window <= 8 s, voice-usable and
-# app-interactive <= 20 s each (~4x the measured medians, so machine variance
-# never flakes while every real regression class blows through). Exit 78 =
-# "could not measure" (no interpreter/harness) -> fail OPEN; a headless host
-# checks the window anchor only. Costs ~30-60 s per push — pushes are rare and
-# deliberate in this repo. Skip once with JARVIS_SKIP_BOOT_BUDGET=1.
-boot_budget_gate="scripts/ci/check_boot_budget.py"
-if [ -f "$boot_budget_gate" ] && [ "${JARVIS_SKIP_BOOT_BUDGET:-0}" != "1" ]; then
- echo "pre-push: boot-budget gate — measuring one isolated cold boot (~30-60 s) ..."
- "$PY" "$boot_budget_gate" </dev/null
- rc=$?
- if [ "$rc" -ne 0 ] && [ "$rc" -ne 78 ]; then
- status=1
- boot_budget_hit=1
- fi
-fi
-
rm -f "$refs_file"
if [ "$status" -ne 0 ]; then
@@ -303,77 +104,11 @@ if [ "$status" -ne 0 ]; then
echo "pre-push BLOCKED: CREDENTIAL gate (private email / secret in pushed files)."
echo " See the findings above. Remove the credential from the commit, then retry."
fi
- if [ "$language_hit" -ne 0 ]; then
- echo "pre-push BLOCKED: LANGUAGE gate (newly added German text)."
- fi
- if [ "${cli_coverage_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: CLI COVERAGE gate (a route module is not mounted)."
- echo " Mount it in jarvis/ui/web/server.py — see the findings above."
- fi
- if [ "${danger_meta_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: DANGER METADATA gate (destructive route without x-jarvis-dangerous)."
- echo " Add openapi_extra={\"x-jarvis-dangerous\": True} to the route decorator."
- fi
- if [ "${deadcfg_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: DEAD CONFIG SWITCH gate (a new config field nothing reads)."
- echo " The settings screen and jarvis.toml would promise behaviour that does"
- echo " not exist. Wire the field up, or remove it. Triage:"
- echo " python scripts/ci/check_config_switches_wired.py --report"
- fi
- if [ "${silentexc_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: SILENT EXCEPTION gate (a new except that says nothing)."
- echo " Log it (feature name + what was skipped), re-raise it, or write a"
- echo " comment on the except line saying why silence is right here."
- echo " Then: python scripts/ci/check_silent_exception_handlers.py --update"
- fi
- if [ "${docgen_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: CLI DOCGEN drift (jarvis-cli-reference.md out of date)."
- echo " Run: python scripts/ci/gen_cli_reference.py and commit the result."
- fi
- if [ "${cmddocs_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: COMMANDS DOCGEN drift (commands-reference.md out of date)."
- echo " Run: python scripts/ci/gen_commands_reference.py and commit the result."
- fi
- if [ "${docs_privacy_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: DOCS PRIVACY gate (personal data in docs/)."
- echo " See the findings above. Fix with:"
- echo " python scripts/ci/docs_privacy_scan.py --fix <file>"
- echo " or run the docs-privacy-reviewer sub-agent for a semantic pass."
- fi
- if [ "${public_docs_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: PUBLIC DOCS contract (reader guide incomplete or unsafe)."
- echo " Run: python scripts/ci/check_public_docs.py"
- fi
- if [ "${privkey_hit:-0}" -ne 0 ]; then
+ if [ "$privkey_hit" -ne 0 ]; then
echo "pre-push BLOCKED: PRIVATE-KEY gate (private key / passphrase in the tree)."
echo " Signing private keys live ONLY in GitHub Actions secrets, never in the"
echo " repo. Remove the key material shown above (public keys are fine)."
fi
- if [ "${dist_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: DIST CONSISTENCY gate (half-shipped frontend bundle)."
- echo " dist/index.html (or a chunk it loads) references files git does not"
- echo " track — a fresh clone would boot to a blank spinner. Commit the"
- echo " rebuilt bundle as ONE set (see the MISSING list above):"
- echo " git add jarvis/ui/web/dist/index.html jarvis/ui/web/dist/assets/"
- fi
- if [ "${reqsync_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: REQUIREMENTS SYNC gate (requirements.in != pyproject deps)."
- echo " See the diff above. Fix requirements.in, then regenerate the lockfile:"
- echo " uv pip compile --universal --generate-hashes --python-version 3.11 --output-file=requirements.txt requirements.in"
- fi
- if [ "${lockfile_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: LOCKFILE gate (requirements.txt not universal or has GPU/CUDA/torch wheels)."
- echo " See the findings above. Regenerate the platform-universal lockfile with:"
- echo " uv pip compile --universal --generate-hashes --python-version 3.11 --output-file=requirements.txt requirements.in"
- fi
- if [ "${boot_budget_hit:-0}" -ne 0 ]; then
- echo "pre-push BLOCKED: BOOT BUDGET gate (cold-boot startup budget exceeded)."
- echo " A change put work on the critical startup path. Move it behind"
- echo " _heavy_backend_bg / a deferred scan (docs/diagnostics/BOOT-TTU-NOTES.md,"
- echo " section 'How to add a feature WITHOUT slowing boot')."
- echo " Verify locally: python scripts/ci/check_boot_budget.py"
- echo " Skip once: JARVIS_SKIP_BOOT_BUDGET=1 git push"
- fi
echo "Bypass once with: git push --no-verify (layer-3 CI is the backstop)."
fi
exit "$status"