@ai-ecoverse/slicc-shared-web 1.21.0 → 1.22.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 +58 -0
- package/harness/trace.mjs +3 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -75,6 +75,63 @@ A workflow of its own (not this reusable one) gets the same line from the compos
|
|
|
75
75
|
if: always()
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
+
## Certification self-guard
|
|
79
|
+
|
|
80
|
+
`.github/actions/cert-self-guard` is a shared composite action for PR certification lanes. It inspects the PR's diff against its base (both paths of a rename included) and rejects certification-path edits with `cert-review: needs coordinator review` unless `cert-review-approved` was applied after the current head **arrived at GitHub** by a user whose GitHub repository permission is **admin or maintain**. The arrival time is the earliest `created_at` from `commits/{sha}/check-suites`, or, if unavailable, the PR timeline's latest matching head-push event. If neither server-side source is available, approval is `INCOMPLETE`. The client-controlled committer date is retained only as information in the receipt; it never authorizes approval. Write permission is not enough. It reads the label application from the issue timeline and checks the labeler's current permission through the API, rather than trusting the event sender or the label's presence alone. Removing and reapplying the label replaces the approval event; an old application cannot qualify. Missing git history, API errors, stale heads, ambiguous group membership and truncated timeline evidence fail closed as `INCOMPLETE`.
|
|
81
|
+
|
|
82
|
+
The guard's assumption is that **workers never apply or remove `cert-review-approved`; only a lane coordinator does, after reading the certification-path change**. The permission API cannot distinguish a coordinator from a worker: all agents act as `trieloff`, an admin. Coordinator-only labelling is therefore a **procedural assumption**, not something the permission check enforces. On `synchronize`, the guard itself removes that label automatically and blocks a touched PR until the coordinator approves its new head. A failed removal is red. This automated invalidation is not permission for workers to change the label manually. A re-run of the original synchronize event still requires fresh approval; run the subsequent label event instead.
|
|
83
|
+
|
|
84
|
+
On `merge_group`, the guard walks the first-parent merge ancestry from `head_sha` back to `base_sha`, resolves each merge's second parent to exactly one open PR, and inspects that member's actual merged delta. It checks approval against that queued head, not just whatever head the PR API currently returns. A moved head, an unexplained non-merge commit or an unapproved certification-path PR makes the group red. This assumes the queue's **merge-commit method** with two-parent synthetic merges; squash/rebase or any other unexplained ancestry fails closed. It does not call an LLM or run candidate code.
|
|
85
|
+
|
|
86
|
+
Callers use **one external `uses:` line pinned to a full commit SHA**, not a local action path or the PR's checkout. The composite executes its script from `github.action_path`, the downloaded pinned action directory. Each lane supplies one newline-separated `paths` list covering its certification workflows, reviewer/classifier/record tools and runners. The default list covers `.github/workflows/cert*.yml`, `.github/workflows/cert*.yaml`, `scripts/cert/**`, `tools/cert-review/**` and `.github/actions/cert-self-guard/**`. Inclusive repository-relative globs use Node's `path.matchesGlob`; negations are not supported. Include the caller's **entire cert workflow**, so changing the guard's own `uses:` line or pinned SHA is itself guarded. An empty or invalid list fails closed.
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
on:
|
|
90
|
+
pull_request:
|
|
91
|
+
types: [opened, synchronize, reopened, labeled, unlabeled, ready_for_review]
|
|
92
|
+
merge_group:
|
|
93
|
+
types: [checks_requested]
|
|
94
|
+
|
|
95
|
+
permissions:
|
|
96
|
+
contents: read
|
|
97
|
+
checks: read
|
|
98
|
+
pull-requests: write
|
|
99
|
+
|
|
100
|
+
steps:
|
|
101
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
102
|
+
with:
|
|
103
|
+
ref: ${{ github.event.pull_request.base.sha || github.event.merge_group.head_sha }}
|
|
104
|
+
fetch-depth: 0
|
|
105
|
+
persist-credentials: false
|
|
106
|
+
- name: Fetch the exact trees to inspect, without executing them
|
|
107
|
+
env:
|
|
108
|
+
HEAD: ${{ github.event.pull_request.head.sha || github.event.merge_group.head_sha }}
|
|
109
|
+
BASE: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
|
|
110
|
+
run: git fetch --no-tags origin "$BASE" "$HEAD"
|
|
111
|
+
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020
|
|
112
|
+
with:
|
|
113
|
+
node-version: 24
|
|
114
|
+
- uses: ai-ecoverse/slicc-shared-web/.github/actions/cert-self-guard@<full-commit-sha>
|
|
115
|
+
with:
|
|
116
|
+
paths: |
|
|
117
|
+
.github/workflows/cert*.yml
|
|
118
|
+
.github/workflows/cert*.yaml
|
|
119
|
+
scripts/cert/**
|
|
120
|
+
tools/cert-review/**
|
|
121
|
+
scripts/cert-runner/**
|
|
122
|
+
approval-label: cert-review-approved
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
The caller uses the triggers shown above and runs this metadata-only step separately from candidate execution. It needs Node 24+, **`actions/checkout` with `fetch-depth: 0`** (for merge-base and group ancestry), complete local git objects for the exact base/head/group ancestry, `contents: read`, **`checks: read`** for server-side head-arrival evidence and **`pull-requests: write`** for automatic label invalidation. A failed DELETE is red `INCOMPLETE`; the integration suite covers a permission-denied DELETE. Use GitHub-hosted isolated runners for candidate build/test jobs, with read-only tokens, no secrets and `persist-credentials: false`. The guard neither executes their code nor needs review, signing or publishing credentials. No CODEOWNERS or code-owner ruleset requirement is imposed by this action.
|
|
126
|
+
|
|
127
|
+
Outputs are `status` (`PASS`, `FAIL`, `INCOMPLETE`), `touched` and a structured JSON `receipt` containing the exact head(s), changed/guarded paths, approval event, labeler permission and reason. Every non-PASS result exits nonzero. The receipt and job summary include this precise limitation:
|
|
128
|
+
|
|
129
|
+
> self-guard catches accidental cert-path edits; not enforced against a deliberate rewrite of the workflow
|
|
130
|
+
|
|
131
|
+
A `pull_request` workflow can be deliberately rewritten to skip the guard, change its inputs or fabricate a status. This is an accidental-self-certification guard, **not** an organization-required-workflow security boundary. Pinning the action stops accidental use of the PR's implementation but does not force a candidate-controlled workflow to call it. Ruleset changes or an organization-required workflow are a separate owner decision.
|
|
132
|
+
|
|
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, API refusal and groups containing an unapproved or stale PR.
|
|
134
|
+
|
|
78
135
|
## Which unit tests a commit runs
|
|
79
136
|
|
|
80
137
|
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:
|
|
@@ -156,6 +213,7 @@ test('boots', async (t) => {
|
|
|
156
213
|
- when profiling is on, it saves a CPU profile sample of every page and worker in the test, including workers started by other workers, as `stall-<n>-<target>-<session>.cpuprofile`;
|
|
157
214
|
- it adds a line per target to `console.log`, saying whether that target is running or paused;
|
|
158
215
|
- on the first stall, it records a 10 s browser trace as `stall-1-trace.json` (open it in DevTools' Performance panel or Perfetto). The browser collects it with V8 CPU samples per thread, task, IPC, Blink and loading events, so it shows what a page's main thread is doing even when that thread no longer answers CDP. It logs each process's CPU time over the window, and for each renderer its main thread's task count, the call chain of its longest or still open task (function, file, line and URL of a request), and where its CPU samples fall. The targets are sampled after the trace starts, so their new profiles carry their call frames into it. A call that started before the trace shows only as a node id, since its frames were named before; a thread that is blocked keeps `Tracing.start` waiting, which the harness logs and traces through;
|
|
216
|
+
- 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;
|
|
159
217
|
- 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.
|
|
160
218
|
|
|
161
219
|
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`.
|
package/harness/trace.mjs
CHANGED
|
@@ -87,7 +87,9 @@ function mains(events, { names, processes }) {
|
|
|
87
87
|
for (const event of events) {
|
|
88
88
|
const ours = names.get(`${event.pid}:${event.tid}`) === 'CrRendererMain';
|
|
89
89
|
if (!ours || processes.get(event.pid) !== 'Renderer' || event.ph === 'M') continue;
|
|
90
|
-
|
|
90
|
+
const list = found.get(event.pid);
|
|
91
|
+
if (list) list.push(event);
|
|
92
|
+
else found.set(event.pid, [event]);
|
|
91
93
|
}
|
|
92
94
|
return [...found].map(([pid, slices]) => main(pid, slices, last));
|
|
93
95
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.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,11 +62,11 @@
|
|
|
62
62
|
"release": "semantic-release"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@ai-ecoverse/slicc-browsers": "1.7.
|
|
65
|
+
"@ai-ecoverse/slicc-browsers": "1.7.5",
|
|
66
66
|
"@biomejs/biome": "2.5.15",
|
|
67
67
|
"monocart-coverage-reports": "2.13.2",
|
|
68
68
|
"playwright-core": "1.64.0",
|
|
69
|
-
"pnpm": "12.
|
|
69
|
+
"pnpm": "12.11.1",
|
|
70
70
|
"semantic-release": "25.0.9"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|