@ai-ecoverse/slicc-shared-web 1.27.0 → 1.27.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/README.md CHANGED
@@ -134,7 +134,7 @@ The committed public CLI integration regressions use real git repositories and a
134
134
 
135
135
  ## Certification review (cert-review v2)
136
136
 
137
- `.github/workflows/cert-review.yml` is a reusable workflow that certifies every non-draft pull request into `main` and sets one **`cert-review` check run** on its head (app 15368, always `success` or `failure`, never neutral or skipped). It follows Lars's 2026-10-19 model: no approval or label gates (draft status decides), findings as line comments on the diff, an LLM that reads and never runs PR code, and a separate job that validates the closed verdict schema and posts it. The design note is `slicc-agent-plan/cert-review-v2.md`; the reference implementation is slicc-extension's (B28).
137
+ `.github/workflows/cert-review.yml` is a reusable workflow that certifies every non-draft pull request into `main` and sets one **`cert-review` commit status** on its head (created by `github-actions[bot]`, its `target_url` the run attempt that wrote it, always `success` or `failure`). It is a commit status, not a check run: GitHub attaches a check run created with `GITHUB_TOKEN` to an older check suite, so a ruleset that requires it reports it as expected forever (B28, slicc-extension#133). The caller grants `checks: read` and `statuses: write`. It follows Lars's 2026-10-19 model: no approval or label gates (draft status decides), findings as line comments on the diff, an LLM that reads and never runs PR code, and a separate job that validates the closed verdict schema and posts it. The design note is `slicc-agent-plan/cert-review-v2.md`; the reference implementation is slicc-extension's (B28).
138
138
 
139
139
  A caller (`.github/workflows/cert-review.yml` in the repo, its only cert workflow):
140
140
 
@@ -157,7 +157,8 @@ jobs:
157
157
  permissions:
158
158
  contents: read
159
159
  actions: read
160
- checks: write
160
+ checks: read
161
+ statuses: write
161
162
  issues: write
162
163
  pull-requests: write
163
164
  with:
@@ -169,7 +170,7 @@ jobs:
169
170
  AWS_BEARER_TOKEN_BEDROCK: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }}
