commit ac5961c973c30ef628c596911a3696557c03875d
parent 76e03c2eeeb6e18b80f740cbd25dbc690e85063b
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 12 Nov 2026 08:11:04 -0500
common: the model log's scrub closes the second review's gaps -- a credential query parameter after a JSON-escaped ampersand (backslash-u0026), & or %26 and with a %3D, an Authorization value of any scheme word and in quotes (SharedKey's colon included), a cookie value stops at a brace so '{cookie:a=…' is linear again; a date or a time after secret:/token:/password: (or in a *_SECRET= assignment) is left alone; the timing test holds 24 more adversarial 160k strings under 250 ms
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat:
3 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/common/lib/llm/callLog.ts b/common/lib/llm/callLog.ts
@@ -160,32 +160,55 @@ const LOOKS_SECRET = "(?=[A-Za-z0-9._~+/=-]{0,200}?(?:[0-9+/=_~]|[a-z][A-Z]))";
const LOOKS_SECRET_ANY_CASE = "(?=[A-Za-z0-9._~+/=-]{0,200}?[0-9+/=_~])";
const ENV_CREDENTIAL = /(?:^|_)(?:TOKEN|KEY|SECRET|PASSWORD|PASSWD|PWD|CREDENTIALS?|COOKIES?|AUTH)$/;
+// What follows `secret:` / `token:` / `password:` is a credential unless it is
+// a date or a time ("Secret: 2026-11-07T10:00 meeting", "token: 10:30am-11am")
+// or a link ("Token: https://…" — a link's own credentials are the other
+// rules'). An ordinary word never gets this far: the rules that call this ask
+// for a digit or a sign in the value first. (Each alternative starts on its own
+// character, and the trailing punctuation is trimmed by a loop: linear.)
+const DATE_OR_TIME = /^(?:[\d.:/,+-]|T|Z|[ap]\.?m\.?|utc|gmt)+$/i;
+const TRAILING_PUNCT = ").]!?:";
+const credentialLike = (v: string) => {
+ let end = v.length;
+ while (end > 0 && TRAILING_PUNCT.includes(v[end - 1]!)) end--;
+ const core = v.slice(0, end);
+ if (/\d/.test(core) && /[-:/]/.test(core) && DATE_OR_TIME.test(core)) return false;
+ return !/^[a-z][a-z0-9+.-]{0,20}:\/\//i.test(core);
+};
+
type Shape = readonly [RegExp, string | ((...m: string[]) => string)];
const CREDENTIAL_SHAPES: readonly Shape[] = [
// user:password@ in a URL
[/(?<![A-Za-z0-9+.-])([a-z][a-z0-9+.-]{0,20}:\/\/)[^\s/@:"'<>]{0,256}:[^\s/@"'<>]{1,512}@/gi, "$1[secret]@"],
// a query parameter named like a credential — and `ip`, the fetcher's public
// address in a signed media URL
- [new RegExp(`([?&;](?:${CREDENTIAL_PARAM}|ip|ipbits))=[^&\\s"'\`<>#;)\\]}]{1,4096}`, "gi"), "$1=[secret]"],
+ // — after `?`, `&` or `;` however the text writes them (`\u0026` in a
+ // player's JSON, `&`, `%26`), and `=` or its `%3D`
+ [new RegExp(`((?:[?&;]|\\\\u0026|&|%26|%3F)(?:${CREDENTIAL_PARAM}|ip|ipbits))(=|%3D)[^&\\s"'\`<>#;)\\]}\\\\]{1,4096}`, "gi"), "$1$2[secret]"],
// an Authorization header's value, whatever it is
- [/\b(authorization["']?[ \t]{0,8}[:=][ \t]{0,8}["']?(?:Bearer|Basic)[ \t]{1,8})[^\s"']{1,4096}/gi, "$1[secret]"],
+ // (a scheme word that is one: Bearer, Basic, Token, Digest, …)
+ [/\b((?:proxy-)?authorization["']?[ \t]{0,8}[:=][ \t]{0,8}["']?(?:Bearer|Basic|Token|Digest|Negotiate|Api-?Key|OAuth|JWT|Hawk|NTLM|AWS4-HMAC-SHA256)[ \t]{1,8})[^\s"']{1,4096}/gi, "$1[secret]"],
+ // (any other scheme word, when what follows it reads like a credential —
+ // `SharedKey acct:sig…` has a colon in it, so the look ahead takes any
+ // character the value can hold)
+ [/\b((?:proxy-)?authorization["']?[ \t]{0,8}[:=][ \t]{0,8}["']?[A-Za-z][\w-]{0,24}[ \t]{1,8})(?=[^\s"']{0,200}?[0-9+/=_~])([^\s"']{8,4096})/gi, (m, head, value) => (credentialLike(value!) ? `${head}[secret]` : m!)],
// Bearer / Basic anywhere, when what follows reads like a credential
// ("Basic counterintelligence" and "bearer of bad news" are words)
[new RegExp(`\\b(Bearer|Basic)[ \\t]{1,8}${LOOKS_SECRET}[A-Za-z0-9._~+/=-]{16,4096}`, "g"), "$1 [secret]"],
// a Cookie header: at the start of a line (or a JSON field), and nothing
// but cookie pairs to the end of it — "cookie: chocolate=best ever" is a sentence
- [/(^|[\n{,])([ \t]{0,16}["']?(?:set-)?cookie["']?[ \t]{0,8}:[ \t]{0,8}["']?)[\w.%!#$&*+^`|~-]{1,128}=[^\s;,"']{0,4096}(?:;[ \t]?[\w.%-]{1,128}(?:=[^\s;,"']{0,4096})?){0,64};?(?=[ \t]{0,8}(?:["'}\r\n]|$))/gi, "$1$2[secret]"],
+ [/(^|[\n{,])([ \t]{0,16}["']?(?:set-)?cookie["']?[ \t]{0,8}:[ \t]{0,8}["']?)[\w.%!#$&*+^`|~-]{1,128}=[^\s;,"'{}]{0,4096}(?:;[ \t]?[\w.%-]{1,128}(?:=[^\s;,"'{}]{0,4096})?){0,64};?(?=[ \t]{0,8}(?:["'}\r\n]|$))/gi, "$1$2[secret]"],
// a key header
- [/\b((?:x-api-key|api[-_]?key|authorization|proxy-authorization)["']?[ \t]{0,8}[:=][ \t]{0,8}["']?)[A-Za-z0-9._~+/-]{16,4096}/gi, "$1[secret]"],
+ [/\b((?:x-api-key|api[-_]?key|authorization|proxy-authorization)["']?[ \t]{0,8}(?:[:=]|%3D)[ \t]{0,8}["']?)[A-Za-z0-9._~+/-]{16,4096}/gi, "$1[secret]"],
// a login cookie wherever it is quoted: name=value, "name":"value", a
// cookie-jar line (name <tab> value)
[new RegExp(`\\b(${LOGIN_COOKIE})(["']?[ \\t]{0,8}[:=][ \\t]{0,8}["']?)[^;\\s"'&,}]{1,4096}`, "g"), "$1$2[secret]"],
[new RegExp(`\\b(${LOGIN_COOKIE})([ \\t]{1,8})[A-Za-z0-9._~%+/=-]{16,4096}`, "g"), "$1$2[secret]"],
// a password, a token, a secret written out: `password: hunter2…`,
// "token":"…" — when the value reads like one
- [new RegExp(`\\b(pass(?:word|wd)|pwd|secret|(?:access|auth|api|session)[_-]?(?:token|key)|token)(["']?[ \\t]{0,8}[:=][ \\t]{0,8}["']?)${LOOKS_SECRET_ANY_CASE}[^\\s"',;]{8,4096}`, "gi"), "$1$2[secret]"],
+ [new RegExp(`\\b(pass(?:word|wd)|pwd|secret|(?:access|auth|api|session)[_-]?(?:token|key)|token)(["']?[ \\t]{0,8}(?:[:=]|%3D)[ \\t]{0,8}["']?)${LOOKS_SECRET_ANY_CASE}([^\\s"',;]{8,4096})`, "gi"), (m, name, sep, value) => (credentialLike(value!) ? `${name}${sep}[secret]` : m!)],
// an environment assignment: WORKER_TOKEN=…, NAME_KEY=…
- [/(?<![A-Za-z0-9_])([A-Z][A-Z0-9_]{2,80})=([^\s"'&;,]{8,4096})/g, (m, name) => (ENV_CREDENTIAL.test(name!) ? `${name}=[secret]` : m!)],
+ [/(?<![A-Za-z0-9_])([A-Z][A-Z0-9_]{2,80})=([^\s"'&;,]{8,4096})/g, (m, name, value) => (ENV_CREDENTIAL.test(name!) && credentialLike(value!) ? `${name}=[secret]` : m!)],
// keys that say what they are
[/\bsk-(?:ant-)?[A-Za-z0-9_-]{20,512}/g, "[secret]"],
[/\bgh[pousr]_[A-Za-z0-9]{30,255}/g, "[secret]"],
diff --git a/common/lib/llm/callLogPrivacy.test.ts b/common/lib/llm/callLogPrivacy.test.ts
@@ -173,6 +173,31 @@ test("every scrub pattern is linear: 160,000 characters of each rule's trigger s
"=": rep("="),
"authorization:": rep("authorization: "),
"one long word": "a".repeat(N),
+ // The second review's (12 Nov): a brace before a cookie name, and the rest of its list.
+ "{cookie:a=x": rep("{cookie:a=xxxxxxxxxx"),
+ ",cookie:a=b;c": rep(",cookie:a=b;c=d;e"),
+ "&a": rep("&a"),
+ "&a-": rep("&a-"),
+ "?a_b.": rep("?a_b."),
+ ";access_": rep(";access_"),
+ "a://b:c": rep("a://b:cccccc"),
+ "a://b:c:": rep("a://b:c:c:c:"),
+ "Bearer short": rep("Bearer aaaaaaaaaaaaaaa "),
+ "token:word": rep("token:aaaaaaa "),
+ "token=long": rep(`token=${"a".repeat(300)} `),
+ "eyJ.eyJ.": rep("eyJaaaaaaaa.eyJaaaaaaaa."),
+ "auth_token tab": rep("auth_token\taaaaaaa "),
+ "AB_KEY=short": rep("AB_KEY=short "),
+ " /home/x": rep(" /home/x"),
+ "authorization: Bearer": rep("authorization: Bearer "),
+ "authorization: word": rep("authorization: word "),
+ "x-api-key:": rep("x-api-key:aaaa "),
+ "__Secure-": rep("__Secure-a"),
+ "sk-short": rep("sk-aaaaaaaaaaaaaaaaaaa "),
+ "set-cookie lines": rep("\nset-cookie: a=b; c"),
+ "\\u0026": rep("\\u0026a"),
+ "%26": rep("%26a%3D"),
+ "&": rep("&a"),
};
const scrub = { secrets: ["abcdefFAKE-TEST-VALUE"], roots: ["/srv/archive", "/home/someone"] };
scrubText("warm up https://u:p@h/x?token=abc Bearer abcdefghijklmnop0123", scrub);
@@ -259,3 +284,42 @@ test("scrubBounded: a text is cut to its cap and a margin before the scrub — a
scrubBounded("a.".repeat(2_000_000), 40_000, clean);
assert.ok(performance.now() - t0 < 250);
});
+
+test("scrubText (second review): an ampersand however it is written, an encoded `=`, any Authorization scheme", () => {
+ const cases: [string, string][] = [
+ ['"url":"https://rr1.googlevideo.com/videoplayback?expire=1\\u0026token=FAKE-TEST-VALUE\\u0026ip=203.0.113.9\\u0026itag=18"', '"url":"https://rr1.googlevideo.com/videoplayback?expire=1\\u0026token=[secret]\\u0026ip=[secret]\\u0026itag=18"'],
+ ["a href=?v=1&sig=AAAA.BBBB&t=4", "a href=?v=1&sig=[secret]&t=4"],
+ ["api_key%3DFAKE-TEST-VALUE", "api_key%3D[secret]"],
+ ["next=%2Fcb%3Fx%3D1%26access_token%3DFAKE-TEST-VALUE", "next=%2Fcb%3Fx%3D1%26access_token%3D[secret]"],
+ ['Authorization: "Token FAKE-TEST-VALUEabcdef"', 'Authorization: "Token [secret]"'],
+ ["authorization: Digest dXNlcjpwYXNz", "authorization: Digest [secret]"],
+ ["Proxy-Authorization: Basic dXNlcjpwYXNz", "Proxy-Authorization: Basic [secret]"],
+ ["Authorization: SharedKey acct:FAKE-TEST-VALUE", "Authorization: SharedKey [secret]"],
+ ["\\u0026token=FAKE-TEST-VALUE", "\\u0026token=[secret]"],
+ ["?a=1&token=FAKE-TEST-VALUE&b=2", "?a=1&token=[secret]&b=2"],
+ ];
+ for (const [text, want] of cases) assert.equal(scrubText(text, {}), want);
+ // An authorization that is a sentence stays one.
+ for (const plain of ["authorization: pending approval tomorrow", "Authorization: granted by the committee", "Authorization: expires 2026-11-07T10:00."]) assert.equal(scrubText(plain, {}), plain);
+});
+
+test("scrubText (second review): what follows secret: / token: / password: is a credential, not a date, a time or a link", () => {
+ for (const plain of [
+ "Secret: 2026-11-07T10:00 meeting",
+ "password: 2026-11-07, as agreed",
+ "token: 10:30-11:45",
+ "token: 10:30am-11:45am, then lunch",
+ "Secret: 2026-11-07T10:00Z.",
+ "secret: (2026-11-07)",
+ "SECRET=2026-11-07T10:00",
+ "Token: https://example.com/watch?v=abc123",
+ "the key to this is basic economics, a token gesture; his secret: he ate 400 calories",
+ "my password is hunter2 and the session was great",
+ "He said: key=value pairs are simple",
+ ])
+ assert.equal(scrubText(plain, {}), plain);
+ assert.equal(scrubText("Secret: 2026hunter2hunter", {}), "Secret: [secret]");
+ assert.equal(scrubText("password: 12345678", {}), "password: [secret]");
+ assert.equal(scrubText("PASSWORD=hunter2!", {}), "PASSWORD=[secret]");
+ assert.equal(scrubText("export ANTHROPIC_API_KEY='sk-ant-abcdefghijklmnopqrstuvwx'", {}), "export ANTHROPIC_API_KEY='[secret]'");
+});
diff --git a/editor/CHANGELOG.md b/editor/CHANGELOG.md
@@ -2,7 +2,8 @@
## [Unreleased]
- **umtool: a Model log shows what the model was asked, what it answered, and what the code did with it.** Until now a prompt was shown nowhere, and a local model's calls were in no ledger. Every model call of a run is now recorded, on every route (a local model, the Claude API, this session), and listed in a **Model log** panel on the run page (`/research/runs/<article>/<n>`), the article's Iterations tab and each media draft. Calls are grouped by phase (terms, reading, meaning check, grouping). A row has the first lines of what was asked, what came back, the seconds, and whether its answer was kept, dropped or rewritten, with the reason and each item's fate. A row opens to the whole prompt and answer (40,000 characters of each are kept). A log holds 20,000 calls or 32 MB; past that the panel says the log is full, and later calls are not recorded. The header counts the calls, the seconds and the models; a filter narrows to kept, dropped or rewritten; the list follows a run while it runs. `umtool model-log <article> <n>` (or `--job <jobId>`) prints the same, with `--phase`, `--outcome`, `--task`, `--run`, `--call <run.call>` for one call's whole text, and `--json`; a control sequence in a recorded text is printed as its escape (`\x1b`), never sent to the terminal. `/settings/generation` shows, per task, the route and the model it will run on, "no API key configured" when there is none, and the model of its last run.
-- **The job page has the Model log too, and a local model's calls are in the usage ledger.** A job that calls a model (a report draft, a refresh, triage, verdicts, a frame scan, clip suggestions, video assist) shows its calls on `/jobs/<id>`, as umtool does. Calls to a local model are appended to `.generation/usage.jsonl` with route `local` and cost 0, so `pnpm ops get generation-usage` lists every model a run called, and a run that was local only lists no other. `pnpm ops get iterations` gains each iteration's call count and seconds. The record keeps the text sent to the model and nothing else: no header and no model host; the editor's `WORKER_TOKEN`, an API key, every environment variable named like a credential, and host paths are taken out before a line is written, anything shaped like a credential (a URL's user and password, a token in a query string, a `Bearer` value, a cookie line, a key that says what it is) loses its value whoever's it is, and a failed call's message has its URLs and addresses removed. Links are kept.
+- **The job page has the Model log too, and a local model's calls are in the usage ledger.** A job that calls a model (a report draft, a refresh, triage, verdicts, a frame scan, clip suggestions, video assist) shows its calls on `/jobs/<id>`, as umtool does. Calls to a local model are appended to `.generation/usage.jsonl` with route `local` and cost 0, so `pnpm ops get generation-usage` lists every model a run called, and a run that was local only lists no other. `pnpm ops get iterations` gains each iteration's call count and seconds. The record keeps the text sent to the model and nothing else: no header and no model host; the editor's `WORKER_TOKEN`, an API key, every environment variable named like a credential, and host paths are taken out before a line is written, anything shaped like a credential (a URL's user and password, a token in a query string however its `&` and `=` are written — `\u0026`, `&`, `%26`, `%3D` — an `Authorization` value of any scheme, a `Bearer` value, a cookie line, a key that says what it is) loses its value whoever's it is, while a date or a time after `secret:` or `token:` is left as it is, and a failed call's message has its URLs and addresses removed. Links are kept.
+- **Cancelling a job whose program never started no longer stops the editor.** A download cancelled after its channel directory was gone sent SIGTERM to the editor's whole process group: Node's `kill()` on a child that failed to spawn has no pid and signals the caller's own group. A kill on such a child is now a no-op in the editor, and umtool and the standalone scripts (the queue lock, `render-mode on -- <cmd>`, loudness, voice, TTS, diarization, `pnpm e2e:all`) check the child's pid before every kill; a sweep test holds them to it.
- **A published archive is a source: connect it once, sweep it, and fetch its cited clips with no local corpus.** A fresh clone pointed at jeralyzer.pages.dev could search it through the MCP and do nothing else: Create had no corpus to offer, and every clip of a channel the editor did not archive was a 404 `Channel "<slug>" not found`. An archive is now connected by its origin — `/sites` → **Connected archives**, or `pnpm ops archives --json '{"connect":"https://jeralyzer.pages.dev"}'` (`"dryRun": true` reads it and writes nothing; `pnpm ops get archives` lists them) — and kept in `settings.remoteArchives`. `TRANSCRIPT_SITE_URL`'s archive is offered without being connected, so a clone set up as AGENTS.md says starts with one. Create offers each connected archive as a sweep's source, preselected when this machine has no corpus of its own, the MCP's `list_sources` lists them and `generate` passes the choice. A sweep over an archive cites that archive's origin, whatever `generation.citationOrigin` says, and its revisions, drafts and refreshes inherit it. A clip window cited from one registers its channel **remote-only** on first need (`fetch-windows` and `fetch-window` take `"archive"`, and the MCP's `fetch_clip` names it): a `config.json` and nothing else, shown as "remote only" in the channel list, skipped by every sync, lane, scan and site build, and left out of the site form's channel picker. On a whole-recording platform (Rumble) a window means downloading the whole recording, which nobody planned for a channel that is not archived here: it is refused with the recording's length and estimated size until the ask carries `"allowWholeRecording": true`. The archive's documents are cached on disk by its build (512 MB by default), read one at a time and paced. `corpus.json` is spec 6 (the export's changelog): each channel names its platform and its page there; an older archive's platform is read from a record's `webpageUrl`.
- **A connected archive is untrusted input.** umtool can connect one and is open on the LAN, and everything an archive serves is someone else's JSON. An archive on this machine or its network — loopback, private, link-local and CGNAT addresses in any spelling (decimal, hex, IPv4 carried inside IPv6), a `.local`/`.internal`/`.lan` name, or a name that resolves to one — is refused at connect, before anything is asked of it, unless the editor runs with `ARCHILYZER_ALLOW_PRIVATE_ARCHIVES=1` or the origin is `TRANSCRIPT_SITE_URL`'s or already in `settings.json`; the check is made once, at connect. Its documents are read on its own origin only: a redirect elsewhere is refused unfollowed, a manifest its `corpus.json` names on another origin is not followed, and no document past 32 MB is read or kept. A record's page URL is fetched only when its host is its channel's video platform's own domain or a subdomain (`evilyoutube.com` and `youtube.com.evil.example` are not YouTube); a URL carrying a backslash, whitespace or a control character is refused unparsed, because Node and yt-dlp's Python read its host differently; and what reaches yt-dlp is the URL the check parsed, never the archive's own string. A remote-only channel whose archive was removed from settings is refused before its record is read.
- **umtool: the Source chip connects an archive, and an article swept over one is cut from it.** The Source chip takes an archive's address, reads it and connects it through the editor; a connected archive is offered as the source of **Article from a question** and of a new article, first when this machine has no corpus. The chain of an article swept over an archive asks the editor for its windows with the archive named and each record's page URL, so the cited channels are registered remote-only and fetched; a manifest with no sweep naming an origin takes the archive as its QR origin. A Rumble window fails the step with every recording's size, nothing fetched, until **Fetch the whole recordings** (`umtool chain <article> <n> --allow-whole-recording`). `--stop-before-render` ends Draft everything before the voices, and its new `cut-windows` step fetches the drafted cut's windows, asking the editor only for those not on disk. The cue walk, the link check and a source's build identity read an archive under the same rules as the editor (its own origin, 32 MB), and a chain whose archive is no longer connected stops and says to connect it again.