LegalDocs-Assist, operated by CaseFlow Automation Ltd

PII Masking Architecture

Technical Summary for DPIA / Compliance Reference
PlatformLegalDocs-Assist (legaldocs-assist.co.uk)
OperatorCaseFlow Automation Ltd, registered with the ICO (ZC013423), operating under UK GDPR
Last Updated24 July 2026
ClassificationInternal, Compliance
Document PurposeDPIA / Compliance Reference

1. Overview

LegalDocs-Assist 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 and integrity architecture:

LayerLocationPurpose
Layer 1, Text handling of source documentsUser's browser and serverText‑based PDFs are read in the user's browser and only the extracted text is transmitted. Word and plain‑text documents submitted to the document slots are reduced to text on the server and masked before any AI processing. Scanned documents, photographs, audio and the Medical Pagination tool are the documented exceptions (see Section 2).
Layer 2, PII Masking GatewayServer-side (Edge Function)Regex-based pattern matching attempts to detect and replace personal identifiers with neutral placeholders before text is transmitted to the AI model. This layer is designed to reduce, not eliminate, Personal Data in prompts sent to the AI model.
Layer 3, Citation ScrubberServer-side (Edge Function)On AI outputs, an automated post-processor (citationScrubber.ts) strips fabricated or unverified case citations while preserving legitimate references that match the 210-authority knowledge base. This is an anti-hallucination control, not a privacy control, and is included here to give a complete picture of the server-side processing pipeline.

2. Layer 1, Text handling of source documents

Text‑based PDFs are read in the user's browser using pdfjs-dist (Mozilla's PDF.js) and only the extracted text is transmitted, for the drafting tools and for the Witness Statement document slots alike. Word and plain‑text documents submitted to the document slots are reduced to text on the server and masked before any AI processing. Three documented exceptions apply where an original file does reach the server: (i) scanned or image‑only documents, briefly processed so the text can be read at all; (ii) photographs and audio recordings submitted to the document slots, which the AI reads directly because there is no text to mask first; and (iii) the Medical Pagination tool (see 2.1). All exception paths run under Zero Data Retention terms, prompts and outputs are not stored by the AI provider, and the platform's automated deletion controls apply.

2.1 Medical Pagination Exception

The Medical Pagination tool is a documented exception to browser‑side parsing. Because medical bundles are typically scanned PDFs that require server-side OCR to produce an indexed bundle, the source PDF is uploaded to encrypted storage for processing. Retention is tightly scoped:

The Medical Pagination function does not invoke the PII Masking Gateway, because the function produces a navigable bundle rather than sending free text to an AI model.

2.2 Document-Slots Extraction (July 2026)

The guided intake posts documents for structured field extraction. Text‑bearing documents pass through the masking gateway with a reversible map before the model call: the model sees neutral placeholders, and the extracted fields are restored to their real values on the server afterwards. The model never sees the unmasked text of these documents. Scanned documents, photographs and audio recordings are the exception class described above. From 24 July 2026 the gateway also masks HMRC tax identifiers (Unique Taxpayer References and PAYE references), added ahead of tax return uploads through the loss-of-profit slot.

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. Every AI‑facing function that receives text invokes the masking gateway before the model call; there is no text path that bypasses it. Inputs that arrive as scans, photographs or audio cannot be masked before reading, because masking requires text. Those paths are documented exceptions protected by Zero Data Retention terms and automated deletion, and any structured fields they produce are masked again in later drafting steps.

3.2 Data Categories Detected

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

