// The research CASE's shapes (lib/research/cases.mjs is the store), shared by // the routes, the board page and P5's Create. Types only: safe for a client // component. /** A case's scope: the R1 source handle and filters, and the query that found its quotes. */ export type CaseScope = { source: string; channels?: string[]; dateFrom?: string; dateTo?: string; states?: string[]; mediaType?: "video" | "livestream"; posts?: boolean; query?: string; regex?: boolean; }; /** Where a quote was read: enough to cite it, re-read it, and clip it. */ export type QuoteCite = { kind: "video" | "post"; /** The R1 source handle it was read through. */ source: string; /** The channel's slug (the corpus's directory name). */ channel: string; /** The source's channel key (a hub's is `:`). */ channelKey?: string; channelName?: string; site?: string; /** The recording's id in the archive (Rumble: the embed id). */ video: string; /** The editor's directory id when it is not `video` (Rumble: the URL slug). */ dirVideo?: string; title?: string; /** YYYYMMDD. */ date?: string; /** The first cue's start, seconds. */ t: number; /** The last cue's end, seconds. */ end: number; clock?: string; /** transcript | captions | unknown | post. */ track?: string; /** An alternate caption track's id (`en`, `en-GB`, …) when not the primary. */ trackId?: string; /** The moment link (a viewer link on the source's origin), or null. */ url: string | null; /** The citation in the house format, as R1's Copy citation writes it. */ citation?: string; duration?: number; author?: string; localOnly?: boolean; }; export type VerifyState = "ok" | "drifted" | "missing" | "unreadable"; /** What the last re-verify read at a quote's cite. Never applied to the quote by itself. */ export type QuoteVerify = { status: VerifyState; at: string; /** The words the transcript has there now (drifted). */ now?: string; /** Where those words start now, seconds. */ nowAt?: number; message?: string; /** The record has both `en` and `en-orig` and they differ at the cite. */ enOrig?: { text: string; quoted: string; other: string }; }; export type Quote = { /** `q`. */ id: string; /** `s`, or null: Unsorted. */ section: string | null; /** The words, verbatim, as the transcript had them when pinned. */ text: string; cite: QuoteCite; /** Ours: what the quote shows, in plain words. */ claim: string; /** Ours. */ note: string; /** False until the operator checked who is speaking (co-hosts, panels). */ speakerChecked: boolean; pinnedAt: string; query?: string; verify?: QuoteVerify; /** Earlier words, kept when the operator took the current ones. */ history?: { text: string; at: string; why: string }[]; /** R3: a finding an agent's sweep kept ("Open as a board" on a run), not a person's pin; R6: a line a triage flagged. */ by?: "agent" | "triage"; }; export type CaseSection = { id: string; title: string }; /** A group of the board, in order (lib/research/board.mjs groupsOf): a section, or Unsorted (id null). */ export type BoardGroup = { id: string | null; title: string; quotes: Quote[] }; /** The search a case's quotes were pinned from: its counts and its reading log. */ export type CaseSearch = { session: string; query: string; total: number; complete: boolean; notReached: string[]; sourceLabel?: string; at: string; }; export type CaseHandoff = { to: "article" | "video"; href: string; at: string; what?: string }; export type CaseDoc = { format: "umtool-research-case"; version: 1; id: string; title: string; scope: CaseScope; search: CaseSearch | null; sessions: string[]; sections: CaseSection[]; quotes: Quote[]; notes: string; handoffs: CaseHandoff[]; /** R3: the agent run this board was opened from (`/research/runs/
/`). */ run?: { article: string; n: number; at: string }; /** R6: the triage run this board was made from (`/series//triage/`). */ triage?: { schedule: string; k: number; at: string }; counters: { quote: number; section: number }; createdAt: string; updatedAt: string; }; /** GET /api/research/cases: one row. */ export type CaseSummary = { id: string; /** `c:`. */ piece: string; title: string; quotes: number; sections: number; updatedAt: string; scope: CaseScope; /** Quotes the last re-verify found drifted or missing. */ drifted: number; /** A case.json that cannot be read: listed, never overwritten. */ error?: string; }; /** GET /api/research/cases/: the case and what the board shows beside it. */ export type CaseView = { case: CaseDoc; piece: string; /** Relative to REPORTS_ROOT. */ stored: string; /** The source's label, when it is still offered. */ sourceLabel: string | null; /** The reading log of the case's search: read and skipped of `search.total`. */ reading: { read: number; skipped: number; error?: string } | null; /** Quotes from a local-only channel: no hand-off may target a public site. */ localOnly: number; }; export type ArticlePlan = { to: "article"; /** The article the sweep writes (the case id, unless the confirm names another). */ article: string; articleExists: boolean; question: string; channels: string[]; dateFrom?: string; dateTo?: string; /** A local sweep's reading set (D2): the top `recordings` by rarity × hits, plus one per year-quarter a rare term hits (at most `spreadMax`); `minutes`: the estimate on this machine's measured seconds a call. */ reading?: { recordings: number; spreadMax: number; minutes?: number }; source: string; model: string | null; /** The API agent's extractor (the policy's), when the sweep runs on Claude. */ extractor?: string | null; route: string | null; capUsd: number | null; /** False: R3's "Run a sweep on this scope" -- no seed, the policy's sweep route. */ seeded?: boolean; /** The board as cited markdown: the sweep's report starts from it (seed.md). Empty when not seeded. */ seed: { chars: number; quotes: number }; spends: true; refusals: string[]; warnings: string[]; policyError?: string; }; export type VideoPlan = { to: "video"; /** The project folder under REPORTS_ROOT. */ slug: string; title: string; siteOrigin: string; clips: { id: string; channel: string; video: string; start: number; end: number; quote: string }[]; writes: string; spends: false; refusals: string[]; warnings: string[]; }; export type HandoffPlan = ArticlePlan | VideoPlan;