Archilyzer · Source

archilyzer

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

commit 207ad6cd2e21d922c7ca60fb1f93d0c775c710a1
parent 42d362f4307520a0f7fedfa0941de9cbfbedc668
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date:   Thu, 12 Nov 2026 10:51:28 -0500

lookouts: no citation, no key -- an idea with no cited moment gets no story key and is not surfaced

ideaKey answers null for an idea with no moment: every moment-less idea
hashed the same empty list, so one verdict ruled them all and the de-
duplication by key would fold distinct ideas into one. surfacedIdeas
keeps a stored run's ideas that cite a moment and carry their moments'
key; the readout's idea and unruled counts read it.

Co-Authored-By: Claude <noreply@anthropic.com>

Diffstat:
Mcommon/lib/lookoutStore.test.ts | 59++++++++++++++++++++++++++++++++++++++++++++++-------------
Mcommon/lib/lookoutStore.ts | 25++++++++++++++++++++++---
2 files changed, 68 insertions(+), 16 deletions(-)

diff --git a/common/lib/lookoutStore.test.ts b/common/lib/lookoutStore.test.ts @@ -17,6 +17,7 @@ import { readLookoutVerdicts, sanitizeLookoutVerdicts, setLookoutVerdict, + surfacedIdeas, writeLookoutRun, type LookoutIdea, type LookoutRun, @@ -31,13 +32,20 @@ async function corpus() { } const M = (channel: string, video: string, start: number) => ({ channel, video, start }); +type Mo = ReturnType<typeof M>; +// The key of moments that have one (every list here cites at least one). +const K = (ms: Mo[]): string => { + const k = ideaKey(ms); + assert.ok(k, "a cited idea has a key"); + return k; +}; test("an idea's key is its story: order-free, 5-second grain, changed by a moment added", () => { - const a = ideaKey([M("example-news", "v1", 100), M("example-live", "v2", 2000)]); + const a = K([M("example-news", "v1", 100), M("example-live", "v2", 2000)]); assert.match(a, /^[0-9a-f]{16}$/); - assert.equal(ideaKey([M("example-live", "v2", 2001), M("example-news", "v1", 99)]), a); - assert.notEqual(ideaKey([M("example-news", "v1", 100), M("example-live", "v2", 2010)]), a); - assert.notEqual(ideaKey([M("example-news", "v1", 100), M("example-live", "v2", 2000), M("example-news", "v3", 5)]), a); + assert.equal(K([M("example-live", "v2", 2001), M("example-news", "v1", 99)]), a); + assert.notEqual(K([M("example-news", "v1", 100), M("example-live", "v2", 2010)]), a); + assert.notEqual(K([M("example-news", "v1", 100), M("example-live", "v2", 2000), M("example-news", "v3", 5)]), a); }); test("the store is a dot path under the corpus, and ids are checked before any path is made", async () => { @@ -56,8 +64,8 @@ test("the store is a dot path under the corpus, and ids are checked before any p test("a verdict is set atomically, keeps the note it had, and two at once both land", async () => { const p = await corpus(); try { - const k1 = ideaKey([M("example-news", "v1", 10), M("example-news", "v2", 20)]); - const k2 = ideaKey([M("example-news", "v3", 10), M("example-news", "v4", 20)]); + const k1 = K([M("example-news", "v1", 10), M("example-news", "v2", 20)]); + const k2 = K([M("example-news", "v3", 10), M("example-news", "v4", 20)]); const now = new Date("2026-11-11T12:00:00Z"); await setLookoutVerdict(p, "weekly", { key: k1, verdict: "maybe", note: " check the date ", now }); const made = await setLookoutVerdict(p, "weekly", { key: k1, verdict: "make", project: "shorts-2026-11/x", now }); @@ -83,7 +91,7 @@ test("a verdict is set atomically, keeps the note it had, and two at once both l }); test("a hand-damaged verdicts file reads as what is valid in it", async () => { - const k = ideaKey([M("a", "b", 0)]); + const k = K([M("a", "b", 0)]); assert.deepEqual( sanitizeLookoutVerdicts({ ideas: { [k]: { verdict: "make", at: "x" }, bad: { verdict: "make", at: "x" }, [k.replace(/^./, "f")]: { verdict: "meh", at: "x" } } }), { version: 1, ideas: { [k]: { verdict: "make", at: "x" } } }, @@ -101,7 +109,8 @@ test("a hand-damaged verdicts file reads as what is valid in it", async () => { } }); -function idea(key: string): LookoutIdea { +function idea(moments: Mo[]): LookoutIdea { + const key = K(moments); return { id: key.slice(0, 6), key, @@ -112,7 +121,7 @@ function idea(key: string): LookoutIdea { estimatedLengthSec: 60, confidence: "high", confidenceWhy: "c", - moments: [], + moments: moments.map((m) => ({ ...m, date: "2026-11-10", end: m.start + 10, quote: "q" })), caveats: [], sensitive: false, }; @@ -145,10 +154,11 @@ test("runs: listed newest first, the latest summarised, unruled ideas counted, s verdicts: { make: 0, maybe: 0, no: 0 }, }); assert.equal(await measuredSecondsPerCall(p, "weekly"), null); - const k1 = ideaKey([M("a", "b", 0), M("a", "c", 0)]); - const k2 = ideaKey([M("a", "d", 0), M("a", "e", 0)]); - await writeLookoutRun(p, run("20261110T120000Z-aaaa", [idea(k1)], 100, 400)); - await writeLookoutRun(p, run("20261111T120000Z-bbbb", [idea(k1), idea(k2)], 50, 100)); + const m1 = [M("a", "b", 0), M("a", "c", 0)]; + const m2 = [M("a", "d", 0), M("a", "e", 0)]; + const k1 = K(m1); + await writeLookoutRun(p, run("20261110T120000Z-aaaa", [idea(m1)], 100, 400)); + await writeLookoutRun(p, run("20261111T120000Z-bbbb", [idea(m1), idea(m2)], 50, 100)); await setLookoutVerdict(p, "weekly", { key: k1, verdict: "no" }); assert.deepEqual(await listLookoutRunIds(p, "weekly"), ["20261111T120000Z-bbbb", "20261110T120000Z-aaaa"]); const r = await lookoutReadout(p, "weekly"); @@ -165,3 +175,26 @@ test("runs: listed newest first, the latest summarised, unruled ideas counted, s await rm(p.transcriptsDir, { recursive: true, force: true }); } }); + +test("no citation, no key: a moment-less idea has none, and a stored one is not surfaced, counted or ruled", async () => { + assert.equal(ideaKey([]), null); + // Two moment-less ideas would otherwise share one key (the empty list's + // hash) — and one verdict, and the de-duplication would fold them. + const cited = idea([M("a", "b", 0), M("a", "c", 30)]); + const uncited: LookoutIdea = { ...cited, id: "bare", key: "FAKE-TEST-VALUE", moments: [] }; + const forged: LookoutIdea = { ...cited, id: "forged", key: "FAKE-TEST-VALUE" }; + assert.deepEqual( + surfacedIdeas({ ideas: [cited, uncited, forged] }).map((i) => i.id), + [cited.id], + "an idea with no moment, and one whose key is not its moments', are not findings", + ); + const p = await corpus(); + try { + await writeLookoutRun(p, run("20261111T120000Z-dddd", [cited, uncited, forged])); + const r = await lookoutReadout(p, "weekly"); + assert.equal(r.lastRun?.ideas, 1); + assert.equal(r.unruled, 1); + } finally { + await rm(p.transcriptsDir, { recursive: true, force: true }); + } +}); diff --git a/common/lib/lookoutStore.ts b/common/lib/lookoutStore.ts @@ -115,12 +115,31 @@ const grain = (s: number) => Math.round(s / 5) * 5; * rounded to 5 s). The same moments in any order give the same key; a moment * nudged by a second or two gives the same key; a moment added or removed * gives another. + * + * NO CITATION, NO KEY: an idea with no moment answers null. Every moment-less + * idea would hash the same empty list, so one verdict on one of them would + * rule them all, and the run's de-duplication by key would fold distinct + * ideas into one. Such an idea is not a finding: a run drops it (counted), + * and a stored one is not surfaced (`surfacedIdeas`). */ -export function ideaKey(moments: readonly Pick<LookoutMoment, "channel" | "video" | "start">[]): string { +export function ideaKey(moments: readonly Pick<LookoutMoment, "channel" | "video" | "start">[]): string | null { const parts = [...new Set(moments.map((m) => `${m.channel}/${m.video}@${grain(m.start)}`))].sort(); + if (parts.length === 0) return null; return createHash("sha1").update(parts.join("\n")).digest("hex").slice(0, 16); } +/** + * The ideas of a stored run that are findings: each cites at least one moment + * and carries the key its moments give. A hand-edited or older run's idea + * with no moment, or a key that is not its moments', is left out — never + * shown, counted or ruled. + */ +export function surfacedIdeas(run: Pick<LookoutRun, "ideas">): LookoutIdea[] { + return run.ideas.filter( + (i) => isObject(i) && Array.isArray(i.moments) && i.moments.length > 0 && isIdeaKey(i.key) && ideaKey(i.moments) === i.key, + ); +} + // ─── Runs ─── export type LookoutRunStatus = "done" | "partial" | "failed"; @@ -212,7 +231,7 @@ export function summarizeLookoutRun(run: LookoutRun): LookoutRunSummary { model: run.model, calls: run.calls, seconds: run.seconds, - ideas: run.ideas.length, + ideas: surfacedIdeas(run).length, }; } @@ -361,7 +380,7 @@ export async function lookoutReadout(paths: Pick<Paths, "transcriptsDir">, id: s latest = await readLookoutRun(paths, id, runId); if (latest) break; } - const unruled = latest ? latest.ideas.filter((i) => !verdicts.ideas[i.key]).length : 0; + const unruled = latest ? surfacedIdeas(latest).filter((i) => !verdicts.ideas[i.key]).length : 0; return { lastRun: latest ? summarizeLookoutRun(latest) : null, runs: runIds.length,