build: gate merges on release lint via pre-push hook
- Commit
8b42f044208fcf8f1c4889afc92f413b5f18ebe3- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-01 22:07 UTC (4 days ago)
- Parents
9996e7a
Owner-directed enforcement: nothing may merge into main without its modules' lint checks having run green. - .githooks/pre-push (committed, enable with 'git config core.hooksPath .githooks'): on pushes to main, runs :module:lintVitalRelease for every app/library module the pushed range touches and rejects the push on failure. Worktree branches are untouched; only the merge target is gated. - Root AGENTS.md §5 now states the rule for agents and the parent: agents verify lint + lintVitalRelease + unit tests in their worktree before committing, the parent re-runs release lint per touched module before pushing, and --no-verify is never the answer. This closes the hole that broke ./install all three times today (dialogs sweep left modules that did not compile, and weather/taxi release-lint errors sat on main undetected): release lint now runs mechanically at the push, not from memory.
Diff
.githooks/pre-push
diff --git a/.githooks/pre-push b/.githooks/pre-pushnew file mode 100755index 0000000000..fee90cc483--- /dev/null+++ b/.githooks/pre-push@@ -0,0 +1,58 @@+#!/bin/bash+# Pre-push gate: no commit reaches main unless every app/library module it+# touches passes release lint (and unit tests for modules with them).+# Agents work in worktrees and never push; the parent merges and pushes.+# This hook makes that merge-time verification mechanical instead of remembered.+set -u+remote="$1"+url="$2"+zero="0000000000000000000000000000000000000000"+changed_modules() {+ local range="$1"+ git diff --name-only "$range" 2>/dev/null | awk -F/ '+ {+ if ($1=="games" && NF>=2) print $1"/"$2;+ else if ($1=="library" && NF>=2) print $1"/"$2;+ else if ($1=="sdk" && NF>=2) print $1"/"$2;+ else print $1;+ }' | sort -u+}+fail=0+while read -r local_ref local_sha remote_ref remote_sha; do+ # Only guard pushes to main (the merge target); worktree branches are free.+ case "$remote_ref" in+ refs/heads/main|refs/heads/master) ;;+ *) continue ;;+ esac+ if [ "$remote_sha" = "$zero" ]; then+ range="$local_sha"+ else+ range="$remote_sha..$local_sha"+ fi+ mods=$(changed_modules "$range")+ if [ -z "$mods" ]; then+ continue+ fi+ gradle_mods=""+ rust_mods=""+ for m in $mods; do+ case "$m" in+ library/ui|library/network|library/room|library/map|library/ml|library/ocr|library/image|library/media|library/e2ee-p2p|library/widgets|library/work|library/biometric|library/ink|library/downloadservice|library/format|library/locationprovider|library/aosp-stubs|library/wearlink|library/qr|library/markdown|library/jni-bridge|library/markdown|sdk/games|sdk/cast|sdk/openassistant)+ gradle_mods="$gradle_mods :$(echo "$m" | tr / :)";;+ *)+ # App modules are top-level dirs (or games/<x>) containing build.gradle.kts+ if [ -f "$m/build.gradle.kts" ] || ls $m/build.gradle.kts >/dev/null 2>&1; then+ gradle_mods="$gradle_mods :$(echo "$m" | tr / :)"+ fi+ ;;+ esac+ done+ if [ -n "$gradle_mods" ]; then+ echo "pre-push: running release lint for:$gradle_mods"+ if ! ./gradlew $(for g in $gradle_mods; do echo "${g}:lintVitalRelease"; done) --console=plain -q; then+ echo "pre-push: REJECTED — lintVitalRelease failed. Fix the module before merging/pushing." >&2+ fail=1+ fi+ fi+done+exit $fail
AGENTS.md
diff --git a/AGENTS.md b/AGENTS.mdindex ea388f868a..7e5d4110bc 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -151,3 +151,4 @@ Formatting (current state): Kotlin uses ktlint's standard rule set via the `org. - Other agents share the tree. Prohibited except reading state: `stash/revert/reset/checkout . /clean` etc. Only `add` + `commit` allowed, and only paths you changed — check `git status` first, never `add -A/.`, never stage without committing instantly. - Commit message: line 1 is ≤80 chars, always in the format `appname: short description (#iss)`. Then a blank line and a full body: what changed and why, the context (bug/symptom, root cause, constraints, alternatives rejected), notable implementation details, user-visible effect, and how it was verified. Write in plain prose/bullets, wrapped at ~72 chars. The body feeds AI-written release notes, so make it complete; never stop at one line. - LF only; never commit line-ending churn. `FAIL_ON_PROJECT_REPOS` — never add repos in modules. Read `SUPPLY_CHAIN_RISKS.md` before new third-party dep.+- **Lint gate (mandatory).** No change merges to main without its modules' lint checks green: the agent verifies `./gradlew :<module>:lint :<module>:lintVitalRelease` (plus unit tests) in its worktree before committing, and the parent re-runs release lint for every module a cherry-picked commit touches before pushing. The `.githooks/pre-push` hook (enable once per clone with `git config core.hooksPath .githooks`) enforces this mechanically on pushes to main — a failing `lintVitalRelease` rejects the push. Never bypass with `--no-verify`; fix the module instead.