Skip to content

Guide Validation Gate

Reese Hodge edited this page Sep 30, 2026 · 6 revisions

Guide: Validation Gate

The local gate is:

pnpm run validate

package.json defines it as:

eslint . && prettier --check . && tsc --build && pnpm -r --if-present build && pnpm -r --if-present test

So the required order is:

  1. lint
  2. format:check
  3. typecheck
  4. build
  5. test

All five must pass before work is considered done. See Concept-Testing-And-TDD for the broader testing principle and Guide-Local-Setup for first-time setup.

Individual scripts

Command Purpose
pnpm run lint ESLint over the configured repo surface
pnpm run lint:fix ESLint auto-fix
pnpm run format:check Prettier check without writing
pnpm run format Prettier write
pnpm run typecheck TypeScript project build
pnpm run build Workspace builds
pnpm run test Workspace tests
pnpm run test:coverage Workspace tests with coverage where configured

CI runs the same quality stages as separate steps, plus a separate dependency audit job. A locally green validate does not replace CI's audit.

The gate is enforced on main, not merely recommended

Until 2026-09-30 the "Main Branch Protection" ruleset carried only deletion and non_fast_forward. Anyone could push straight to main, and a red CI or Audit could not stop a merge — which is exactly how the advisory failure in Log entry 37 came to be discovered on main rather than on a pull request. The ruleset now also requires:

Rule Setting
Pull request Required, 0 approving reviews (solo maintainer)
Required status checks CI and Audit
Strict / up-to-date branch Off — a PR need not be rebased on every main commit
Bypass Repository admin, always

The check names come from the name: fields of the two jobs in .github/workflows/ci.yml. Renaming a job without updating its required context blocks merging: the old required check never reports, stays pending, and does not satisfy the gate. Rename the job and the ruleset context together. A conditionally skipped job is different: GitHub reports its check as success, which can satisfy a required context. A workflow skipped by path, branch, or commit-message filtering instead leaves its required check pending. See GitHub's required-check troubleshooting guide.

The sharp edge of requiring Audit

pnpm audit queries the live advisory database, so a newly published advisory turns every open pull request red at once, including ones touching nothing related — see Concept-Supply-Chain-Discipline. Requiring Audit therefore converts that from a noisy signal into a full stop on merging.

That is the intended behavior, and the admin bypass is the pressure valve. It exists for the case where the fix is genuinely blocked upstream, not as a way around a red build: the normal response is to fix the advisory, which on 2026-09-30 took a lockfile refresh and one commit.

Trap: the local wiki clone is intentionally ignored

prettier --check . is repo-wide. A local wiki/ clone is a separate git repo, contains author-controlled wiki prose, and would break or churn formatting if Prettier saw it. That is why:

  • .prettierignore excludes wiki/.
  • .gitignore excludes /wiki/.

This is the same pattern Guide-Wiki-Contributing relies on: edit the wiki locally, lint the wiki with wiki tooling when needed, but keep the main repo's validation gate independent of the optional clone. Gotchas links here for this trap.

Trap: root scripts are silently outside coverage

eslint.config.mjs ignores:

  • scripts/
  • *.mjs

vitest.workspace.ts includes only:

  • packages/frontend
  • packages/agent
  • packages/repo-tools

That means a root-level script in scripts/ or an .mjs helper can be unlinted and untested while pnpm run validate still passes. This is why repo tooling belongs in a workspace package such as packages/repo-tools instead of root scripts. Gotchas links here for this trap too.

This is not hypothetical. wiki:push was a root package.json one-liner, git add -A && git commit -m "Update wiki" && git push. The && chain encodes a conditional — push only if the commit succeeded — which is logic, and logic in a root script is checked by nothing. On a clone whose work was already committed, git commit exited non-zero and the push silently never ran. It took a wiki that looked published but was not to surface it. Moving it into packages/repo-tools put it under types, lint and eight tests.

The rule that follows: a root package.json script may chain commands, but the moment it encodes a decision, it belongs in a package.

What this gate does not mean

validate proves the configured repo surface is clean. It does not prove wiki pages are linted, browser-edited wiki content is safe, or AWS deployments are correct. For wiki rules, read Wiki-Conventions. For deploy behavior, read Guide-Deployment.

Clone this wiki locally