Skip to content

Commit 332eb61

Browse files
cliffhallclaude
andcommitted
chore: address PR #1792 round-5 findings (airtight guard + doc/config sync)
- verify-format-coverage: assert the root `validate` chain invokes each client's `validate` (cd <dir> && npm run validate), closing the last reachability edge — a client dropped from the root chain now fails the guard even though its own globs still exist. Negative-tested. - eslint.config.js: widen the shared `files` block to test-servers/src/**/*.{ts,tsx,mts,cts} to match the widened lint:shared glob, so a future .mts/.cts there is lint-gated, not just prettier-gated. - AGENTS.md: scope the "uniform extension set" claim to client globs (core stays {ts,tsx}, shared {ts,tsx,mts,cts}), with verify:format-coverage as the backstop — removing the self-contradiction with the line below. npm run ci green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01XNdjEPKLG637X8YmhDiEk5
1 parent 0fa0f1b commit 332eb61

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎AGENTS.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ gh project item-edit --project-id PVT_kwDOCt2Azc4BJVxt --id "$ITEM_ID" --field-i
214214
- after making the changes, respond to each review comment with what was done (or why it was ignored)
215215

216216
### Mandatory pre-push gate
217-
- ALWAYS do `npm run format` before committing — the **root** `format` auto-fixes `core/` (`format:core`), the root `scripts/` tooling (`format:scripts`), the root "shared" surface (`format:shared` — `test-servers/src/**`, `vitest.shared.mts`, the root `eslint.config.js`), and every client's scope in one shot. Every format glob uses the uniform extension set `*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}` (#1792) so a new-extension file can't slip the gate, and `npm run verify:format-coverage` (the first step of `validate`, #1792) fails if any tracked source file is left uncovered by a `format:check` glob. `validate` runs `format:check` (the non-fixing variant, including `format:check:core`, `format:check:scripts`, and `format:check:shared`) and will fail in CI on any unformatted file, so always run the auto-fixer first rather than letting `format:check` catch it.
217+
- ALWAYS do `npm run format` before committing — the **root** `format` auto-fixes `core/` (`format:core`), the root `scripts/` tooling (`format:scripts`), the root "shared" surface (`format:shared` — `test-servers/src/**`, `vitest.shared.mts`, the root `eslint.config.js`), and every client's scope in one shot. Every **client** format glob uses the uniform extension set `*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}` (#1792) so a new-extension file can't slip the gate; `core/` stays `{ts,tsx}` and the shared surface `{ts,tsx,mts,cts}` (their surfaces can't hold the other extensions), and `npm run verify:format-coverage` (the first step of `validate`, #1792) is the backstop — it fails if any tracked source file is left uncovered by a `format:check` glob regardless of which glob was expected to catch it. `validate` runs `format:check` (the non-fixing variant, including `format:check:core`, `format:check:scripts`, and `format:check:shared`) and will fail in CI on any unformatted file, so always run the auto-fixer first rather than letting `format:check` catch it.
218218
- **`npm run ci` is the mandatory pre-push command** — it mirrors `.github/workflows/main.yml` (minus `npm install`): `validate` → `coverage` → `verify:build-gate` (the #1769 browser-externalized-builtin build gate) → `smoke` → Storybook play-function tests (installs Playwright chromium if needed). It now runs **`npm run coverage`**, the per-file ≥90 gate (lines/statements/functions/branches) that CI enforces — so `npm run ci` is a true superset of GitHub CI, and passing it locally means CI's gates will pass. Expect several minutes. **`npm run validate`** remains the fast inner-loop check during development (unit tests only — no coverage gate, no smoke, no Storybook), but it is **NOT** an acceptable substitute for `npm run ci` before pushing: `validate` runs `test`, not `test:coverage`, so it does **zero** coverage gating. Skipping the gate is how a push passes every fast local check and still fails CI (this exact gap broke PR #1601 on a function-coverage regression).
219219
- ALWAYS do `npm run format` before committing, then **`npm run ci`** before pushing. From the repo root, `validate` runs **`verify:format-coverage` first** (the #1792 guard — asserts every tracked source file is covered by a `format:check` glob), then the **`core/` gate** (`validate:core`), then chains the four per-client validations (`validate:web` → `validate:cli` → `validate:tui` → `validate:launcher`); each client delegates to its own `npm run validate` in its own folder (no coverage — fast). Every client is self-validating and the top level just chains them, building each client's bundle along the way (no cross-client build dependencies).
220220
- **`validate:core` is the root-owned format + lint gate (#1689, widened in #1778 and #1767).** Each client's `prettier`/`eslint` is scoped to its own dir, so nothing reached `core/`, the root `scripts/`, or the root "shared" surface before — `validate:core` closes that: it runs `format:check:core` (`prettier --check "core/**/*.{ts,tsx}"`) + `format:check:scripts` (`prettier --check "scripts/**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"`, the root build/verify tooling — #1778) + `format:check:shared` + `lint:core` (`eslint "core/**/*.{ts,tsx}"` via the **root** `eslint.config.js`) + `lint:shared`. Use `npm run format:core` / `npm run format:scripts` / `npm run format:shared` to auto-fix (all folded into the root `format`). The **shared surface** (#1767) is `test-servers/src/**/*.{ts,tsx,mts,cts}`, the root `vitest.shared.mts`, and the root `eslint.config.js` — first-party code no client's `eslint .` / `prettier` reaches; it is both prettier-gated (`format:check:shared`) and eslint-gated (`lint:shared`, via a second `files` block in the root `eslint.config.js` scoped to Node globals). The `scripts/` gate is prettier-only — the root has no eslint config for `.mjs`. The root carries prettier/eslint as devDependencies for this; `core/` is isomorphic (browser + Node globals, no JSX today — the `{ts,tsx}` glob future-proofs against a `core/**/*.tsx`). The root `eslint.config.js` honors an `_`-prefix as the intentionally-unused marker (`argsIgnorePattern`/`varsIgnorePattern`/`caughtErrorsIgnorePattern: '^_'`). **prettier is pinned to an exact version** (not a caret) in all five `package.json`s (#1790) so the gate's verdict can't shift with an in-range patch bump.

‎eslint.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export default defineConfig([
4545
},
4646
{
4747
files: [
48-
"test-servers/src/**/*.ts",
48+
"test-servers/src/**/*.{ts,tsx,mts,cts}",
4949
"vitest.shared.mts",
5050
"eslint.config.js",
5151
],

‎scripts/verify-format-coverage.mjs‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,30 @@ function globToRegExp(glob) {
147147
return new RegExp("^" + re + "$");
148148
}
149149

150+
/**
151+
* Assert the root `validate` chain actually invokes each non-root manifest's
152+
* `validate` (via `cd <dir> && npm run validate`). Without this, a client's
153+
* globs would still be harvested from its own `validate` and count as coverage
154+
* even if the root chain stopped running that client — the same "gate silently
155+
* stops gating" failure as the reachable-script check, one level up. Returns the
156+
* list of manifest dirs the root chain does NOT reach.
157+
*/
158+
function clientsUnreachedFromRoot() {
159+
const rootPkg = JSON.parse(
160+
readFileSync(path.join(repoRoot, "package.json"), "utf8"),
161+
);
162+
const reachedNames = reachableScripts(rootPkg.scripts);
163+
const reachedCommands = [...reachedNames]
164+
.map((n) => rootPkg.scripts?.[n])
165+
.filter((c) => typeof c === "string");
166+
return MANIFESTS.filter((dir) => dir !== ".").filter(
167+
(dir) =>
168+
!reachedCommands.some(
169+
(c) => c.includes(`cd ${dir}`) && /npm run validate/.test(c),
170+
),
171+
);
172+
}
173+
150174
/** Build the set of coverage predicates from all manifests' format globs. */
151175
function buildMatchers() {
152176
const matchers = [];
@@ -176,6 +200,22 @@ function trackedSourceFiles() {
176200
return out.split("\n").filter(Boolean);
177201
}
178202

203+
const unreachedClients = clientsUnreachedFromRoot();
204+
if (unreachedClients.length > 0) {
205+
console.error(
206+
`verify:format-coverage — the root \`validate\` chain does not invoke ${unreachedClients.length} client validation(s):\n`,
207+
);
208+
for (const dir of unreachedClients)
209+
console.error(` ${dir} (expected \`cd ${dir} && npm run validate\`)`);
210+
console.error(
211+
"\nA client whose `validate` the root chain never runs is not format-gated by CI,",
212+
);
213+
console.error(
214+
"even though its globs exist. Restore the `validate:<client>` link in the root `validate`.",
215+
);
216+
process.exit(1);
217+
}
218+
179219
const matchers = buildMatchers();
180220
const files = trackedSourceFiles();
181221
const ungated = files.filter((f) => !matchers.some((m) => m(f)));

0 commit comments

Comments
 (0)