Archilyzer · Source

archilyzer

Archilyzer
git clone https://archilyzer.pages.dev/source/archilyzer.git
Log | Files | Refs | README | LICENSE

commit 78ba3ee25717346cf327884a18c30337e6f95e77
parent 078ac8441547cbe01b86ada422f06562bf4e99c5
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Wed, 14 Oct 2026 02:43:19 -0400

umtool: research facets stay browser-safe; the session key (node:crypto) is session.mjs

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

Diffstat:
Mumtool/lib/research/corpus.ts | 3++-
Mumtool/lib/research/facets.mjs | 27+++------------------------
Mumtool/lib/research/facets.test.mjs | 3++-
Aumtool/lib/research/session.mjs | 23+++++++++++++++++++++++
4 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/umtool/lib/research/corpus.ts b/umtool/lib/research/corpus.ts @@ -13,7 +13,8 @@ import { passesFilters } from "yt-dlp-transcript-common/lib/search/evalTree"; import { clock } from "yt-dlp-transcript-common/lib/search/window"; import type { TranscriptDetail } from "yt-dlp-transcript-common/lib/transcripts"; import { REPORTS_ROOT } from "../paths.mjs"; -import { citationText, facetsOf, hitKey, isoDate, sessionKey, trackOf, yearOf } from "./facets.mjs"; +import { citationText, facetsOf, hitKey, isoDate, trackOf, yearOf } from "./facets.mjs"; +import { sessionKey } from "./session.mjs"; import { readLog } from "./log.mjs"; import { markRanges } from "./query.mjs"; import { isLocalOnly } from "./rules.mjs"; diff --git a/umtool/lib/research/facets.mjs b/umtool/lib/research/facets.mjs @@ -1,6 +1,6 @@ -// The Research results' facets, keys and citation text: pure, so the server -// that builds a result, the page that filters it and the tests agree. -import { createHash } from "node:crypto"; +// The Research results' facets, keys and citation text: pure and +// browser-safe, so the server that builds a result, the page that filters it +// and the tests agree. (The session key needs node:crypto: session.mjs.) /** * What a record's text is, from its `transcriptFormat` (the per-video @@ -62,27 +62,6 @@ export function facetsOf(hits) { } /** - * The scratch session a reading log belongs to until R2's cases exist: the - * query and the scope, normalised, hashed. Same query, same scope, same log. - * - * @param {Record<string, unknown>} scope source, query, regex, channels, dates, states, mediaType, posts - */ -export function sessionKey(scope) { - const norm = { - source: String(scope.source ?? ""), - query: String(scope.query ?? "").trim(), - regex: scope.regex === true, - channels: [...((scope.channels ?? []))].map(String).sort(), - dateFrom: scope.dateFrom ?? "", - dateTo: scope.dateTo ?? "", - states: [...((scope.states ?? []))].map(String).sort(), - mediaType: scope.mediaType ?? "", - posts: scope.posts === true, - }; - return createHash("sha1").update(JSON.stringify(norm)).digest("hex").slice(0, 16); -} - -/** * A citation in the house format (mcp/src/instructions.ts; common's * authoringRules): the quoted words, then `[<title> @ <m:ss>](<moment url>)` * for a video, `[post by <author>, <date>](<url>)` for a post. A video with diff --git a/umtool/lib/research/facets.test.mjs b/umtool/lib/research/facets.test.mjs @@ -1,6 +1,7 @@ import test from "node:test"; import assert from "node:assert/strict"; -import { citationText, facetsOf, hitKey, isoDate, sessionKey, trackOf, yearOf } from "./facets.mjs"; +import { citationText, facetsOf, hitKey, isoDate, trackOf, yearOf } from "./facets.mjs"; +import { sessionKey } from "./session.mjs"; import { isLocalOnly, LOCAL_ONLY_CHANNELS } from "./rules.mjs"; test("trackOf: vtt is captions, *-json our transcription, anything else unknown", () => { diff --git a/umtool/lib/research/session.mjs b/umtool/lib/research/session.mjs @@ -0,0 +1,23 @@ +// The reading log's scratch session key (server side: node:crypto). +import { createHash } from "node:crypto"; + +/** + * The scratch session a reading log belongs to until R2's cases exist: the + * query and the scope, normalised, hashed. Same query, same scope, same log. + * + * @param {Record<string, unknown>} scope source, query, regex, channels, dates, states, mediaType, posts + */ +export function sessionKey(scope) { + const norm = { + source: String(scope.source ?? ""), + query: String(scope.query ?? "").trim(), + regex: scope.regex === true, + channels: [...((scope.channels ?? []))].map(String).sort(), + dateFrom: scope.dateFrom ?? "", + dateTo: scope.dateTo ?? "", + states: [...((scope.states ?? []))].map(String).sort(), + mediaType: scope.mediaType ?? "", + posts: scope.posts === true, + }; + return createHash("sha1").update(JSON.stringify(norm)).digest("hex").slice(0, 16); +}