@shivaedev/quality 0.28.1 → 0.28.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.28.2 - 2026-10-19
4
+
5
+ ### Changed
6
+
7
+ - `testProjects()` sizes workers from a connection budget instead of CPU capacity. Set `connectionBudget` and `connectionsPerWorker` to match the repository's PostgreSQL usage, or set `maxWorkers` to override the calculation.
8
+
3
9
  ## 0.28.1 - 2026-10-19
4
10
 
5
11
  ### Fixed
package/README.md CHANGED
@@ -294,6 +294,17 @@ export default defineConfig({ test: testProjects() });
294
294
 
295
295
  `testProjects` runs unit tests and specs in Node and `.dom` tests and specs in test-story's DOM environment by default. The DOM environment keeps Node's host constructors separate from the happy-dom window, so DOM specs need no project remap. Each test gets 30 seconds instead of Vitest's 5, because tests that start servers, browsers or CLIs take seconds on a busy CI runner. `.slow` tests run only when `--project slow` asks for them. Type tests are excluded from Vitest and belong in the compiler's input. Every project excludes `**/.worktrees/**` so a checkout does not collect specs from its worktrees.
296
296
 
297
+ Worker concurrency comes from a configured PostgreSQL connection budget, independent of CPU count: `max(1, floor(connectionBudget / connectionsPerWorker))`. The defaults are 80 usable connections and 14 connections per worker, giving five workers. The budget leaves room on a typical 100-connection server for administration and other clients; the estimate allows for full-app tests with several pools. Set the budget from your server's `SHOW max_connections`, subtracting connections reserved for other clients and concurrent test processes. Quality does not query the server. If even one worker exceeds the budget, it still runs one worker; reduce that test's pool sizes or increase the server capacity.
298
+
299
+ Set the per-worker estimate to the peak connections held by one test worker, and supply your usable budget or an explicit worker override:
300
+
301
+ ```ts
302
+ testProjects({ connectionBudget: 84, connectionsPerWorker: 14 });
303
+ testProjects({ maxWorkers: 4 });
304
+ ```
305
+
306
+ The first configuration allows six workers, including on a two-CPU runner. `maxWorkers` takes precedence over the connection calculation. Counts and estimates must be positive safe integers. Vitest's native `--maxWorkers` CLI option can also override the returned configuration for a single run.
307
+
297
308
  Coverage is opt-in: `testProjects({ coverage: true })` enables Vitest's V8 provider across the selected projects. Install `@vitest/coverage-v8` at the same version as Vitest. The report includes unvisited `src/**/*.ts` and `src/**/*.tsx` files and excludes declarations, tests, specs and `test-support`. To customize it, pass native Vitest coverage options, for example `testProjects({ coverage: { reporter: ["lcov", "text-summary"] } })`. No separate coverage config is needed.
298
309
 
299
310
  Outside CI, `testProjects` sets `silent: "passed-only"` so local runs show logs only from failing tests. When `CI` is set to a nonempty value, it sets `silent: false` so CI keeps all test logs. It leaves `reporters` unset so Vitest can auto-detect its agent reporter. If a repository adds a reporter, spread `configDefaults.reporters` instead of replacing the defaults:
@@ -1,6 +1,9 @@
1
1
  import { type TestUserConfig } from "vitest/config";
2
2
  export interface TestProjectsOptions {
3
+ readonly connectionBudget?: number;
4
+ readonly connectionsPerWorker?: number;
3
5
  readonly coverage?: boolean | NonNullable<TestUserConfig["coverage"]>;
6
+ readonly maxWorkers?: number;
4
7
  }
5
- export declare function testProjects({ coverage }?: TestProjectsOptions): TestUserConfig;
8
+ export declare function testProjects(options?: TestProjectsOptions): TestUserConfig;
6
9
  //# sourceMappingURL=testProjects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testProjects.d.ts","sourceRoot":"","sources":["../src/testProjects.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAe5F,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;CACtE;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAgB,EAAE,GAAE,mBAAwB,GAAG,cAAc,CAgC3F"}
