From a8668ebd77aa531945767a3bbd44379688540c5b Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Sat, 6 Jun 2026 04:44:52 -0300 Subject: [PATCH] chore(governance): raise coverage gate 40 -> 60 test:coverage now enforces 60/60/60/60 (statements/lines/functions/branches); real coverage is ~75-82% so this tightens the floor without new test work. Updates the c8 --check-coverage thresholds in package.json and the matching references in CLAUDE.md (Quick Start, testing table, Copilot policy, Hard Rule #9). Salvaged from the never-pushed chore/skills-governance-tdd-vps branch; the i18n CLAUDE.md mirrors carry a separate pre-existing drift and are not gated by check-docs-sync. --- CLAUDE.md | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index 9b33648ec3..19b0d64802 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -11,7 +11,7 @@ npm run build # Production build (Next.js 16 standalone) npm run lint # ESLint (0 errors expected; warnings are pre-existing) npm run typecheck:core # TypeScript check (should be clean) npm run typecheck:noimplicit:core # Strict check (no implicit any) -npm run test:coverage # Unit tests + coverage gate (40/40/40/40 — statements/lines/functions/branches) +npm run test:coverage # Unit tests + coverage gate (60/60/60/60 — statements/lines/functions/branches) npm run check # lint + test combined npm run check:cycles # Detect circular dependencies ``` @@ -366,7 +366,7 @@ For any non-trivial change, read the matching deep-dive first: | E2E (Playwright) | `npm run test:e2e` | | Protocol E2E (MCP+A2A) | `npm run test:protocols:e2e` | | Ecosystem | `npm run test:ecosystem` | -| Coverage gate | `npm run test:coverage` (40/40/40/40 — statements/lines/functions/branches) | +| Coverage gate | `npm run test:coverage` (60/60/60/60 — statements/lines/functions/branches) | | Coverage report | `npm run coverage:report` | **PR rule**: If you change production code in `src/`, `open-sse/`, `electron/`, or `bin/`, you must include or update tests in the same PR. @@ -382,7 +382,7 @@ For any non-trivial change, read the matching deep-dive first: Why this matters: fixing bug A while opening bug B is worse than not fixing at all. The TDD/VPS gate enforces surgical scope — you touch only what the failing test proves is broken. Examples where this paid off: #3090 (claude-web 403), #3113 (WS HTTP fallback), #3052 (heap-guard auto-calibration). -**Copilot coverage policy**: When a PR changes production code and coverage is below 40% (statements/lines/functions/branches), do not just report — add or update tests, rerun the coverage gate, then ask for confirmation. Include commands run, changed test files, and final coverage result in the PR report. +**Copilot coverage policy**: When a PR changes production code and coverage is below 60% (statements/lines/functions/branches), do not just report — add or update tests, rerun the coverage gate, then ask for confirmation. Include commands run, changed test files, and final coverage result in the PR report. --- @@ -428,7 +428,7 @@ git push -u origin feat/your-feature 6. Never silently swallow errors in SSE streams 7. Always validate inputs with Zod schemas 8. Always include tests when changing production code -9. Coverage must stay ≥40% (statements, lines, functions, branches). +9. Coverage must stay ≥60% (statements, lines, functions, branches). 10. Never bypass Husky hooks (`--no-verify`, `--no-gpg-sign`) without explicit operator approval. 11. Never embed public upstream OAuth client_id/secret or Firebase Web keys as string literals — always go through `resolvePublicCred()` (`open-sse/utils/publicCreds.ts`). See `docs/security/PUBLIC_CREDS.md`. 12. Never return raw `err.stack` / `err.message` in HTTP / SSE / executor responses — always route through `buildErrorBody()` or `sanitizeErrorMessage()` (`open-sse/utils/error.ts`). See `docs/security/ERROR_SANITIZATION.md`. diff --git a/package.json b/package.json index 863a99b8a8..269c95b51d 100644 --- a/package.json +++ b/package.json @@ -122,7 +122,7 @@ "test:vitest:ui": "vitest run --config vitest.config.ts tests/unit/ui", "test:ecosystem": "node scripts/dev/run-ecosystem-tests.mjs", "test:system": "cross-env DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx --import ./open-sse/utils/setupPolyfill.ts --test --test-force-exit --test-concurrency=1 tests/e2e/system-failover.test.ts", - "test:coverage": "cross-env DISABLE_SQLITE_AUTO_BACKUP=true c8 --output-dir coverage --exclude=tests/** --exclude=**/*.test.* --reporter=text-summary --reporter=html --reporter=json-summary --reporter=lcov --check-coverage --statements 40 --lines 40 --functions 40 --branches 40 node --max-old-space-size=8192 --import tsx --import ./open-sse/utils/setupPolyfill.ts --test --test-force-exit --test-concurrency=8 tests/unit/*.test.ts", + "test:coverage": "cross-env DISABLE_SQLITE_AUTO_BACKUP=true c8 --output-dir coverage --exclude=tests/** --exclude=**/*.test.* --reporter=text-summary --reporter=html --reporter=json-summary --reporter=lcov --check-coverage --statements 60 --lines 60 --functions 60 --branches 60 node --max-old-space-size=8192 --import tsx --import ./open-sse/utils/setupPolyfill.ts --test --test-force-exit --test-concurrency=8 tests/unit/*.test.ts", "test:coverage:legacy": "c8 --output-dir coverage --exclude=open-sse --check-coverage --lines 50 --functions 50 --branches 50 node --import tsx --test tests/unit/*.test.ts", "coverage:report": "c8 report --output-dir coverage --exclude=tests/** --exclude=**/*.test.* --reporter=text --reporter=text-summary --reporter=html --reporter=json-summary --reporter=lcov", "coverage:summary": "node scripts/check/test-report-summary.mjs --input coverage/coverage-summary.json --output coverage/coverage-report.md",