ceulen 0.29.1 → 0.30.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/CHANGELOG.md +105 -5
- package/extensions/lib/test/audit-attestations.test.sh +187 -0
- package/extensions/lib/test/check-provenance-fixtures.test.sh +81 -0
- package/extensions/lib/test/smoke-install.test.sh +103 -0
- package/extensions/modules/repair/configPanel.ts +32 -2
- package/extensions/modules/repair/index.ts +126 -0
- package/extensions/modules/repair/lib/clock.ts +106 -0
- package/extensions/modules/repair/lib/repeat-reminder.ts +90 -0
- package/extensions/modules/repair/lib/settings.ts +22 -1
- package/extensions/modules/repair/lib/spill-store.ts +72 -0
- package/extensions/modules/repair/lib/spill.ts +287 -0
- package/extensions/modules/repair/test/clock.test.ts +85 -0
- package/extensions/modules/repair/test/dsh-enrichments.test.ts +375 -0
- package/extensions/modules/repair/test/repeat-reminder.test.ts +100 -0
- package/extensions/modules/repair/test/settings.test.ts +5 -1
- package/extensions/modules/repair/test/spill-utf8.test.ts +297 -0
- package/extensions/modules/repair/test/spill.test.ts +208 -0
- package/package.json +2 -2
- package/scripts/audit-attestations.sh +139 -0
- package/scripts/check-provenance-fixtures.sh +93 -0
- package/scripts/smoke-install.sh +90 -0
- package/scripts/verify-provenance.sh +45 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,113 @@
|
|
|
1
|
+
## 0.30.0 — 2026-11-22
|
|
2
|
+
|
|
3
|
+
Three DeepSeek Harness enrichments in the **repair** module — all-model, all
|
|
4
|
+
handlers (no new tool, no new module), plus the hardening that live panes and
|
|
5
|
+
review forced out of the spill recovery hint.
|
|
6
|
+
|
|
7
|
+
- **`repair.spillMaxTokens`** (default 12500 = DSH's base-preset
|
|
8
|
+
`maxInlineTokens`, `0` disables) — a tool result over the budget keeps its
|
|
9
|
+
head and tail (DSH's half-budget-per-end retention, surrogate-pair-safe), the
|
|
10
|
+
full text lands in a private per-process temp file, and the notice names the
|
|
11
|
+
path. Estimation is DSH's fixed density (`ceil(chars/4) + 4` per text block),
|
|
12
|
+
so there is no tokenizer dependency. **Scope is returned content**: pi's
|
|
13
|
+
`read`/`bash` truncate inside the tool before `tool_result` fires, so their
|
|
14
|
+
dropped bytes are unrecoverable at this seam and those results are excluded —
|
|
15
|
+
keyed on `details.truncation.truncated` / `details.fullOutputPath` METADATA,
|
|
16
|
+
never on notice text, so a wrapped read of a file that merely *contains*
|
|
17
|
+
"Use offset=" still spills. The beneficiaries are the tools with no
|
|
18
|
+
self-truncation (subagent reports, `github pr_diff`, `web_extract`, `munin_*`).
|
|
19
|
+
- **`repair.repeatReminder`** (default on) — an advisory footer on the
|
|
20
|
+
3rd/5th/8th consecutive call with identical arguments (deep key-sorted
|
|
21
|
+
canonicalization, so property order is irrelevant). It never blocks: the call
|
|
22
|
+
runs and its real output survives, which is what distinguishes it from the two
|
|
23
|
+
guards that refuse (permission's doom-loop on denied calls, munin's dampener —
|
|
24
|
+
whose `munin_*` tools are excluded here). A new user message resets the chain;
|
|
25
|
+
nested calls are skipped.
|
|
26
|
+
- **`repair.clock`** (default off) + `repair.clockRefreshMs` (default 600000) —
|
|
27
|
+
pi injects no model-visible date/time anywhere (`system-prompt.js` renders with
|
|
28
|
+
`timestamp: 0`), so a long goal/cron session cannot tell when "today" is. A
|
|
29
|
+
`ceulen-clock` custom message carries an ISO stamp with numeric offset + IANA
|
|
30
|
+
zone and the elapsed span, one injection per refresh window so the appended
|
|
31
|
+
message stays out of the cache-churn path.
|
|
32
|
+
|
|
33
|
+
**Spill recovery is an executable hint, and it took four rounds of live-pane
|
|
34
|
+
findings to get right.** Each was measured, not theorised:
|
|
35
|
+
|
|
36
|
+
1. A hardcoded `head -c 50000` costs 12,504 estimated tokens — *over* the
|
|
37
|
+
12,500 default — so the recovery re-spilled and the model looped. The page
|
|
38
|
+
size is now derived from the ACTIVE budget.
|
|
39
|
+
2. `read` is never a safe recovery: the spill file exceeds the budget by
|
|
40
|
+
definition, and pi's read has no byte-budget parameter. A 100-line read at
|
|
41
|
+
budget 2000 cost 2,254 tokens and respilled live. The hint always pages by
|
|
42
|
+
bytes through `bash`.
|
|
43
|
+
3. A raw `head -c` splits multibyte characters at the page boundary, and bash
|
|
44
|
+
decodes each page independently, so a 3-byte character straddling the cut is
|
|
45
|
+
lost in **both** pages. Pages now pass through `iconv -c` and print their own
|
|
46
|
+
next offset, so a trimmed byte is re-read whole.
|
|
47
|
+
4. pi's bash caps at **both** 2000 lines and 50 KiB, truncating with
|
|
48
|
+
`truncateTail` — it drops the page's HEAD while the offset has already
|
|
49
|
+
advanced past it (measured: 2,083 lines → 83 lines / 247 bytes lost). Pages
|
|
50
|
+
are now clamped on three axes (token budget, `minLine × 1900`, and 45,000
|
|
51
|
+
bytes) and piped through `head -n`.
|
|
52
|
+
|
|
53
|
+
- **Tests** — `spill`, `repeat-reminder`, `clock`, `dsh-enrichments` and
|
|
54
|
+
`spill-utf8` suites (66 new cases). The spill tests run the notice's OWN
|
|
55
|
+
emitted command and reassemble, and every page is validated by passing its RAW
|
|
56
|
+
output — offset marker included — through pi's real `truncateTail`, because a
|
|
57
|
+
text assertion cannot see any of the four failures above.
|
|
58
|
+
- **AGENTS.md** — the repair section documents the three features, the
|
|
59
|
+
returned-content scope, the metadata-only exclusions, and the binding
|
|
60
|
+
thresholds of the page clamps (the 99,996-byte window requires `minLine ≥ 53`;
|
|
61
|
+
the over-cap region starts at 27) so the documented blast radius cannot drift
|
|
62
|
+
from the code.
|
|
63
|
+
|
|
1
64
|
# Changelog
|
|
65
|
+
## 0.29.2 — 2026-11-22
|
|
66
|
+
|
|
67
|
+
Verification tooling only — no module, setting, or tool behavior changed.
|
|
68
|
+
|
|
69
|
+
- **`scripts/audit-attestations.sh`** — audits the attestation endpoint for
|
|
70
|
+
every published version, which is what a claim like "no earlier release has
|
|
71
|
+
provenance" actually requires. Classification is three-way and only a **404**
|
|
72
|
+
counts as absent: a 429/5xx, a transport failure, or a malformed 200 (non-JSON,
|
|
73
|
+
missing/empty `attestations`, attestation without `predicateType`) is an
|
|
74
|
+
ERROR, and any ERROR makes the script exit non-zero. It also verifies its own
|
|
75
|
+
cover invariant, so a bucket that silently absorbs anomalies cannot make a
|
|
76
|
+
broken audit look clean.
|
|
77
|
+
- **`scripts/verify-provenance.sh`** — one release; fails unless
|
|
78
|
+
`https://slsa.dev/provenance/v1` is present. HTTP 200 is not the gate, and
|
|
79
|
+
neither is a bare `publish/v0.1` attestation.
|
|
80
|
+
- **`scripts/check-provenance-fixtures.sh`** — extracts the fixture bodies from
|
|
81
|
+
AGENTS.md's own grep-vs-parse table and re-runs both matchers on each, so the
|
|
82
|
+
documented table cannot drift from the measurement.
|
|
83
|
+
- **Tests** — `audit-attestations.test.sh` (10 cases: clean history, 429, 500,
|
|
84
|
+
non-JSON 200, missing `attestations`, empty array, missing `predicateType`,
|
|
85
|
+
unreadable packument, truncated 404 body, SLSA URL outside `predicateType`)
|
|
86
|
+
and `check-provenance-fixtures.test.sh` (7 cases, verifying the verifier).
|
|
87
|
+
Both run under `npm test`.
|
|
88
|
+
- **AGENTS.md Release flow** corrected: provenance is the `--provenance` flag and
|
|
89
|
+
not implied by `id-token: write`; read a tool's own exit status rather than a
|
|
90
|
+
pipeline's; capture a response body before matching it; parse the JSON and
|
|
91
|
+
require exact `attestations[].predicateType` equality (a substring match
|
|
92
|
+
accepts the URL sitting in an `error` field or an unrelated `description`).
|
|
93
|
+
|
|
2
94
|
## 0.29.1 — 2026-11-22
|
|
3
95
|
|
|
4
96
|
- **npm provenance actually enabled.** `publish.yml` ran `npm publish --access
|
|
5
97
|
public` and nothing else; `id-token: write` permits provenance but does not
|
|
6
|
-
request it
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
now `--provenance` on the publish command, and AGENTS.md documents the
|
|
10
|
-
so a workflow permissions block is never mistaken for evidence again.
|
|
98
|
+
request it. Checked **all 31 published versions** against the registry
|
|
99
|
+
(`dist.attestations` in the packument, plus the attestation endpoint for a
|
|
100
|
+
sample): **none** carries an attestation except this one (0.29.1). The flag
|
|
101
|
+
is now `--provenance` on the publish command, and AGENTS.md documents the
|
|
102
|
+
check so a workflow permissions block is never mistaken for evidence again.
|
|
103
|
+
The check itself is predicate-based, not status-based: two distinct
|
|
104
|
+
attestations can appear — npm's own publish recording (`publish/v0.1`) and the
|
|
105
|
+
SLSA build provenance — and only the latter is a build-provenance claim, so an
|
|
106
|
+
HTTP 200 (or a `publish/v0.1` alone) does not establish it.
|
|
107
|
+
`scripts/verify-provenance.sh <version>` fails unless
|
|
108
|
+
`https://slsa.dev/provenance/v1` is present. Endpoint checked on all 31
|
|
109
|
+
published versions: 0.29.1 is the only 200 (both predicates); the other 30
|
|
110
|
+
return 404 with neither.
|
|
11
111
|
- Nothing else changed: no module, setting, or tool behavior differs from
|
|
12
112
|
0.29.0.
|
|
13
113
|
|
|
@@ -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; }
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Contract test for scripts/smoke-install.sh.
|
|
3
|
+
#
|
|
4
|
+
# The script's whole value is that EVERY wrong answer is fatal — a version
|
|
5
|
+
# mismatch, a missing file, or a file that should have been deleted must all
|
|
6
|
+
# exit non-zero. These cases were added because a hand-rolled version of this
|
|
7
|
+
# check reported success while only printing its failures.
|
|
8
|
+
#
|
|
9
|
+
# Network-dependent (it installs from the registry), so it targets versions that
|
|
10
|
+
# already exist and keeps the assertion set small. Set SMOKE_TEST_VERSION to
|
|
11
|
+
# override the version under test.
|
|
12
|
+
#
|
|
13
|
+
# DELIBERATELY NOT wired into `npm test`: the rest of the suite is offline (the
|
|
14
|
+
# audit test points AUDIT_REGISTRY at a local fake server, the fixture check has
|
|
15
|
+
# no network at all), and a registry dependency in CI would make every push
|
|
16
|
+
# slower and flakier than the checks it protects. Run this as part of the RELEASE
|
|
17
|
+
# flow, after the tarball resolves — that is the moment it has something to
|
|
18
|
+
# prove.
|
|
19
|
+
set -eu
|
|
20
|
+
|
|
21
|
+
ROOT="$(CDPATH= cd -- "$(dirname -- "$0")/../../.." && pwd)"
|
|
22
|
+
SCRIPT="$ROOT/scripts/smoke-install.sh"
|
|
23
|
+
VER="${SMOKE_TEST_VERSION:-0.29.2}"
|
|
24
|
+
|
|
25
|
+
fail=0
|
|
26
|
+
# expect <desc> <want-rc> [--expect-msg <substring>] -- <script args>...
|
|
27
|
+
#
|
|
28
|
+
# Exit status ALONE is not enough: every failure path in the script exits 1, so a
|
|
29
|
+
# transient registry error makes "missing --require" pass for the wrong reason.
|
|
30
|
+
# A case that cares WHICH check fired asserts its message too.
|
|
31
|
+
expect() {
|
|
32
|
+
desc="$1"; want="$2"; shift 2
|
|
33
|
+
wantMsg=""
|
|
34
|
+
if [ "${1:-}" = "--expect-msg" ]; then wantMsg="$2"; shift 2; fi
|
|
35
|
+
[ "${1:-}" = "--" ] && shift
|
|
36
|
+
|
|
37
|
+
set +e
|
|
38
|
+
sh "$SCRIPT" "$@" > "$TMPOUT" 2>&1
|
|
39
|
+
rc=$?
|
|
40
|
+
set -e
|
|
41
|
+
|
|
42
|
+
# Exact comparison, not a "did it fail at all" test. Collapsing every negative
|
|
43
|
+
# case to "non-zero" would let the usage path (2) pass while reporting 1, i.e.
|
|
44
|
+
# it would stop pinning the documented distinction between a usage error and a
|
|
45
|
+
# failed check.
|
|
46
|
+
if [ "$rc" -ne "$want" ]; then
|
|
47
|
+
echo "FAIL [$desc] expected rc=$want, got $rc"; sed 's/^/ /' "$TMPOUT"; fail=1; return
|
|
48
|
+
fi
|
|
49
|
+
if [ -n "$wantMsg" ] && ! grep -qF "$wantMsg" "$TMPOUT"; then
|
|
50
|
+
echo "FAIL [$desc] exited $rc but without the expected message: $wantMsg"
|
|
51
|
+
echo " (a different failure — e.g. a registry error — cannot satisfy this case)"
|
|
52
|
+
sed 's/^/ /' "$TMPOUT"; fail=1; return
|
|
53
|
+
fi
|
|
54
|
+
echo "ok [$desc] rc=$rc${wantMsg:+ [$wantMsg]}"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
TMPOUT=$(mktemp)
|
|
58
|
+
trap 'rm -f "$TMPOUT"' EXIT INT TERM
|
|
59
|
+
|
|
60
|
+
# Baseline: the real payload asserts clean.
|
|
61
|
+
expect "real payload => exit 0" 0 -- \
|
|
62
|
+
"$VER" \
|
|
63
|
+
--require extensions/modules/repair/lib/persistent-bash.ts \
|
|
64
|
+
--forbid extensions/modules/steering/lib/anchor.ts
|
|
65
|
+
|
|
66
|
+
# A missing --require path must be fatal (this is the defect being pinned: the
|
|
67
|
+
# old inline check printed the miss and still exited 0).
|
|
68
|
+
expect "missing --require => its own message" 1 \
|
|
69
|
+
--expect-msg "FAIL: missing scripts/does-not-exist.sh" -- \
|
|
70
|
+
"$VER" --require scripts/does-not-exist.sh
|
|
71
|
+
|
|
72
|
+
# A --forbid path that IS present must be fatal (a deleted file must stay gone).
|
|
73
|
+
expect "violated --forbid => its own message" 1 \
|
|
74
|
+
--expect-msg "unexpected extensions/modules/repair/lib/persistent-bash.ts" -- \
|
|
75
|
+
"$VER" --forbid extensions/modules/repair/lib/persistent-bash.ts
|
|
76
|
+
|
|
77
|
+
# An install failure must be fatal, not silently skipped.
|
|
78
|
+
expect "nonexistent version => install-failure message" 1 \
|
|
79
|
+
--expect-msg "FAIL: npm install ceulen@9.9.9 exited non-zero" -- \
|
|
80
|
+
"9.9.9"
|
|
81
|
+
|
|
82
|
+
# A version mismatch must be fatal, exercised through the real CLI via
|
|
83
|
+
# --expect-version (install one version, assert another).
|
|
84
|
+
expect "version mismatch => its own message" 1 \
|
|
85
|
+
--expect-msg "installed version $VER != requested 0.0.0-deliberately-wrong" -- \
|
|
86
|
+
"$VER" --expect-version 0.0.0-deliberately-wrong
|
|
87
|
+
|
|
88
|
+
# Usage errors are distinguishable from check failures.
|
|
89
|
+
expect "no version argument => usage message" 2 \
|
|
90
|
+
--expect-msg "usage: smoke-install.sh"
|
|
91
|
+
|
|
92
|
+
# The success path must actually SAY it checked the version, so a reader can
|
|
93
|
+
# tell a real pass from a vacuous one.
|
|
94
|
+
set +e
|
|
95
|
+
sh "$SCRIPT" "$VER" > "$TMPOUT" 2>&1
|
|
96
|
+
set -e
|
|
97
|
+
if grep -q "ok version $VER" "$TMPOUT"; then
|
|
98
|
+
echo "ok [report] version assertion reported"
|
|
99
|
+
else
|
|
100
|
+
echo "FAIL [report] no version line in the output"; sed 's/^/ /' "$TMPOUT"; fail=1
|
|
101
|
+
fi
|
|
102
|
+
|
|
103
|
+
[ "$fail" -eq 0 ] && { echo; echo "ALL PASS"; } || { echo >&2; echo "FAILURES PRESENT" >&2; exit 1; }
|
|
@@ -78,13 +78,41 @@ export function buildRepairGroups(cfg: RepairSettings): PanelGroup[] {
|
|
|
78
78
|
description: "One bash per session: cwd, exported variables, functions, and background jobs survive across calls (DeepSeek Harness parity). Plan mode always runs one-shot.",
|
|
79
79
|
warning: "Binds at session start — applies to the next session. While on, auto-background bash is suspended: background long jobs inside the shell with '&'.",
|
|
80
80
|
}),
|
|
81
|
+
row("repair.spillMaxTokens", "Tool-result token budget", "number", cfg.spillMaxTokens, (v) => {
|
|
82
|
+
// Mirror the autoBgSecs guard: non-numeric input must not persist NaN.
|
|
83
|
+
const n = Math.floor(Number(v));
|
|
84
|
+
if (Number.isFinite(n) && n >= 0) cfg.spillMaxTokens = n;
|
|
85
|
+
}, {
|
|
86
|
+
defaultValue: DEFAULT_REPAIR_SETTINGS.spillMaxTokens,
|
|
87
|
+
description: "Results over this many estimated tokens keep their head and tail; the full text is saved to a file the model can read. 0 disables. (DeepSeek Harness spill-policy.)",
|
|
88
|
+
}),
|
|
89
|
+
row("repair.repeatReminder", "Repeat-call reminder", "toggle", cfg.repeatReminder, (v) => {
|
|
90
|
+
cfg.repeatReminder = v === true;
|
|
91
|
+
}, {
|
|
92
|
+
defaultValue: DEFAULT_REPAIR_SETTINGS.repeatReminder,
|
|
93
|
+
description: "Advisory footer when the same tool call repeats with identical arguments (3rd/5th/8th). Never blocks — targeting DeepSeek Flash's loop failure mode.",
|
|
94
|
+
}),
|
|
95
|
+
row("repair.clock", "Model-visible clock", "toggle", cfg.clock, (v) => {
|
|
96
|
+
cfg.clock = v === true;
|
|
97
|
+
}, {
|
|
98
|
+
defaultValue: DEFAULT_REPAIR_SETTINGS.clock,
|
|
99
|
+
description: "Inject the current date/time and elapsed-since-last-activity into the request. Pi injects no clock anywhere (DeepSeek Harness time-context).",
|
|
100
|
+
}),
|
|
101
|
+
row("repair.clockRefreshMs", "Clock refresh interval", "number", cfg.clockRefreshMs, (v) => {
|
|
102
|
+
const n = Math.floor(Number(v));
|
|
103
|
+
if (Number.isFinite(n) && n >= 0) cfg.clockRefreshMs = n;
|
|
104
|
+
}, {
|
|
105
|
+
defaultValue: DEFAULT_REPAIR_SETTINGS.clockRefreshMs,
|
|
106
|
+
description: "Minimum milliseconds between clock injections in one session (default 600000 = 10 min). Keeps the appended clock out of the cache-churn path.",
|
|
107
|
+
}),
|
|
81
108
|
],
|
|
82
109
|
},
|
|
83
110
|
];
|
|
84
111
|
}
|
|
85
112
|
|
|
86
113
|
const OWNED_PREFIX = "repair.";
|
|
87
|
-
const BOOL_KEYS = ["arguments", "editRetry", "guards", "autoGenGuard", "autoBg", "persistentBash"] as const;
|
|
114
|
+
const BOOL_KEYS = ["arguments", "editRetry", "guards", "autoGenGuard", "autoBg", "persistentBash", "repeatReminder", "clock"] as const;
|
|
115
|
+
const NUMBER_KEYS = ["autoBgSecs", "spillMaxTokens", "clockRefreshMs"] as const;
|
|
88
116
|
|
|
89
117
|
/** repair's ModuleConfig for the central /config panel. The factory receives
|
|
90
118
|
* the module's guarded pi but needs nothing from it — settings live in the
|
|
@@ -100,7 +128,9 @@ export function repairConfig(_pi: ExtensionAPI): ModuleConfig {
|
|
|
100
128
|
for (const key of BOOL_KEYS) {
|
|
101
129
|
if (working[key] !== before[key]) patch[key] = working[key];
|
|
102
130
|
}
|
|
103
|
-
|
|
131
|
+
for (const key of NUMBER_KEYS) {
|
|
132
|
+
if (working[key] !== before[key]) patch[key] = working[key];
|
|
133
|
+
}
|
|
104
134
|
const file = writeRepairSection(patch);
|
|
105
135
|
const notes = [`Repair settings saved to ${file}.`];
|
|
106
136
|
if (patch.autoBg !== undefined || patch.autoBgSecs !== undefined) {
|