## Source document recovery
ClaimFlow AI stores source documents differently based on source type:
- `PDF`: stored as a local file during development and referenced through `Document.storagePath`
- `EMAIL_TEXT`: stored directly in Postgres as `Document.contentText`
Soft delete does not remove the original source content. It only sets `Document.deletedAt` and hides the document from active dashboard/review queries.
Because email text is stored in `Document.contentText`, re-uploading the same email text can restore the previous document and reuse the existing extraction/validation run without calling Gemini again.
Testing
1. Submit email text
2. Open the run detail page
3. Confirm Source document card appears
4. Confirm original email text is visible
5. Click Copy email text
6. Soft delete the document
7. Confirm it disappears from dashboard
8. Submit same email text again
9. Confirm "Email text restored..." message
10. Open restored run
11. Confirm original email text is still visible
1. Source document Card Appears

Testing Email Text
Subject: Motor Insurance Claim - Policy AUTO-2026-5512 - Accident on Bengaluru Outer Ring Road
Hello Claims Team,
I would like to file a motor insurance claim for my vehicle.
Policy Number: AUTO-2026-5512
Claim Number: CLM-2026-1003
Insured Name: Rohan Verma
Claimant Name: Rohan Verma
Contact Email: [email protected]
Contact Phone: +91-9876501234
Vehicle Registration Number: KA05MN7890
Vehicle Make: Honda
Vehicle Model: City
Vehicle Year: 2020
Date of Accident: 2026-04-21
Time of Accident: 20:45
Place of Accident: Bengaluru Outer Ring Road
Type of Loss: Third Party
Description:
My car collided with another vehicle at a traffic signal on Bengaluru Outer Ring Road. The third-party vehicle had visible rear-side damage, and my front bumper and bonnet were also damaged.
Damaged Parts:
- Front bumper
- Bonnet
- Right headlight
Estimated Repair Cost: INR 68000
Police Report Filed: No
Repair Estimate Attached: Yes
Damage Photo Attached: Yes
Police Report Attached: No
Please let me know if any additional documents are required.
Regards,
Rohan Verma
2. I deleted the email and then submitted same email .
- If contentHash is not present → will create a new document. Since document is verified by
sourceType + contentHash
- Firstly content hash was not present for EMAIL_TEXT so my DB shows two documents with same
contentText

- If document ( here with same sourceType and contentHash ) exist is restores it.

3. Timeline shows that document ( EMAIL_TEXT ) was soft deleted

Same was also true for PDF