@ai-ecoverse/slicc-shared-web 1.25.1 → 1.26.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 +50 -1
- package/harness/recorder.mjs +47 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -132,6 +132,55 @@ A `pull_request` workflow can be deliberately rewritten to skip the guard, chang
|
|
|
132
132
|
|
|
133
133
|
The committed public CLI integration regressions use real git repositories and a fake GitHub HTTP API. Run only this non-browser suite locally with `node --test test/integration/cert-self-guard.test.mjs`; CI also runs it with the full integration suite. It covers touched/untouched changes, a self-passing workflow/pin edit, rename paths, label timing against **server-side arrival** (including a backdated committer date), permission, approval followed by a push, delayed synchronize preserving a post-push approval, unknown arrival causing conservative invalidation, API refusal and groups containing an unapproved or stale PR.
|
|
134
134
|
|
|
135
|
+
## Certification review (cert-review v2)
|
|
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).
|
|
138
|
+
|
|
139
|
+
A caller (`.github/workflows/cert-review.yml` in the repo, its only cert workflow):
|
|
140
|
+
|
|
141
|
+
```yaml
|
|
142
|
+
name: cert-review
|
|
143
|
+
on:
|
|
144
|
+
pull_request_target:
|
|
145
|
+
branches: [main]
|
|
146
|
+
types: [opened, synchronize, reopened, ready_for_review, converted_to_draft, labeled, unlabeled, edited]
|
|
147
|
+
merge_group:
|
|
148
|
+
permissions:
|
|
149
|
+
contents: read
|
|
150
|
+
concurrency:
|
|
151
|
+
group: ${{ (((github.event.action == 'labeled' || github.event.action == 'unlabeled') && github.event.label.name != 'cert-review-approved') || (github.event.action == 'edited' && !github.event.changes.base)) && format('cert-review-noop-{0}', github.run_id) || format('cert-review-{0}-{1}', github.event_name == 'pull_request' && 'leg' || 'pr', github.event.pull_request.number || github.event.merge_group.head_sha) }}
|
|
152
|
+
cancel-in-progress: ${{ github.event_name != 'merge_group' }}
|
|
153
|
+
jobs:
|
|
154
|
+
cert:
|
|
155
|
+
name: cert
|
|
156
|
+
uses: ai-ecoverse/slicc-shared-web/.github/workflows/cert-review.yml@<sha>
|
|
157
|
+
permissions:
|
|
158
|
+
contents: read
|
|
159
|
+
actions: read
|
|
160
|
+
checks: write
|
|
161
|
+
issues: write
|
|
162
|
+
pull-requests: write
|
|
163
|
+
with:
|
|
164
|
+
tools-ref: <the same sha>
|
|
165
|
+
rules: scripts/cert/review.txt
|
|
166
|
+
loud: |
|
|
167
|
+
src/**
|
|
168
|
+
secrets:
|
|
169
|
+
AWS_BEARER_TOKEN_BEDROCK: ${{ secrets.AWS_BEARER_TOKEN_BEDROCK }}
|
|
170
|
+
```
|
|
171
|
+
|
|
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
|
+
- **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`.
|
|
174
|
+
- **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.
|
|
175
|
+
- **Job names:** the caller's job may have any name; the merge group matches the called jobs by their ` / post`, ` / plan` and ` / self-guard` suffixes.
|
|
176
|
+
- **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`.
|
|
177
|
+
- **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.
|
|
178
|
+
- **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.
|
|
179
|
+
- **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.
|
|
180
|
+
- **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.
|
|
181
|
+
- **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.
|
|
182
|
+
- **Releases** carry no cert line: merged on main means certified; supply-chain provenance stays a code-only check in each repo.
|
|
183
|
+
|
|
135
184
|
## Which unit tests a commit runs
|
|
136
185
|
|
|
137
186
|
The diff-coverage hook, `slicc-unit-cover`, runs only the unit tests that cover the staged change, then `slicc-diff-cover` on their `coverage/unit/lcov.info`, so every staged line in `src/` still has to run:
|
|
@@ -218,7 +267,7 @@ test('boots', async (t) => {
|
|
|
218
267
|
- 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;
|
|
219
268
|
- 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.
|
|
220
269
|
|
|
221
|
-
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. 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`.
|
|
270
|
+
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`.
|
|
222
271
|
|
|
223
272
|
Why it works the way it does:
|
|
224
273
|
|
package/harness/recorder.mjs
CHANGED
|
@@ -11,7 +11,8 @@ const Util = mcrUtil.Util ?? mcrUtil.default;
|
|
|
11
11
|
|
|
12
12
|
const profiled = new Set(['page', 'worker', 'service_worker', 'shared_worker']);
|
|
13
13
|
const sampling = [['Profiler.setSamplingInterval', { interval: 100 }], ['Profiler.start']];
|
|
14
|
-
const
|
|
14
|
+
const unloading = 'sliccHarnessUnload';
|
|
15
|
+
const unload = `addEventListener('beforeunload', function ${unloading}() { debugger; })`;
|
|
15
16
|
|
|
16
17
|
function pathOf(url) {
|
|
17
18
|
return URL.canParse(url) ? new URL(url).pathname : '';
|
|
@@ -133,6 +134,44 @@ function contextOf(sessions, parents, sessionId) {
|
|
|
133
134
|
return undefined;
|
|
134
135
|
}
|
|
135
136
|
|
|
137
|
+
export function caused({ callFrames = [], hitBreakpoints = [] }, target = {}, exits = new Map()) {
|
|
138
|
+
const [top] = callFrames;
|
|
139
|
+
if (!top) return false;
|
|
140
|
+
const unloaded = target.type === 'page' && top.url === '';
|
|
141
|
+
if (unloaded && top.functionName === unloading) return true;
|
|
142
|
+
const lines = hitBreakpoints.length > 0 ? exits.get(pathOf(top.url)) : undefined;
|
|
143
|
+
return Boolean(lines?.includes(top.location.lineNumber));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function ownership(parents) {
|
|
147
|
+
const owned = new Map();
|
|
148
|
+
const targets = new Map();
|
|
149
|
+
const debugging = new Set();
|
|
150
|
+
const mine = (sessionId) => owned.get(targets.get(sessionId)) === sessionId;
|
|
151
|
+
return {
|
|
152
|
+
mine,
|
|
153
|
+
adopt({ sessionId, targetInfo }, parent) {
|
|
154
|
+
targets.set(sessionId, targetInfo.targetId);
|
|
155
|
+
if ((parent && !mine(parent)) || owned.has(targetInfo.targetId)) return false;
|
|
156
|
+
owned.set(targetInfo.targetId, sessionId);
|
|
157
|
+
if (parent) parents.set(sessionId, parent);
|
|
158
|
+
return true;
|
|
159
|
+
},
|
|
160
|
+
watch(sessionId) {
|
|
161
|
+
if (targets.has(sessionId) && !mine(sessionId)) debugging.add(sessionId);
|
|
162
|
+
},
|
|
163
|
+
held(sessionId) {
|
|
164
|
+
const targetId = targets.get(sessionId);
|
|
165
|
+
return [...debugging].some((other) => targets.get(other) === targetId);
|
|
166
|
+
},
|
|
167
|
+
drop(sessionId) {
|
|
168
|
+
if (mine(sessionId)) owned.delete(targets.get(sessionId));
|
|
169
|
+
targets.delete(sessionId);
|
|
170
|
+
debugging.delete(sessionId);
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
|
|
136
175
|
export function retain(scripts, result) {
|
|
137
176
|
for (const script of result) {
|
|
138
177
|
const prev = scripts.get(script.url);
|
|
@@ -180,6 +219,7 @@ export function recorder(cdp, server, { coverage = ['/'], exits = new Map(), pro
|
|
|
180
219
|
const parents = new Map();
|
|
181
220
|
const tabs = new Map();
|
|
182
221
|
const early = [];
|
|
222
|
+
const own = ownership(parents);
|
|
183
223
|
const ours = covered(server, coverage);
|
|
184
224
|
let run = null;
|
|
185
225
|
|
|
@@ -264,12 +304,12 @@ export function recorder(cdp, server, { coverage = ['/'], exits = new Map(), pro
|
|
|
264
304
|
|
|
265
305
|
cdp.on(async ({ method, params, sessionId }) => {
|
|
266
306
|
if (method === 'Target.attachedToTarget') {
|
|
267
|
-
if (
|
|
268
|
-
await attach(params);
|
|
307
|
+
if (own.adopt(params, sessionId)) await attach(params);
|
|
269
308
|
}
|
|
270
309
|
if (method === 'Target.detachedFromTarget') {
|
|
271
310
|
sessions.delete(params.sessionId);
|
|
272
311
|
pauses.delete(params.sessionId);
|
|
312
|
+
own.drop(params.sessionId);
|
|
273
313
|
}
|
|
274
314
|
if (method === 'Runtime.consoleAPICalled') {
|
|
275
315
|
const text = params.args.map((arg) => arg.value ?? arg.description).join(' ');
|
|
@@ -279,9 +319,12 @@ export function recorder(cdp, server, { coverage = ['/'], exits = new Map(), pro
|
|
|
279
319
|
const { exception, text } = params.exceptionDetails;
|
|
280
320
|
log(sessionId, `uncaught ${exception?.description ?? text}`);
|
|
281
321
|
}
|
|
322
|
+
if (method?.startsWith('Debugger.')) own.watch(sessionId);
|
|
282
323
|
if (method === 'Debugger.paused') {
|
|
283
324
|
pauses.set(sessionId, pauseOf(sessions.get(sessionId), params));
|
|
284
|
-
|
|
325
|
+
const target = sessions.get(sessionId);
|
|
326
|
+
const resumable = !own.held(sessionId) || caused(params, target, exits);
|
|
327
|
+
if (own.mine(sessionId) && resumable) await paused(sessionId);
|
|
285
328
|
}
|
|
286
329
|
if (method === 'Debugger.resumed') pauses.delete(sessionId);
|
|
287
330
|
if (method === CRASHED) log(sessionId, params.reason);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.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.9.1",
|
|
66
66
|
"@biomejs/biome": "2.5.15",
|
|
67
67
|
"monocart-coverage-reports": "2.13.2",
|
|
68
68
|
"playwright-core": "1.64.0",
|