CaseFlow Automation

PII Masking Architecture

Technical Summary for DPIA / Compliance Reference
PlatformCaseFlow Automation (caseflowautomation.co.uk)
Last Updated30 June 2026
ClassificationInternal - Compliance
Document PurposeDPIA / Compliance Reference

1. Overview

CaseFlow Automation processes insurer correspondence and case details using AI to generate legal analysis and draft responses. To support UK GDPR data-minimisation principles (Article 5(1)(c)), the platform implements a three-layer privacy architecture:

LayerLocationPurpose
Layer 1 - Local ProcessingUser's browserText-based PDFs are extracted entirely client-side; the file never reaches our servers. A server-side fallback is used only when a PDF is a scanned image (no embedded text), in which case the file is uploaded to a private temporary bucket for OCR and removed immediately after processing.
Layer 2 - PII Masking Gateway (in transit)Server-side (Edge Function)Regex-based pattern matching detects and replaces personal identifiers with neutral placeholders before text is transmitted to the AI model.
Layer 3 - At-Rest MaskingDatabase (triggers)The same masking patterns are applied via PostgreSQL triggers (public.mask_pii()) on insert/update to correspondence, ai_replies, case_advice, preemptive_letters, and taxi_risk_assessments. Saved history therefore contains placeholders, not raw identifiers, mitigating impact in the event of unauthorised database access.

Temporary File Retention

The temp-pdfs storage bucket is private. Files are deleted by the application immediately after OCR completes. A scheduled pg_cron job (purge-temp-pdfs-daily, 03:00 UTC) acts as a safety net, removing any object older than 24 hours. In typical operation the bucket is empty.

2. Layer 1 - Local Processing and the OCR Path

2.1 Local-extraction path (typed documents)

2.2 Document-upload / OCR path (scanned PDFs and images)

3. Layer 2 - PII Masking Gateway

3.1 Architecture

The masking gateway (piiRedactor.ts) is a shared server-side module invoked by every AI-facing Edge Function before any text is sent to the language model. It operates as a mandatory processing step on the server.

3.2 Data Categories Detected

The gateway attempts to detect and mask the following UK-specific identifier types:

#CategoryPlaceholderExample Patterns
1Email addresses[EMAIL_REDACTED]Standard email format
2National Insurance Numbers[NINO_REDACTED]AB 12 34 56 C
3UK Driving Licence Numbers[DRIVING_LICENCE_REDACTED]16-character DVLA format
4Vehicle Registration Marks[VRM_REDACTED]Current, prefix, suffix, dateless - requires β‰₯2 digits to avoid car model false positives
5UK PostcodesNot masked (preserved)Deliberately preserved because postcodes are material to basic-hire-rate and locality arguments. A separate output-side scrubber removes any postcode the AI introduces that was not present in the original input.
6UK Phone Numbers[PHONE_REDACTED]Landline, mobile, +44 international
7Dates of Birth[DOB_REDACTED]Contextual only (preceded by DOB/born)
8Bank Account Numbers[ACCOUNT_REDACTED]Account number with contextual prefix
9Policy / Claim References[REF_REDACTED]Markers include POL, CLM, REF, CLAIM, POLICY, FILE, BHR, CHR, CHO, TPI, plus structured formats such as 24-ABC-123456 and ABC/2025/12345
10Street Addresses[ADDRESS_REDACTED]House number + street name (conservative)
11Person Names[NAME_REDACTED]Titled names (Mr/Mrs/Ms/Miss/Dr/Prof + surname) are always masked. Bare/untitled names are masked only in high-precision contexts: field labels (e.g. "Claimant:", "Driver:", "Insured:"), salutations ("Dear ..."), sign-offs, and "Re <name>" in email subjects. Guards protect case citations and company names. A bare first name and surname in free prose with none of those cues may not be caught.

3.3 Processing Order

Patterns are applied in a specific sequence (most specific first) to prevent partial matches or false positives:

1. Emails β†’ 2. NINOs β†’ 3. Driving Licences β†’ 4. VRMs β†’ 5. Phone Numbers β†’ 6. DOBs β†’ 7. Bank Details β†’ 8. References β†’ 9. Addresses β†’ 10. Titled Names β†’ 11. Bare Personal Names. UK postcodes are deliberately not part of the masking sequence; they are preserved for locality/BHR analysis, and a separate output-side scrubber removes any postcode the AI introduces that was not present in the original input.

3.4 Logging

Each invocation logs the count and types of items masked (e.g., PII redaction: 3 items redacted (types: EMAIL, VRM, REF)). No original PII values are logged.

4. Integration Points

The PII Masking Gateway is invoked in the following backend functions:

FunctionPurpose
analyze-correspondenceInsurer correspondence analysis
generate-replyAI-generated reply drafting
case-adviceLive case strategic guidance
generate-argument-letterArgument letter generation
extract-loss-of-use-timelineLoss-of-Use Chronology extraction (in-memory only, nothing stored)

All text reaching the model for analysis passes through the gateway. "No bypass path" means exactly that: every analysis, drafting and advice call is preceded by masking, and this includes text produced by OCR of a scanned page, which is masked on return before it is used for analysis. The only text the model sees unmasked is the raw image of a scanned page it is asked to read, which it processes under zero-retention terms.

5. GTA vs Case Law Data Separation

As of 13 February 2026, the platform enforces strict separation between GTA protocol data and case law:

Claim TypeKnowledge Provided to AICase Law Included?
GTA Claim (ticked)GTA sections, hire rate tables, EV-to-ICE mappings onlyNo - case law is explicitly excluded
Non-GTA Claim (unticked)Case law databaseYes - full case law knowledge base

This ensures GTA claims receive advice grounded solely in GTA protocol and rate tables, while non-GTA claims receive case law citations. The separation prevents cross-contamination of authority sources and reduces hallucination risk.

EV Handling Under GTA

Electric vehicles not listed in standard GTA rate tables are mapped to ICE equivalent groups with mandatory explanatory notes. Accident dates are preserved as non-identifying data.

6. Anti-Hallucination Controls

ControlImplementation
Low Temperaturetemperature: 0.3 on all AI calls
Explicit System Prompts"Do NOT invent case names", "Only cite cases from the provided knowledge base"
Knowledge IsolationGTA claims receive no case law; non-GTA claims receive no GTA rate data
Final Output Scrubbing (Layer 3)Active — citationScrubber.ts runs on all AI outputs. Strips fabricated or unverified case citations while preserving legitimate legal references. Applied across all six edge functions (Analysis, Reply, Case Advice, Liability Assessment, Argument Letter, Pre-Emptive Letter).

7. Limitations & Honest Framing

The platform UI and Privacy Policy use deliberately honest language:

Known Limitations

8. Data Flow Summary

User's Browser Server (Edge Function) AI Model β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ PDF β†’ Local β”‚ ── user submits ─► β”‚ Receive text β”‚ β”‚ β”‚ β”‚ text extract β”‚ text for AI β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ (no upload) β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ masked β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ PII Masking β”‚ β”œβ”€β”€text──►│ LLM β”‚ β”‚ β”‚ β”‚ β”‚ Gateway β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ (piiRedactor.ts) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

9. Regulatory Alignment

PrincipleImplementation
Data Minimisation (Art. 5(1)(c))Three-layer approach: local processing, in-transit masking gateway, and at-rest masking
Privacy by Design (Art. 25)Masking gateway is mandatory in the processing pipeline; no bypass
Transparency (Art. 13/14)UI wording and Privacy Policy describe the approach honestly
Accountability (Art. 5(2))Source code is auditable; server logs record masking activity without storing PII

10. Recommendations for Further Hardening