@ai-ecoverse/slicc-shared-web 1.27.1 → 1.28.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 +3 -3
- package/harness/cdp.mjs +8 -1
- package/harness/recorder.mjs +17 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -171,7 +171,7 @@ jobs:
|
|
|
171
171
|
```
|
|
172
172
|
|
|
173
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.
|
|
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
|
+
- **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, except under `evidence-notes` (globs of `<artifact>/<path>` the caller marks as upstream data, such as a dependency tarball's diff), where it is a suspect note for the review. The evidence workflow is part of the cert path (every workflow is in the default guard paths).
|
|
175
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.
|
|
176
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`.
|
|
177
177
|
- **tools-ref** must be the sha in the caller's `uses:`; the plan reads the caller that runs (main's tip, `github.sha`, on `pull_request_target`) and fails closed on a mismatch. The rules and the review's workspace come from that same commit, not from the pull request's possibly stale `base.sha`; `base.sha` only anchors the diff.
|
|
@@ -255,7 +255,7 @@ test('boots', async (t) => {
|
|
|
255
255
|
|
|
256
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:
|
|
257
257
|
- when the browser dies, every pending and later call rejects with `<method>: browser exited with <signal>` (or `with code <n>`);
|
|
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;
|
|
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;
|
|
259
259
|
- `until`, `within`, `goto` and `reload` stop retrying and rethrow it;
|
|
260
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`.
|
|
261
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)).
|
|
@@ -271,7 +271,7 @@ test('boots', async (t) => {
|
|
|
271
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;
|
|
272
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.
|
|
273
273
|
|
|
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, 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`.
|
|
275
275
|
|
|
276
276
|
Why it works the way it does:
|
|
277
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')
|
|
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);
|
package/harness/recorder.mjs
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "1.28.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",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"release": "semantic-release"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@ai-ecoverse/slicc-browsers": "1.
|
|
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",
|