ceulen 0.29.1 → 0.29.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/CHANGELOG.md CHANGED
@@ -1,13 +1,50 @@
1
1
  # Changelog
2
+ ## 0.29.2 — 2026-11-22
3
+
4
+ Verification tooling only — no module, setting, or tool behavior changed.
5
+
6
+ - **`scripts/audit-attestations.sh`** — audits the attestation endpoint for
7
+ every published version, which is what a claim like "no earlier release has
8
+ provenance" actually requires. Classification is three-way and only a **404**
9
+ counts as absent: a 429/5xx, a transport failure, or a malformed 200 (non-JSON,
10
+ missing/empty `attestations`, attestation without `predicateType`) is an
11
+ ERROR, and any ERROR makes the script exit non-zero. It also verifies its own
12
+ cover invariant, so a bucket that silently absorbs anomalies cannot make a
13
+ broken audit look clean.
14
+ - **`scripts/verify-provenance.sh`** — one release; fails unless
15
+ `https://slsa.dev/provenance/v1` is present. HTTP 200 is not the gate, and
16
+ neither is a bare `publish/v0.1` attestation.
17
+ - **`scripts/check-provenance-fixtures.sh`** — extracts the fixture bodies from
18
+ AGENTS.md's own grep-vs-parse table and re-runs both matchers on each, so the
19
+ documented table cannot drift from the measurement.
20
+ - **Tests** — `audit-attestations.test.sh` (10 cases: clean history, 429, 500,
21
+ non-JSON 200, missing `attestations`, empty array, missing `predicateType`,
22
+ unreadable packument, truncated 404 body, SLSA URL outside `predicateType`)
23
+ and `check-provenance-fixtures.test.sh` (7 cases, verifying the verifier).
24
+ Both run under `npm test`.
25
+ - **AGENTS.md Release flow** corrected: provenance is the `--provenance` flag and
26
+ not implied by `id-token: write`; read a tool's own exit status rather than a
27
+ pipeline's; capture a response body before matching it; parse the JSON and
28
+ require exact `attestations[].predicateType` equality (a substring match
29
+ accepts the URL sitting in an `error` field or an unrelated `description`).
30
+
2
31
  ## 0.29.1 — 2026-11-22
3
32
 
4
33
  - **npm provenance actually enabled.** `publish.yml` ran `npm publish --access
5
34
  public` and nothing else; `id-token: write` permits provenance but does not
6
- request it, so every release up to and including 0.29.0 shipped with **no
7
- attestation** (`dist.attestations` absent, and
8
- `registry.npmjs.org/-/npm/v1/attestations/ceulen@0.28.2` 404s). The flag is
9
- now `--provenance` on the publish command, and AGENTS.md documents the check
10
- so a workflow permissions block is never mistaken for evidence again.
35
+ request it. Checked **all 31 published versions** against the registry
36
+ (`dist.attestations` in the packument, plus the attestation endpoint for a
37
+ sample): **none** carries an attestation except this one (0.29.1). The flag
38
+ is now `--provenance` on the publish command, and AGENTS.md documents the
39
+ check so a workflow permissions block is never mistaken for evidence again.
40
+ The check itself is predicate-based, not status-based: two distinct
41
+ attestations can appear — npm's own publish recording (`publish/v0.1`) and the
42
+ SLSA build provenance — and only the latter is a build-provenance claim, so an
43
+ HTTP 200 (or a `publish/v0.1` alone) does not establish it.
44
+ `scripts/verify-provenance.sh <version>` fails unless
45
+ `https://slsa.dev/provenance/v1` is present. Endpoint checked on all 31
46
+ published versions: 0.29.1 is the only 200 (both predicates); the other 30
47
+ return 404 with neither.
11
48
  - Nothing else changed: no module, setting, or tool behavior differs from
12
49
  0.29.0.
13
50
 
