ClaimVerify extract() shrinks the stdout slice one character at a time: 200 KB of trailing probe log costs ~21 s of CPU
Observed on 7.54.0.
What
// LIFEOS/TOOLS/ClaimVerify.ts:100
const jsonStart = stdout.search(/[{[]/);
if (jsonStart >= 0) {
for (let end = stdout.length; end > jsonStart; end--) {
try {
const obj = JSON.parse(stdout.slice(jsonStart, end));
...
} catch { /* keep shrinking the slice */ }
}
}
Whenever the JSON is not the last thing on stdout — or the requested path is absent entirely — this performs a JSON.parse over an O(n)-sized slice for each of n end positions. maxBuffer is 32 MB and PROBE_TIMEOUT_MS bounds the probe, not the parse, so nothing caps the cost.
The gate asserter's documented "probe emitted no parseable gate result" branch is the worst case, and a gate probe that prints a build or test log before its verdict is the normal shape of one.
Repro
{"claim_type":"gate",
"probe_cmd":"printf '{\"status\":\"green\"}\\n'; head -c 200000 /dev/zero | tr '\\0' 'x'",
"expect":{"ok_path":"ok"}}
time bun LIFEOS/TOOLS/ClaimVerify.ts --claim-file claim.json
Observed: verdict UNVERIFIABLE, exit 3, 18.27s user 0.57s system 87% cpu 21.486 total.
Same claim with a 100 KB tail: 3.75s user 0.18s system 96% cpu 4.078 total — roughly 5x the cost for 2x the input.
Expected
Sub-second regardless of trailing log volume.
Fix sketch
Locate the JSON span in a single pass by brace/bracket balance from jsonStart and parse only that span, with a hard cap on slice length.
Closing this myself: I filed it in error.
ClaimVerify.ts is not part of this project. It is a local tool in my own install, and I mis-attributed it to LIFEOS/TOOLS/ when sweeping that directory — it ships in no release payload and appears nowhere in main. The quadratic-parse bug is real, but it is mine to fix, not yours.
Apologies for the noise. The other eight in this batch (#2184-#2189, #2191, #2192) I re-checked line by line against main after this, and each one reproduces in the shipped payload at the cited line.