From c318cea6dbf03b4e332215d91ecf6ea500476ec9 Mon Sep 17 00:00:00 2001 From: Jeroen Schweitzer Date: Mon, 8 Jun 2026 10:39:55 +0200 Subject: [PATCH] chore(config): gate cargo test in pre-push on Rust changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add `cargo test --quiet` to the pre-push Rust block (sharing clippy's target/ guard) so the suite runs automatically on every push touching server/. Nothing ran the tests before — pre-push did only fmt/clippy/deny and there is no CI — so a Rust regression could reach main unverified. Document the resulting agent-spawn rule in team-patterns.md: don't have implementation agents pre-run fmt/clippy/test pre-emptively, since the push gate now enforces all three. The gate is authoritative; the lead patches any fallout at push. Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/rules/team-patterns.md | 20 ++++++++++++++++++++ .config/hooks/pre-push | 13 ++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/.claude/rules/team-patterns.md b/.claude/rules/team-patterns.md index 44a35c0ba..0b1915638 100644 --- a/.claude/rules/team-patterns.md +++ b/.claude/rules/team-patterns.md @@ -31,3 +31,23 @@ When leading a team (workshop, batch, or any multi-agent session): - If an agent has not sent a message in ~20 minutes, ping them for a status update. - **Bottleneck detection:** if other agents are idle and waiting on one agent's output, that agent's silence is a red flag — check on them immediately, do not wait for the next natural message. - When checking on a stuck agent, offer to reassign the task or pull in another agent to help. + +## Agent verification — don't duplicate the push gate + +The pre-push hook (`.config/hooks/pre-push`) is the source of truth for Rust +verification and **runs on every push the lead makes** when `server/` changed: +`cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, and `cargo test` +(plus `cargo deny`, ruff, JSON validation, systems.db stamp). There is no CI (no +`.gitea`/`.github`/`.forgejo` workflows) — the push gate is the only automatic +verification, so it is deliberately comprehensive. + +Therefore, when spawning implementation agents, do **not** tell them to run +`cargo fmt`, `cargo clippy`, or `cargo test` pre-emptively — the push gate enforces +all three, so it is pure duplication. Worse, an agent running a *weaker* check (e.g. +plain `cargo clippy` without `-D warnings`) reports a false "clean". Let agents write +code; the gate is authoritative. + +On a gate failure at push: fmt auto-fixes (`cargo fmt`); clippy is a quick lead patch; +a `cargo test` failure is a real regression — fix it, or SendMessage the still-alive +agent to fix it in-context. Net: agents verify nothing the gate already covers, and the +lead lets the gate catch fallout on push. diff --git a/.config/hooks/pre-push b/.config/hooks/pre-push index 0d717c7d7..a11c3870a 100755 --- a/.config/hooks/pre-push +++ b/.config/hooks/pre-push @@ -97,8 +97,19 @@ elif command -v cargo >/dev/null 2>&1 && [ -d "$REPO_ROOT/server" ]; then else echo "pre-push: clippy — OK" fi + + # cargo test — the ONLY automatic correctness gate: nothing else (no CI + # workflows exist) runs the suite, so without this a Rust regression + # reaches main unverified. Gated on server/ changes; shares the target/ + # guard with clippy so a cold worktree isn't forced into a full build. + echo "pre-push: checking Rust (cargo test)..." + if ! (cd "$REPO_ROOT/server" && cargo test --quiet 2>&1); then + ERRORS=$((ERRORS + 1)) + else + echo "pre-push: cargo test — OK" + fi else - echo "pre-push: skipping clippy (no target/ — run 'cargo build' once to enable)" + echo "pre-push: skipping clippy + test (no target/ — run 'cargo build' once to enable)" fi # --- Rust dependency audit (cargo deny) — requires deny.toml config ---