170
171
  ```
171
172
 
172
- - **Jobs** (`cert / …`): `self-guard` (cert-self-guard v1.24.2, pinned), `plan` (read-only: fork, draft, cert path, not behaviour, too large, or review), `review` (Claude on Bedrock with Read/Glob/Grep only, no Bash/Write/Web, structured output in `verdict.schema.json`, `contents: read`, the key in that step only), `post` (the only writer of `cert-review`: validates the verdict, re-anchors comments into diff hunks, posts one review, `REQUEST_CHANGES` on a failure, and runs a code-only prompt-injection and opaque-file scan that can only fail a pass), and `merge group` (code only: each member's newest run of the caller on its head must have certified it).
173
+ - **Jobs** (`cert / …`): `self-guard` (cert-self-guard v1.24.2, pinned), `plan` (read-only: fork, draft, cert path, not behaviour, too large, or review), `review` (Claude on Bedrock with Read/Glob/Grep only, no Bash/Write/Web, structured output in `verdict.schema.json`, `contents: read`, the key in that step only), `post` (the only writer of `cert-review`: validates the verdict, re-anchors comments into diff hunks, posts one review, `REQUEST_CHANGES` on a failure, and runs a code-only prompt-injection and opaque-file scan that can only fail a pass), and `merge group` (code only: each member's newest run of the caller on its head must have certified it; it waits while that run is still queued or running, up to 7 minutes shared across the members, passes over finished noop runs only, and stops at the first member that isn't certified). GitHub API reads are retried on 5xx and network errors, and both fallbacks also run when a job is cancelled.
173
174
  - **CI evidence** (`evidence-workflow`, `evidence-artifacts`, optional): for a repository whose certification needs pull-request code to run (tests, scripted scenarios), that code runs in the repository's own CI workflow on `pull_request`, with no secrets and a read-only token, and uploads artifacts. The `evidence` job (`contents`/`actions: read`, no secrets, no pull-request code) waits up to `evidence-wait-minutes` for that workflow's newest `pull_request` run on the head (this repository, this pull request), takes the newest finished `push` run on the base branch at or behind the base, downloads the artifacts whose names match by id, checks each zip's sha256 against its digest, unpacks it into `<side>/<artifact id>/` without links, binary files and the head side's images (no code can scan an image's text; main's images stay) or more than four times `evidence-max-mb` in total, scans the head side's text for bidi or zero-width controls and reviewer-aimed text, and uploads one `cert-review-evidence` artifact that the review downloads by id. Post checks that the run's only evidence artifact has the evidence job's id and digest. The newest artifact of each name is taken, and only if it was made in the run's latest attempt; unsafe names are skipped. The prompt names both runs; the head side is data written by the pull request's code. A missing run, artifact or digest, or another evidence artifact, is `incomplete: evidence`, never a review; an injection hit in the evidence fails the check in code. The evidence workflow is part of the cert path (every workflow is in the default guard paths).
174
175
  - **Code check** (`code-check`, optional): a command the `evidence` job runs from the caller's tree at main (on the bootstrap `pull_request` leg, the head's), after `npm ci --ignore-scripts`, with `BASE_SHA` (the merge base), `HEAD_SHA` (fetched as objects, never checked out on `pull_request_target`) and a read-only `GH_TOKEN`. A non-zero exit, or no result, is a fail finding in code with the output's verdict line; the full output is evidence for the review. slicc-bios runs its pin release-state this way, so the pull request's own code can't make it pass.
175
176
  - **The rules** file is the caller's own section of the prompt ("the repository and what to certify"), read from `main`; the frame around it (untrusted text, severity, tests, answer format) is shared in `.github/cert-review/frame.txt`. A missing rules file stops the review, which reads as `incomplete`.
@@ -178,7 +179,8 @@ jobs:
178
179
  - **Security boundary:** `pull_request_target` runs main's caller, prompt and post code, so a pull request can't change its own cert path. Every workflow and action is in the default guard paths, so a pull request can't add its own check writer without the coordinator's `cert-review-approved`. The merge group accepts only runs of the caller's path on `pull_request_target`.
179
180
  - **Bootstrap (one pull request per repo, no ruleset flip):** the switching pull request's caller also lists `pull_request:` with the same types, in a concurrency group of its own (`cert-review-leg-<n>`), so the two legs never cancel each other. While main's caller has no `pull_request_target`, that leg certifies the switching pull request with its own code (under the coordinator's label) and the merge group accepts its run. Once main has it, the leg is a no-op and only `pull_request_target` runs count. A follow-up removes the leg.
180
181
  - **Secrets never get posted:** post withholds any verdict that carries a value this run holds (the Bedrock key, the job token; raw, JSON-escaped, base64, base64url, hex or URL-encoded) or a known token shape (`gh[pousr]_`, `github_pat_`, `AKIA`/`ASIA`, `ABSK`, a JWT, a PEM block): the check is `incomplete: verdict carries a secret` and nothing is posted. Other long mixed-case runs (a lockfile's sha512 integrity, a base64 quote) are redacted in place and posted.
181
- - **A second writer fails closed:** post and the merge group list every `cert-review` check run on the head; one from another app, one whose `external_id` names no run of the caller on the right event and head, a duplicate for one run, or one whose conclusion its run's post job contradicts, fails the check and opens one alert issue.
182
+ - **The last writer:** GitHub enforces the newest `cert-review` status, and any workflow's `GITHUB_TOKEN` with `statuses: write` writes as `github-actions[bot]`, so a status written *after* ours can't be caught by this workflow. A pull request can add such a workflow only under the coordinator's `cert-review-approved` (every workflow is a guard path), and the org "require workflows" ruleset makes the merge depend on this workflow's own run, not on the status (slicc-agent-plan/cert-review-v2-probe.md). Apply that ruleset per repository.
183
+ - **A second writer fails closed:** post and the merge group list every `cert-review` status and check run on the head. A status not created by `github-actions[bot]`, or whose `target_url` isn't an attempt of a run of the caller on the right event and head, a check run from another app or whose `external_id` names no such run, a second write for one run attempt, or a state that the attempt's post (or merge group) job contradicts, fails the check and opens one alert issue.
182
184
  - **The injection scan** (code, on added lines outside the guard paths): bidirectional and zero-width controls and text aimed at the reviewer (a `"verdict": "pass"` literal, "as the cert reviewer", generic override phrases that name the reviewer or verdict) force a failure; generic phrases alone ("system prompt", "ignore previous instructions") are a note, and the review is told those lines are suspect. `injection-allow` (globs, read from main's caller, so guard-protected) exempts test fixtures from the aimed rule; controls are never exempt.
183
185
  - **The one label:** `cert-review-approved` is the single exception to "no labels" (PM, provisional): it applies only to pull requests that change the certifier, it can't turn a failure into a pass (success needs the guard's approval and a pass verdict), and the approver is an agent. Dropping it is the `approval-label` input plus the guard step, with nothing else depending on it.
184
186
  - **Releases** carry no cert line: merged on main means certified; supply-chain provenance stays a code-only check in each repo.
@@ -253,7 +255,7 @@ test('boots', async (t) => {
253
255
 
254
256
  `chrome.page(t)` opens a tab and returns the page API: `goto(path)`, `reload()`, `evaluate(fn, ...args)`, `until(fn, ...args)`, `press(key, ...modifiers)` (a key name like `Enter` or `F5`, or a single character typed with its US-layout key code), `type(text)`, `insert(text)`, `enter()`, `init(fn)` (runs in every new document), `expose(name, handler)` (a binding the page calls with a JSON string), `screenshot(file)`, `tab()` (another tab in the same context), `close()`, `send(method, params, ms)` (a raw CDP call in the tab's session), `errors`, `responses` and `dir` (the test's artifact directory). `chrome.pid` is the browser's process id and `chrome.profile` its `slicc-harness-*` profile directory in `$TMPDIR`. `goto` and `reload` wait until the new document is complete and no longer `about:blank`, and retry the navigation once if that never happens. `until` polls until the function returns a truthy value (not only strict `true`) and resolves with that value; the timeout error names the last result. `within(ms, fn, ...args)` is `until` with its own deadline, for a stage that should take a known time. `run(fn, ...args)` or `run(options, fn, ...args)` is for a job that may outlast the `timeout`: it starts `fn` in the page without holding a `Runtime.evaluate` open, then polls it every `everyMs` (1 s) with short evaluates, and resolves or rejects with the job's own result. It decides slow from hung by progress, not by the clock. Progress is a change in `marker` (a function run in the page at each poll, such as `() => window.done`) or in what `progress` returns (an async function run in Node, such as a probe of a process tree's CPU time). With either one set, a job whose progress stays the same for `quietMs` (60 s) fails with `<label>: no progress for N s after M s`, the last marker and progress values, and the page's pending requests and navigations. `maxMs` (30 min) is the outer bound for a job that keeps moving but never ends. Without a `marker` or `progress` only `maxMs` applies. `label` defaults to the start of `fn`'s source. The job's value must survive `returnByValue`, as with `evaluate`. Both stop at the deadline even if one evaluation never answers. Every CDP call has a deadline: `connect(url).send(method, params, sessionId, ms)` rejects with `<method>: no answer in <ms> ms` (60 s unless given), so a stuck page fails its test instead of hanging the run. A crash fails it at once instead:
255
257
  - when the browser dies, every pending and later call rejects with `<method>: browser exited with <signal>` (or `with code <n>`);
256
- - when a renderer crashes, every pending and later call to that target, and to the dedicated workers it started, rejects with `<method>: page renderer crashed (<status>, code <n>) at <url>` (or `worker`, `shared worker`, `service worker`), and `console.log` gets the same line;
258
+ - when a renderer crashes, every pending and later call to that target, and to the dedicated workers it started, rejects with `<method>: page renderer crashed (<status>, code <n>) at <url>` (or `worker`, `shared worker`, `service worker`), and `console.log` gets the same line. A service worker that Chrome stops and starts again reports `Inspector.targetCrashed` and then `Inspector.targetReloadedAfterCrash`: its calls work again from the restart on, it isn't called crashed when it restarts within 200 ms, and the harness runs its held start in each session of its own, so the restarted worker doesn't stay paused at start;
257
259
  - `until`, `within`, `goto` and `reload` stop retrying and rethrow it;
258
260
  - both errors end with the last five lines of the browser's stderr, and each test keeps up to 200 lines it wrote during the test in `chrome-stderr.log`.
259
261
  - a test that saw a renderer crash, or a browser that died of anything but `SIGKILL`, keeps Chrome's minidump of it as `<id>.dmp` in its artifact directory (see [Crash dumps](#crash-dumps)).
@@ -269,7 +271,7 @@ test('boots', async (t) => {
269
271
  - the summary runs in the test process, which also serves the page's files and talks CDP, so it is linear in the trace's events: a busy page's half-million-event trace takes well under a second, and the page's fetches keep getting answers meanwhile;
270
272
  - it adds a line for every debugger pause still held in the browser, in any target, with its id, URL, start time, reason and top call frames.
271
273
 
272
- Coverage is kept as one entry per script URL, each worker's counts summed into it as the worker's coverage is taken, so a run of thousands of workers keeps no more than its distinct scripts. A worker paused at its exit breakpoint is resumed as soon as its coverage and profile are taken; the profile is written to disk after. A pause in one target blocks every page in the same renderer process, so those pause lines name the culprit even when it isn't the page under test. The harness resumes its own coverage pauses (`beforeunload`, worker exits) within 10 s, even when collecting coverage fails. Any other pause in a session of its own, such as a `debugger;` statement, it resumes too, unless a test debugs that target in a session it attached itself (with `Target.attachToTarget` on `chrome.cdp`, say, and `Debugger.enable`): then that pause stays held for `Debugger.evaluateOnCallFrame` until the test resumes it. The harness never resumes a session the test attached, sends it no commands and takes no coverage, console lines or profiles from it. Downloads of intercepted URLs time out after 60 s and are tried up to three times; a `4xx` is not retried. `chrome.requests` lists the paths the server saw in this test, `chrome.overrides` is a `Map` of paths to bodies served instead of files, and `chrome.cdn` takes `status` (answer every intercepted request with it), `corrupt` (flip the last byte) and lists the intercepted `requests`. All of them reset with each test. `serve(options)` starts the same server on its own, for an `npm start`.
274
+ Coverage is kept as one entry per script URL, each worker's counts summed into it as the worker's coverage is taken, so a run of thousands of workers keeps no more than its distinct scripts. A worker paused at its exit breakpoint is resumed as soon as its coverage and profile are taken; the profile is written to disk after. A pause in one target blocks every page in the same renderer process, so those pause lines name the culprit even when it isn't the page under test. The harness resumes its own coverage pauses (`beforeunload`, worker exits) within 10 s, even when collecting coverage fails. Any other pause in a session of its own, such as a `debugger;` statement, it resumes too, unless a test debugs that target in a session it attached itself (with `Target.attachToTarget` on `chrome.cdp`, say, and `Debugger.enable`): then that pause stays held for `Debugger.evaluateOnCallFrame` until the test resumes it. The harness never resumes a session the test attached, nor a start the test holds with its own `Target.setAutoAttach` and `waitForDebuggerOnStart`, sends it no commands and takes no coverage, console lines or profiles from it. Downloads of intercepted URLs time out after 60 s and are tried up to three times; a `4xx` is not retried. `chrome.requests` lists the paths the server saw in this test, `chrome.overrides` is a `Map` of paths to bodies served instead of files, and `chrome.cdn` takes `status` (answer every intercepted request with it), `corrupt` (flip the last byte) and lists the intercepted `requests`. All of them reset with each test. `serve(options)` starts the same server on its own, for an `npm start`.
273
275
 
274
276
  Why it works the way it does:
275
277
 
package/harness/cdp.mjs CHANGED
@@ -98,7 +98,14 @@ export async function connect(url, { exited, tail = () => [] } = {}) {
98
98
  targets.delete(params.sessionId);
99
99
  drop((call) => call.sessionId === params.sessionId, 'target detached');
100
100
  }
101
- if (method === 'Inspector.targetCrashed') setTimeout(crash, 200, sessionId);
101
+ if (method === 'Inspector.targetCrashed') {
102
+ const target = targets.get(sessionId);
103
+ if (target) target.stopping = setTimeout(crash, 200, sessionId);
104
+ }
105
+ if (method === 'Inspector.targetReloadedAfterCrash') {
106
+ clearTimeout(targets.get(sessionId)?.stopping);
107
+ crashed.delete(sessionId);
108
+ }
102
109
  if (method === 'Target.targetCrashed') {
103
110
  const status = `${params.status}, code ${params.errorCode}`;
104
111
  for (const session of sessionsOf(params.targetId)) crash(session, status);
@@ -147,11 +147,14 @@ export function ownership(parents) {
147
147
  const owned = new Map();
148
148
  const targets = new Map();
149
149
  const debugging = new Set();
150
+ const waiting = new Set();
150
151
  const mine = (sessionId) => owned.get(targets.get(sessionId)) === sessionId;
151
152
  return {
152
153
  mine,
153
- adopt({ sessionId, targetInfo }, parent) {
154
+ ours: (sessionId) => mine(sessionId) || waiting.has(sessionId),
155
+ adopt({ sessionId, targetInfo, waitingForDebugger }, parent) {
154
156
  targets.set(sessionId, targetInfo.targetId);
157
+ if (waitingForDebugger && (!parent || mine(parent))) waiting.add(sessionId);
155
158
  if ((parent && !mine(parent)) || owned.has(targetInfo.targetId)) return false;
156
159
  owned.set(targetInfo.targetId, sessionId);
157
160
  if (parent) parents.set(sessionId, parent);
@@ -168,6 +171,7 @@ export function ownership(parents) {
168
171
  if (mine(sessionId)) owned.delete(targets.get(sessionId));
169
172
  targets.delete(sessionId);
170
173
  debugging.delete(sessionId);
174
+ waiting.delete(sessionId);
171
175
  },
172
176
  };
173
177
  }
@@ -267,6 +271,10 @@ export function recorder(cdp, server, { coverage = ['/'], exits = new Map(), pro
267
271
  return ready;
268
272
  }
269
273
 
274
+ function resume(sessionId) {
275
+ return cdp.send('Runtime.runIfWaitingForDebugger', {}, sessionId).catch(ignore);
276
+ }
277
+
270
278
  function log(sessionId, line) {
271
279
  const target = sessions.get(sessionId);
272
280
  const into = run ? target?.browserContextId === run.context && run.console : target && early;
@@ -302,15 +310,22 @@ export function recorder(cdp, server, { coverage = ['/'], exits = new Map(), pro
302
310
  return all;
303
311
  }
304
312
 
305
- cdp.on(async ({ method, params, sessionId }) => {
313
+ async function lifecycle({ method, params, sessionId }) {
306
314
  if (method === 'Target.attachedToTarget') {
307
315
  if (own.adopt(params, sessionId)) await attach(params);
316
+ else if (own.ours(params.sessionId)) await resume(params.sessionId);
308
317
  }
309
318
  if (method === 'Target.detachedFromTarget') {
310
319
  sessions.delete(params.sessionId);
311
320
  pauses.delete(params.sessionId);
312
321
  own.drop(params.sessionId);
313
322
  }
323
+ const restarted = method === 'Inspector.targetReloadedAfterCrash';
324
+ if (restarted && own.ours(sessionId)) await resume(sessionId);
325
+ }
326
+
327
+ cdp.on(async ({ method, params, sessionId }) => {
328
+ await lifecycle({ method, params, sessionId });
314
329
  if (method === 'Runtime.consoleAPICalled') {
315
330
  const text = params.args.map((arg) => arg.value ?? arg.description).join(' ');
316
331
  log(sessionId, `${params.type} ${text}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "1.27.0",
3
+ "version": "1.27.2",
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",
@@ -62,7 +62,7 @@
62
62
  "release": "semantic-release"
63
63
  },
64
64
  "devDependencies": {
65
- "@ai-ecoverse/slicc-browsers": "1.9.2",
65
+ "@ai-ecoverse/slicc-browsers": "1.10.3",
66
66
  "@biomejs/biome": "2.5.15",
67
67
  "monocart-coverage-reports": "2.13.2",
68
68
  "playwright-core": "1.64.0",