// A CASE'S EVIDENCE, as the export prints it (release 38 lane C, stage 10). `evidence.json` (CaseEvidence[]) is // written by umtool's evidence stage (umtool/lib/research/case-evidence.ts); the export (casePipelineRun.ts // runExport → casePipeline.ts reportMarkdown) lists it in an Evidence section with this. Pure, client-safe; the // lines are the house markdown reportHtml reads (links only, no emphasis). import { evidenceLabel, forumAttachmentLabel, isEvidenceKind, isEvidenceState, type CaseEvidence } from "./caseTypes"; const clean = (s: string) => String(s ?? "").replace(/\s+/g, " ").trim(); const iso = (ts?: string) => (ts && /^\d{8}/.test(ts) ? `${ts.slice(0, 4)}-${ts.slice(4, 6)}-${ts.slice(6, 8)}` : ""); /** The rows of an evidence.json value that are rows (anything else dropped). */ export function evidenceRows(raw: unknown): CaseEvidence[] { return (Array.isArray(raw) ? raw : []).filter( (r): r is CaseEvidence => !!r && typeof r === "object" && typeof r.id === "string" && isEvidenceKind(r.kind) && isEvidenceState(r.state) && typeof r.url === "string", ); } /** One row as a report line: its label, its link, what it backs. */ export function evidenceLine(r: CaseEvidence): string { const backs = r.findings?.length ? ` (for ${r.findings.join(", ")})` : ""; if (r.kind === "forum-attachment") { const files = r.files?.length ? `, ${r.files.length} ${r.files.length === 1 ? "file" : "files"} captured` : r.state === "captured" ? "" : `, ${r.state}`; return `- ${forumAttachmentLabel(r.position, r.post)} — [the post](${r.url})${files}${backs}`; } if (r.state === "excluded") return `- ${evidenceLabel(r)} — ${r.url}${r.at ? `, asked for ${iso(r.at)}` : ""}${backs}`; if (r.state === "captured" && r.captureTs) return `- ${evidenceLabel(r)} — [${r.url}](https://web.archive.org/web/${r.captureTs}/${r.url})${backs}`; const what = r.state === "failed" ? "Wayback capture failed" : "Wayback capture not taken yet"; return `- ${what} — ${r.url}${r.at ? `, for ${iso(r.at)}` : ""}${r.message ? `: ${clean(r.message)}` : ""}${backs}`; } /** The Evidence section (none when there is no evidence). */ export function evidenceSection(rows: readonly CaseEvidence[]): string[] { if (!rows.length) return []; return ["## Evidence", "", "Captures and forum attachments the case took. A forum attachment is unverified: looked at, not vouched for.", "", ...rows.map(evidenceLine), ""]; }