@ai-ecoverse/slicc-shared-web 2.14.3 → 2.15.0

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/README.md CHANGED
@@ -84,7 +84,7 @@ The caller cancels superseded runs on pull requests only, so a push to `main` ne
84
84
 
85
85
  **Flaky tests.** With `flaky-retry` above 0 (this repo's own CI sets 3; the default, 0, runs the tests once, as before), a shard whose tests failed reruns its failing files once, right away, on the same runner and commit, through `slicc-flaky retry`, which the test, `integration` and `flaky` jobs take from the pipeline's own commit. A test that fails, then passes is a flip; one that fails twice is a failure. A test is its file and its top-level name, and its key is the first 16 hex digits of `sha256(file \0 name)`. There is no rerun, and the shard fails as before, without a JUnit report or a failing test in it, with more than `flaky-retry` failing files, or when less than the rerun's limit, min(15 min, a quarter of `timeout-minutes`), is left of `timeout-minutes`. A failing test whose JUnit `file=` isn't one of the run's `test-glob` files, such as Go's package directory, is never rerun (`not rerun: a failing test names no test file: <file>`), `integration` never excuses such a flip, whatever a shard's `flaky.json` says, and `flaky` logs it and files nothing. The rerun gets `SLICC_TEST_RETRY=1` and only those files, writes `junit/<shard>.retry.xml` (and no second `.files` list), keeps the first run's `artifacts/` and `coverage/` (its own artifacts go to `artifacts/retry/`), and is killed at the limit. `junit/<shard>.flaky.json` records each retried test's first and retry outcome, its first error and the runner. A flip passes the shard only if an open `flaky-test` issue has its key and has seen it on another commit (it has no `new` label, or its commit isn't this one), the test file doesn't match `strict-tests` and the pull request doesn't change it; every other flip stays red, and so does a test that is skipped, cancelled or missing on the rerun, a rerun that ran no test, wrote no JUnit report or timed out, and a test that passed first and failed on the rerun. Only the rerun's results count for those tests; its exit status doesn't, so a check after `node --test` in `test` (such as this repo's `verify.mjs`) doesn't fail a rerun of one file. `lint` reads the open `flaky-test` issues once (with `issues: read`) and the pull request's changed files, and hands them to the shards and `integration`; when it can't, no flake is known and every flip stays red. `integration` judges each shard's flips again from its JUnit reports and that list, counts only the failures it doesn't excuse, keeps every other check on the first run, and names the flakes: `integration: PASS … , 2 known flakes passed on retry (#916, #844)`. Each shard also uploads the tests that finally failed as `failed-<shard>-<attempt>`, and a test that failed on an earlier attempt of the run and passes now counts as a flip in the report, though not for the gate. The `flaky` job (`issues: write`, `actions: read`, `continue-on-error`) writes a table of the run's flips and failures to its step summary and files one issue per test: title `flaky: <file name> › <test name>`, label `flaky-test`, `new` until a second commit, `guard` for a strict row, whose issue and comments name only the test, the run and the commit, and ``Key: `<key>` `` in the body. It finds the issue among the open ones, then among those closed in the last 30 days, which it reopens, and otherwise opens one; it comments at most once per issue per run with the run and attempt, the event, the pull request, the shard, the runner, the commit and the first error (at most 3,000 characters). It posts nothing that holds the job token or a token-shaped string (the same scan the cert review's `post` had), nothing on a branch matching `flaky-quiet-branches`, nothing on a pull request whose run also has a failure or a shard that wasn't rerun, nothing for a test the pull request changes, and nothing at all when a run would open more than 5 issues (`flaky: <n> flips in one run, not filing (infrastructure?)`). In the merge queue, each open issue whose test passed first time gets `<!-- clean: <n> since <date> -->` in its body, which a flip clears; at `flaky-close-after` it is closed with `no flip in <n> clean merge-group runs since <date>; a new flip reopens it`. It needs `node --test` through the shared harness: `$TEST` must honour `SLICC_TEST_FILES` and write node's JUnit report with `file=`.