1
+ {"version":3,"file":"testProjects.d.ts","sourceRoot":"","sources":["../src/testProjects.ts"],"names":[],"mappings":"AAEA,OAAO,EAA0C,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAe5F,MAAM,WAAW,mBAAmB;IACnC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;IACtE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC7B;AAmBD,wBAAgB,YAAY,CAAC,OAAO,GAAE,mBAAwB,GAAG,cAAc,CAkC9E"}
@@ -9,9 +9,23 @@ function named(environment) {
9
9
  function excluding(...patterns) {
10
10
  return [...defaultExclude, "**/.worktrees/**", named("typecheck"), TYPECHECK_ALONE, ...patterns];
11
11
  }
12
- export function testProjects({ coverage = false } = {}) {
12
+ function positiveInteger(name, value) {
13
+ if (!Number.isSafeInteger(value) || value < 1) {
14
+ throw new RangeError(`${name} must be a positive safe integer`);
15
+ }
16
+ return value;
17
+ }
18
+ function workerCount({ connectionBudget = 80, connectionsPerWorker = 14, maxWorkers }) {
19
+ if (maxWorkers !== undefined) {
20
+ return positiveInteger("maxWorkers", maxWorkers);
21
+ }
22
+ return Math.max(1, Math.floor(positiveInteger("connectionBudget", connectionBudget) / positiveInteger("connectionsPerWorker", connectionsPerWorker)));
23
+ }
24
+ export function testProjects(options = {}) {
25
+ const { coverage = false } = options;
13
26
  const ci = Effect.runSync(Config.String("CI").pipe(Config.withDefault("")).parse(ConfigProvider.fromEnv()));
14
27
  return {
28
+ maxWorkers: workerCount(options),
15
29
  ...(coverage === false
16
30
  ? {}
17
31
  : {
@@ -1 +1 @@
1
- {"version":3,"file":"testProjects.js","sourceRoot":"","sources":["../src/testProjects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,E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CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;SAC9G;QACD,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa;QAClC,+IAA+I;QAC/I,WAAW,EAAE,MAAM;KACnB,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shivaedev/quality",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "description": "Repository quality gate with typed rules, a baseline of existing debt and a registry of reasoned exceptions",
5
5
  "homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/quality#readme",
6
6
  "bugs": {
@@ -16,12 +16,34 @@ function excluding(...patterns: readonly string[]): string[] {
16
16
  }
17
17
 
18
18
  export interface TestProjectsOptions {
19
+ readonly connectionBudget?: number;
20
+ readonly connectionsPerWorker?: number;
19
21
  readonly coverage?: boolean | NonNullable<TestUserConfig["coverage"]>;
22
+ readonly maxWorkers?: number;
20
23
  }
21
24
 
22
- export function testProjects({ coverage = false }: TestProjectsOptions = {}): TestUserConfig {
25
+ function positiveInteger(name: string, value: number): number {
26
+ if (!Number.isSafeInteger(value) || value < 1) {
27
+ throw new RangeError(`${name} must be a positive safe integer`);
28
+ }
29
+ return value;
30
+ }
31
+
32
+ function workerCount({ connectionBudget = 80, connectionsPerWorker = 14, maxWorkers }: TestProjectsOptions): number {
33
+ if (maxWorkers !== undefined) {
34
+ return positiveInteger("maxWorkers", maxWorkers);
35
+ }
36
+ return Math.max(
37
+ 1,
38
+ Math.floor(positiveInteger("connectionBudget", connectionBudget) / positiveInteger("connectionsPerWorker", connectionsPerWorker)),
39
+ );
40
+ }
41
+
42
+ export function testProjects(options: TestProjectsOptions = {}): TestUserConfig {
43
+ const { coverage = false } = options;
23
44
  const ci = Effect.runSync(Config.String("CI").pipe(Config.withDefault("")).parse(ConfigProvider.fromEnv()));
24
45
  return {
46
+ maxWorkers: workerCount(options),
25
47
  ...(coverage === false
26
48
  ? {}
27
49
  : {