#CategoryPlaceholderNotes
1Email addresses[EMAIL_REDACTED]Standard email format
2National Insurance Numbers[NINO_REDACTED]AB 12 34 56 C
3NHS Numbers[NHS_REDACTED]10-digit NHS numbers (grouped 3-3-4 and contextual forms), validated against the Mod-11 check digit to eliminate false positives.
4UK Driving Licence Numbers[DRIVING_LICENCE_REDACTED]16-character DVLA format
5Vehicle Registration Marks[VRM_REDACTED]Current, prefix, suffix, dateless. Requires at least two digits in the prefix to prevent false positives on car model names (e.g. X3, A3, M5).
6UK PostcodesNot masked (preserved by design)Postcodes are deliberately preserved because they are material to BHR locality arguments and to housing disrepair venue analysis. Two safeguards make this safe: (i) the AI provider operates under enterprise terms that prohibit training on inputs or outputs, and (ii) a separate postcodeScrubber.ts module operates on AI outputs to remove any postcode that did not appear in the original input, preventing fabricated locality data.
7UK Phone Numbers[PHONE_REDACTED]Landline, mobile, +44 international
8Dates of Birth[DOB_REDACTED]Only when preceded by contextual keywords (DOB, date of birth, born)
9IBANs[IBAN_REDACTED]International Bank Account Numbers, all supported country formats.
10Credit / Debit Card Numbers[CARD_REDACTED]13- to 19-digit card numbers, validated with the Luhn check to suppress false positives on long reference numbers.
11UK Sort Codes[SORTCODE_REDACTED]Six-digit sort codes (e.g. 12-34-56), only in banking context.
12Bank Account Numbers[ACCOUNT_REDACTED]Account number patterns with contextual prefix.
13Policy / Claim References[REF_REDACTED]Structured reference formats including POL, CLM, REF, CLAIM, POLICY, FILE, BHR, CHR, CHO and TPI prefixes (each requiring at least one digit in the reference), plus patterns like 24-ABC-123456 and ABC/2025/12345.
14Street Addresses[ADDRESS_REDACTED]House number plus street name (conservative matching).
15Person Names[NAME_REDACTED]Titled names (Mr / Mrs / Ms / Miss / Dr / Prof plus surname) are always masked. Bare / untitled names are masked in high-precision contexts: structured field labels (e.g. Claimant:, Driver:, Insured:, Witness:), letter salutations (Dear …) and sign-offs (Yours sincerely, …). An aggressive output-side re-scrub additionally catches bare First-Last name pairs anywhere in AI outputs, with guards that protect case citations (X v Y) and known organisation names. Witness Statement Generator carve-out: the Witness Statement Generator deliberately skips masking of names, vehicle registration marks and reference numbers on its inputs, because a statement must attribute evidence and identifiers verbatim. All other categories are masked, and the system-prompt overlays pass through the same redactor as the user prompt.
16UTR (Unique Taxpayer Reference)[UTR_REDACTED]HMRC Unique Taxpayer References. Masked whenever a UTR label is present (solid 10-digit or 5-5 spaced form, optional trailing K). Bare 5-5 spaced pairs are masked only when they pass the HMRC check-digit test, so arbitrary number pairs are not eaten. Bare unspaced 10-digit numbers are never masked as UTRs, avoiding collision with NHS and phone numbers.
17PAYE References[PAYE_REF_REDACTED]Employer PAYE references (three-digit tax office, slash, alphanumeric tail; letters required after the slash in standalone form so date-like strings such as 100/2024 never match), PAYE labels in context, and 13-character Accounts Office references (e.g. 123PA00045678).

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. NHS Numbers (Mod-11 validated) β†’ 4. UTR (check-digit validated) β†’ 5. PAYE References β†’ 6. Driving Licences β†’ 7. VRMs β†’ Postcodes preserved (see 3.2) β†’ 8. Phone Numbers β†’ 9. DOBs β†’ 10. IBANs β†’ 11. Card Numbers (Luhn-checked) β†’ 12. Sort Codes β†’ 13. Bank Account Numbers β†’ 14. References β†’ 15. Addresses β†’ 16. Titled Names β†’ 17. Bare Names in high-precision contexts (field labels, salutations, sign-offs). An aggressive output-side re-scrub then runs on AI responses to catch bare First-Last name pairs that slipped past the input gateway, with guards for case citations and company names.

3.4 Logging

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

4. Integration Points

The PII Masking Gateway is invoked in the following backend functions. Each function is listed with the user-facing path that triggers it, so a reviewer can map the architectural claim onto the deployed product surface.

Backend FunctionUser-Facing Path
analyze-correspondenceInsurer Letter Analyser on the Dashboard.
generate-replyAI Reply Generator, reached from inside the Insurer Letter Analyser once an incoming letter has been analysed.
generate-witness-statementClaimant Witness Statement wizard, and the Defence Analysis sub-step invoked from within the same wizard.
liability-assessmentLiability Assessment tool.
generate-argument-letterArgument letter drafting, reached from (a) the Liability Assessment results panel via the Draft Argument dialog, and (b) the History page's saved Case Advice records.
reassess-impecuniosityImpecuniosity Assessment wizard, when assessment inputs are re-scored after evidence is added.
analyze-bank-statementBank statement upload step inside the Impecuniosity Assessment wizard.
build-disrepair-chronologyHousing Disrepair Chronology tool.
action-checklistAction Checklist, reached from the Insurer Letter Analyser results.
pii-checkPII Check tool, reached from the Insurer Letter Analyser results.

Every AI‑facing function that receives text invokes the masking gateway before the model call; there is no text path that bypasses it. Inputs that arrive as scans, photographs or audio cannot be masked before reading, because masking requires text. Those paths are documented exceptions protected by Zero Data Retention terms and automated deletion, and any structured fields they produce are masked again in later drafting steps.

5. GTA vs Case Law Data Separation

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 database (210 UK authorities)Yes, 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 AI calls where the model parameter is exposed.
Explicit System PromptsInstructions such as "Do not invent case names" and "Only cite cases from the provided knowledge base" are issued in every system prompt.
Knowledge IsolationGTA claims receive no case law; non-GTA claims receive no GTA rate data.
Final Output Scrubbing (Layer 3)The citationScrubber.ts module strips fabricated or unverified case citations while preserving legitimate legal references. It is applied to the AI outputs of analyze-correspondence, generate-reply, generate-argument-letter, and liability-assessment.
Postcode Output ScrubbingThe postcodeScrubber.ts module checks AI outputs in analyze-correspondence and generate-reply against postcodes that actually appeared in the input. Any postcode not present in the input is removed, preventing the model from fabricating locality references.

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 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ (text path) β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ masked β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ Layer 2: PII β”‚ β”œβ”€β”€text──►│ LLM β”‚ β”‚ β”‚ β”‚ β”‚ Masking Gateway β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ (piiRedactor.ts) β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ Layer 3: Citation β”‚ │◄─output── β”‚ β”‚ β”‚ β”‚ β”‚ Scrubber β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

9. Regulatory Alignment

PrincipleImplementation
Data Minimisation (Art. 5(1)(c))Three-layer approach: local processing, server-side masking, output scrubbing.
Privacy by Design (Art. 25)Every AI‑facing function that receives text invokes the masking gateway before the model call; scans, photos and audio are documented exceptions under Zero Data Retention.
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. Validation Evidence

The PII masking gateway has been tested against a controlled suite of dummy UK PII samples across the categories listed in Section 3.2. The test report is available for due diligence review on request. Re-validation is performed after any change to the pattern set.

11. Recommendations for Further Hardening