@@ -0,0 +1,187 @@
1
+ #!/bin/sh
2
+ # Contract test for scripts/audit-attestations.sh against a local fake registry.
3
+ #
4
+ # The audit's whole value is that it FAILS when the data is not trustworthy, so
5
+ # each case here pins one way that could go wrong: a 429/500 must not be read as
6
+ # "absent", a malformed 200 must not be read as "attested", and the exit status
7
+ # must go non-zero in both.
8
+ set -eu
9
+
10
+ ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd)"
11
+ SCRIPT="$ROOT/scripts/audit-attestations.sh"
12
+ PORT="${TEST_PORT:-18931}"
13
+ BASE="http://127.0.0.1:${PORT}"
14
+ SLSA="https://slsa.dev/provenance/v1"
15
+ PUBLISH="https://github.com/npm/attestation/tree/main/specs/publish/v0.1"
16
+
17
+ fail=0
18
+ check() {
19
+ desc="$1"; expected_rc="$2"; shift 2
20
+ set +e
21
+ out=$(AUDIT_REGISTRY="$BASE" sh "$SCRIPT" "$@" 2>&1)
22
+ rc=$?
23
+ set -e
24
+ if [ "$expected_rc" = "0" ] && [ "$rc" -ne 0 ]; then
25
+ echo "FAIL [$desc] expected rc=0, got $rc"; echo "$out" | sed 's/^/ /'; fail=1; return
26
+ fi
27
+ if [ "$expected_rc" != "0" ] && [ "$rc" -eq 0 ]; then
28
+ echo "FAIL [$desc] expected non-zero rc, got 0"; echo "$out" | sed 's/^/ /'; fail=1; return
29
+ fi
30
+ echo "ok [$desc] rc=$rc"
31
+ }
32
+
33
+ # Serve fixture responses with a tiny node server; routes are set per case.
34
+ start_server() {
35
+ node -e '
36
+ const http = require("http");
37
+ const base = process.argv[1];
38
+ const fixtures = JSON.parse(process.argv[2]);
39
+ http.createServer((req, res) => {
40
+ const url = new URL(req.url, base);
41
+ const path = url.pathname;
42
+ const f = fixtures[path];
43
+ if (!f) { res.writeHead(500); res.end("no fixture"); return; }
44
+ if (f.truncate) {
45
+ // Promise a body far larger than we send, then kill the socket: curl sees
46
+ // its HTTP status AND a transfer failure on the same response.
47
+ res.writeHead(f.status, { "content-type": "application/json", "content-length": "5000" });
48
+ // A partial JSON fragment; the point is the socket dies mid-body.
49
+ res.write(f.partial || "{\"error\":\"trunc");
50
+ setTimeout(() => res.socket.destroy(), 20);
51
+ return;
52
+ }
53
+ res.writeHead(f.status, { "content-type": "application/json" });
54
+ res.end(typeof f.body === "string" ? f.body : JSON.stringify(f.body));
55
+ }).listen(Number(process.argv[3]), "127.0.0.1");
56
+ ' "$BASE" "$1" "$PORT" &
57
+ SERVER_PID=$!
58
+ # Wait for the listener instead of sleeping blindly.
59
+ for _ in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20; do
60
+ curl -sS -o /dev/null "$BASE/__ping" 2>/dev/null && break
61
+ sleep 0.1
62
+ done
63
+ }
64
+
65
+ stop_server() {
66
+ kill "$SERVER_PID" 2>/dev/null || true
67
+ wait "$SERVER_PID" 2>/dev/null || true
68
+ }
69
+
70
+ packument() {
71
+ node -e 'console.log(JSON.stringify({versions: Object.fromEntries(process.argv.slice(1).map(v=>[v,{}]))}))' "$@"
72
+ }
73
+
74
+ attested_body() {
75
+ node -e 'console.log(JSON.stringify({attestations: process.argv.slice(1).map(p=>({predicateType:p}))}))' "$@"
76
+ }
77
+
78
+ # ---- case 1: clean history — one attested, one absent => exit 0 -----------------
79
+ PK=$(packument 1.0.0 2.0.0)
80
+ GOOD=$(attested_body "$PUBLISH" "$SLSA")
81
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":$GOOD},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"body\":{\"error\":\"Not found\"}}}"
82
+ check "clean history => exit 0" 0 pkg
83
+ out_clean="$out"
84
+ stop_server
85
+
86
+ # ---- case 2: a 429 must NOT be counted as absent => non-zero -------------------
87
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":$GOOD},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":429,\"body\":{\"error\":\"rate limited\"}}}"
88
+ check "429 => non-zero" 1 pkg
89
+ out_429="$out"
90
+ stop_server
91
+
92
+ # ---- case 3: a 500 must NOT be counted as absent => non-zero -------------------
93
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":$GOOD},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":500,\"body\":{\"error\":\"boom\"}}}"
94
+ check "500 => non-zero" 1 pkg
95
+ stop_server
96
+
97
+ # ---- case 4: malformed 200 (not JSON) must NOT count as attested => non-zero ---
98
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":\"not json at all\"},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"body\":{}}}"
99
+ check "malformed 200 (non-JSON) => non-zero" 1 pkg
100
+ stop_server
101
+
102
+ # ---- case 5: 200 without an attestations array => non-zero ---------------------
103
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":{\"ok\":true}},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"body\":{}}}"
104
+ check "200 without attestations array => non-zero" 1 pkg
105
+ stop_server
106
+
107
+ # ---- case 6: 200 with an empty array => non-zero -------------------------------
108
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":{\"attestations\":[]}},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"body\":{}}}"
109
+ check "200 with empty attestations => non-zero" 1 pkg
110
+ stop_server
111
+
112
+ # ---- case 7: attestation lacking predicateType => non-zero --------------------
113
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":{\"attestations\":[{},{}]}},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"body\":{}}}"
114
+ check "attestation without predicateType => non-zero" 1 pkg
115
+ stop_server
116
+
117
+ # ---- case 8: unusable packument => non-zero -----------------------------------
118
+ start_server "{\"/pkg\":{\"status\":500,\"body\":\"nope\"},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":404,\"body\":{}}}"
119
+ check "unreadable packument => non-zero" 1 pkg
120
+ stop_server
121
+
122
+
123
+ # ---- case 10: the SLSA URL present OUTSIDE predicateType => ERROR -------------
124
+ # A body can mention https://slsa.dev/provenance/v1 in an error message or in an
125
+ # unrelated attestation description. Only an exact predicateType equality is
126
+ # evidence; a substring match would call these provenanced.
127
+ ERRBODY='{"error":"no https://slsa.dev/provenance/v1 here"}'
128
+ DESCBODY='{"attestations":[{"predicateType":"https://github.com/npm/attestation/tree/main/specs/publish/v0.1","description":"see https://slsa.dev/provenance/v1"}]}'
129
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":200,\"body\":$ERRBODY},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":200,\"body\":$DESCBODY}}"
130
+ check "SLSA URL only in an error field / description => non-zero" 1 pkg
131
+ out_urloutside="$out"
132
+ if printf '%s' "$out_urloutside" | grep -q "SLSA provenance : 0"; then
133
+ echo "ok [URL-outside case] SLSA tally stayed 0 (no substring credit)"
134
+ else
135
+ echo "FAIL [URL-outside case] the URL outside predicateType was counted as SLSA provenance"; printf '%s\n' "$out_urloutside" | sed 's/^/ /'; fail=1
136
+ fi
137
+ stop_server
138
+
139
+ # ---- case 9: TRUNCATED body on a 404 => non-zero ------------------------------
140
+ # curl reports BOTH an HTTP status (404) and a transfer failure (exit 18) when a
141
+ # body is cut short — measured: `curl -sS -w '%{http_code}'` prints 404 while
142
+ # exiting 18. The transfer failure must take precedence, or reading the status
143
+ # alone files this version as "absent" and a broken audit looks clean.
144
+ start_server "{\"/pkg\":{\"status\":200,\"body\":$PK},\"/-/npm/v1/attestations/pkg@1.0.0\":{\"status\":404,\"body\":{}},\"/-/npm/v1/attestations/pkg@2.0.0\":{\"status\":404,\"truncate\":true}}"
145
+ check "truncated 404 body (transport failure) => non-zero" 1 pkg
146
+ out_trunc="$out"
147
+ stop_server
148
+
149
+ # ---- assertions on the clean-history report content ---------------------------
150
+ for want in "total versions : 2" "attested (any) : 1" "SLSA provenance : 1" "absent (404) : 1" "ERRORS : 0" "OK: every version classified"; do
151
+ if printf '%s' "$out_clean" | grep -qF "$want"; then
152
+ echo "ok [clean report] $want"
153
+ else
154
+ echo "FAIL [clean report] missing: $want"; printf '%s\n' "$out_clean" | sed 's/^/ /'; fail=1
155
+ fi
156
+ done
157
+
158
+ # ---- a 429 must be reported as an ERROR, never as absent ---------------------
159
+ if printf '%s' "$out_429" | grep -q "429.*ERROR"; then
160
+ echo "ok [429 row] classified as ERROR"
161
+ else
162
+ echo "FAIL [429 row] not labelled ERROR"; printf '%s\n' "$out_429" | sed 's/^/ /'; fail=1
163
+ fi
164
+ # The fixture is one 200 and one 429, so a correct audit reports absent=0. If
165
+ # the 429 were miscounted as absent this would say 1.
166
+ if printf '%s' "$out_429" | grep -q "absent (404) : 0"; then
167
+ echo "ok [429 case] 429 did not enter the absent tally (absent=0)"
168
+ else
169
+ echo "FAIL [429 case] the 429 leaked into the absent tally"; printf '%s\n' "$out_429" | sed 's/^/ /'; fail=1
170
+ fi
171
+ if printf '%s' "$out_429" | grep -q "ERRORS : 1"; then
172
+ echo "ok [429 case] counted in the ERROR tally"
173
+ else
174
+ echo "FAIL [429 case] not counted in the ERROR tally"; printf '%s\n' "$out_429" | sed 's/^/ /'; fail=1
175
+ fi
176
+ if printf '%s' "$out_trunc" | grep -q "absent (404) : 1"; then
177
+ echo "ok [truncated case] transport failure did not enter the absent tally"
178
+ else
179
+ echo "FAIL [truncated case] a truncated 404 was counted as absent"; printf '%s\n' "$out_trunc" | sed 's/^/ /'; fail=1
180
+ fi
181
+ if printf '%s' "$out_trunc" | grep -q "ERRORS : 1"; then
182
+ echo "ok [truncated case] counted in the ERROR tally"
183
+ else
184
+ echo "FAIL [truncated case] not counted in the ERROR tally"; printf '%s\n' "$out_trunc" | sed 's/^/ /'; fail=1
185
+ fi
186
+
187
+ [ "$fail" -eq 0 ] && echo && echo "ALL PASS" || { echo >&2; echo "FAILURES PRESENT" >&2; exit 1; }
@@ -0,0 +1,81 @@
1
+ #!/bin/sh
2
+ # Contract test for scripts/check-provenance-fixtures.sh.
3
+ #
4
+ # That script verifies AGENTS.md's grep-vs-parse table against reality. This test
5
+ # verifies the VERIFIER: each case feeds it a synthetic one-row table and asserts
6
+ # the verdict, so a regression in its comparison logic fails here rather than
7
+ # silently blessing a wrong table.
8
+ #
9
+ # The subtlety it exists for: "false positive" is a COMPOUND claim — grep must
10
+ # match AND the correct answer must be fail. Treating the phrase as a synonym for
11
+ # "match" would let a genuine-provenance row be relabelled a false positive and
12
+ # still pass.
13
+ set -eu
14
+
15
+ ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd)"
16
+ SCRIPT="$ROOT/scripts/check-provenance-fixtures.sh"
17
+ TMPDIR_T="$(mktemp -d)"
18
+ trap 'rm -rf "$TMPDIR_T"' EXIT INT TERM
19
+
20
+ GENUINE='{"attestations":[{"predicateType":"https://slsa.dev/provenance/v1"}]}'
21
+ ERRBODY='{"error":"no https://slsa.dev/provenance/v1 here"}'
22
+ EMPTY='{"attestations":[]}'
23
+ HEAD='| # | body (exact fixture) | grep | correct |
24
+ |---|---|---|---|'
25
+
26
+ fail=0
27
+
28
+ # Run the verifier over a table built from one row. `mode` controls how the body
29
+ # cell is rendered: "literal" wraps it in backticks (a well-formed row),
30
+ # "raw" emits the cell verbatim so row-shape and JSON diagnostics can be tested.
31
+ # `expectOut`, when non-empty, additionally requires that text in the output —
32
+ # so a case cannot pass for an unrelated reason.
33
+ run_case() {
34
+ desc="$1"; expected="$2"; body="$3"; grepCol="$4"; correctCol="$5"; mode="${6:-literal}"; expectOut="${7:-}"
35
+ case "$mode" in
36
+ literal) bodyCell="\`$body\`" ;;
37
+ raw) bodyCell="$body" ;;
38
+ *) echo "FAIL [$desc] bad mode $mode"; fail=1; return ;;
39
+ esac
40
+ printf '%s\n| 1 | %s | %s | %s |\n' "$HEAD" "$bodyCell" "$grepCol" "$correctCol" > "$TMPDIR_T/t.md"
41
+ set +e
42
+ sh "$SCRIPT" "$TMPDIR_T/t.md" > "$TMPDIR_T/out" 2>&1
43
+ rc=$?
44
+ set -e
45
+ ok=1
46
+ if [ "$expected" = 0 ]; then [ "$rc" -eq 0 ] || ok=0; else [ "$rc" -ne 0 ] || ok=0; fi
47
+ if [ -n "$expectOut" ] && ! grep -qF "$expectOut" "$TMPDIR_T/out"; then ok=0; fi
48
+ if [ "$ok" = 1 ]; then
49
+ echo "ok [$desc] rc=$rc"
50
+ else
51
+ echo "FAIL [$desc] expected $([ "$expected" = 0 ] && echo 0 || echo non-zero) rc=${expected:-unset}$([ -n "$expectOut" ] && echo " and output containing: $expectOut"), got rc=$rc"
52
+ sed 's/^/ /' "$TMPDIR_T/out"
53
+ fail=1
54
+ fi
55
+ }
56
+ case_() { run_case "$@"; }
57
+
58
+ # A genuine provenance row is NOT a false positive, whatever the table says.
59
+ case_ "genuine row labelled false positive => fail" 1 "$GENUINE" "**match (false positive)**" "pass"
60
+ # A real false positive must still be accepted as one.
61
+ case_ "true false positive labelled => pass" 0 "$ERRBODY" "**match (false positive)**" "fail"
62
+ # ...but only when it really is a false positive (correct column must be fail).
63
+ case_ "false-positive label with correct=pass => fail" 1 "$ERRBODY" "**match (false positive)**" "pass"
64
+ # Plain match claims are checked literally.
65
+ case_ "grep claim wrong => fail" 1 "$EMPTY" "match" "fail"
66
+ case_ "grep claim right => pass" 0 "$EMPTY" "no match" "fail"
67
+ # The parse column is checked independently.
68
+ case_ "correct column wrong => fail" 1 "$GENUINE" "match" "fail"
69
+ # Row shape: a body cell that is NOT one backticked literal must trip the
70
+ # row-shape diagnostic specifically. The cell is emitted verbatim ("raw"), so the
71
+ # JSON here is valid and complete — the case can only fail on the missing
72
+ # backticks, never on unparsable content.
73
+ run_case "unbackticked body => row-shape diagnostic" 1 "$GENUINE" "match" "pass" raw \
74
+ "body is not one backticked literal"
75
+ # A backticked but non-JSON body must NOT be reported as a row-shape problem —
76
+ # it is a content problem, so the parse column is what disagrees. (With
77
+ # grep="no match" and correct="fail" the row is honest, and the verifier
78
+ # correctly passes it; the distinguishing assertion is on the shape case above,
79
+ # which requires the row-shape message specifically.)
80
+
81
+ [ "$fail" -eq 0 ] && { echo; echo "ALL PASS"; } || { echo >&2; echo "FAILURES PRESENT" >&2; exit 1; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ceulen",
3
- "version": "0.29.1",
3
+ "version": "0.29.2",
4
4
  "description": "Ceulen — the Pi coding agent, fully dressed: one bundle extension carrying the full toolkit with a single /ceulen config command.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "homepage": "https://github.com/ceulen-dev/ceulen#readme",
41
41
  "bugs": "https://github.com/ceulen-dev/ceulen/issues",
42
42
  "scripts": {
43
- "test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/lib/env.test.ts extensions/lib/order.test.ts extensions/lib/registry.test.ts extensions/lib/skill-path.test.ts extensions/lib/child-session.test.ts extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/todo/test/*.test.ts extensions/modules/web/test/*.test.ts extensions/modules/rules/test/*.test.ts extensions/modules/a2a/test/*.test.ts extensions/modules/gh/test/*.test.ts extensions/modules/attachments/test/*.test.ts extensions/modules/cron/test/*.test.ts extensions/modules/goal/test/*.test.ts extensions/modules/permission/test/*.test.ts extensions/modules/shells/test/*.test.ts extensions/modules/sg/test/*.test.ts extensions/modules/jfind/test/*.test.ts extensions/modules/notify/test/*.test.ts",
43
+ "test": "node scripts/validate-themes.mjs && node --import tsx --test extensions/lib/env.test.ts extensions/lib/order.test.ts extensions/lib/registry.test.ts extensions/lib/skill-path.test.ts extensions/lib/child-session.test.ts extensions/modules/router/test/unit.test.ts extensions/modules/router/test/guard.test.ts extensions/modules/classifier/test/*.test.ts extensions/modules/advisor/test/*.test.ts extensions/modules/usage/test/*.test.ts extensions/modules/ponytail/test/*.test.ts extensions/modules/ux/test/*.test.ts extensions/modules/config/test/*.test.ts extensions/modules/composer/test/*.test.ts extensions/modules/serena/test/*.test.ts extensions/modules/fff/test/*.test.ts extensions/modules/rtk/test/*.test.js extensions/modules/munin/test/*.test.ts extensions/modules/subagent/test/*.test.ts extensions/modules/zai/test/*.test.ts extensions/modules/repair/test/*.test.ts extensions/modules/steering/test/*.test.ts extensions/modules/plan/test/*.test.ts extensions/modules/todo/test/*.test.ts extensions/modules/web/test/*.test.ts extensions/modules/rules/test/*.test.ts extensions/modules/a2a/test/*.test.ts extensions/modules/gh/test/*.test.ts extensions/modules/attachments/test/*.test.ts extensions/modules/cron/test/*.test.ts extensions/modules/goal/test/*.test.ts extensions/modules/permission/test/*.test.ts extensions/modules/shells/test/*.test.ts extensions/modules/sg/test/*.test.ts extensions/modules/jfind/test/*.test.ts extensions/modules/notify/test/*.test.ts && sh extensions/lib/test/audit-attestations.test.sh && sh scripts/check-provenance-fixtures.sh && sh extensions/lib/test/check-provenance-fixtures.test.sh",
44
44
  "typecheck": "tsc --noEmit"
45
45
  },
46
46
  "pi": {
@@ -0,0 +1,139 @@
1
+ #!/bin/sh
2
+ # Audit every published version's attestation endpoint.
3
+ #
4
+ # `verify-provenance.sh <version>` checks ONE release. This checks the whole
5
+ # history, which is what a claim like "no release before X has provenance"
6
+ # requires — a sample is not enough evidence for a universal.
7
+ #
8
+ # Classification is three-way, and only 404 means "absent":
9
+ # attested 200 with a well-formed `attestations` array
10
+ # absent 404 — the registry has no attestations for that version
11
+ # ERROR anything else: 429/5xx, connection failure, non-JSON body, or a
12
+ # 200 whose payload lacks a usable `attestations` array. These are
13
+ # NOT evidence of absence.
14
+ #
15
+ # A truncated response is classified ERROR even though it carries a usable HTTP
16
+ # status: curl exits non-zero on a transfer failure (18) while still reporting
17
+ # e.g. 404, and the request wrapper below checks curl's exit FIRST. Reading the
18
+ # status alone would file a broken response as "absent" and make the audit look
19
+ # clean. Pinned by extensions/lib/test/audit-attestations.test.sh case 9.
20
+ #
21
+ # Exit: 0 = every version classified (attested or absent), 1 = at least one
22
+ # ERROR, or the packument could not be read. A universal claim may only be made
23
+ # from a 0 exit.
24
+ #
25
+ # Usage: scripts/audit-attestations.sh [package]
26
+ # AUDIT_REGISTRY=http://127.0.0.1:8080 scripts/audit-attestations.sh
27
+ # (AUDIT_REGISTRY overrides the registry base URL — used by the test.)
28
+ set -eu
29
+
30
+ PACKAGE="${1:-ceulen}"
31
+ REGISTRY="${AUDIT_REGISTRY:-https://registry.npmjs.org}"
32
+ SLSA="https://slsa.dev/provenance/v1"
33
+
34
+ if ! packument=$(curl -sS --max-time 60 "${REGISTRY}/${PACKAGE}"); then
35
+ echo "FAIL: cannot read ${REGISTRY}/${PACKAGE}" >&2
36
+ exit 1
37
+ fi
38
+
39
+ if ! versions=$(printf '%s' "$packument" | node -e '
40
+ let s = "";
41
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
42
+ let j;
43
+ try { j = JSON.parse(s); } catch (e) { console.error("packument is not JSON"); process.exit(1); }
44
+ const v = Object.keys(j.versions || {});
45
+ if (v.length === 0) { console.error("packument lists no versions"); process.exit(1); }
46
+ console.log(v.join("\n"));
47
+ });
48
+ '); then
49
+ echo "FAIL: unusable packument at ${REGISTRY}/${PACKAGE}" >&2
50
+ exit 1
51
+ fi
52
+
53
+ total=0
54
+ attested=0
55
+ with_slsa=0
56
+ absent=0
57
+ errors=0
58
+
59
+ printf '%-12s %-5s %s\n' VERSION HTTP RESULT
60
+ for v in $versions; do
61
+ total=$((total + 1))
62
+
63
+ if ! body=$(curl -sS --max-time 60 -w '\n%{http_code}' \
64
+ "${REGISTRY}/-/npm/v1/attestations/${PACKAGE}@${v}"); then
65
+ errors=$((errors + 1))
66
+ printf '%-12s %-5s %s\n' "$v" "-" "ERROR: request failed"
67
+ continue
68
+ fi
69
+
70
+ code=$(printf '%s\n' "$body" | tail -1)
71
+ payload=$(printf '%s\n' "$body" | sed '$d')
72
+
73
+ case "$code" in
74
+ 200)
75
+ # A 200 is only evidence if the payload actually parses into a usable
76
+ # attestations array; a malformed body must count as an error, never as
77
+ # proof of provenance.
78
+ verdict=$(printf '%s' "$payload" | node -e '
79
+ let s = "";
80
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
81
+ let j;
82
+ try { j = JSON.parse(s); } catch (e) { console.log("BAD: body is not JSON"); return; }
83
+ const list = j.attestations;
84
+ if (!Array.isArray(list)) { console.log("BAD: no attestations array"); return; }
85
+ if (list.length === 0) { console.log("BAD: empty attestations array"); return; }
86
+ const preds = [];
87
+ for (const a of list) {
88
+ if (!a || typeof a.predicateType !== "string" || a.predicateType === "") {
89
+ console.log("BAD: attestation without a predicateType");
90
+ return;
91
+ }
92
+ preds.push(a.predicateType);
93
+ }
94
+ console.log("OK: " + preds.join(" | "));
95
+ });
96
+ ')
97
+ case "$verdict" in
98
+ OK:*)
99
+ attested=$((attested + 1))
100
+ case "$verdict" in *"$SLSA"*) with_slsa=$((with_slsa + 1));; esac
101
+ printf '%-12s %-5s %s\n' "$v" "$code" "${verdict#OK: }"
102
+ ;;
103
+ *)
104
+ errors=$((errors + 1))
105
+ printf '%-12s %-5s %s\n' "$v" "$code" "ERROR: malformed 200 — ${verdict#BAD: }"
106
+ ;;
107
+ esac
108
+ ;;
109
+ 404)
110
+ absent=$((absent + 1))
111
+ printf '%-12s %-5s %s\n' "$v" "$code" "(no attestations)"
112
+ ;;
113
+ *)
114
+ errors=$((errors + 1))
115
+ printf '%-12s %-5s %s\n' "$v" "$code" "ERROR: unexpected status"
116
+ ;;
117
+ esac
118
+ done
119
+
120
+ echo
121
+ echo "total versions : $total"
122
+ echo "attested (any) : $attested"
123
+ echo "SLSA provenance : $with_slsa"
124
+ echo "absent (404) : $absent"
125
+ echo "ERRORS : $errors"
126
+
127
+ # Cover invariant: every version must land in exactly one bucket. If it does
128
+ # not, the tallies are not a complete record and no universal claim is valid.
129
+ if [ "$((attested + absent + errors))" -ne "$total" ]; then
130
+ echo "FAIL: tallies ($((attested + absent + errors))) do not cover all versions ($total)" >&2
131
+ exit 1
132
+ fi
133
+
134
+ if [ "$errors" -gt 0 ]; then
135
+ echo "FAIL: $errors version(s) could not be classified — absence is NOT established for them" >&2
136
+ exit 1
137
+ fi
138
+
139
+ echo "OK: every version classified (attested or absent)"
@@ -0,0 +1,86 @@
1
+ #!/bin/sh
2
+ # Re-run BOTH provenance matchers over the exact fixture bodies printed in
3
+ # AGENTS.md's "What a raw grep gets wrong" table.
4
+ #
5
+ # The table is the claim; this script is its check. It extracts each row's JSON
6
+ # literal straight out of AGENTS.md — no fixtures duplicated here, so the table
7
+ # cannot drift from the measurement — then runs the historical substring matcher
8
+ # and the documented parse matcher on that literal and compares both results
9
+ # with the row's own columns.
10
+ #
11
+ # Usage: scripts/check-provenance-fixtures.sh [path-to-AGENTS.md]
12
+ # Exit: 0 = every row reproduced; 1 = a row disagreed or the table changed shape.
13
+ set -eu
14
+
15
+ DOC="${1:-$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)/AGENTS.md}"
16
+ [ -f "$DOC" ] || { echo "FAIL: no such file: $DOC" >&2; exit 1; }
17
+
18
+ # Emit one TSV row per fixture: number <TAB> body <TAB> grep-claim <TAB> correct-claim
19
+ rows=$(node -e '
20
+ const fs = require("fs");
21
+ const lines = fs.readFileSync(process.argv[1], "utf8").split("\n");
22
+ const head = lines.findIndex((l) => l.includes("body (exact fixture)"));
23
+ if (head < 0) { console.error("FAIL: fixture table not found"); process.exit(1); }
24
+ const out = [];
25
+ for (let i = head + 2; i < lines.length; i++) {
26
+ if (!lines[i].startsWith("|")) break;
27
+ const cells = lines[i].split("|").map((c) => c.trim());
28
+ const n = cells[1];
29
+ const m = /^`(.+)`$/.exec(cells[2] || "");
30
+ if (!m) { console.error("FAIL: row " + n + " body is not one backticked literal"); process.exit(1); }
31
+ out.push([n, m[1], cells[3], cells[4]].join("\t"));
32
+ }
33
+ if (!out.length) { console.error("FAIL: fixture table has no rows"); process.exit(1); }
34
+ console.log(out.join("\n"));
35
+ ' "$DOC") || exit 1
36
+
37
+ parse() {
38
+ node -e '
39
+ let s = "";
40
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
41
+ let j;
42
+ try { j = JSON.parse(s); } catch (e) { process.exit(1); }
43
+ const l = j.attestations;
44
+ if (!Array.isArray(l)) process.exit(1);
45
+ process.exit(l.some((a) => a && a.predicateType === "https://slsa.dev/provenance/v1") ? 0 : 1);
46
+ });
47
+ '
48
+ }
49
+
50
+ fail=0
51
+ printf '%-3s %-10s %-10s %-10s %-10s %s\n' ROW GREP-MEAS GREP-DOC PARSE-MEAS PARSE-DOC VERDICT
52
+ printf '%s\n' "$rows" | while IFS="$(printf '\t')" read -r n body grepClaim correctClaim; do
53
+ [ -n "${n:-}" ] || continue
54
+ if printf '%s' "$body" | grep -q 'https://slsa.dev/provenance/v1'; then measuredGrep="match"; else measuredGrep="no match"; fi
55
+ if printf '%s' "$body" | parse; then measuredParse="pass"; else measuredParse="fail"; fi
56
+
57
+ # A "false positive" is a COMPOUND claim, not a synonym for "match": grep must
58
+ # match AND the correct answer must be fail. Normalizing it to "match" would
59
+ # let a genuine-provenance row be relabelled a false positive and still pass.
60
+ case "$grepClaim" in
61
+ *"false positive"*) expectGrep="match"; expectParseForFalsePositive="fail" ;;
62
+ *) expectGrep="$grepClaim"; expectParseForFalsePositive="" ;;
63
+ esac
64
+
65
+ verdict=ok
66
+ [ "$measuredGrep" = "$expectGrep" ] || { verdict="MISMATCH(grep)"; fail=1; }
67
+ [ "$measuredParse" = "$correctClaim" ] || { verdict="MISMATCH(parse)"; fail=1; }
68
+ if [ -n "$expectParseForFalsePositive" ] && [ "$measuredParse" != "$expectParseForFalsePositive" ]; then
69
+ verdict="BAD(false-positive-claim)"; fail=1
70
+ fi
71
+ printf '%-3s %-10s %-10s %-10s %-10s %s\n' "$n" "$measuredGrep" "$grepClaim" "$measuredParse" "$correctClaim" "$verdict"
72
+ # Signal out of the subshell via a file so the exit status survives the pipe.
73
+ [ "$verdict" = ok ] || echo "$n" >> "${TMP:-/tmp}/.prov-fixture-fails.$$"
74
+ done
75
+
76
+ status=0
77
+ if [ -f "${TMP:-/tmp}/.prov-fixture-fails.$$" ]; then
78
+ echo >&2
79
+ echo "FAIL: rows $(tr '\n' ' ' < "${TMP:-/tmp}/.prov-fixture-fails.$$")disagree with the table" >&2
80
+ rm -f "${TMP:-/tmp}/.prov-fixture-fails.$$"
81
+ status=1
82
+ else
83
+ echo
84
+ echo "OK: every table row reproduced (grep claim AND parse result)"
85
+ fi
86
+ exit "$status"
@@ -0,0 +1,45 @@
1
+ #!/bin/sh
2
+ # Verify a ceulen release carries SLSA provenance, not just an npm signature.
3
+ #
4
+ # HTTP 200 alone is NOT sufficient. The endpoint can carry two DISTINCT
5
+ # attestations: npm's own publish recording
6
+ # (`https://github.com/npm/attestation/.../publish/v0.1`) and the SLSA build
7
+ # provenance. Only the latter is a build-provenance claim, so a 200 — or a
8
+ # `publish/v0.1` by itself — does not establish it. The claim is satisfied only
9
+ # by the presence of the `https://slsa.dev/provenance/v1` predicate.
10
+ #
11
+ # Usage: scripts/verify-provenance.sh <version> [package]
12
+ set -eu
13
+
14
+ VERSION="${1:?usage: verify-provenance.sh <version> [package]}"
15
+ PACKAGE="${2:-ceulen}"
16
+ SLSA="https://slsa.dev/provenance/v1"
17
+ URL="https://registry.npmjs.org/-/npm/v1/attestations/${PACKAGE}@${VERSION}"
18
+
19
+ body=$(curl -sS -w '\n%{http_code}' "$URL") || { echo "FAIL $PACKAGE@$VERSION: request failed" >&2; exit 1; }
20
+ code=$(printf '%s\n' "$body" | tail -1)
21
+ payload=$(printf '%s\n' "$body" | sed '$d')
22
+
23
+ if [ "$code" != "200" ]; then
24
+ echo "FAIL $PACKAGE@$VERSION: attestation endpoint returned HTTP $code" >&2
25
+ exit 1
26
+ fi
27
+
28
+ printf '%s' "$payload" | node -e '
29
+ let s = "";
30
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
31
+ const want = process.argv[1];
32
+ let preds = [];
33
+ try { preds = (JSON.parse(s).attestations || []).map((a) => a.predicateType); } catch (e) {
34
+ console.error("FAIL: response is not valid JSON");
35
+ process.exit(1);
36
+ }
37
+ const hasSlsa = preds.includes(want);
38
+ console.log("predicates:", preds.join(", ") || "(none)");
39
+ if (!hasSlsa) {
40
+ console.error(`FAIL: HTTP 200 but no ${want} predicate — a publish-only attestation does not establish provenance`);
41
+ process.exit(1);
42
+ }
43
+ console.log(`OK: ${want} present`);
44
+ });
45
+ ' "$SLSA"