diff --git a/packages/plugins/README.md b/packages/plugins/README.md index 27d6a357c..bdb0d1e95 100644 --- a/packages/plugins/README.md +++ b/packages/plugins/README.md @@ -398,7 +398,8 @@ there. `signal` aborts when the watch stops waiting. `pi` returns its fit check (`packages/harness/src/pi-fit.mjs`), called exactly as `preflight` calls it, so the two share one cache and one running check. Its digest is that check's digest of the binary's files; a failed check gives none. A -failure whose line says "can't be checked" is `fit: "unknown"`. +failure whose line, after pi's lookup label, starts with "can't be checked" +is `fit: "unknown"`. `claude-code` returns the sha256 of the binary's real file and the first line of `--version`, and captures `--help` as the `help` surface, both run from that same real file with only PATH and a scratch HOME. Its lookup for @@ -436,7 +437,16 @@ get the same treatment. A record also carries `via` (`inspect` or (`{ harness, at, from, to, failed, line }`, with `from` null on a first sight) is given only when the state or the binary is not the last record's. The digest names the binary; when neither record has one (pi gives none for -a failed check), the version label stands in for it. +a failed check), the version label stands in for it, and only when both +records have a version: a timeout or a throw knows none, and is not a new +binary. So unknown 2.0, a timeout, then unknown 2.1, all with no digest, +gives no transition for the version; W1 keeps no last known version. + +The redaction applies to the stored surfaces too, so a surface is for +display and comparison, not for fit rules: with USER set to `model`, the +stored `help` reads `--` where claude printed `--model`. A fit rule +(slice W2's flag check, for one) runs inside the module on the text the +binary printed and puts its answer in `fit`, `failed` and `line`. ## Transcript usage source (row 124) diff --git a/packages/plugins/src/harness-watch.mjs b/packages/plugins/src/harness-watch.mjs index ddc3b6ab4..fc6fa31b7 100644 --- a/packages/plugins/src/harness-watch.mjs +++ b/packages/plugins/src/harness-watch.mjs @@ -80,11 +80,13 @@ export async function watchHarnesses({ last = [], env = process.env, scratch = n // The latest digest the last record knew: its own, or the one it carried forward. const known = (prior) => [prior?.digest, prior?.lastDigest].find((d) => typeof d === "string" && DIGEST.test(d)) ?? null; // Whether two records are of the same binary. The digest decides; when neither record has one -// (pi gives none for a failed check), the version label stands in for it. +// (pi gives none for a failed check), the version label stands in for it, but only when both +// records have one: a pass that timed out or threw knows no version, which is not a new binary. function sameBinary(prior, record) { const was = typeof prior.digest === "string" ? prior.digest : null; if (was !== null || record.digest !== null) return was === record.digest; - return (typeof prior.version === "string" ? prior.version : null) === record.version; + const before = typeof prior.version === "string" ? prior.version : null; + return before === null || record.version === null || before === record.version; } const brief = (r) => ({ state: STATES.includes(r.state) ? r.state : "unknown", version: typeof r.version === "string" ? r.version : null, digest: typeof r.digest === "string" ? r.digest : null }); diff --git a/packages/plugins/tests/harness-watch.test.mjs b/packages/plugins/tests/harness-watch.test.mjs index e48461bf0..ff34745ae 100644 --- a/packages/plugins/tests/harness-watch.test.mjs +++ b/packages/plugins/tests/harness-watch.test.mjs @@ -171,6 +171,14 @@ test("W1 a new binary first seen through an unknown, red or missing record still assert.deepEqual(b.transitions.map((x) => [x.from.version, x.to.version, x.line]), [["2.0.0", "2.1.0", "lacks --no-mcp"]]); const c = await pass({ h: red("2.1.0", "lacks --no-mcp") }, { last: b.records }); assert.deepEqual(c.transitions, []); + // A pass that knows no version (a timeout or a throw) is not a new binary: unknown with 2.0, + // then a timeout, then unknown with 2.0 again, then a throw gives no transition after the first. + const d = await pass({ h: none }, { last: [] }); + const e = await pass({ h: "hang" }, { last: d.records, timeoutMs: 200 }); + const f = await pass({ h: { ...none, version: "2.0.0" } }, { last: e.records }); + const g = await pass({ h: "throw" }, { last: f.records }); + assert.deepEqual([d, e, f, g].map((x) => x.transitions.length), [1, 0, 0, 0]); + assert.deepEqual([e, g].map((x) => byName(x).h.version), [null, null]); }); test("W1 an answer that throws when read, a Proxy or inherited fields is unknown, and the other harnesses still get records", async (t) => {