solidprivacy-nl commited on
Commit
cf45c80
·
1 Parent(s): cc948fc

Add v13.0 Scrub Key specification

Browse files
Files changed (1) hide show
  1. SCRUB_KEY_SPEC.md +143 -0
SCRUB_KEY_SPEC.md ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Scrub Key Specification — v13.0 pure model
2
+
3
+ ## Purpose
4
+
5
+ A Scrub Key is a local mapping file that records which original values were replaced by which placeholders during the Scrub review workflow.
6
+
7
+ It prepares the future workflow:
8
+
9
+ ```text
10
+ Scrub → Review → Scrub Key → AI → Reinsert → Export → Audit
11
+ ```
12
+
13
+ The v13.0 scope is specification and pure model only. It does not add UI controls, export buttons, reinsert UI, cloud processing, or persistent storage.
14
+
15
+ ## Core concept
16
+
17
+ A Scrub Key makes scrubbed text reversible when the key is available. This means the Scrub Key supports pseudonymization, not full anonymization.
18
+
19
+ The scrubbed document and the Scrub Key must be treated as separate security objects:
20
+
21
+ - the scrubbed document may be suitable for external processing after human review;
22
+ - the Scrub Key contains the mapping needed to restore sensitive values;
23
+ - the Scrub Key must stay local and protected;
24
+ - users should not share the key with external AI services unless explicitly intended and allowed by their policy, client instruction, and legal basis.
25
+
26
+ ## Safety position
27
+
28
+ A Scrub Key is powerful because it can restore original terms. That also makes it sensitive.
29
+
30
+ Required user-facing safety language for future UI work:
31
+
32
+ ```text
33
+ Een Scrub Key maakt deze tekst omkeerbaar. Dit is pseudonimisering, geen volledige anonimisering. Bewaar de sleutel lokaal en beveiligd. Deel de Scrub Key niet met externe AI-diensten, tenzij dit bewust is bedoeld en toegestaan.
34
+ ```
35
+
36
+ Scrub Key export/import must not silently change document meaning. Future import and reinsert steps must preserve the exact reviewed mapping and should warn if a placeholder is missing, duplicated, ambiguous, or changed in the AI output.
37
+
38
+ ## Mapping item fields
39
+
40
+ Each mapping item supports these fields:
41
+
42
+ | Field | Required | Meaning |
43
+ | --- | --- | --- |
44
+ | `original_value` | yes | The original sensitive value before replacement. |
45
+ | `placeholder` | yes | The placeholder that replaced the original value. |
46
+ | `entity_type` | yes | The stable technical entity type. |
47
+ | `type_label` | yes | The user-facing type label shown to the reviewer. |
48
+ | `source` | yes | Source of the row, for example detected, candidate, manual, or remembered. |
49
+ | `review_status` | yes | Review status at key-build time. |
50
+ | `include_state` | yes | Whether this item is included in the key. v13.0 emits included rows only. |
51
+ | `timestamp` | yes | Timestamp supplied by the reviewed row. The pure model does not create time itself. |
52
+ | `document_label` | optional | Optional document, project, dossier, or matter label. |
53
+
54
+ ## v13.0 excluded-row policy
55
+
56
+ The v13.0 pure model uses this policy:
57
+
58
+ ```text
59
+ excluded_rows_policy = omitted
60
+ ```
61
+
62
+ Only rows explicitly selected for inclusion are written into the Scrub Key. Excluded rows are omitted rather than exported as inactive mappings. This keeps the first model aligned with current export semantics: unchecked rows are not part of the output mapping.
63
+
64
+ A later version may add an explicit audit mode that records excluded rows separately, but that is outside this workpackage.
65
+
66
+ ## Determinism and timestamp rule
67
+
68
+ The pure model is deterministic. It does not call the system clock.
69
+
70
+ If a timestamp is needed, it must be supplied by the caller in the reviewed row. Validation reports an empty or missing timestamp as an issue. This avoids hidden side effects and makes tests stable.
71
+
72
+ ## JSON shape
73
+
74
+ A Scrub Key is a JSON object with metadata and an `items` list.
75
+
76
+ Example using synthetic Dutch legal values only:
77
+
78
+ ```json
79
+ {
80
+ "schema": "solidprivacy.scrub_key",
81
+ "schema_version": "1.0",
82
+ "workflow": "Scrub → Review → Scrub Key → AI → Reinsert → Export → Audit",
83
+ "privacy_model": "pseudonymization_not_full_anonymization",
84
+ "reversible": true,
85
+ "storage_policy": "local_only_protect_key",
86
+ "external_ai_policy": "do_not_share_key_unless_explicitly_intended_and_allowed",
87
+ "excluded_rows_policy": "omitted",
88
+ "document_label": "Dossier voorbeeld",
89
+ "item_count": 1,
90
+ "items": [
91
+ {
92
+ "original_value": "BETROKKENE-TEST-A",
93
+ "placeholder": "[PERSOON_1]",
94
+ "entity_type": "PERSON",
95
+ "type_label": "Naam",
96
+ "source": "detected",
97
+ "review_status": "auto_detected",
98
+ "include_state": "included",
99
+ "timestamp": "2026-06-07T10:00:00Z",
100
+ "document_label": "Dossier voorbeeld"
101
+ }
102
+ ]
103
+ }
104
+ ```
105
+
106
+ ## Pure helper API
107
+
108
+ The initial pure helper module is `scrub_key.py`.
109
+
110
+ Supported functions:
111
+
112
+ ```python
113
+ build_scrub_key(rows, document_label=None) -> dict
114
+ scrub_key_to_json(scrub_key) -> str
115
+ scrub_key_from_json(text) -> dict
116
+ validate_scrub_key(scrub_key) -> list[str]
117
+ ```
118
+
119
+ The helpers accept dictionaries, lists of dictionaries, and DataFrame-like objects with `to_dict(orient="records")`. They do not import Streamlit or pandas.
120
+
121
+ ## Non-goals for v13.0
122
+
123
+ This specification/model does not add:
124
+
125
+ - Streamlit UI integration;
126
+ - export/download buttons;
127
+ - reinsert UI;
128
+ - cloud processing;
129
+ - secret storage;
130
+ - real personal data examples;
131
+ - encrypted vault/storage;
132
+ - document-meaning transformation;
133
+ - AI output parsing.
134
+
135
+ ## Future phases
136
+
137
+ Planned follow-up work can build on this model:
138
+
139
+ 1. Scrub Key JSON export UI.
140
+ 2. Scrub Key import/reload.
141
+ 3. Local reinsert of AI output.
142
+ 4. Pseudonymization warnings in the UI.
143
+ 5. Audit logging around export/import and reinsertion.