solidprivacy-nl commited on
Commit
da7e220
·
1 Parent(s): c98b03d

Add AI-output reinsert workflow review

Browse files
Files changed (1) hide show
  1. AI_OUTPUT_REINSERT_WORKFLOW_REVIEW.md +779 -0
AI_OUTPUT_REINSERT_WORKFLOW_REVIEW.md ADDED
@@ -0,0 +1,779 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI-output / document reinsert workflow review
2
+
3
+ Status: completed recommendation.
4
+ Workpackage: WP9 — AI-output / document reinsert workflow UX and architecture review.
5
+ Repository: `solidprivacy-nl/scrub`.
6
+ Date: 2026-06-08.
7
+
8
+ This review decides what Scrub should do next for AI-output and document-level reinsert before implementation starts.
9
+
10
+ No code, UI, export behavior, Scrub Key behavior, AI calls or cloud processing are changed by this document.
11
+
12
+ ---
13
+
14
+ ## 1. Decision summary
15
+
16
+ Pasted-text reinsert is useful and should remain available, but it is not sufficient as the final legal-document workflow.
17
+
18
+ Recommended direction:
19
+
20
+ ```text
21
+ Use a two-mode interface:
22
+
23
+ 1. Anonimiseren
24
+ 2. Originele waarden terugzetten
25
+
26
+ Keep pasted-text reinsert as the simplest path.
27
+ Add document-level reinsert in controlled phases.
28
+ Prioritize TXT and DOCX before PDF.
29
+ Do not implement full PDF reinsert yet.
30
+ Do not add AI calls.
31
+ Do not add cloud processing.
32
+ ```
33
+
34
+ The next implementation should not be a broad UI refactor or full document rehydration. It should be helper-first and test-first.
35
+
36
+ Recommended next implementation workpackage:
37
+
38
+ ```text
39
+ WP10 — v13.4 TXT/DOCX reinsert foundation helper and tests
40
+ ```
41
+
42
+ Goal of WP10:
43
+
44
+ ```text
45
+ Prepare document-level reinsert without changing UI yet:
46
+ - add pure TXT reinsert input/output helper behavior;
47
+ - add a pure DOCX placeholder replacement helper design/implementation if feasible;
48
+ - add synthetic tests;
49
+ - keep PDF out of scope;
50
+ - keep AI/cloud out of scope;
51
+ - keep export semantics unchanged.
52
+ ```
53
+
54
+ ---
55
+
56
+ ## 2. Current baseline
57
+
58
+ The implemented v13.3 reinsert flow is:
59
+
60
+ ```text
61
+ User pastes text into the reinsert area.
62
+ User loads or provides a Scrub Key.
63
+ Scrub restores mapped placeholders locally.
64
+ User can download restored text as TXT.
65
+ ```
66
+
67
+ This is a safe baseline because it is deterministic, local and simple. It also avoids prematurely claiming that Scrub can reliably rehydrate every Word or PDF document.
68
+
69
+ However, the current baseline is only a text-level workflow. It does not yet match the natural workflow of a legal professional who receives or produces AI output as DOCX or PDF.
70
+
71
+ ---
72
+
73
+ ## 3. The first three obvious ideas challenged
74
+
75
+ ### Idea 1 — Keep only pasted-text reinsert
76
+
77
+ Question:
78
+
79
+ ```text
80
+ Is copying AI-output text from a PDF/DOCX and pasting it into Scrub good enough?
81
+ ```
82
+
83
+ Decision:
84
+
85
+ ```text
86
+ Limit this idea. Keep pasted-text reinsert, but do not treat it as the final product workflow.
87
+ ```
88
+
89
+ Critique:
90
+
91
+ - Usability burden: legal users should not have to manually copy text from a generated document, paste it into Scrub, then manually reconstruct the output.
92
+ - Loss of formatting: copy/paste loses headings, tables, numbering, footnotes, page structure and sometimes line breaks.
93
+ - Legal-document workflow friction: lawyers and legal support staff often work in Word/PDF outputs, not plain text boxes.
94
+ - Risk of incomplete copying: a user may accidentally omit a header, footer, table cell, footnote, exhibit label or final paragraph.
95
+ - Poor fit for DOCX/PDF outputs: if the AI result is returned as a Word document or PDF, a plain text reinsert result creates extra manual work and extra error risk.
96
+
97
+ Why it still matters:
98
+
99
+ Pasted text is still the safest fallback and should remain available. It is useful for quick AI chat output, email snippets, short summaries and debugging. It should be positioned as the simple path, not the only path.
100
+
101
+ ---
102
+
103
+ ### Idea 2 — Add direct PDF/DOCX reinsert immediately
104
+
105
+ Question:
106
+
107
+ ```text
108
+ Should Scrub immediately support upload of any AI-output PDF or Word document and return a de-anonymized document?
109
+ ```
110
+
111
+ Decision:
112
+
113
+ ```text
114
+ Reject as an immediate broad implementation. Split DOCX and PDF, and start with DOCX helper work only after TXT helper behavior is stable.
115
+ ```
116
+
117
+ Critique:
118
+
119
+ - DOCX is feasible, but needs careful placeholder replacement across paragraphs, runs, tables, headers and footers.
120
+ - Word placeholders may be split across runs. A naïve string replacement can miss placeholders or damage formatting.
121
+ - PDF is harder than DOCX because it may require text extraction, layout reconstruction, font handling, coordinates or OCR.
122
+ - Scanned PDFs are high-risk because text may not exist as selectable text. OCR would add accuracy, privacy and dependency questions.
123
+ - Preserving formatting and metadata hygiene is non-trivial.
124
+ - Scrub must not silently claim reliable document restoration if only text extraction/replacement is actually supported.
125
+
126
+ Recommended interpretation:
127
+
128
+ Document-level reinsert should be built, but not as one big feature. DOCX should be handled before PDF. PDF should first be investigated as text extraction only, with explicit limitation warnings.
129
+
130
+ ---
131
+
132
+ ### Idea 3 — Add one combined screen for everything
133
+
134
+ Question:
135
+
136
+ ```text
137
+ Should anonymize and de-anonymize live in the same long workflow?
138
+ ```
139
+
140
+ Decision:
141
+
142
+ ```text
143
+ Reject as the main UX direction. Use explicit modes instead.
144
+ ```
145
+
146
+ Critique:
147
+
148
+ - Cognitive overload: the existing workflow already includes upload, recognition, review, Scrub Key export/import, reinsert and downloads.
149
+ - Users may confuse scrub/anonymize with reinsert/de-anonymize.
150
+ - The reversible Scrub Key flow has different risks from anonymization. It can restore sensitive values and therefore needs its own mental model.
151
+ - Privacy state must be explicit: `opgeschoond`, `omkeerbaar met sleutel`, and `hersteld met originele waarden` are different states.
152
+ - A single-scroll Streamlit flow makes it too easy to miss where the user is in the privacy lifecycle.
153
+
154
+ Recommended interpretation:
155
+
156
+ The UI should start with a mode choice. The current single-scroll flow can continue temporarily while helpers mature, but the product direction should be two visible modes.
157
+
158
+ ---
159
+
160
+ ## 4. Model architecture perspective
161
+
162
+ ### 4.1 Scrub Key as reversible mapping layer
163
+
164
+ The Scrub Key is the reversible mapping layer between original values and placeholders.
165
+
166
+ Conceptually:
167
+
168
+ ```text
169
+ original sensitive value <-> placeholder
170
+ ```
171
+
172
+ The Scrub Key must remain a separate security object from the scrubbed document. The scrubbed document may be safe enough for AI or external processing after review. The Scrub Key can restore sensitive values and must stay local and protected.
173
+
174
+ This means Scrub Key support is pseudonymization, not full anonymization.
175
+
176
+ ### 4.2 Text-level reinsert versus document-level reinsert
177
+
178
+ Text-level reinsert is the simplest architecture:
179
+
180
+ ```text
181
+ text + Scrub Key -> restored text + audit summary
182
+ ```
183
+
184
+ It is already implemented and should remain the core deterministic operation.
185
+
186
+ Document-level reinsert should wrap the same core operation rather than create a second replacement engine.
187
+
188
+ Preferred architecture:
189
+
190
+ ```text
191
+ TXT/DOCX/PDF intake
192
+ -> extract replaceable text units
193
+ -> call deterministic placeholder replacement logic
194
+ -> rebuild output where safe
195
+ -> return restored output + audit summary
196
+ ```
197
+
198
+ The pure text replacement logic should remain authoritative.
199
+
200
+ ### 4.3 DOCX placeholder replacement helper as likely next pure helper
201
+
202
+ DOCX is the most realistic next document format because Word documents are common in legal drafting and review.
203
+
204
+ The next DOCX helper should be pure and testable. It should not start in Streamlit UI.
205
+
206
+ The helper should consider:
207
+
208
+ - paragraphs;
209
+ - tables;
210
+ - headers and footers where feasible;
211
+ - run-splitting risk;
212
+ - preservation of basic formatting;
213
+ - output as a new restored DOCX file, not overwrite input;
214
+ - audit summary: replaced placeholders, unknown placeholders, missing placeholders, unsupported areas.
215
+
216
+ A first DOCX helper may explicitly limit scope if needed. It is better to support a smaller reliable DOCX subset than claim full document fidelity.
217
+
218
+ ### 4.4 PDF reinsert as later/high-risk
219
+
220
+ PDF should not be implemented as full document reinsert yet.
221
+
222
+ Recommended PDF path:
223
+
224
+ 1. Investigate text-based PDF extraction only.
225
+ 2. Report whether placeholders are found.
226
+ 3. Provide restored plain text if reliable enough.
227
+ 4. Do not reconstruct a restored PDF until a reliability review proves that layout, metadata and scanning limitations are acceptable.
228
+
229
+ Scanned PDFs and OCR should remain out of scope until explicitly approved.
230
+
231
+ ### 4.5 Separate anonymization and reinsert pipelines
232
+
233
+ Scrub should maintain two separate pipelines:
234
+
235
+ ```text
236
+ Pipeline 1 — Anonymization
237
+ Input document/text -> recognition -> review -> scrubbed output -> Scrub Key -> export
238
+
239
+ Pipeline 2 — Reinsert
240
+ AI output / scrubbed output + Scrub Key -> restored output -> audit -> export
241
+ ```
242
+
243
+ The pipelines can share the Scrub Key model and deterministic replacement helper, but they should not share UI state in a way that silently mutates review rows or export behavior.
244
+
245
+ ### 4.6 No AI calls inside Scrub
246
+
247
+ Reinsert must not call AI.
248
+
249
+ Scrub’s role is:
250
+
251
+ ```text
252
+ prepare safe text/documents for AI
253
+ restore original values locally after AI use
254
+ ```
255
+
256
+ The AI step is external to Scrub. Scrub should never need the user’s AI provider credentials for this workflow.
257
+
258
+ ### 4.7 Local-only processing
259
+
260
+ All reinsert processing should remain local-first. No Scrub Key, original values or restored output should be sent to cloud services by Scrub.
261
+
262
+ The Hugging Face demo may still run as a hosted prototype, but the product architecture must be compatible with the long-term desktop/offline direction.
263
+
264
+ ---
265
+
266
+ ## 5. Strategic perspective
267
+
268
+ ### 5.1 Product promise
269
+
270
+ Scrub’s product promise is:
271
+
272
+ ```text
273
+ Sensitive information stays local.
274
+ The user remains in control.
275
+ The document stays readable.
276
+ ```
277
+
278
+ Document-level reinsert supports the third part of that promise. A restored plain text box is not enough when the professional deliverable is a formatted legal document.
279
+
280
+ ### 5.2 Legal-professional workflow
281
+
282
+ A realistic legal workflow is:
283
+
284
+ 1. A user uploads or pastes a source document.
285
+ 2. Scrub anonymizes/pseudonymizes the document.
286
+ 3. The user reviews replacements.
287
+ 4. The user exports scrubbed content and a Scrub Key.
288
+ 5. The user uses scrubbed content in an AI tool or external process.
289
+ 6. The user receives AI output, often as text, DOCX or PDF.
290
+ 7. The user returns to Scrub to restore original values locally.
291
+ 8. The user reviews the restored output before sharing or filing.
292
+
293
+ This makes reinsert a separate product capability, not just a small extra textbox.
294
+
295
+ ### 5.3 Positioning: Anonimiseren, Terugzetten, Controle/Audit
296
+
297
+ The product should eventually present three clear concepts:
298
+
299
+ ```text
300
+ Anonimiseren
301
+ Originele waarden terugzetten
302
+ Controle / Audit
303
+ ```
304
+
305
+ For the next UI direction, the first two should be primary modes:
306
+
307
+ ```text
308
+ 1. Anonimiseren
309
+ 2. Originele waarden terugzetten
310
+ ```
311
+
312
+ `Controle / Audit` can be a supporting layer inside both modes at first. It does not need to be a separate top-level mode yet.
313
+
314
+ ### 5.4 When document-level reinsert becomes strategically important
315
+
316
+ Document-level reinsert becomes strategically important when Scrub is used for real legal AI workflows. Professionals will expect to upload an AI-output file and receive a restored file, not manually copy/paste text and rebuild formatting.
317
+
318
+ However, trust is more important than breadth. A reliable DOCX-first workflow is strategically better than a broad but unreliable DOCX/PDF promise.
319
+
320
+ ---
321
+
322
+ ## 6. Tactical perspective — phased implementation sequence
323
+
324
+ Recommended sequence:
325
+
326
+ ### Phase A — Keep current text-paste reinsert, improve guidance
327
+
328
+ Status:
329
+
330
+ ```text
331
+ Keep as current baseline.
332
+ ```
333
+
334
+ Purpose:
335
+
336
+ - Keep simple pasted-text reinsert available.
337
+ - Clarify that this is best for plain text / AI chat output.
338
+ - Explain that restored text may again contain confidential information.
339
+
340
+ Implementation risk:
341
+
342
+ - Low.
343
+
344
+ ### Phase B — Add TXT upload/download reinsert
345
+
346
+ Status:
347
+
348
+ ```text
349
+ Recommended next small implementation layer.
350
+ ```
351
+
352
+ Purpose:
353
+
354
+ - Let users upload a `.txt` AI-output file plus a Scrub Key.
355
+ - Use the same deterministic reinsert helper.
356
+ - Return restored text as `.txt`.
357
+
358
+ Why before DOCX:
359
+
360
+ - Very testable.
361
+ - No layout complexity.
362
+ - Validates document-upload flow without changing reinsert semantics.
363
+
364
+ ### Phase C — Add DOCX reinsert helper, pure helper + tests
365
+
366
+ Status:
367
+
368
+ ```text
369
+ Recommended after TXT helper/path is stable.
370
+ ```
371
+
372
+ Purpose:
373
+
374
+ - Build a helper that opens DOCX, replaces placeholders, and writes a new restored DOCX.
375
+ - Keep it outside Streamlit at first.
376
+ - Use synthetic DOCX fixtures only.
377
+
378
+ Required guardrails:
379
+
380
+ - Do not overwrite uploaded files.
381
+ - Report unsupported document parts.
382
+ - Preserve basic formatting where feasible.
383
+ - Test paragraphs, runs, tables and simple headers/footers if feasible.
384
+ - Document limitations clearly.
385
+
386
+ ### Phase D — Add DOCX reinsert UI
387
+
388
+ Status:
389
+
390
+ ```text
391
+ Only after Phase C tests are stable.
392
+ ```
393
+
394
+ Purpose:
395
+
396
+ - Add `.docx` upload in `Originele waarden terugzetten` mode.
397
+ - Return restored `.docx` and audit summary.
398
+ - Ask for app verification because UI/download behavior changes.
399
+
400
+ ### Phase E — Investigate PDF text extraction only
401
+
402
+ Status:
403
+
404
+ ```text
405
+ Research/contract phase only.
406
+ ```
407
+
408
+ Purpose:
409
+
410
+ - Determine whether text-based PDFs with placeholders can be extracted reliably.
411
+ - Report scanned/image-only PDFs as unsupported.
412
+ - Avoid OCR initially.
413
+
414
+ ### Phase F — Consider PDF output only after reliability review
415
+
416
+ Status:
417
+
418
+ ```text
419
+ Do not build yet.
420
+ ```
421
+
422
+ Purpose:
423
+
424
+ - Only consider restored PDF output if layout, metadata, text extraction and limitation messaging are reliable enough.
425
+
426
+ ---
427
+
428
+ ## 7. Operational perspective
429
+
430
+ ### 7.1 Testability
431
+
432
+ All document-level reinsert behavior should start with pure helpers and synthetic tests.
433
+
434
+ Recommended tests:
435
+
436
+ - TXT input with placeholders;
437
+ - TXT input with unknown placeholders;
438
+ - TXT input with missing key placeholders;
439
+ - DOCX paragraph replacement;
440
+ - DOCX table replacement;
441
+ - DOCX split-run placeholder behavior;
442
+ - DOCX no-placeholder behavior;
443
+ - invalid Scrub Key behavior;
444
+ - duplicate placeholder behavior;
445
+ - no AI/cloud markers remain true/false as expected.
446
+
447
+ ### 7.2 Helper-first implementation
448
+
449
+ Do not start by editing the Streamlit UI.
450
+
451
+ Recommended order:
452
+
453
+ ```text
454
+ pure helper -> tests -> specification update -> UI wiring -> app verification
455
+ ```
456
+
457
+ This avoids fragile parallel edits to `fix_streamlit_nested_expanders.py`.
458
+
459
+ ### 7.3 Synthetic data only
460
+
461
+ Use only synthetic Dutch legal placeholders and values. Do not commit real client names, real case data, real BSNs, real addresses or real Scrub Keys.
462
+
463
+ ### 7.4 Metadata risks
464
+
465
+ Document-level reinsert can reintroduce sensitive values and can also carry document metadata.
466
+
467
+ DOCX/PDF output should eventually align with document hygiene work:
468
+
469
+ - remove or warn about metadata;
470
+ - avoid hidden content leakage;
471
+ - avoid tracked changes surprises;
472
+ - avoid comments containing sensitive values.
473
+
474
+ This review does not implement metadata cleaning. It flags the risk so future document-level work does not silently expand the product promise.
475
+
476
+ ### 7.5 Export/download semantics
477
+
478
+ Existing scrubbed TXT, CSV, DOCX and PDF downloads must not change.
479
+
480
+ Reinsert downloads should be separate from anonymized/scrubbed downloads and clearly labelled as restored output.
481
+
482
+ Suggested naming distinction:
483
+
484
+ ```text
485
+ Download opgeschoonde tekst/document
486
+ Download herstelde tekst/document
487
+ ```
488
+
489
+ ### 7.6 App verification requirements
490
+
491
+ No app verification is required for this WP9 review because no UI behavior changed.
492
+
493
+ Future UI work must request app verification when:
494
+
495
+ - mode choice is added;
496
+ - TXT upload is added;
497
+ - DOCX restored download is added;
498
+ - any export/download UI is changed.
499
+
500
+ ### 7.7 Avoiding parallel edits
501
+
502
+ Future UI work should not run in parallel with other work that edits:
503
+
504
+ - `fix_streamlit_nested_expanders.py`;
505
+ - `presidio_streamlit.py`;
506
+ - review table flow;
507
+ - export/download flow;
508
+ - shared session state.
509
+
510
+ ### 7.8 No cloud processing
511
+
512
+ Document reinsert must not introduce cloud processing. OCR, external converters or AI-based document reconstruction must not be added without explicit approval.
513
+
514
+ ### 7.9 Audit summary requirements
515
+
516
+ Every reinsert result should include an audit summary:
517
+
518
+ - file type;
519
+ - mapping item count;
520
+ - active mapping count;
521
+ - replacement count;
522
+ - unknown placeholders;
523
+ - missing placeholders;
524
+ - duplicate placeholders;
525
+ - validation issues;
526
+ - local-only status;
527
+ - AI processing status;
528
+ - cloud processing status;
529
+ - unsupported document areas if applicable.
530
+
531
+ ---
532
+
533
+ ## 8. Visual / UX perspective
534
+
535
+ ### 8.1 Interface options compared
536
+
537
+ #### Option A — Tabs
538
+
539
+ Pros:
540
+
541
+ - Simple in Streamlit.
542
+ - Clear separation between `Anonimiseren` and `Originele waarden terugzetten`.
543
+ - Lower implementation complexity than separate pages.
544
+
545
+ Cons:
546
+
547
+ - Tabs can still share too much session state if not carefully handled.
548
+ - Users may not notice mode-level warnings if tabs are visually too light.
549
+
550
+ Assessment:
551
+
552
+ ```text
553
+ Good near-term direction.
554
+ ```
555
+
556
+ #### Option B — Landing page with two large choices
557
+
558
+ Pros:
559
+
560
+ - Best mental model.
561
+ - Strong privacy-state separation.
562
+ - Works well for future desktop product.
563
+ - Reduces confusion between scrubbing and restoring.
564
+
565
+ Cons:
566
+
567
+ - Larger UI change.
568
+ - Needs careful implementation in current patch-based Streamlit setup.
569
+
570
+ Assessment:
571
+
572
+ ```text
573
+ Best target direction, but implement carefully after helper foundation.
574
+ ```
575
+
576
+ #### Option C — Accordion/stepper
577
+
578
+ Pros:
579
+
580
+ - Fits current single-page Streamlit style.
581
+ - Can show workflow sequence.
582
+
583
+ Cons:
584
+
585
+ - Still risks becoming one long mixed workflow.
586
+ - Reinsert may feel like a sub-step of anonymization rather than a separate capability.
587
+
588
+ Assessment:
589
+
590
+ ```text
591
+ Acceptable temporary bridge, not the ideal long-term structure.
592
+ ```
593
+
594
+ #### Option D — Separate pages
595
+
596
+ Pros:
597
+
598
+ - Strong separation.
599
+ - Good for mature product.
600
+
601
+ Cons:
602
+
603
+ - More refactor work.
604
+ - Risky while UI is still patch-based.
605
+
606
+ Assessment:
607
+
608
+ ```text
609
+ Good later, not the next small step.
610
+ ```
611
+
612
+ #### Option E — Current single-scroll Streamlit flow
613
+
614
+ Pros:
615
+
616
+ - Already implemented.
617
+ - Lowest short-term risk.
618
+
619
+ Cons:
620
+
621
+ - Poor scalability.
622
+ - Hard to explain privacy state.
623
+ - Reinsert is buried after export/Scrub Key controls.
624
+ - Does not clearly answer: am I anonymizing or restoring?
625
+
626
+ Assessment:
627
+
628
+ ```text
629
+ Keep temporarily, but do not continue expanding it indefinitely.
630
+ ```
631
+
632
+ ### 8.2 Recommended visual direction
633
+
634
+ Yes, the UI should start with a mode choice.
635
+
636
+ Recommended target:
637
+
638
+ ```text
639
+ Welkom bij Scrub
640
+
641
+ Wat wilt u doen?
642
+
643
+ [Anonimiseren]
644
+ Maak tekst of documenten veilig voor AI of delen.
645
+
646
+ [Originele waarden terugzetten]
647
+ Gebruik een Scrub Key om placeholders lokaal terug te zetten in AI-output of scrubbed output.
648
+ ```
649
+
650
+ Near-term Streamlit implementation can be tabs:
651
+
652
+ ```text
653
+ Tab 1: Anonimiseren
654
+ Tab 2: Originele waarden terugzetten
655
+ ```
656
+
657
+ Longer-term product implementation can become a landing page or separate pages.
658
+
659
+ ### 8.3 Ideal user journey — Anonimiseren
660
+
661
+ 1. User chooses `Anonimiseren`.
662
+ 2. User uploads DOCX/PDF/TXT or pastes text.
663
+ 3. Scrub detects sensitive values locally.
664
+ 4. User reviews replacements.
665
+ 5. User downloads scrubbed output.
666
+ 6. User downloads Scrub Key if reversible workflow is needed.
667
+ 7. UI warns that the Scrub Key must remain protected.
668
+
669
+ ### 8.4 Ideal user journey — Originele waarden terugzetten
670
+
671
+ 1. User chooses `Originele waarden terugzetten`.
672
+ 2. User uploads or pastes a Scrub Key.
673
+ 3. User provides AI-output or scrubbed output:
674
+ - paste text now;
675
+ - TXT upload next;
676
+ - DOCX upload later;
677
+ - PDF later only if supported.
678
+ 4. Scrub validates the key and detects placeholders.
679
+ 5. User clicks an explicit restore action.
680
+ 6. Scrub restores original values locally.
681
+ 7. UI shows restored output and audit summary.
682
+ 8. User downloads restored output.
683
+ 9. UI warns that restored output may again contain confidential information.
684
+
685
+ ---
686
+
687
+ ## 9. Required recommendation answers
688
+
689
+ ### 1. Is pasted-text reinsert enough for now?
690
+
691
+ Yes, it is enough as the current safe baseline and fallback.
692
+
693
+ No, it is not enough as the final legal-document workflow.
694
+
695
+ ### 2. Should document upload reinsert be supported?
696
+
697
+ Yes, but phased and helper-first.
698
+
699
+ Start with TXT, then DOCX, then only investigate PDF.
700
+
701
+ ### 3. Should DOCX be prioritized before PDF?
702
+
703
+ Yes.
704
+
705
+ DOCX is closer to normal legal drafting workflows and is more feasible to handle with controlled helper logic. PDF should remain later and high-risk.
706
+
707
+ ### 4. Should anonymization and de-anonymization be separated visually?
708
+
709
+ Yes.
710
+
711
+ The UI should move toward a two-mode structure:
712
+
713
+ ```text
714
+ 1. Anonimiseren
715
+ 2. Originele waarden terugzetten
716
+ ```
717
+
718
+ ### 5. What should be the next implementation workpackage?
719
+
720
+ ```text
721
+ WP10 — v13.4 TXT/DOCX reinsert foundation helper and tests
722
+ ```
723
+
724
+ Recommended scope:
725
+
726
+ - no UI first;
727
+ - add pure TXT document-level reinsert helper behavior;
728
+ - add or design DOCX placeholder replacement helper;
729
+ - add synthetic regression tests;
730
+ - keep PDF out of scope;
731
+ - keep AI/cloud out of scope;
732
+ - do not change existing export/download behavior.
733
+
734
+ ### 6. What should explicitly not be built yet?
735
+
736
+ Do not build yet:
737
+
738
+ - full PDF reinsert;
739
+ - OCR for scanned PDFs;
740
+ - AI-based document reconstruction;
741
+ - cloud conversion;
742
+ - automatic AI calls;
743
+ - server-side Scrub Key storage;
744
+ - automatic document rehydration without explicit user action;
745
+ - a broad UI refactor in parallel with other UI work;
746
+ - metadata-clean document promises until document hygiene work is explicitly scoped;
747
+ - changes to existing scrubbed export/download semantics.
748
+
749
+ ---
750
+
751
+ ## 10. Final recommendation
752
+
753
+ Scrub should keep pasted-text reinsert, but treat it as the simple/manual path.
754
+
755
+ The product should move toward a two-mode UX:
756
+
757
+ ```text
758
+ Anonimiseren
759
+ Originele waarden terugzetten
760
+ ```
761
+
762
+ Document-level reinsert should be supported, because legal professionals work with documents, not only copied text. But the implementation should be cautious:
763
+
764
+ ```text
765
+ TXT first.
766
+ DOCX second.
767
+ PDF later only after reliability review.
768
+ ```
769
+
770
+ The next workpackage should build the helper/test foundation, not immediately change the UI.
771
+
772
+ This keeps the product aligned with the core promise:
773
+
774
+ ```text
775
+ local-first
776
+ user control
777
+ readable documents
778
+ safe auditability
779
+ ```