Minnesota med-mal records platform: five phases from research validation to chronology view
rmerk/mike spent a single day on May 11, 2026 shipping a vertical slice that turns Mike into a Minnesota-jurisdiction-aware med-mal records pipeline. The work spans research validation, project templates, a ~6,900-LOC extraction pipeline, and a citation-anchored chronology view - all grounded in specific MN statutes and Supreme Court authority.
Phase 0 (research validation) produced twenty substantive deltas across two plan documents before a line of code was written. The red-flag rules were five-of-five breach-only; there was no causation rule, no § 145.64 peer-review hard-refuse policy, no Plutshack supports_element tagging. The subfolder taxonomy needed four more folders. The extraction plan also inherited two factual errors about MN law: § 145.682(4)'s expert-affidavit clock runs from Rule 26.04(a) discovery commencement, and the prima facie test is Plutshack's three-element formulation, not a five-element informed-consent test. Phase 0 caught all of that before Phase 2's multi-day build.
Phase 1 adds one nullable column (projects.template_id), a code-only template registry, and a med-mal-case template that scaffolds twelve folders on project create. The POST /projects handler inserts subfolders in two passes, resolving parent references by array index, with CASCADE-on-failure atomicity. The frontend gets a template picker and an eleven-schema recommended-reviews strip covering chronology, bills-and-EOBs, MAR, transfusion log, vitals, labs, imaging index, red-flag scan, provider-defendant map, causation-chain, and expert-opinions (§ 145.682). Migration 0001 ran directly to prod because Supabase's free plan returns PaymentRequiredException on branch creation; that constraint is documented in CLAUDE.md and applies to any fork on a free-tier org.
Phase 2 is the main extraction pipeline: migrations 0002-0005, per-page Claude JSON extraction with raster/vision fallback for empty text layers, and a § 145.64 compliance gate in peerReviewVisionPrescan.ts that halts before any event extraction if peer-review markers appear on scanned pages. No bypass env var - the author is explicit. Six red-flag rules ship in redFlags.ts, each tagged to a Plutshack supports_element (duty / breach / causation / damages). Optional EXTRACTION_ASYNC_MODE=queue for serverless deployments. Vitest + Supertest cover 403/404/409 and malformed-PDF paths.
Phase 3 adds /projects/[id]/timeline/[docId] reading the Phase 2 event log via the existing events endpoint. Zero backend changes, zero LLM calls. The earlier Rail B plan - populate tabular cells from event SQL - was ruled out: the tabular_cells table is keyed one-per-doc, so per-encounter data can't be represented without collapsing it into a single cell and losing sort, filter, and per-row inspection. MAR, vitals, and labs are deferred to Phase 3.5 as separate Timeline-pattern surfaces.
Import calculus. The full stack is MN med-mal specific; red-flag rules and extraction defenses cite statutes by number. Porting to another jurisdiction means rewriting the rule library and column prompts. But three pieces port cleanly: the Phase 1 templates infrastructure (project templates + recommended-tabular-review registry) is domain-agnostic; the Phase 2 raster/vision fallback for scanned pages is reusable for any structured-extraction pipeline; the Phase 3 Timeline view works for any event-log source. Migration 0001 ran outside the normal branch flow and should be re-run cleanly in a fresh environment. Migration 0005 needs re-applying per environment with an unindexed-FK advisor check.
Spotted something wrong? Or know the PR text has fresher detail than the writeup above?