Skip to content

CI: one local pre-push gate that runs CI's own steps, enforced for agents - #6369

Merged
shai-almog merged 9 commits into
masterfrom
pre-push-gates
Dec 1, 2026
Merged

shai-almog merged 9 commits into
masterfrom
pre-push-gates

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Most failed PR runs over the last five weeks were checks any machine can run: Vale and LanguageTool counts, inline guide source blocks, image alt text cut short by a comma, Playground snippets (including core javadoc), copyright headers, PMD/SpotBugs, Initializr fixture rules and launcher drift. Agents ran hand-copied versions of those checks that judge differently from CI: plain vale exits 0 on findings CI counts, and a bare check-copyright-headers.sh only sees the working tree.

What this adds

  • scripts/pre-push-gates.sh: CI's own selector (select-ci-members.py) picks the gates. Nothing is copied: the workflow steps themselves run through scripts/ci/run-workflow-steps.py, with a real GITHUB_ENV, so the step that records a Vale count feeds the step that fails on it.
    • Covers source-gates.yml and check-workflows.yml in full, the developer guide lint and quality steps, blog prose, website unit checks, Playground snippets and Initializr launchers.
    • --full adds SpotBugs/PMD/Checkstyle via the quality report, the build hint catalog, cast semantics, Mermaid rendering, the Hugo build and the guide's Java snippet compile.
    • Every selected CI member without a local gate is printed as NOT RUN.
  • Runner fidelity:
    • It follows the job's setup-java version, and fails rather than run on the wrong JDK.
    • It is deliberately stricter than the runner, never looser: it ignores if: and always runs with pipefail.
  • Enforcement for agents: a clean pass over a clean tree records HEAD in <git common dir>/cn1-pre-push-gates. The Claude Code hook in .claude/settings.json (scripts/ci/claude-pre-push-hook.py) blocks an agent's git push or gh pr create of a commit that isn't recorded there, or of a Java-changing commit recorded without --full. Humans pushing from a terminal are not affected.
  • Drift guard: check-workflows.yml runs pre-push-gates.sh --validate-steps, so renaming a step the gate names fails the PR that renames it. It also runs the hook's unit tests.
  • validate-guide-snippets.py honours CN1_MAVEN_REPO_LOCAL, so it never reads ~/.m2, and CN1_GUIDE_SNIPPETS_NO_COMPILE.
  • CLAUDE.md gets a "Before every push" checklist.

Verification

  • Planted defects on a worktree of master: comma-cut alt text, an inline source block and a header-less Java file. Each one was reported FAILED.
  • A real failing branch (ledge-platformer head): the gate reproduced CI's copyright and Initializr failures. It also found a broken include and LanguageTool matches that CI never reached.
  • Red team: three adversarial rounds on the hook and on CI fidelity. Every finding was fixed, and the hook's parser cases are now unit tests.
  • This branch: scripts/pre-push-gates.sh --full passes every gate. Only the guide figure comparison is NOT RUN, and it is CI-only.

The local Vale (3.14.1) and Hugo (0.151.2) differ from the CI pins (3.13.0 and 0.171.0). The script warns about that. Hugo 0.151 cannot build master's site at all.

🤖 Generated with Claude Code

shai-almog and others added 9 commits December 1, 2026 10:08
…ents

Most failed PR runs were checks any machine can run (Vale/LanguageTool
counts, inline guide snippets, comma-cut alt text, copyright headers,
Playground snippets, Initializr rules). Agents ran hand-copied commands
that judged differently from CI.

- scripts/pre-push-gates.sh picks gates with CI's selector and runs the
  workflow steps themselves through scripts/ci/run-workflow-steps.py.
- A clean pass records HEAD; .claude/settings.json wires
  scripts/ci/claude-pre-push-hook.py to block agent pushes of unrecorded
  commits (Java changes need --full).
- check-workflows.yml runs --validate-steps so renaming a step the gate
  names fails the PR that renames it.
- validate-guide-snippets.py honours CN1_MAVEN_REPO_LOCAL and
  CN1_GUIDE_SNIPPETS_NO_COMPILE.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cs; setup-java with unresolvable versions fails
@shai-almog
shai-almog merged commit 525118a into master Dec 1, 2026
3 of 8 checks passed
@shai-almog
shai-almog deleted the pre-push-gates branch December 1, 2026 09:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant