The model documents invariants ("at most one approved link per token") as the caller's responsibility with no runtime enforcement. The WebView silently repairs violations (e.g. findLast over multi-approved links, filtering dangling analysisIds), which masks corruption in production.
- Add a
validateTextAnalysis(analysis) pass (extend type-guards.ts) that reports: multiple approved links per target, links whose analysisId has no payload, payloads referenced by zero links, and invalid enum values (Confidence, AssignmentStatus are currently unchecked).
- Run it on draft/project load and before save; log violations with counts (no user-facing noise), keeping the existing tolerant rendering behavior.
- Route all approved-status mutations through the existing slice reducers (already effectively the case) and document that as the enforcement point.
Size: S
The model documents invariants ("at most one
approvedlink per token") as the caller's responsibility with no runtime enforcement. The WebView silently repairs violations (e.g.findLastover multi-approved links, filtering danglinganalysisIds), which masks corruption in production.validateTextAnalysis(analysis)pass (extendtype-guards.ts) that reports: multiple approved links per target, links whoseanalysisIdhas no payload, payloads referenced by zero links, and invalid enum values (Confidence,AssignmentStatusare currently unchecked).Size: S