@ai-ecoverse/slicc-shared-web 1.21.1 → 1.22.1

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.
Files changed (2) hide show
  1. package/README.md +57 -0
  2. 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. Approval is **head-bound, cleared on any later push**. On `synchronize`, the guard compares the latest label application with the current head's server-side arrival before invalidating it. An old application (not newer than that arrival) is removed automatically and a touched PR is blocked until its new head is approved. If the coordinator already approved the new head after the push but before a delayed synchronize job starts, the label is **kept** and the ordinary admin/maintain permission check still applies. A permission lookup failure leaves that newer label in place but returns `INCOMPLETE`; keeping the label is not itself approval. If arrival/timing evidence is unavailable, the guard conservatively removes the label, returns `INCOMPLETE`, and records that reason. This is deliberately strict even when the PR does not touch certification paths: a present label with unknown timing is still invalidated and returns `INCOMPLETE`. A known stale label on an untouched PR is removed without blocking that PR (`PASS`). A failed removal is also red `INCOMPLETE`. This automated invalidation is not permission for workers to change the label manually. Re-running an old synchronize event does not clear a newer head-bound approval.
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, delayed synchronize preserving a post-push approval, unknown arrival causing conservative invalidation, 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:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "1.21.1",
3
+ "version": "1.22.1",
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.3",
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.11.0",
69
+ "pnpm": "12.11.1",
70
70
  "semantic-release": "25.0.9"
71
71
  },
72
72
  "peerDependencies": {