86
86
 
87
- **Reviewer** runs twice, once with [claude-code-action](https://github.com/anthropics/claude-code-action) and once with [codex-action](https://github.com/openai/codex-action), on the same prompt, whether the tests passed or not. Both run on Amazon Bedrock with the org secret `AWS_BEARER_TOKEN_BEDROCK`, in the region of the org variable `CERT_AWS_REGION` (`us-west-2` without it). Claude uses the model in `CERT_BEDROCK_MODEL` (`global.anthropic.claude-opus-5-5` without it), as the cert reviews do. When that run ends without a verdict (no `structured_output`, or a result with `is_error`), the job runs Claude once more on `CERT_BEDROCK_FALLBACK_MODEL` (`global.anthropic.claude-sonnet-5-5` without it) and takes that verdict; when the second run has none either, the job fails and `review / claude` is `error`, as before. After each run one log line gives only the structural fields of `claude-execution-output.json` (the result's `subtype`, `is_error`, `stop_reason`, `num_turns`, `total_cost_usd`, `terminal_reason` and `api_error_status`, the refusal category and the assistant error kind), or says the file is missing; a value that isn't a plain word shows as `?`, so no model text, transcript or diff reaches the public log. The file is then deleted, and nothing uploads it. Codex uses its built-in `amazon-bedrock-runtime` provider (codex-action waits for its OpenAI proxy's `<run id>.json` in `codex-home` whenever it has a prompt, so the job writes a placeholder one) and the model in `CODEX_BEDROCK_MODEL` (`global.openai.gpt-6.1-sol` without it). Models that Bedrock serves only through inference profiles, as Sol 6.1 is, need the runtime provider and the profile's `global.` id; the `amazon-bedrock` provider's endpoint doesn't list them. The job token can only read. Each reviewer gets:
87
+ **Reviewer** runs twice, once with [claude-code-action](https://github.com/anthropics/claude-code-action) and once with [codex-action](https://github.com/openai/codex-action), on the same prompt, whether the tests passed or not. Both run on Amazon Bedrock with the org secret `AWS_BEARER_TOKEN_BEDROCK`, in the region of the org variable `CERT_AWS_REGION` (`us-west-2` without it). Claude uses the model in `CERT_BEDROCK_MODEL` (`global.anthropic.claude-opus-5-5` without it), as the cert reviews do. When that run ends without a verdict (no `structured_output`, or a result with `is_error`), the job runs Claude once more on `CERT_BEDROCK_FALLBACK_MODEL` (`global.anthropic.claude-sonnet-5-5` without it) and takes that verdict; when the second run has none either, the job fails and `review / claude` is `error`, as before. After each run one log line gives only the structural fields of `claude-execution-output.json` (the result's `subtype`, `is_error`, `stop_reason`, `num_turns`, `total_cost_usd`, `terminal_reason` and `api_error_status`, the refusal category and the assistant error kind), or says the file is missing; a value that isn't a plain word shows as `?`, so no model text, transcript or diff reaches the public log. The file is then deleted, and nothing uploads it. Codex uses its built-in `amazon-bedrock-runtime` provider (codex-action waits for its OpenAI proxy's `<run id>.json` in `codex-home` whenever it has a prompt, so the job writes a placeholder one) and the model in `CODEX_BEDROCK_MODEL` (`global.openai.gpt-6.1-sol` without it). Bedrock sometimes rejects a request partway through a Codex session with `invalid_request_error` / `validation_error` ("invalid encrypted view"): Codex replays each turn's encrypted reasoning in the next request, always does for this provider, and has no setting to stop it, and a new session has none to replay. So when the first run exits non-zero or ends without a final message, the job runs Codex once more, a new session on the same model with the same inputs, and takes that verdict; when the second run has none either, the job fails and `review / codex` is `error`, as before. On a GitHub-hosted runner codex-action's `drop-sudo` removes sudo for the rest of the job, so a second run can't start there and fails at once. After each run one log line gives only structural facts from the session's rollout in `codex-home`: the step's outcome, whether it left a message, how the turn ended, the API error's `type` and `code`, Codex's error kind and the tokens used, or says there is no rollout; a value that isn't a plain word shows as `?`. The rollout is then deleted, and nothing uploads it. Models that Bedrock serves only through inference profiles, as Sol 6.1 is, need the runtime provider and the profile's `global.` id; the `amazon-bedrock` provider's endpoint doesn't list them. The job token can only read. Each reviewer gets:
88
88
 
89
89
  - the pull request's head, with full history, as the working directory, and its base in `$RUNNER_TEMP/base`, each after `npm ci` (claude-code-action needs the working directory to be a checkout, and a base nested inside it would break the head's Biome config). Everything else the reviewers get or write (the prompt, context, integration artifacts, `browsers.json`, findings and screenshots) is in `$RUNNER_TEMP/review`, outside the checkout, so a reviewer's `npm run lint` sees only the repository;
90
90
  - `$RUNNER_TEMP/review/integration/`, every shard's artifact;
@@ -332,6 +332,7 @@ test('boots', async (t) => {
332
332
  | `extensions` | Unpacked extension directories to load. They are loaded with `Extensions.loadUnpacked` (behind `--enable-unsafe-extension-debugging`) once the harness is attached, so their service workers start paused like every other target. Their scripts are covered and profiled like the repo's own, and tests then run in the default browser context, closing their tabs when they end, because Chrome does not run extensions in the per-test contexts | none |
333
333
  | `extension` | Load the [harness extension](#harness-extension). `false`, or `SLICC_HARNESS_EXTENSION=0` in the environment, leaves it out; any other value of either is an error | `true` |
334
334
  | `headless` | Run Chrome headless | `true` unless `CI` is set; `SLICC_HEADLESS=1` or `0` overrides |
335
+ | `nice` | Lower Chrome's CPU priority to nice 10 (or keep the test process's, if that is lower still) right after it starts, so its helpers and every renderer it starts later inherit it, and a suite that runs several files side by side leaves a developer machine responsive | `true` unless `CI` is set; `SLICC_NICE=1` or `0` overrides |
335
336
  | `persistent` | Run every test in the default browser context, on the launch's on-disk `slicc-harness-*` profile, instead of a fresh off-the-record context per test. Off-the-record contexts keep OPFS in memory, with a far smaller real budget than `navigator.storage.estimate()` reports, so a suite that stores hundreds of MB there needs this. When a test ends, its tabs are closed and `Storage.clearDataForOrigin` (`storageTypes: 'all'`) clears the server's origin, every origin a page in the context showed (popups the app opened included) and every origin the harness's tabs got a response from, so nothing leaks into the next test. If clearing fails, the test fails | `false` |
336
337
  | `executable` | The Chromium binary. Without it, `$CHROME_PATH`, then slicc-cdp's `findBrowser()`, then playwright-core (see above) | found |
337
338
  | `args` | Extra Chromium flags, such as `--host-resolver-rules` or `--ignore-certificate-errors` | none |
@@ -391,8 +392,8 @@ A lane that can't have it opts out explicitly, in one of two ways:
391
392
 
392
393
  `close()` stops Chrome and removes its profile. It asks Chrome to close, waits up to 10 s for the exit, sends `SIGKILL`, waits up to 5 s more and then moves on with a warning, so a browser that ignores `Browser.close` or a missed exit never hangs teardown. A test process that ends without `close()` still leaves nothing running:
393
394
  - on `exit` and on `SIGINT`, `SIGTERM` or `SIGHUP`, the harness kills every browser it started in that process, with all its helper processes (Chrome runs in its own process group), with `SIGKILL` and removes its profile and crash dump directory, then re-raises the signal so the process ends the way it would have;
394
- - when the test process dies of `SIGKILL`, no handler runs. A watchdog, a `sh` in its own process group that reads a pipe from the test process, then gets end of file and kills Chrome's process group with `SIGKILL` at once. Chrome also shuts itself down when the CDP pipe closes, but that can take seconds. Only the profile stays behind;
395
- - the first `launch()` in a process removes every `slicc-harness-*` directory in `$TMPDIR` that is older than a day, or older than a minute and no running process uses as its `--user-data-dir`. It never kills a process.
395
+ - when the test process dies of `SIGKILL`, no handler runs. A watchdog, a `sh` in its own process group that reads a pipe from the test process, then gets end of file and kills Chrome's process group with `SIGKILL` at once. Chrome also shuts itself down when the CDP pipe closes, but that can take seconds. Only the profile and the crash dump directory stay behind;
396
+ - the first `launch()` in a process removes every `slicc-harness-*` directory in `$TMPDIR` that is older than a day, or older than a minute and no running process uses as its `--user-data-dir`, and every `slicc-crashes-*` crash dump directory that is older than a day, or older than a minute and no running process (crashpad's `--database`) names. It never kills a process.
396
397
 
397
398
  ## Crash dumps
398
399
 
@@ -1,7 +1,7 @@
1
1
  import { execFile, spawn } from 'node:child_process';
2
2
  import { rmSync } from 'node:fs';
3
3
  import { lstat, mkdir, mkdtemp, readdir, rm, writeFile } from 'node:fs/promises';
4
- import { tmpdir } from 'node:os';
4
+ import { getPriority, setPriority, tmpdir } from 'node:os';
5
5
  import { basename, join } from 'node:path';
6
6
  import { env as inherited } from 'node:process';
7
7
  import { promisify } from 'node:util';
@@ -9,7 +9,7 @@ import { executablePath, explicit } from './browser.mjs';
9
9
  import { cdn } from './cdn.mjs';
10
10
  import { CRASHED, connect, pipe, SEND_TIMEOUT } from './cdp.mjs';
11
11
  import { screenFor } from './display.mjs';
12
- import { crashpad } from './dumps.mjs';
12
+ import { crashpad, DUMPS } from './dumps.mjs';
13
13
  import {
14
14
  builtinWanted,
15
15
  exclusive,
@@ -53,6 +53,23 @@ export function headlessByDefault(env = inherited) {
53
53
  return !env.CI || env.CI === 'false' || env.CI === '0';
54
54
  }
55
55
 
56
+ export const NICE = 10;
57
+
58
+ export function niceByDefault(env = inherited) {
59
+ if (env.SLICC_NICE === '1') return true;
60
+ if (env.SLICC_NICE === '0') return false;
61
+ return !env.CI || env.CI === 'false' || env.CI === '0';
62
+ }
63
+
64
+ export function lower(pid, nice = NICE) {
65
+ try {
66
+ setPriority(pid, Math.max(getPriority(pid), nice));
67
+ return true;
68
+ } catch {
69
+ return false;
70
+ }
71
+ }
72
+
56
73
  export const modeFlags = (headless) =>
57
74
  headless ? ['--headless=new'] : ['--enable-unsafe-swiftshader'];
58
75
 
@@ -106,7 +123,8 @@ export async function start(
106
123
  profile,
107
124
  args = commandLine(profile),
108
125
  executable = undefined,
109
- env = inherited
126
+ env = inherited,
127
+ nice = false
110
128
  ) {
111
129
  const path = executable ?? (await executablePath({ env }));
112
130
  const child = spawn(path, args, {
@@ -114,6 +132,7 @@ export async function start(
114
132
  detached: true,
115
133
  stdio: ['ignore', 'ignore', 'pipe', 'pipe', 'pipe'],
116
134
  });
135
+ if (nice && child.pid > 0) lower(child.pid);
117
136
  const stderr = lines(child.stderr);
118
137
  const drained = new Promise((resolve) => child.stderr.once('close', resolve));
119
138
  const exited = new Promise((resolve) => {
@@ -239,16 +258,18 @@ export async function commandLines() {
239
258
  export async function prune(dir = tmpdir(), grace = GRACE) {
240
259
  const lines = await commandLines().catch(ignore);
241
260
  const used = (path) => lines.some((line) => line.includes(`--user-data-dir=${path} `));
261
+ const held = (name) => lines.some((line) => line.includes(`${name} `));
262
+ const busy = (name, path) => (name.startsWith(PREFIX) ? used(path) : held(name));
242
263
  const names = await readdir(dir).catch(() => []);
243
264
  const now = Date.now();
244
265
  const removing = names
245
- .filter((name) => name.startsWith(PREFIX))
266
+ .filter((name) => name.startsWith(PREFIX) || name.startsWith(DUMPS))
246
267
  .map(async (name) => {
247
268
  const path = join(dir, name);
248
269
  const info = await lstat(path).catch(ignore);
249
270
  if (!info?.isDirectory()) return;
250
271
  const age = now - info.mtimeMs;
251
- const orphaned = lines !== null && age > grace && !used(path);
272
+ const orphaned = lines !== null && age > grace && !busy(name, path);
252
273
  if (age > DAY || orphaned) await rm(path, { recursive: true, force: true }).catch(ignore);
253
274
  });
254
275
  await Promise.all(removing);
@@ -332,6 +353,7 @@ export async function launch({
332
353
  profile = inherited.SLICC_PROFILE === '1',
333
354
  realistic = false,
334
355
  headless = headlessByDefault(),
356
+ nice = niceByDefault(),
335
357
  persistent = false,
336
358
  executable,
337
359
  } = {}) {
@@ -354,7 +376,8 @@ export async function launch({
354
376
  userData,
355
377
  commandLine(userData, loaded, args, realistic, builtin, headless),
356
378
  browser,
357
- screen.env
379
+ screen.env,
380
+ nice
358
381
  ).catch((error) => scrap(error, screen.close));
359
382
  const untrack = track(child, [userData, dumps.dir], [screen.child].filter(Boolean));
360
383
  const cdp = await connect(pipe(child.stdio[3], child.stdio[4]), {
package/harness/dumps.mjs CHANGED
@@ -5,13 +5,14 @@ import { env } from 'node:process';
5
5
  import { sleep } from './util.mjs';
6
6
 
7
7
  export const DUMP_WAIT = 10000;
8
+ export const DUMPS = 'slicc-crashes-';
8
9
 
9
10
  async function list(dir, sub) {
10
11
  return (await readdir(join(dir, sub)).catch(() => [])).map((file) => join(sub, file));
11
12
  }
12
13
 
13
14
  export async function crashpad() {
14
- const dir = await mkdtemp(join(tmpdir(), 'slicc-crashes-'));
15
+ const dir = await mkdtemp(join(tmpdir(), DUMPS));
15
16
  const kept = new Set();
16
17
  const scan = async () => {
17
18
  const [pending, completed, writing] = await Promise.all(
package/harness/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  export { connect } from './cdp.mjs';
2
- export { headlessByDefault, launch, modeFlags } from './chrome.mjs';
2
+ export { headlessByDefault, launch, modeFlags, niceByDefault } from './chrome.mjs';
3
3
  export { screenFor } from './display.mjs';
4
4
  export {
5
5
  BUILTIN_ID as EXTENSION_ID,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "2.14.3",
3
+ "version": "2.15.0",
4
4
  "description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -75,12 +75,12 @@
75
75
  "release": "semantic-release"
76
76
  },
77
77
  "devDependencies": {
78
- "@ai-ecoverse/slicc-browsers": "1.24.0",
79
- "@ai-ecoverse/slicc-cdp": "1.50.1",
78
+ "@ai-ecoverse/slicc-browsers": "1.26.5",
79
+ "@ai-ecoverse/slicc-cdp": "1.52.4",
80
80
  "@biomejs/biome": "2.6.6",
81
81
  "lefthook": "2.2.2",
82
- "monocart-coverage-reports": "3.2.0",
83
- "pnpm": "12.18.0",
82
+ "monocart-coverage-reports": "3.2.1",
83
+ "pnpm": "12.19.0",
84
84
  "semantic-release": "25.0.9"
85
85
  },
86
86
  "peerDependencies": {