Add pinned SAOS Polish court judgments snapshot

#21
artifacts/saos_ontology_manifest.json ADDED
@@ -0,0 +1,569 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "actors": [
3
+ {
4
+ "id": "hf:PiotrSty",
5
+ "identifiers": {
6
+ "github": "PiotrStyla",
7
+ "hugging_face": "PiotrSty"
8
+ },
9
+ "identity": "Piotr Styła",
10
+ "kind": "human"
11
+ }
12
+ ],
13
+ "attestations": [
14
+ {
15
+ "actor_id": "hf:PiotrSty",
16
+ "created_at": "2026-09-05T06:45:57.253621Z",
17
+ "id": "slayer://attestation/saos/schema_valid@sha256:076e1dda8918af803ecf9d1dc74f69536bf5e8e481f9a18c605f1237097db76b",
18
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
19
+ "supported_by": [
20
+ "slayer://evidence/saos/schema_validation@sha256:87209fd66de594f15ee22a7a34b851fb491397fa52624d3a392ef38e63f806d1",
21
+ "slayer://evidence/saos/artifact_checksums@sha256:c80bd061eadc8c631f2746668334ec0da3a1b7acd33ef7c05e6d5334b0ed0e0c"
22
+ ],
23
+ "type": "schema_valid",
24
+ "value": true
25
+ },
26
+ {
27
+ "actor_id": "hf:PiotrSty",
28
+ "created_at": "2026-09-05T06:45:57.253621Z",
29
+ "id": "slayer://attestation/saos/source_completeness@sha256:8cd33e860f10f49f9f19e3ad9c146003e5161b35d4b49638a433617e36c045ed",
30
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
31
+ "supported_by": [
32
+ "slayer://evidence/saos/source_completeness_observation@sha256:58e8c4938862d5a6dec240d8fe0fa8a515fb94a3439e3472d9ba520e198b6706"
33
+ ],
34
+ "type": "source_completeness",
35
+ "value": "partial_snapshot"
36
+ },
37
+ {
38
+ "actor_id": "hf:PiotrSty",
39
+ "created_at": "2026-09-05T06:45:57.253621Z",
40
+ "id": "slayer://attestation/saos/provenance@sha256:007a8ee8597184b32e11500266c0441dfa8952a195387625f361d8c8f3537f33",
41
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
42
+ "supported_by": [
43
+ "slayer://evidence/saos/pinned_source_inventory@sha256:ecbbb0fbf442e371475f6f6a89909522a6524d9464be5f113765272297670459"
44
+ ],
45
+ "type": "provenance",
46
+ "value": "pinned_and_hashed"
47
+ },
48
+ {
49
+ "actor_id": "hf:PiotrSty",
50
+ "created_at": "2026-09-05T06:45:57.253621Z",
51
+ "id": "slayer://attestation/saos/pii_scrubbing@sha256:9ee1a64e2440b1465e2412ef10e6470502b8fb730a9e50d663587d3cd8918787",
52
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
53
+ "supported_by": [
54
+ "slayer://evidence/saos/normalization_and_pii_metrics@sha256:ad762d906f3391e1b818654a8fdbc1bdb3c8c022e83997abea972251ee65e37a"
55
+ ],
56
+ "type": "pii_scrubbing",
57
+ "value": "pattern_scrub_applied_not_guaranteed"
58
+ },
59
+ {
60
+ "actor_id": "hf:PiotrSty",
61
+ "created_at": "2026-09-05T06:45:57.253621Z",
62
+ "id": "slayer://attestation/saos/legal_status@sha256:9233cc03387de9175ffa86f6bddc38192920938f65ce9f1c1934a4ded573cab7",
63
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
64
+ "supported_by": [
65
+ "slayer://evidence/saos/legal_provenance_review@sha256:958944289fd5a323346e43bc9e11438b6c408b06fe9b288a0449bf1afaf58fd3"
66
+ ],
67
+ "type": "legal_status",
68
+ "value": "review_needed_documented_official_materials"
69
+ }
70
+ ],
71
+ "claim_evidence": [
72
+ {
73
+ "claim_id": "slayer://claim/saos@sha256:f3dcf4db368c7cb7cec7913fdcc18242373137ee70f5a5c04eb6f3400e6f28fe",
74
+ "evidence_id": "slayer://evidence/saos/pinned_source_inventory@sha256:ecbbb0fbf442e371475f6f6a89909522a6524d9464be5f113765272297670459",
75
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
76
+ "relation": "SUPPORTS"
77
+ },
78
+ {
79
+ "claim_id": "slayer://claim/saos@sha256:aacbbe6a634fb32bbd6ec8d85e9ba090fe4faef389118f5730c7948f961ba180",
80
+ "evidence_id": "slayer://evidence/saos/source_completeness_observation@sha256:58e8c4938862d5a6dec240d8fe0fa8a515fb94a3439e3472d9ba520e198b6706",
81
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
82
+ "relation": "SUPPORTS"
83
+ },
84
+ {
85
+ "claim_id": "slayer://claim/saos@sha256:0fa5f4ef3582a00733d6b62b2bd377027f6734e6669a8a3c63ad0dd6f7399d04",
86
+ "evidence_id": "slayer://evidence/saos/schema_validation@sha256:87209fd66de594f15ee22a7a34b851fb491397fa52624d3a392ef38e63f806d1",
87
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
88
+ "relation": "SUPPORTS"
89
+ },
90
+ {
91
+ "claim_id": "slayer://claim/saos@sha256:0fa5f4ef3582a00733d6b62b2bd377027f6734e6669a8a3c63ad0dd6f7399d04",
92
+ "evidence_id": "slayer://evidence/saos/artifact_checksums@sha256:c80bd061eadc8c631f2746668334ec0da3a1b7acd33ef7c05e6d5334b0ed0e0c",
93
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
94
+ "relation": "SUPPORTS"
95
+ },
96
+ {
97
+ "claim_id": "slayer://claim/saos@sha256:86781759c2cbf09530bf68b14b35ddb8f8de875515d10492120fb50a21ffc125",
98
+ "evidence_id": "slayer://evidence/saos/normalization_and_pii_metrics@sha256:ad762d906f3391e1b818654a8fdbc1bdb3c8c022e83997abea972251ee65e37a",
99
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
100
+ "relation": "SUPPORTS"
101
+ },
102
+ {
103
+ "claim_id": "slayer://claim/saos@sha256:869bd1c50beb64f64ed605509b5d766f2fabf71d853cc4b2897f1f8010853266",
104
+ "evidence_id": "slayer://evidence/saos/legal_provenance_review@sha256:958944289fd5a323346e43bc9e11438b6c408b06fe9b288a0449bf1afaf58fd3",
105
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
106
+ "relation": "SUPPORTS"
107
+ }
108
+ ],
109
+ "claims": [
110
+ {
111
+ "asserted_by": "hf:PiotrSty",
112
+ "falsification_condition": "A source file is missing or its recorded size or SHA-256 differs.",
113
+ "id": "slayer://claim/saos@sha256:f3dcf4db368c7cb7cec7913fdcc18242373137ee70f5a5c04eb6f3400e6f28fe",
114
+ "scope": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
115
+ "statement": "The contribution is derived from the 14 files of the pinned PiotrSty SAOS snapshot.",
116
+ "supported_by": [
117
+ "slayer://evidence/saos/pinned_source_inventory@sha256:ecbbb0fbf442e371475f6f6a89909522a6524d9464be5f113765272297670459"
118
+ ]
119
+ },
120
+ {
121
+ "asserted_by": "hf:PiotrSty",
122
+ "falsification_condition": "The pinned snapshot row count equals the official live count observed for this run.",
123
+ "id": "slayer://claim/saos@sha256:aacbbe6a634fb32bbd6ec8d85e9ba090fe4faef389118f5730c7948f961ba180",
124
+ "scope": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
125
+ "statement": "The contributed dataset is a partial historical SAOS snapshot and not a complete current copy.",
126
+ "supported_by": [
127
+ "slayer://evidence/saos/source_completeness_observation@sha256:58e8c4938862d5a6dec240d8fe0fa8a515fb94a3439e3472d9ba520e198b6706"
128
+ ]
129
+ },
130
+ {
131
+ "asserted_by": "hf:PiotrSty",
132
+ "falsification_condition": "A retained row violates the schema or an artifact checksum differs.",
133
+ "id": "slayer://claim/saos@sha256:0fa5f4ef3582a00733d6b62b2bd377027f6734e6669a8a3c63ad0dd6f7399d04",
134
+ "scope": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
135
+ "statement": "All retained rows conform to the DynaWord source schema and recorded artifact checksums.",
136
+ "supported_by": [
137
+ "slayer://evidence/saos/schema_validation@sha256:87209fd66de594f15ee22a7a34b851fb491397fa52624d3a392ef38e63f806d1",
138
+ "slayer://evidence/saos/artifact_checksums@sha256:c80bd061eadc8c631f2746668334ec0da3a1b7acd33ef7c05e6d5334b0ed0e0c"
139
+ ]
140
+ },
141
+ {
142
+ "asserted_by": "hf:PiotrSty",
143
+ "falsification_condition": "The committed protocol omits a documented transformation or a retained match contradicts its recorded metric.",
144
+ "id": "slayer://claim/saos@sha256:86781759c2cbf09530bf68b14b35ddb8f8de875515d10492120fb50a21ffc125",
145
+ "scope": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
146
+ "statement": "Pattern-based PII scrubbing and documented text normalization were applied, without asserting perfect de-identification.",
147
+ "supported_by": [
148
+ "slayer://evidence/saos/normalization_and_pii_metrics@sha256:ad762d906f3391e1b818654a8fdbc1bdb3c8c022e83997abea972251ee65e37a"
149
+ ]
150
+ },
151
+ {
152
+ "asserted_by": "hf:PiotrSty",
153
+ "falsification_condition": "The records are not official materials or legal review rejects the documented statutory basis.",
154
+ "id": "slayer://claim/saos@sha256:869bd1c50beb64f64ed605509b5d766f2fabf71d853cc4b2897f1f8010853266",
155
+ "scope": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
156
+ "statement": "The records are court materials with a documented statutory reuse argument, pending formal legal review and subject to stated limitations.",
157
+ "supported_by": [
158
+ "slayer://evidence/saos/legal_provenance_review@sha256:958944289fd5a323346e43bc9e11438b6c408b06fe9b288a0449bf1afaf58fd3"
159
+ ]
160
+ }
161
+ ],
162
+ "evidence": [
163
+ {
164
+ "id": "slayer://evidence/saos/dataset_record_counts@sha256:06d786acc8282a7cf7a6257dac50ed31d1cea8bf859a7bb767de22ac24d53650",
165
+ "observation_type": "dataset_record_counts",
166
+ "observed_at": "2026-09-05T06:45:57.253621Z",
167
+ "payload": {
168
+ "added": "2026-09-04",
169
+ "authors_with_value": 279091,
170
+ "by_court_type": {
171
+ "COMMON": 229370,
172
+ "CONSTITUTIONAL_TRIBUNAL": 9503,
173
+ "NATIONAL_APPEAL_CHAMBER": 19758,
174
+ "SUPREME": 38058
175
+ },
176
+ "by_judgment_type": {
177
+ "DECISION": 64761,
178
+ "REASONS": 18693,
179
+ "REGULATION": 3231,
180
+ "RESOLUTION": 2469,
181
+ "SENTENCE": 207535
182
+ },
183
+ "chars": 5897001250,
184
+ "created_max": "2017-05-11",
185
+ "created_min": "1986-05-28",
186
+ "drop_dup": 0,
187
+ "drop_lang": 0,
188
+ "drop_short": 3,
189
+ "invalid_dates": 1,
190
+ "kept": 296689,
191
+ "license": "public-domain (official documents)",
192
+ "licenses": {
193
+ "public-domain (official documents)": 296689
194
+ },
195
+ "normalization": {
196
+ "bank_accounts_redacted": 66,
197
+ "control_characters_removed": 0,
198
+ "emails_redacted": 14,
199
+ "labelled_identifiers_redacted": 253,
200
+ "labelled_phones_redacted": 60,
201
+ "normalized_records": 263987,
202
+ "pesel_candidates_redacted": 0
203
+ },
204
+ "official_count_observed_at": "2026-09-04",
205
+ "official_total_results": 540726,
206
+ "snapshot_live_count_ratio": 0.5486919437940843,
207
+ "source_revision": "736cba4f92999e29d3e49409b0713c88fc683714",
208
+ "source_rows": 296692,
209
+ "stats_recomputed_from_parquet": true,
210
+ "target_base_revision": "a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
211
+ "tokens": 2265448504
212
+ },
213
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
214
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
215
+ },
216
+ {
217
+ "id": "slayer://evidence/saos/artifact_checksums@sha256:c80bd061eadc8c631f2746668334ec0da3a1b7acd33ef7c05e6d5334b0ed0e0c",
218
+ "observation_type": "artifact_checksums",
219
+ "observed_at": "2026-09-05T06:45:57.253621Z",
220
+ "payload": {
221
+ "attribution_sha256": "0fda03e770bc8db94694f4758239ea6fda80e16e5398aee2b5a308a48896c857",
222
+ "datasheet_sha256": "2b18ec4c003fdd66c07d773d378703e54e2f4d5d3579e80a7c397a6b5edf7478",
223
+ "legal_evidence_sha256": "5edf35c7c62b686ed7aaa7b6b569262a7f0faa46d7ca639bb4d6df909124b445",
224
+ "parquet_sha256": "f265dfe410aef0b0a2453f16e05d6398292af6a66db713bfaad554b4ee0dbf55",
225
+ "source_inventory_sha256": "48c922173253bd9045037ec534b6a11f53fa7bb7e8f6731f8e1420df826826e8",
226
+ "source_profile_sha256": "ed0418723c3e895b1e9de3da9fffbb807f7231a8252aacee10998f16daef4e31",
227
+ "stats_sha256": "7b1ea5b70d4bf67da038ff8d4b68bc2c01bea33554d1f8e8b31f3fd8785e7f1c"
228
+ },
229
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
230
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
231
+ },
232
+ {
233
+ "id": "slayer://evidence/saos/pinned_source_inventory@sha256:ecbbb0fbf442e371475f6f6a89909522a6524d9464be5f113765272297670459",
234
+ "observation_type": "pinned_source_inventory",
235
+ "observed_at": "2026-09-05T06:45:57.253621Z",
236
+ "payload": {
237
+ "aggregate_digest": "sha256:d1e1743a9901c381e6617391f65ca2686e317dd7c3d8b3552093e0104040c88c",
238
+ "files": [
239
+ {
240
+ "path": "data/train-00000-of-00014.parquet",
241
+ "sha256": "f76b008a2061dc85589a51f4c868cc6484c9dff57a09b53e72b3d5390cbb632f",
242
+ "size": 180401965
243
+ },
244
+ {
245
+ "path": "data/train-00001-of-00014.parquet",
246
+ "sha256": "0641823cad2fc981da1f0398c4202e25e6489994828812ef8bf3701bbb254930",
247
+ "size": 213080176
248
+ },
249
+ {
250
+ "path": "data/train-00002-of-00014.parquet",
251
+ "sha256": "f707bc330140dac0052f5e169cb6dff5918948877f1b4dd471c3070de0230593",
252
+ "size": 243953893
253
+ },
254
+ {
255
+ "path": "data/train-00003-of-00014.parquet",
256
+ "sha256": "f72f79df6fe494fd91cbb82e63083fb375e18a59ad772232a719fa46fb9cbe3a",
257
+ "size": 239361563
258
+ },
259
+ {
260
+ "path": "data/train-00004-of-00014.parquet",
261
+ "sha256": "c5d2ccc87ff2a3d8f7ba64b24f689d92e3def50a70792f59446f58bc2ac04a90",
262
+ "size": 240427543
263
+ },
264
+ {
265
+ "path": "data/train-00005-of-00014.parquet",
266
+ "sha256": "9139c736363b6c151373fd159c0f30cc06fe65d52c01acc547737463f5500fc7",
267
+ "size": 234121713
268
+ },
269
+ {
270
+ "path": "data/train-00006-of-00014.parquet",
271
+ "sha256": "6b0d88e3ef45b0c246b79aa47aa1fc337c997305159f1d6e84e6e95798995495",
272
+ "size": 242598279
273
+ },
274
+ {
275
+ "path": "data/train-00007-of-00014.parquet",
276
+ "sha256": "4b1c3a69948d1ff713a0dd39d71ddb9d4cd85156a947c2b8e4c55264ed947cc0",
277
+ "size": 253305954
278
+ },
279
+ {
280
+ "path": "data/train-00008-of-00014.parquet",
281
+ "sha256": "3a4298ee101bf2b9fc6a339db0f4ce7471519b5e36c828ff6166617983d08c60",
282
+ "size": 256220979
283
+ },
284
+ {
285
+ "path": "data/train-00009-of-00014.parquet",
286
+ "sha256": "41b963dd3669d5bf97f6e381019483ac52674f2889cd31efe30928ca02ab0275",
287
+ "size": 257319050
288
+ },
289
+ {
290
+ "path": "data/train-00010-of-00014.parquet",
291
+ "sha256": "960243ec221eac979ee226aeb630c9f9325af774e703e8af6285386f06b57541",
292
+ "size": 257444913
293
+ },
294
+ {
295
+ "path": "data/train-00011-of-00014.parquet",
296
+ "sha256": "d8c54ec1698d9ab53e86b4064401efda174cd4b9580b256fac8bb0ada79ad886",
297
+ "size": 260380321
298
+ },
299
+ {
300
+ "path": "data/train-00012-of-00014.parquet",
301
+ "sha256": "fe294f0ef3b851928cc37a22d29c66dfd55c4951a09b76f5cb89a6b64082c762",
302
+ "size": 266750435
303
+ },
304
+ {
305
+ "path": "data/train-00013-of-00014.parquet",
306
+ "sha256": "5c27b08e9559bf0ba8d63ed7f1daa7f19db0cd4fcb774d715e7d046e34a373b2",
307
+ "size": 273748222
308
+ }
309
+ ],
310
+ "repository": "PiotrSty/saos-polish-court-judgments",
311
+ "revision": "736cba4f92999e29d3e49409b0713c88fc683714"
312
+ },
313
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
314
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
315
+ },
316
+ {
317
+ "id": "slayer://evidence/saos/source_completeness_observation@sha256:58e8c4938862d5a6dec240d8fe0fa8a515fb94a3439e3472d9ba520e198b6706",
318
+ "observation_type": "source_completeness_observation",
319
+ "observed_at": "2026-09-05T06:45:57.253621Z",
320
+ "payload": {
321
+ "complete": false,
322
+ "observed_at": "2026-09-04",
323
+ "official_total_results": 540726,
324
+ "ratio": 0.5486919437940843,
325
+ "snapshot_rows": 296692
326
+ },
327
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
328
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
329
+ },
330
+ {
331
+ "id": "slayer://evidence/saos/normalization_and_pii_metrics@sha256:ad762d906f3391e1b818654a8fdbc1bdb3c8c022e83997abea972251ee65e37a",
332
+ "observation_type": "normalization_and_pii_metrics",
333
+ "observed_at": "2026-09-05T06:45:57.253621Z",
334
+ "payload": {
335
+ "bank_accounts_redacted": 66,
336
+ "control_characters_removed": 0,
337
+ "emails_redacted": 14,
338
+ "labelled_identifiers_redacted": 253,
339
+ "labelled_phones_redacted": 60,
340
+ "normalized_records": 263987,
341
+ "pesel_candidates_redacted": 0
342
+ },
343
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
344
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
345
+ },
346
+ {
347
+ "id": "slayer://evidence/saos/schema_validation@sha256:87209fd66de594f15ee22a7a34b851fb491397fa52624d3a392ef38e63f806d1",
348
+ "observation_type": "schema_validation",
349
+ "observed_at": "2026-09-05T06:45:57.253621Z",
350
+ "payload": {
351
+ "records": 296689,
352
+ "schema": [
353
+ "id",
354
+ "text",
355
+ "source",
356
+ "added",
357
+ "created",
358
+ "token_count",
359
+ "license",
360
+ "author"
361
+ ],
362
+ "valid": true
363
+ },
364
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
365
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
366
+ },
367
+ {
368
+ "id": "slayer://evidence/saos/legal_provenance_review@sha256:958944289fd5a323346e43bc9e11438b6c408b06fe9b288a0449bf1afaf58fd3",
369
+ "observation_type": "legal_provenance_review",
370
+ "observed_at": "2026-09-05T06:45:57.253621Z",
371
+ "payload": {
372
+ "artifact": "data/saos/saos.license-evidence.json",
373
+ "formal_legal_review": "not_performed",
374
+ "sha256": "5edf35c7c62b686ed7aaa7b6b569262a7f0faa46d7ca639bb4d6df909124b445",
375
+ "status": "documented-statutory-basis-review-needed"
376
+ },
377
+ "run_id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
378
+ "subject_version": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
379
+ }
380
+ ],
381
+ "object": {
382
+ "id": "slayer://object/dataset-source/saos",
383
+ "kind": "dataset_source",
384
+ "metadata": {
385
+ "domain": "legal/judicial",
386
+ "language": "pl",
387
+ "provider": "SAOS"
388
+ },
389
+ "name": "saos"
390
+ },
391
+ "ontology_version": "slayer.ai/research-ontology/v0.1",
392
+ "protocol": {
393
+ "id": "slayer://object/protocol/saos-filter",
394
+ "kind": "dataset_filtering",
395
+ "name": "saos-filter",
396
+ "specification": {
397
+ "configuration": {
398
+ "date_valid_year_range": [
399
+ 1900,
400
+ 2027
401
+ ],
402
+ "deduplication": {
403
+ "algorithm": "sha1",
404
+ "field": "normalized_text",
405
+ "scope": "within_source"
406
+ },
407
+ "execution": {
408
+ "parquet_compression": "zstd",
409
+ "record_batch_size": 128,
410
+ "source_workers": 14,
411
+ "token_threads": 14,
412
+ "token_threads_per_worker": 1
413
+ },
414
+ "minimum_characters": 200,
415
+ "minimum_polish_diacritic_ratio": 0.005,
416
+ "normalization": [
417
+ "NFKC",
418
+ "space_quote_dash",
419
+ "paragraph_preserving_whitespace",
420
+ "pattern_PII_scrub"
421
+ ],
422
+ "source_revision": "736cba4f92999e29d3e49409b0713c88fc683714",
423
+ "tokenizer": "cl100k_base"
424
+ },
425
+ "entrypoint": "python src/fetch_saos.py",
426
+ "outputs": [
427
+ "DynaWord Parquet",
428
+ "attribution sidecar",
429
+ "datasheet",
430
+ "stats",
431
+ "legal evidence",
432
+ "ontology manifest"
433
+ ],
434
+ "required_inputs": [
435
+ "14 pinned source Parquet shards",
436
+ "source profile",
437
+ "target registry",
438
+ "target findings log"
439
+ ],
440
+ "source_path": "src/fetch_saos.py",
441
+ "summary": "Deterministic normalization and projection of a pinned SAOS judgment snapshot."
442
+ },
443
+ "version": {
444
+ "code_sha256": "a73afbe39a10beb4ac22c773410479b804837e3e78ccecf5a6e728531845c12d",
445
+ "created_at": "2026-09-05T06:45:57.253621Z",
446
+ "created_by": "hf:PiotrSty",
447
+ "digest": "sha256:33de2cc5f9e08a3b22fd6f4303e570a951d184cc8de91aca61ab216250530b3c",
448
+ "id": "slayer://version/protocol/saos-filter@sha256:33de2cc5f9e08a3b22fd6f4303e570a951d184cc8de91aca61ab216250530b3c",
449
+ "object_id": "slayer://object/protocol/saos-filter",
450
+ "payload_uri": "hf://datasets/SlayerLab/polish-dynaword@b28db4c2b1f7273f878b3c54602777f7b224e27b/src/fetch_saos.py",
451
+ "schema_version": "slayer.ai/protocol/v1"
452
+ }
453
+ },
454
+ "relations": [
455
+ {
456
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
457
+ "predicate": "DERIVED_FROM",
458
+ "source_version_id": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
459
+ "target_version_id": "hf://datasets/PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714"
460
+ },
461
+ {
462
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
463
+ "predicate": "COMPATIBLE_WITH",
464
+ "source_version_id": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
465
+ "target_version_id": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f"
466
+ },
467
+ {
468
+ "introduced_by_run": "slayer://run/dataset-filtering/saos-snapshot-20260904",
469
+ "predicate": "FILTERED_BY",
470
+ "source_version_id": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
471
+ "target_version_id": "slayer://version/protocol/saos-filter@sha256:33de2cc5f9e08a3b22fd6f4303e570a951d184cc8de91aca61ab216250530b3c"
472
+ }
473
+ ],
474
+ "run": {
475
+ "actor_id": "hf:PiotrSty",
476
+ "config": {
477
+ "date_valid_year_range": [
478
+ 1900,
479
+ 2027
480
+ ],
481
+ "deduplication": {
482
+ "algorithm": "sha1",
483
+ "field": "normalized_text",
484
+ "scope": "within_source"
485
+ },
486
+ "execution": {
487
+ "parquet_compression": "zstd",
488
+ "record_batch_size": 128,
489
+ "source_workers": 14,
490
+ "token_threads": 14,
491
+ "token_threads_per_worker": 1
492
+ },
493
+ "minimum_characters": 200,
494
+ "minimum_polish_diacritic_ratio": 0.005,
495
+ "normalization": [
496
+ "NFKC",
497
+ "space_quote_dash",
498
+ "paragraph_preserving_whitespace",
499
+ "pattern_PII_scrub"
500
+ ],
501
+ "source_revision": "736cba4f92999e29d3e49409b0713c88fc683714",
502
+ "tokenizer": "cl100k_base"
503
+ },
504
+ "environment": {
505
+ "container_image": null,
506
+ "determinism": {
507
+ "input_order": [
508
+ "train-00000-of-00014.parquet",
509
+ "train-00001-of-00014.parquet",
510
+ "train-00002-of-00014.parquet",
511
+ "train-00003-of-00014.parquet",
512
+ "train-00004-of-00014.parquet",
513
+ "train-00005-of-00014.parquet",
514
+ "train-00006-of-00014.parquet",
515
+ "train-00007-of-00014.parquet",
516
+ "train-00008-of-00014.parquet",
517
+ "train-00009-of-00014.parquet",
518
+ "train-00010-of-00014.parquet",
519
+ "train-00011-of-00014.parquet",
520
+ "train-00012-of-00014.parquet",
521
+ "train-00013-of-00014.parquet"
522
+ ],
523
+ "sampling": "none",
524
+ "seed": null
525
+ },
526
+ "environment_limitation": "No container image was used; material runtime and package versions are recorded.",
527
+ "machine": "AMD64",
528
+ "packages": {
529
+ "pyarrow": "24.0.0",
530
+ "tiktoken": "0.14.0"
531
+ },
532
+ "platform": "Windows-11-10.0.26200-SP0",
533
+ "python": "3.12.14 (main, Aug 25 2026, 14:01:42) [MSC v.1944 64 bit (AMD64)]",
534
+ "python_executable": "C:\\Users\\Hipek\\.cache\\codex-runtimes\\codex-primary-runtime\\dependencies\\python\\python.exe"
535
+ },
536
+ "finished_at": "2026-09-05T06:45:57.253621Z",
537
+ "git_commit": "b28db4c2b1f7273f878b3c54602777f7b224e27b",
538
+ "id": "slayer://run/dataset-filtering/saos-snapshot-20260904",
539
+ "inputs": [
540
+ {
541
+ "role": "source",
542
+ "version_id": "hf://datasets/PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714"
543
+ },
544
+ {
545
+ "role": "target_base",
546
+ "version_id": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f"
547
+ }
548
+ ],
549
+ "outputs": [
550
+ {
551
+ "role": "dataset_source",
552
+ "version_id": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76"
553
+ }
554
+ ],
555
+ "protocol_version_id": "slayer://version/protocol/saos-filter@sha256:33de2cc5f9e08a3b22fd6f4303e570a951d184cc8de91aca61ab216250530b3c",
556
+ "started_at": "2026-09-05T06:29:24.801108Z"
557
+ },
558
+ "schema_version": "slayer.ai/dataset-source-contribution/v1",
559
+ "version": {
560
+ "created_at": "2026-09-05T06:45:57.253621Z",
561
+ "created_by": "hf:PiotrSty",
562
+ "digest": "sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
563
+ "id": "slayer://version/dataset-source/saos@sha256:affd02f630791c68a2b1e3a2f7c05d285b80c0f318dad75e66453261d4fabf76",
564
+ "object_id": "slayer://object/dataset-source/saos",
565
+ "payload_uri": "hf://datasets/SlayerLab/polish-dynaword@f64afeca7bcca3b17c33f41fecf8478a9f6afb65/data/saos/saos.parquet",
566
+ "published_in_commit": "f64afeca7bcca3b17c33f41fecf8478a9f6afb65",
567
+ "schema_version": "slayer.ai/dataset-source/v1"
568
+ }
569
+ }
artifacts/saos_source_inventory.json ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "aggregate_digest": "sha256:d1e1743a9901c381e6617391f65ca2686e317dd7c3d8b3552093e0104040c88c",
3
+ "files": [
4
+ {
5
+ "path": "data/train-00000-of-00014.parquet",
6
+ "sha256": "f76b008a2061dc85589a51f4c868cc6484c9dff57a09b53e72b3d5390cbb632f",
7
+ "size": 180401965
8
+ },
9
+ {
10
+ "path": "data/train-00001-of-00014.parquet",
11
+ "sha256": "0641823cad2fc981da1f0398c4202e25e6489994828812ef8bf3701bbb254930",
12
+ "size": 213080176
13
+ },
14
+ {
15
+ "path": "data/train-00002-of-00014.parquet",
16
+ "sha256": "f707bc330140dac0052f5e169cb6dff5918948877f1b4dd471c3070de0230593",
17
+ "size": 243953893
18
+ },
19
+ {
20
+ "path": "data/train-00003-of-00014.parquet",
21
+ "sha256": "f72f79df6fe494fd91cbb82e63083fb375e18a59ad772232a719fa46fb9cbe3a",
22
+ "size": 239361563
23
+ },
24
+ {
25
+ "path": "data/train-00004-of-00014.parquet",
26
+ "sha256": "c5d2ccc87ff2a3d8f7ba64b24f689d92e3def50a70792f59446f58bc2ac04a90",
27
+ "size": 240427543
28
+ },
29
+ {
30
+ "path": "data/train-00005-of-00014.parquet",
31
+ "sha256": "9139c736363b6c151373fd159c0f30cc06fe65d52c01acc547737463f5500fc7",
32
+ "size": 234121713
33
+ },
34
+ {
35
+ "path": "data/train-00006-of-00014.parquet",
36
+ "sha256": "6b0d88e3ef45b0c246b79aa47aa1fc337c997305159f1d6e84e6e95798995495",
37
+ "size": 242598279
38
+ },
39
+ {
40
+ "path": "data/train-00007-of-00014.parquet",
41
+ "sha256": "4b1c3a69948d1ff713a0dd39d71ddb9d4cd85156a947c2b8e4c55264ed947cc0",
42
+ "size": 253305954
43
+ },
44
+ {
45
+ "path": "data/train-00008-of-00014.parquet",
46
+ "sha256": "3a4298ee101bf2b9fc6a339db0f4ce7471519b5e36c828ff6166617983d08c60",
47
+ "size": 256220979
48
+ },
49
+ {
50
+ "path": "data/train-00009-of-00014.parquet",
51
+ "sha256": "41b963dd3669d5bf97f6e381019483ac52674f2889cd31efe30928ca02ab0275",
52
+ "size": 257319050
53
+ },
54
+ {
55
+ "path": "data/train-00010-of-00014.parquet",
56
+ "sha256": "960243ec221eac979ee226aeb630c9f9325af774e703e8af6285386f06b57541",
57
+ "size": 257444913
58
+ },
59
+ {
60
+ "path": "data/train-00011-of-00014.parquet",
61
+ "sha256": "d8c54ec1698d9ab53e86b4064401efda174cd4b9580b256fac8bb0ada79ad886",
62
+ "size": 260380321
63
+ },
64
+ {
65
+ "path": "data/train-00012-of-00014.parquet",
66
+ "sha256": "fe294f0ef3b851928cc37a22d29c66dfd55c4951a09b76f5cb89a6b64082c762",
67
+ "size": 266750435
68
+ },
69
+ {
70
+ "path": "data/train-00013-of-00014.parquet",
71
+ "sha256": "5c27b08e9559bf0ba8d63ed7f1daa7f19db0cd4fcb774d715e7d046e34a373b2",
72
+ "size": 273748222
73
+ }
74
+ ],
75
+ "repository": "PiotrSty/saos-polish-court-judgments",
76
+ "revision": "736cba4f92999e29d3e49409b0713c88fc683714"
77
+ }
artifacts/saos_source_profile.json ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "characters": 5895441856,
3
+ "counts": {
4
+ "email_placeholder_records": 289,
5
+ "empty_text": 1,
6
+ "invalid_judgment_dates": 1,
7
+ "invisible_character_records": 3315,
8
+ "missing_judges": 17599,
9
+ "phone_placeholder_records": 895,
10
+ "residual_labelled_phone_records": 31,
11
+ "row_groups": 70,
12
+ "rows": 296692,
13
+ "short_text": 3
14
+ },
15
+ "court_types": {
16
+ "COMMON": 229372,
17
+ "CONSTITUTIONAL_TRIBUNAL": 9503,
18
+ "NATIONAL_APPEAL_CHAMBER": 19758,
19
+ "SUPREME": 38059
20
+ },
21
+ "date_max": "2017-05-11",
22
+ "date_min": "0208-03-14",
23
+ "invalid_date_samples": [
24
+ {
25
+ "id": 358516,
26
+ "value": "0208-03-14T00:00:00"
27
+ }
28
+ ],
29
+ "judgment_types": {
30
+ "DECISION": 64761,
31
+ "REASONS": 18695,
32
+ "REGULATION": 3231,
33
+ "RESOLUTION": 2469,
34
+ "SENTENCE": 207536
35
+ },
36
+ "schema": "id: int64\ncourtType: string\njudgmentType: string\njudgmentDate: timestamp[ms]\ncaseNumbers: list<element: string>\n child 0, element: string\njudges: list<element: string>\n child 0, element: string\nsummary: string\ndecision: string\ntextContent: string\nlegalBases: list<element: string>\n child 0, element: string\nkeywords: list<element: string>\n child 0, element: string\nreferencedRegulations: list<element: struct<journalTitle: string, journalNo: int64, journalYear: int64, journalEntry: int64 (... 16 chars omitted)\n child 0, element: struct<journalTitle: string, journalNo: int64, journalYear: int64, journalEntry: int64, text: string (... 1 chars omitted)\n child 0, journalTitle: string\n child 1, journalNo: int64\n child 2, journalYear: int64\n child 3, journalEntry: int64\n child 4, text: string\nreferencedCourtCases: list<element: struct<caseNumber: string, judgmentIds: list<element: int64>, generated: bool>>\n child 0, element: struct<caseNumber: string, judgmentIds: list<element: int64>, generated: bool>\n child 0, caseNumber: string\n child 1, judgmentIds: list<element: int64>\n child 0, element: int64\n child 2, generated: bool\nsource: struct<code: string, judgmentUrl: string, judgmentId: string, publisher: string, reviser: string, pu (... 22 chars omitted)\n child 0, code: string\n child 1, judgmentUrl: string\n child 2, judgmentId: string\n child 3, publisher: string\n child 4, reviser: string\n child 5, publicationDate: string\nreceiptDate: string\ndivision: extension<arrow.json>\ntext_length: int64\n-- schema metadata --\nhuggingface: '{\"info\": {\"features\": {\"id\": {\"dtype\": \"int64\", \"_type\": \"V' + 1682",
37
+ "schemas_identical": true,
38
+ "shards": 14,
39
+ "text_length_max": 2260197,
40
+ "text_length_min": 0
41
+ }
artifacts/source_findings.md CHANGED
@@ -2297,3 +2297,36 @@ The datasheet states the caveats and gives the requested source note; the regist
2297
 
2298
  **Not established** — a lawyer's reading of the SIS terms; the SIS page on the fetch date (bot
2299
  challenge); the Kancelaria Sejmu BIP reuse page; personal names (NERGAL, v2#60).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2297
 
2298
  **Not established** — a lawyer's reading of the SIS terms; the SIS page on the fetch date (bot
2299
  challenge); the Kancelaria Sejmu BIP reuse page; personal names (NERGAL, v2#60).
2300
+
2301
+ ---
2302
+
2303
+ ## saos — Polish court judgments (pinned partial snapshot)
2304
+
2305
+ **Investigated** — 2026-09-04 (review round 2026-09-29).
2306
+
2307
+ **Verdict** — `added` (proposed with `release: None`). 296,689 judgments /
2308
+ 2.27B `cl100k_base` tokens (5.9B chars, dates 1986-05-28 – 2017-05-11) from
2309
+ SAOS — the biggest clean legal-language add since the HPLT removal, and
2310
+ explicitly a **partial** snapshot (54.9% of the live 2026-09-04 API count).
2311
+
2312
+ **Enumeration** — `https://www.saos.org.pl/api/dump/judgments` dump endpoint,
2313
+ captured as the immutable `PiotrSty/saos-polish-court-judgments@736cba4f` with
2314
+ per-record URLs; courts: COMMON 229,370 / SUPREME 38,058 / KIO 19,758 /
2315
+ Constitutional Tribunal 9,503 rows.
2316
+
2317
+ **License evidence** — Copyright Act art. 4(2) + Open Data Act basis, documented
2318
+ in `saos.license-evidence.json`; **formal legal review NOT performed** — the
2319
+ opinion scope (third-party quoted material inside judgments; privacy/GDPR of
2320
+ named private persons for TDM; SAOS/Ministry redistribution terms) and the
2321
+ responsible party (maintainer's Polish-legal reviewer) are written down in the
2322
+ datasheet so the gap is visible, not implicit.
2323
+
2324
+ **Blockers** — release gates: formal legal review (above) and NERGAL pass
2325
+ (pattern scrub only: 14 e-mails, 253 labelled IDs, 60 phones, 66 bank accounts;
2326
+ judgments name private persons). Cross-source text overlap vs
2327
+ `uzp_orzeczenia_pl` measured in the review thread (KIO family overlap).
2328
+
2329
+ **Lesson** — when a contribution explicitly says "legal review not performed",
2330
+ the review ask is not "do the law" but "write down exactly which legal questions
2331
+ remain and whose desk they land on" — turning an open flag into an assignable
2332
+ checklist is the deliverable engineering owes the release process.
data/saos/NOTICE.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Source attribution
2
+
3
+ Official source: System Analizy Orzeczen Sadowych (SAOS), https://www.saos.org.pl/. Per-record canonical SAOS URLs are preserved in saos.attribution.jsonl. Snapshot preparation and contribution: Piotr Styła (PiotrSty / PiotrStyla).
4
+
5
+ # Informacja o przetworzeniu / Processed-data notice
6
+
7
+ Per the reuse conditions of the Constitutional Tribunal (TK)
8
+ (https://trybunal.gov.pl/informacja-publiczna-media/ponowne-wykorzystywanie,
9
+ Warunek 1 and Warunek 2) and Article 15(1) of the Polish Open Data and Reuse
10
+ of Public Sector Information Act of 11 August 2021 (Dz. U. 2021 poz. 1641 as
11
+ amended), for the TK-originated documents contained in this dataset:
12
+
13
+ - **Source / Zrodlo:** System Analizy Orzeczen Sadowych (SAOS),
14
+ https://www.saos.org.pl/, dump API `api/dump/judgments` (documentation:
15
+ https://www.saos.org.pl/help/index.php/dokumentacja-api/api-pobierania-danych).
16
+ The TK documents reach this dataset through SAOS, which points to the
17
+ originating court systems (Ministry of Justice portal, Sad Najwyzszy, TK,
18
+ KIO) as the responsible publishers.
19
+ - **Time of creation / Czas wytworzenia:** judgment dates 1986-05-28 through
20
+ 2017-05-11 (per record in `saos.attribution.jsonl`, `judgmentDate`).
21
+ - **Time of retrieval / Czas pozyskania:** 2026-09-04 - the SAOS dump API was
22
+ queried and the snapshot pinned on that date (intermediary snapshot
23
+ `PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714`).
24
+ - **Author / Tworca:** judges and adjudicating panels named in the records
25
+ (`judges` field in the attribution sidecar), acting in their official
26
+ capacity; where unknown, the author is not stated.
27
+ - **The data has been processed / Dane zostaly przetworzone:** conversion to
28
+ the DynaWord source schema; NFKC Unicode and whitespace normalization;
29
+ stripping of HTML residue; exact-text deduplication (SHA-1 fingerprints);
30
+ conservative pattern-based PII scrubbing (e-mail, PESEL candidates, labelled
31
+ NIP/REGON, labelled phones, bank accounts); minimum-length and
32
+ Polish-diacritic gates; n-gram decontamination against a local reference
33
+ corpus. Automated processing may introduce errors; the processed texts are
34
+ not the official wording.
35
+
36
+ Warunek 3 note: the Constitutional Tribunal and its Chancellery accept no
37
+ responsibility for the content of processed public-sector information
38
+ originally made available in its primary form. The same disclaimer applies on
39
+ the SAOS side: SAOS accepts no responsibility for content and points to the
40
+ source systems. See `saos.md` ("Licensing and privacy") and
41
+ `saos.license-evidence.json` for the full chain-of-title gaps.
data/saos/saos.attribution.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0fda03e770bc8db94694f4758239ea6fda80e16e5398aee2b5a308a48896c857
3
+ size 180397031
data/saos/saos.license-evidence.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "copyright_basis": {
3
+ "act": "Polish Copyright and Related Rights Act",
4
+ "article": "4(2)",
5
+ "finding": "official documents and materials are excluded from copyright",
6
+ "url": "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
7
+ },
8
+ "dataset_record_license": "public-domain (official documents)",
9
+ "formal_legal_review": "not_performed",
10
+ "hf_source_card_license": "unknown",
11
+ "chain_of_title_gaps": [
12
+ "SAOS publishes no licence or terms of reuse: https://www.saos.org.pl/regulamin returns 404 (checked at review, 2026-10-05)",
13
+ "SAOS disclaims responsibility for content and points to the originating systems as the responsible publishers: the Ministry of Justice portal, Sad Najwyzszy (SN), Trybunal Konstytucyjny (TK) and Krajowa Izba Odwolawcza (KIO)",
14
+ "the intermediary snapshot PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714 declares license: unknown and no Creative Commons grant",
15
+ "TK documents carry reuse conditions (attribution + processed-data notice) per https://trybunal.gov.pl/informacja-publiczna-media/ponowne-wykorzystywanie; the notice is in NOTICE.md",
16
+ "SN and KIO reuse terms have not been obtained"
17
+ ],
18
+ "reuse_basis": {
19
+ "asserted_by_contributor": true,
20
+ "verified": false,
21
+ "note": "These Open Data Act articles were carried over from the sejm_api evidence pack and are the contributor's reading, NOT a reuse grant published by SAOS or any source court. They must not be read as a completed rights review of this source.",
22
+ "act": "Polish Open Data and Reuse of Public Sector Information Act",
23
+ "articles": [
24
+ "2(12)",
25
+ "5",
26
+ "6",
27
+ "14(1)",
28
+ "15",
29
+ "17"
30
+ ],
31
+ "url": "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
32
+ },
33
+ "limitations": [
34
+ "formal legal review has not been performed",
35
+ "privacy and personal-data exceptions remain",
36
+ "third-party works quoted or embedded in judgments may retain separate rights",
37
+ "no upstream Creative Commons grant is asserted",
38
+ "the pinned source snapshot is incomplete relative to the live SAOS count (54.9% as of 2026-09-04)",
39
+ "TK dissenting opinions (zdania odrębne) are included and not yet separated",
40
+ "4,541 KIO rows duplicate uzp_orzeczenia_pl and are not yet deduplicated across sources (the overlap audit ran with saos_rows: 0)"
41
+ ],
42
+ "official_source": "https://www.saos.org.pl/api/dump/judgments",
43
+ "official_source_documentation": "https://www.saos.org.pl/help/index.php/dokumentacja-api/api-pobierania-danych",
44
+ "pinned_source": "hf://datasets/PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714",
45
+ "pinned_target_base": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
46
+ "provider": "System Analizy Orzeczen Sadowych (SAOS)",
47
+ "retrieved_at": "2026-09-04",
48
+ "status": "documented-statutory-basis-chain-of-title-gaps-review-needed"
49
+ }
data/saos/saos.md ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # saos
2
+
3
+ Polish court judgments from the System Analizy Orzeczen Sadowych (SAOS),
4
+ converted from a pinned `PiotrSty` snapshot into the DynaWord source schema.
5
+
6
+ ## Dataset description
7
+
8
+ - Official origin: https://www.saos.org.pl/api/dump/judgments
9
+ - API documentation: https://www.saos.org.pl/help/index.php/dokumentacja-api/api-pobierania-danych
10
+ - Pinned source: `PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714`
11
+ - Domain: legal/judicial
12
+ - Language: Polish (`pl`)
13
+ - License label: `public-domain (official documents)`
14
+ - Valid judgment dates: 1986-05-28 through 2017-05-11
15
+ - Added: 2026-09-04
16
+ - Contributor: Piotr Styła (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub)
17
+
18
+ ## Snapshot scope and completeness
19
+
20
+ The source contains **296,692** processed records. A direct query
21
+ of the official SAOS API on 2026-09-04 returned
22
+ **540,726** items. This version therefore represents
23
+ approximately **54.9%** of the live count and MUST NOT be described as a
24
+ complete or current copy of SAOS. The immutable snapshot remains useful as a
25
+ large, auditable legal-language contribution; later synchronization belongs in a
26
+ new dataset Version and Run.
27
+
28
+ ## Content and provenance
29
+
30
+ Each DynaWord row uses the normalized full judgment text. The attribution
31
+ sidecar preserves the source ID, canonical SAOS URL, upstream source URL, court
32
+ type, judgment type, case numbers, named judges acting in an official capacity,
33
+ raw judgment date, source shard and pinned source revision. Generated SAOS
34
+ enrichment fields are not used as training-text claims.
35
+
36
+ ## Courts represented
37
+
38
+ | court type | source rows |
39
+ |---|---:|
40
+ | `COMMON` | 229,370 |
41
+ | `CONSTITUTIONAL_TRIBUNAL` | 9,503 |
42
+ | `NATIONAL_APPEAL_CHAMBER` | 19,758 |
43
+ | `SUPREME` | 38,058 |
44
+
45
+ ## Processing
46
+
47
+ - NFKC Unicode normalization, normalized spaces/quotes/dashes and preserved paragraphs.
48
+ - Article and section numbering is retained because it is substantive legal content.
49
+ - Exact normalized-text deduplication with SHA-1 fingerprints.
50
+ - Minimum 200 characters and the DynaWord Polish-diacritic ratio gate (`>= 0.005`).
51
+ - Pattern scrubbing for email, PESEL candidates, labelled NIP/REGON, labelled phones and bank accounts.
52
+ - Implausible or unparsable judgment dates are left empty in the training schema and preserved raw in the sidecar.
53
+ - HTML residue causes a build failure rather than silently entering the corpus.
54
+
55
+ ## Statistics
56
+
57
+ | measure | value |
58
+ |---|---:|
59
+ | Source records | 296,692 |
60
+ | Documents published | 296,689 |
61
+ | Dropped under 200 characters | 3 |
62
+ | Dropped by Polish-language gate | 0 |
63
+ | Exact normalized duplicates removed | 0 |
64
+ | Records with invalid/implausible dates | 1 |
65
+ | Documents with judge attribution | 279,091 |
66
+ | Characters | 5,897,001,250 |
67
+ | Tokens (`cl100k_base` proxy) | 2,265,448,504 |
68
+
69
+ ## Licensing and privacy
70
+
71
+ Court judgments are documented here as official materials excluded from
72
+ copyright under article 4(2) of the Polish Copyright Act (the basis identified
73
+ in the 2026-10-05 rights review - this is a statutory exclusion, not a
74
+ packaging licence). **Chain-of-title gaps, stated plainly:**
75
+
76
+ - SAOS publishes **no licence or terms of reuse** - `https://www.saos.org.pl/regulamin` returns 404;
77
+ - SAOS **disclaims responsibility for content** and points to the originating systems as the responsible publishers: the Ministry of Justice portal, Sad Najwyzszy (SN), Trybunal Konstytucyjny (TK) and Krajowa Izba Odwolawcza (KIO);
78
+ - the intermediary snapshot `PiotrSty/saos-polish-court-judgments@736cba4` declares `license: unknown`; no Creative Commons grant is asserted at any level;
79
+ - the Open Data Act wording previously cited here was carried over from the `sejm_api` evidence pack; it is the contributor's reading and must not be read as a completed rights review of this source (`saos.license-evidence.json` now flags it as `verified: false`).
80
+
81
+ TK-originated documents carry reuse conditions (attribution + processed-data
82
+ notice): the notice with source and retrieval time is in `NOTICE.md`
83
+ ("Informacja o przetworzeniu"). No formal legal opinion was performed; privacy
84
+ exceptions and separate rights in quoted or embedded works remain. This is
85
+ provenance and engineering documentation, not legal advice.
86
+
87
+ The source reports prior PII scrubbing. This conversion reruns conservative
88
+ pattern-based scrubbing, but does not claim perfect de-identification. Court-
89
+ published anonymization is retained; names of judges acting publicly in their
90
+ official capacity are preserved as attribution.
91
+
92
+ ## Review addenda (2026-09-29)
93
+
94
+ **Scrubber that ran / NERGAL gate.** The scrubber is the pattern pass in
95
+ `src/fetch_saos.py` (e-mail, PESEL candidates, labelled NIP/REGON, labelled
96
+ phones, bank accounts -> `[PII]`-style placeholders; 14 e-mails, 253 labelled
97
+ identifiers, 60 labelled phones and 66 bank-account strings replaced in this
98
+ build). This is **not**
99
+ [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL). The shard must be
100
+ re-run through NERGAL before it is admitted to a release — judgments name
101
+ private persons (parties, attorneys, witnesses) in official capacity contexts
102
+ where the boundary is a legal question, not a regex question. Merge with
103
+ `release: None` is fine meanwhile.
104
+
105
+ **Legal review — what is needed and who does it.** A formal legal opinion has
106
+ NOT been performed. Needed before release, on the merged corpus as used for
107
+ training:
108
+
109
+ 1. Copyright-status confirmation of the art. 4(2) exclusion as applied to full
110
+ judgment texts, including **third-party quoted material inside judgments**
111
+ (party submissions, cited reports, quoted correspondence) which may carry
112
+ separate rights;
113
+ 2. Privacy/GDPR assessment of named private persons in published judgments
114
+ (parties, attorneys, witnesses) for text-and-data-mining reuse — including
115
+ the CJEU/Polish case-law overlay on court-publication practice;
116
+ 3. Provider-side terms check (SAOS / Ministry of Justice redistribution terms).
117
+
118
+ Responsible: the corpus maintainer's legal reviewer (Polish legal background —
119
+ bar/counsel or the institution's legal team). The engineering side can only
120
+ prepare the evidence pack: per-record URLs/court metadata (in the sidecar), the
121
+ `license-evidence.json` snapshot, and sample spot-checks — none of which
122
+ substitutes for the opinion. Until it lands, the source is mergeable with
123
+ `release: None` and excluded from any stable release.
124
+
125
+ ## Rights review addendum (2026-10-05)
126
+
127
+ Addressed in this revision: the TK processed-data notice (source, creation and
128
+ retrieval times, processing description) is added to `NOTICE.md` and summarised
129
+ above; the chain-of-title gaps are stated in this card and machine-readably in
130
+ `saos.license-evidence.json`; the borrowed `sejm_api` Open Data Act framing is
131
+ marked as unverified.
132
+
133
+ Still required **before any release** (merge with `release: None` is fine
134
+ meanwhile):
135
+
136
+ 1. A Polish legal opinion covering reasons, dissents, KIO/TK material and
137
+ quoted third-party works inside judgments.
138
+ 2. Stripping the TK dissenting opinions (`zdania odrębne`, approx. 450
139
+ documents) from the training texts.
140
+ 3. [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL) in place of the
141
+ regex PII scrub.
142
+ 4. Cross-source dedup of the 4,541 KIO rows that duplicate
143
+ `uzp_orzeczenia_pl` - the overlap audit ran with `saos_rows: 0` and is not
144
+ evidence of disjointness.
145
+ 5. A re-pull from the SAOS dump API with a recorded date; this snapshot covers
146
+ 54.9% of live SAOS (540,726 items as of 2026-09-04).
147
+ 6. A documented takedown path for removed/anonymised judgments.
148
+ 7. SN and KIO reuse terms obtained from the originating bodies.
149
+
150
+ ## Known limitations
151
+
152
+ - Partial historical snapshot, not the complete current SAOS database.
153
+ - Legal/judicial register is already heavily represented in Polish DynaWord;
154
+ inclusion changes the training mix and should be evaluated through ablations.
155
+ - Pattern-based PII detection can have false negatives and false positives.
156
+ - Upstream source transformations are described in its card but the repository
157
+ does not include the original collection code or standalone audit artifacts.
data/saos/saos.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f265dfe410aef0b0a2453f16e05d6398292af6a66db713bfaad554b4ee0dbf55
3
+ size 1931132709
data/saos/saos.stats.json ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added": "2026-09-04",
3
+ "authors_with_value": 279091,
4
+ "by_court_type": {
5
+ "COMMON": 229370,
6
+ "CONSTITUTIONAL_TRIBUNAL": 9503,
7
+ "NATIONAL_APPEAL_CHAMBER": 19758,
8
+ "SUPREME": 38058
9
+ },
10
+ "by_judgment_type": {
11
+ "DECISION": 64761,
12
+ "REASONS": 18693,
13
+ "REGULATION": 3231,
14
+ "RESOLUTION": 2469,
15
+ "SENTENCE": 207535
16
+ },
17
+ "chars": 5897001250,
18
+ "created_max": "2017-05-11",
19
+ "created_min": "1986-05-28",
20
+ "drop_dup": 0,
21
+ "drop_lang": 0,
22
+ "drop_short": 3,
23
+ "invalid_dates": 1,
24
+ "kept": 296689,
25
+ "license": "public-domain (official documents)",
26
+ "licenses": {
27
+ "public-domain (official documents)": 296689
28
+ },
29
+ "normalization": {
30
+ "bank_accounts_redacted": 66,
31
+ "control_characters_removed": 0,
32
+ "emails_redacted": 14,
33
+ "labelled_identifiers_redacted": 253,
34
+ "labelled_phones_redacted": 60,
35
+ "normalized_records": 263987,
36
+ "pesel_candidates_redacted": 0
37
+ },
38
+ "official_count_observed_at": "2026-09-04",
39
+ "official_total_results": 540726,
40
+ "snapshot_live_count_ratio": 0.5486919437940843,
41
+ "source_revision": "736cba4f92999e29d3e49409b0713c88fc683714",
42
+ "source_rows": 296692,
43
+ "stats_recomputed_from_parquet": true,
44
+ "target_base_revision": "a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
45
+ "tokens": 2265448504
46
+ }
src/fetch_saos.py ADDED
@@ -0,0 +1,1014 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build a pinned PiotrSty SAOS snapshot for Polish DynaWord."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import collections
8
+ import concurrent.futures
9
+ import datetime as dt
10
+ import hashlib
11
+ import html
12
+ import importlib.metadata
13
+ import json
14
+ import pathlib
15
+ import platform
16
+ import re
17
+ import shutil
18
+ import sys
19
+ import unicodedata
20
+ from typing import Any
21
+
22
+
23
+ SOURCE_NAME = "saos"
24
+ SOURCE_REPOSITORY = "PiotrSty/saos-polish-court-judgments"
25
+ TARGET_REPOSITORY = "SlayerLab/polish-dynaword"
26
+ OFFICIAL_API = "https://www.saos.org.pl/api/dump/judgments"
27
+ OFFICIAL_API_DOCS = "https://www.saos.org.pl/help/index.php/dokumentacja-api/api-pobierania-danych"
28
+ SOURCE_LICENSE = "public-domain (official documents)"
29
+ COPYRIGHT_ACT = "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
30
+ OPEN_DATA_ACT = "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
31
+ COMMIT_PATTERN = re.compile(r"^[0-9a-f]{40}$")
32
+ EXPECTED_FIELDS = (
33
+ "id", "text", "source", "added", "created", "token_count", "license", "author"
34
+ )
35
+ POLISH_RE = re.compile(r"[\u0105\u0107\u0119\u0142\u0144\u00f3\u015b\u017a\u017c\u0104\u0106\u0118\u0141\u0143\u00d3\u015a\u0179\u017b]")
36
+ ALPHA_RE = re.compile(r"[^\W\d_]", re.UNICODE)
37
+ HTML_TAG = re.compile(
38
+ r"</?(?:p|div|span|br|h[1-6]|table|tbody|thead|tr|td|th|ul|ol|li|strong|em|b|i|a|section)"
39
+ r"\s*/?>",
40
+ re.I,
41
+ )
42
+ EMAIL = re.compile(r"(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b")
43
+ PESEL = re.compile(r"(?<!\d)\d{11}(?!\d)")
44
+ LABELLED_IDENTIFIER = re.compile(
45
+ r"(?i)\b(?:NIP|REGON)\s*[:.]?\s*\d(?:[\s-]?\d){8,13}\b"
46
+ )
47
+ LABELLED_PHONE = re.compile(
48
+ r"(?i)(?:\btel\.?|\btelefon|\+48)\s*[:.]?\s*(?:\(?\d{2,3}\)?[\s.-]?){3,5}\d{2,3}"
49
+ )
50
+ BANK_ACCOUNT = re.compile(r"(?<!\d)(?:PL\s*)?\d{2}(?:[\s-]*\d{4}){6}(?!\d)", re.I)
51
+ SPACE_RUN = re.compile(r"[ \t\v\f]+")
52
+ BLANK_RUN = re.compile(r"\n{3,}")
53
+ CONTROL = re.compile(r"[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]")
54
+ TRANSLATION = str.maketrans({
55
+ "\u00a0": " ", "\u2007": " ", "\u202f": " ", "\u200b": "",
56
+ "\ufeff": "", "\u00ad": "", "\u2010": "-", "\u2011": "-",
57
+ "\u2012": "-", "\u2013": "-", "\u2014": "-", "\u2212": "-",
58
+ "\u2018": "'", "\u2019": "'", "\u201c": '"', "\u201d": '"',
59
+ "\u2026": "...",
60
+ })
61
+
62
+
63
+ class BuildError(ValueError):
64
+ pass
65
+
66
+
67
+ def utc_now() -> str:
68
+ return dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
69
+
70
+
71
+ def sha256_file(path: pathlib.Path) -> str:
72
+ digest = hashlib.sha256()
73
+ with path.open("rb") as stream:
74
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
75
+ digest.update(chunk)
76
+ return digest.hexdigest()
77
+
78
+
79
+ def canonical_sha256(value: Any) -> str:
80
+ payload = json.dumps(
81
+ value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
82
+ ).encode("utf-8")
83
+ return hashlib.sha256(payload).hexdigest()
84
+
85
+
86
+ def write_json(path: pathlib.Path, payload: Any) -> None:
87
+ path.write_text(
88
+ json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True, default=str) + "\n",
89
+ encoding="utf-8",
90
+ )
91
+
92
+
93
+ def first_text(value: Any) -> str:
94
+ if value is None:
95
+ return ""
96
+ if isinstance(value, dict):
97
+ return str(value.get("name") or value.get("caseNumber") or value.get("id") or "").strip()
98
+ return str(value).strip()
99
+
100
+
101
+ def list_text(value: Any) -> list[str]:
102
+ if not isinstance(value, list):
103
+ return [first_text(value)] if first_text(value) else []
104
+ return [text for item in value if (text := first_text(item))]
105
+
106
+
107
+ def normalize_text(value: Any) -> tuple[str, collections.Counter[str]]:
108
+ stats: collections.Counter[str] = collections.Counter()
109
+ original = str(value or "")
110
+ text = html.unescape(unicodedata.normalize("NFKC", original)).translate(TRANSLATION)
111
+ text, controls = CONTROL.subn("", text)
112
+ stats["control_characters_removed"] += controls
113
+ lines = [SPACE_RUN.sub(" ", line).strip() for line in text.replace("\r", "\n").split("\n")]
114
+ text = BLANK_RUN.sub("\n\n", "\n".join(lines)).strip()
115
+ if text != original.strip():
116
+ stats["normalized_records"] += 1
117
+ for pattern, key, replacement in (
118
+ (EMAIL, "emails_redacted", "[PII:EMAIL]"),
119
+ (LABELLED_IDENTIFIER, "labelled_identifiers_redacted", "[PII:IDENTIFIER]"),
120
+ (PESEL, "pesel_candidates_redacted", "[PII:PESEL]"),
121
+ (LABELLED_PHONE, "labelled_phones_redacted", "[PII:PHONE]"),
122
+ (BANK_ACCOUNT, "bank_accounts_redacted", "[PII:ACCOUNT]"),
123
+ ):
124
+ text, count = pattern.subn(replacement, text)
125
+ stats[key] += count
126
+ return text, stats
127
+
128
+
129
+ def polish_ratio(text: str) -> float:
130
+ letters = ALPHA_RE.findall(text)
131
+ return len(POLISH_RE.findall(text)) / len(letters) if letters else 0.0
132
+
133
+
134
+ def normalize_date(value: Any) -> tuple[str, str, bool]:
135
+ raw = value.isoformat() if isinstance(value, (dt.date, dt.datetime)) else str(value or "")
136
+ candidate = raw[:10]
137
+ try:
138
+ parsed = dt.date.fromisoformat(candidate)
139
+ except ValueError:
140
+ return "", raw, False
141
+ valid = 1900 <= parsed.year <= dt.date.today().year + 1
142
+ return (parsed.isoformat() if valid else ""), raw, valid
143
+
144
+
145
+ def output_schema(pa: Any) -> Any:
146
+ return pa.schema([
147
+ ("id", pa.string()), ("text", pa.string()), ("source", pa.string()),
148
+ ("added", pa.string()), ("created", pa.string()), ("token_count", pa.int64()),
149
+ ("license", pa.string()), ("author", pa.string()),
150
+ ])
151
+
152
+
153
+ def process_source_shard(task: tuple[str, str, str, str, int, int]) -> dict[str, Any]:
154
+ """Transform one pinned source shard into a deterministic intermediate part."""
155
+ shard_name, part_name, added_date, source_revision, batch_size, token_threads = task
156
+ import pyarrow as pa
157
+ import pyarrow.parquet as pq
158
+ import tiktoken
159
+
160
+ shard = pathlib.Path(shard_name)
161
+ part_dir = pathlib.Path(part_name)
162
+ part_dir.mkdir(parents=True, exist_ok=True)
163
+ parquet_path = part_dir / "data.parquet"
164
+ sidecar_path = part_dir / "attribution.jsonl"
165
+ identity_path = part_dir / "identities.tsv"
166
+ schema = output_schema(pa)
167
+ encoder = tiktoken.get_encoding("cl100k_base")
168
+ counts: collections.Counter[str] = collections.Counter()
169
+ normalization: collections.Counter[str] = collections.Counter()
170
+ court_types: collections.Counter[str] = collections.Counter()
171
+ judgment_types: collections.Counter[str] = collections.Counter()
172
+ seen_ids: set[str] = set()
173
+ seen_texts: set[bytes] = set()
174
+ dates: list[str] = []
175
+ source_parquet = pq.ParquetFile(shard)
176
+ required = {"id", "textContent", "judgmentDate", "courtType", "judgmentType", "caseNumbers", "judges", "source"}
177
+ if not required <= set(source_parquet.schema_arrow.names):
178
+ raise BuildError(f"unexpected source schema in {shard.name}")
179
+
180
+ writer = pq.ParquetWriter(parquet_path, schema, compression="zstd")
181
+ try:
182
+ with sidecar_path.open("w", encoding="utf-8") as sidecar, identity_path.open("w", encoding="ascii") as identities:
183
+ for batch in source_parquet.iter_batches(batch_size=batch_size):
184
+ prepared = []
185
+ for row in batch.to_pylist():
186
+ counts["source_rows"] += 1
187
+ source_id = str(row.get("id") or "").strip()
188
+ if not source_id or source_id in seen_ids:
189
+ counts["drop_duplicate_or_empty_id"] += 1
190
+ continue
191
+ seen_ids.add(source_id)
192
+ text, changes = normalize_text(row.get("textContent"))
193
+ normalization.update(changes)
194
+ if HTML_TAG.search(text):
195
+ raise BuildError(f"HTML residue in source record {source_id}")
196
+ if len(text) < 200:
197
+ counts["drop_short"] += 1
198
+ continue
199
+ if polish_ratio(text) < 0.005:
200
+ counts["drop_lang"] += 1
201
+ continue
202
+ text_digest = hashlib.sha1(text.encode("utf-8")).digest()
203
+ if text_digest in seen_texts:
204
+ counts["drop_dup"] += 1
205
+ continue
206
+ seen_texts.add(text_digest)
207
+ created, raw_date, valid_date = normalize_date(row.get("judgmentDate"))
208
+ if not valid_date:
209
+ counts["invalid_dates"] += 1
210
+ else:
211
+ dates.append(created)
212
+ judges = list_text(row.get("judges"))
213
+ author = "; ".join(judges)
214
+ court_type = str(row.get("courtType") or "")
215
+ judgment_type = str(row.get("judgmentType") or "")
216
+ court_types[court_type] += 1
217
+ judgment_types[judgment_type] += 1
218
+ prepared.append((source_id, text, text_digest, created, raw_date, author, judges, court_type, judgment_type, row))
219
+
220
+ texts = [item[1] for item in prepared]
221
+ token_counts = [
222
+ len(tokens) for tokens in encoder.encode_ordinary_batch(texts, num_threads=token_threads)
223
+ ] if texts else []
224
+ documents = []
225
+ for item, token_count in zip(prepared, token_counts):
226
+ source_id, text, text_digest, created, raw_date, author, judges, court_type, judgment_type, row = item
227
+ document_id = f"{SOURCE_NAME}_{source_id}"
228
+ documents.append({
229
+ "id": document_id, "text": text, "source": SOURCE_NAME,
230
+ "added": added_date, "created": created, "token_count": token_count,
231
+ "license": SOURCE_LICENSE, "author": author,
232
+ })
233
+ source_meta = row.get("source") if isinstance(row.get("source"), dict) else {}
234
+ sidecar.write(json.dumps({
235
+ "id": document_id,
236
+ "source_id": source_id,
237
+ "official_url": f"https://www.saos.org.pl/judgments/{source_id}",
238
+ "upstream_judgment_url": source_meta.get("judgmentUrl"),
239
+ "upstream_source_code": source_meta.get("code"),
240
+ "court_type": court_type,
241
+ "judgment_type": judgment_type,
242
+ "case_numbers": list_text(row.get("caseNumbers")),
243
+ "judges": judges,
244
+ "judgment_date_raw": raw_date,
245
+ "judgment_date_status": "valid" if created else "invalid_or_implausible",
246
+ "source_revision": source_revision,
247
+ "source_shard": shard.name,
248
+ }, ensure_ascii=False, sort_keys=True, default=str) + "\n")
249
+ identities.write(f"{source_id}\t{text_digest.hex()}\n")
250
+ counts["kept"] += 1
251
+ counts["chars"] += len(text)
252
+ counts["tokens"] += token_count
253
+ counts["authors_with_value"] += bool(author)
254
+ if documents:
255
+ writer.write_table(pa.Table.from_pylist(documents, schema=schema))
256
+ finally:
257
+ writer.close()
258
+
259
+ return {
260
+ "shard": shard.name,
261
+ "parquet": str(parquet_path),
262
+ "sidecar": str(sidecar_path),
263
+ "identities": str(identity_path),
264
+ "counts": dict(counts),
265
+ "normalization": dict(normalization),
266
+ "court_types": dict(court_types),
267
+ "judgment_types": dict(judgment_types),
268
+ "created_min": min(dates) if dates else "",
269
+ "created_max": max(dates) if dates else "",
270
+ }
271
+
272
+
273
+ def registry_entry(stats: dict[str, Any], source_revision: str) -> str:
274
+ return (
275
+ f' "{SOURCE_NAME}": {{\n'
276
+ f' "file_key": "{SOURCE_NAME}",\n'
277
+ ' "pretty": "SAOS - Polish court judgments (pinned partial snapshot)",\n'
278
+ f' "license": "{SOURCE_LICENSE}",\n'
279
+ ' "license_spdx": "LicenseRef-Polish-Official-Documents",\n'
280
+ ' "traceable": "Court judgments are documented as official materials outside "\n'
281
+ ' "copyright under Polish Copyright Act art. 4(2); formal legal "\n'
282
+ ' "review has not been performed and statutory limitations remain.",\n'
283
+ f' "upstream": "{OFFICIAL_API}",\n'
284
+ ' "provenance": "Converted from the immutable "\n'
285
+ f' "{SOURCE_REPOSITORY}@{source_revision} snapshot; per-record "\n'
286
+ ' "SAOS URLs and source identifiers are preserved in a sidecar.",\n'
287
+ ' "domain": "legal/judicial",\n'
288
+ f' "created": "{stats["created_min"]}, {stats["created_max"]}",\n'
289
+ ' "is_ocr": False,\n'
290
+ ' "custom_datasheet": True,\n'
291
+ ' },\n'
292
+ )
293
+
294
+
295
+ def update_registry(registry: str, stats: dict[str, Any], source_revision: str) -> str:
296
+ if re.search(rf'^\s{{4}}["\']{SOURCE_NAME}["\']\s*:', registry, re.MULTILINE):
297
+ raise BuildError(f"{SOURCE_NAME} already exists in the target registry")
298
+ marker = ' "dziennik_ustaw": {'
299
+ if registry.count(marker) != 1:
300
+ raise BuildError("cannot locate the dziennik_ustaw registry entry")
301
+ return registry.replace(marker, registry_entry(stats, source_revision) + marker, 1)
302
+
303
+
304
+ def update_findings(findings: str, stats: dict[str, Any], args: argparse.Namespace) -> str:
305
+ marker = "### SAOS snapshot contribution update (2026-09-04)"
306
+ if marker in findings:
307
+ raise BuildError("SAOS findings update already exists")
308
+ coverage = stats["source_rows"] / args.official_total_results
309
+ addition = f"""
310
+
311
+ {marker}
312
+
313
+ `{SOURCE_REPOSITORY}@{args.source_revision}` contains **{stats['source_rows']:,}**
314
+ processed judgments. The official SAOS dump exposed **{args.official_total_results:,}**
315
+ items when checked on {args.official_count_observed_at}; the pinned snapshot is
316
+ therefore a **partial snapshot** ({coverage:.1%} of that live count), not a claim
317
+ of current SAOS completeness. The contribution preserves this limitation in its
318
+ ontology Evidence, Claim, attestation and datasheet. It contributes the available
319
+ cleaned legal text now while leaving a later incremental SAOS synchronization as
320
+ a separate versioned task.
321
+ """
322
+ return findings.rstrip() + addition + "\n"
323
+
324
+
325
+ def legal_evidence(args: argparse.Namespace) -> dict[str, Any]:
326
+ return {
327
+ "status": "documented-statutory-basis-review-needed",
328
+ "formal_legal_review": "not_performed",
329
+ "dataset_record_license": SOURCE_LICENSE,
330
+ "hf_source_card_license": "unknown",
331
+ "provider": "System Analizy Orzeczen Sadowych (SAOS)",
332
+ "official_source": OFFICIAL_API,
333
+ "official_source_documentation": OFFICIAL_API_DOCS,
334
+ "copyright_basis": {
335
+ "act": "Polish Copyright and Related Rights Act",
336
+ "article": "4(2)",
337
+ "finding": "official documents and materials are excluded from copyright",
338
+ "url": COPYRIGHT_ACT,
339
+ },
340
+ "reuse_basis": {
341
+ "act": "Polish Open Data and Reuse of Public Sector Information Act",
342
+ "articles": ["2(12)", "5", "6", "14(1)", "15", "17"],
343
+ "url": OPEN_DATA_ACT,
344
+ },
345
+ "limitations": [
346
+ "formal legal review has not been performed",
347
+ "privacy and personal-data exceptions remain",
348
+ "third-party works quoted or embedded in judgments may retain separate rights",
349
+ "no upstream Creative Commons grant is asserted",
350
+ "the pinned source snapshot is incomplete relative to the live SAOS count",
351
+ ],
352
+ "pinned_source": f"hf://datasets/{SOURCE_REPOSITORY}@{args.source_revision}",
353
+ "pinned_target_base": f"hf://datasets/{TARGET_REPOSITORY}@{args.target_revision}",
354
+ }
355
+
356
+
357
+ def datasheet(stats: dict[str, Any], args: argparse.Namespace) -> str:
358
+ coverage = stats["source_rows"] / args.official_total_results
359
+ court_rows = "\n".join(
360
+ f"| `{key}` | {value:,} |" for key, value in stats["by_court_type"].items()
361
+ )
362
+ return f"""# {SOURCE_NAME}
363
+
364
+ Polish court judgments from the System Analizy Orzeczen Sadowych (SAOS),
365
+ converted from a pinned `PiotrSty` snapshot into the DynaWord source schema.
366
+
367
+ ## Dataset description
368
+
369
+ - Official origin: {OFFICIAL_API}
370
+ - API documentation: {OFFICIAL_API_DOCS}
371
+ - Pinned source: `{SOURCE_REPOSITORY}@{args.source_revision}`
372
+ - Domain: legal/judicial
373
+ - Language: Polish (`pl`)
374
+ - License label: `{SOURCE_LICENSE}`
375
+ - Valid judgment dates: {stats['created_min']} through {stats['created_max']}
376
+ - Added: {args.added_date}
377
+ - Contributor: Piotr Sty\u0142a (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub)
378
+
379
+ ## Snapshot scope and completeness
380
+
381
+ The source contains **{stats['source_rows']:,}** processed records. A direct query
382
+ of the official SAOS API on {args.official_count_observed_at} returned
383
+ **{args.official_total_results:,}** items. This version therefore represents
384
+ approximately **{coverage:.1%}** of the live count and MUST NOT be described as a
385
+ complete or current copy of SAOS. The immutable snapshot remains useful as a
386
+ large, auditable legal-language contribution; later synchronization belongs in a
387
+ new dataset Version and Run.
388
+
389
+ ## Content and provenance
390
+
391
+ Each DynaWord row uses the normalized full judgment text. The attribution
392
+ sidecar preserves the source ID, canonical SAOS URL, upstream source URL, court
393
+ type, judgment type, case numbers, named judges acting in an official capacity,
394
+ raw judgment date, source shard and pinned source revision. Generated SAOS
395
+ enrichment fields are not used as training-text claims.
396
+
397
+ ## Courts represented
398
+
399
+ | court type | source rows |
400
+ |---|---:|
401
+ {court_rows}
402
+
403
+ ## Processing
404
+
405
+ - NFKC Unicode normalization, normalized spaces/quotes/dashes and preserved paragraphs.
406
+ - Article and section numbering is retained because it is substantive legal content.
407
+ - Exact normalized-text deduplication with SHA-1 fingerprints.
408
+ - Minimum 200 characters and the DynaWord Polish-diacritic ratio gate (`>= 0.005`).
409
+ - Pattern scrubbing for email, PESEL candidates, labelled NIP/REGON, labelled phones and bank accounts.
410
+ - Implausible or unparsable judgment dates are left empty in the training schema and preserved raw in the sidecar.
411
+ - HTML residue causes a build failure rather than silently entering the corpus.
412
+
413
+ ## Statistics
414
+
415
+ | measure | value |
416
+ |---|---:|
417
+ | Source records | {stats['source_rows']:,} |
418
+ | Documents published | {stats['kept']:,} |
419
+ | Dropped under 200 characters | {stats['drop_short']:,} |
420
+ | Dropped by Polish-language gate | {stats['drop_lang']:,} |
421
+ | Exact normalized duplicates removed | {stats['drop_dup']:,} |
422
+ | Records with invalid/implausible dates | {stats['invalid_dates']:,} |
423
+ | Documents with judge attribution | {stats['authors_with_value']:,} |
424
+ | Characters | {stats['chars']:,} |
425
+ | Tokens (`cl100k_base` proxy) | {stats['tokens']:,} |
426
+
427
+ ## Licensing and privacy
428
+
429
+ Court judgments are documented here as official materials excluded from
430
+ copyright under article 4(2) of the Polish Copyright Act, with reuse considered
431
+ under the Polish Open Data Act. The source card itself declares `license:
432
+ unknown`, no Creative Commons grant is asserted, and no formal legal opinion was
433
+ performed. Privacy exceptions and separate rights in quoted or embedded works
434
+ remain. This is provenance and engineering documentation, not legal advice.
435
+
436
+ The source reports prior PII scrubbing. This conversion reruns conservative
437
+ pattern-based scrubbing, but does not claim perfect de-identification. Court-
438
+ published anonymization is retained; names of judges acting publicly in their
439
+ official capacity are preserved as attribution.
440
+
441
+ ## Known limitations
442
+
443
+ - Partial historical snapshot, not the complete current SAOS database.
444
+ - Legal/judicial register is already heavily represented in Polish DynaWord;
445
+ inclusion changes the training mix and should be evaluated through ablations.
446
+ - Pattern-based PII detection can have false negatives and false positives.
447
+ - Upstream source transformations are described in its card but the repository
448
+ does not include the original collection code or standalone audit artifacts.
449
+ """
450
+
451
+
452
+ def contract_test() -> str:
453
+ return fr'''"""Contract and ontology checks for the {SOURCE_NAME} contribution."""
454
+
455
+ import hashlib
456
+ import json
457
+ import pathlib
458
+ import re
459
+
460
+ import pyarrow.parquet as pq
461
+
462
+
463
+ ROOT = pathlib.Path(__file__).resolve().parents[1]
464
+ DATA = ROOT / "data" / "{SOURCE_NAME}"
465
+ MANIFEST = ROOT / "artifacts" / "{SOURCE_NAME}_ontology_manifest.json"
466
+ FIELDS = {list(EXPECTED_FIELDS)!r}
467
+
468
+
469
+ def sha256_file(path):
470
+ digest = hashlib.sha256()
471
+ with path.open("rb") as stream:
472
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
473
+ digest.update(chunk)
474
+ return digest.hexdigest()
475
+
476
+
477
+ def test_data_schema_and_stats():
478
+ parquet = DATA / "{SOURCE_NAME}.parquet"
479
+ stats = json.loads((DATA / "{SOURCE_NAME}.stats.json").read_text(encoding="utf-8"))
480
+ source_values, license_values, ids = set(), set(), set()
481
+ rows = chars = tokens = authors = 0
482
+ for batch in pq.ParquetFile(parquet).iter_batches(batch_size=256):
483
+ assert batch.schema.names == FIELDS
484
+ for row in batch.to_pylist():
485
+ rows += 1
486
+ assert row["id"] not in ids
487
+ ids.add(row["id"])
488
+ assert len(row["text"]) >= 200
489
+ assert row["token_count"] > 0
490
+ assert not re.search(
491
+ r"</?(?:p|div|span|br|h[1-6]|table|tbody|thead|tr|td|th|ul|ol|li|strong|em|b|i|a|section)\s*/?>",
492
+ row["text"],
493
+ re.I,
494
+ )
495
+ assert not row["created"] or re.fullmatch(r"20\d{{2}}-\d{{2}}-\d{{2}}|19\d{{2}}-\d{{2}}-\d{{2}}", row["created"])
496
+ source_values.add(row["source"])
497
+ license_values.add(row["license"])
498
+ chars += len(row["text"])
499
+ tokens += row["token_count"]
500
+ authors += bool(row["author"])
501
+ assert rows == stats["kept"]
502
+ assert chars == stats["chars"]
503
+ assert tokens == stats["tokens"]
504
+ assert authors == stats["authors_with_value"]
505
+ assert source_values == {{"{SOURCE_NAME}"}}
506
+ assert license_values == {{"{SOURCE_LICENSE}"}}
507
+
508
+
509
+ def test_sidecar_legal_and_snapshot_honesty():
510
+ stats = json.loads((DATA / "{SOURCE_NAME}.stats.json").read_text(encoding="utf-8"))
511
+ sidecar = DATA / "{SOURCE_NAME}.attribution.jsonl"
512
+ assert sum(1 for _ in sidecar.open(encoding="utf-8")) == stats["kept"]
513
+ legal = json.loads((DATA / "{SOURCE_NAME}.license-evidence.json").read_text(encoding="utf-8"))
514
+ assert legal["formal_legal_review"] == "not_performed"
515
+ assert legal["hf_source_card_license"] == "unknown"
516
+ assert legal["pinned_source"].endswith(stats["source_revision"])
517
+ assert stats["official_total_results"] > stats["source_rows"]
518
+
519
+
520
+ def test_ontology_kernel_and_references():
521
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
522
+ required = {{"object", "version", "protocol", "run", "relations", "evidence",
523
+ "claims", "claim_evidence", "actors", "attestations"}}
524
+ assert required <= set(manifest)
525
+ assert manifest["ontology_version"] == "slayer.ai/research-ontology/v0.1"
526
+ actor_ids = {{item["id"] for item in manifest["actors"]}}
527
+ version = manifest["version"]
528
+ assert version["object_id"] == manifest["object"]["id"]
529
+ assert version["created_by"] in actor_ids
530
+ assert re.fullmatch(r"sha256:[0-9a-f]{{64}}", version["digest"])
531
+ assert re.search(r"@[0-9a-f]{{40}}/", version["payload_uri"])
532
+ protocol = manifest["protocol"]
533
+ protocol_version = protocol["version"]
534
+ assert protocol_version["object_id"] == protocol["id"]
535
+ assert manifest["run"]["protocol_version_id"] == protocol_version["id"]
536
+ assert re.search(r"@[0-9a-f]{{40}}/", protocol_version["payload_uri"])
537
+ assert sha256_file(ROOT / protocol["specification"]["source_path"]) == protocol_version["code_sha256"]
538
+ run = manifest["run"]
539
+ assert run["actor_id"] in actor_ids
540
+ assert run["started_at"] <= run["finished_at"]
541
+ assert {{"python", "platform", "machine", "packages", "determinism"}} <= set(run["environment"])
542
+
543
+ evidence_ids = {{item["id"] for item in manifest["evidence"]}}
544
+ claim_ids = {{item["id"] for item in manifest["claims"]}}
545
+ assert len(evidence_ids) == len(manifest["evidence"])
546
+ assert len(claim_ids) == len(manifest["claims"])
547
+ for item in manifest["evidence"]:
548
+ assert item["run_id"] == run["id"]
549
+ assert item["subject_version"] == version["id"]
550
+ for item in manifest["claims"]:
551
+ assert item["scope"] == version["id"]
552
+ assert item["asserted_by"] in actor_ids
553
+ assert item["falsification_condition"]
554
+ assert set(item["supported_by"]) <= evidence_ids
555
+ for link in manifest["claim_evidence"]:
556
+ assert link["claim_id"] in claim_ids
557
+ assert link["evidence_id"] in evidence_ids
558
+ assert link["relation"] in {{"SUPPORTS", "REFUTES", "QUALIFIES"}}
559
+ for attestation in manifest["attestations"]:
560
+ assert attestation["actor_id"] in actor_ids
561
+ assert attestation["subject_version"] == version["id"]
562
+ assert set(attestation["supported_by"]) <= evidence_ids
563
+ assert any(item["type"] == "source_completeness" and item["value"] == "partial_snapshot" for item in manifest["attestations"])
564
+
565
+ edges = {{}}
566
+ for relation in manifest["relations"]:
567
+ source = relation["source_version_id"]
568
+ target = relation["target_version_id"]
569
+ assert source != target
570
+ assert relation["introduced_by_run"] == run["id"]
571
+ if target.startswith("slayer://version/"):
572
+ edges.setdefault(source, set()).add(target)
573
+ visiting, visited = set(), set()
574
+ def visit(node):
575
+ assert node not in visiting, "version lineage must be acyclic"
576
+ if node in visited:
577
+ return
578
+ visiting.add(node)
579
+ for target in edges.get(node, ()):
580
+ visit(target)
581
+ visiting.remove(node)
582
+ visited.add(node)
583
+ for node in edges:
584
+ visit(node)
585
+
586
+
587
+ def test_manifest_artifact_checksums():
588
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
589
+ checksums = next(item["payload"] for item in manifest["evidence"] if item["observation_type"] == "artifact_checksums")
590
+ paths = {{
591
+ "parquet_sha256": DATA / "{SOURCE_NAME}.parquet",
592
+ "attribution_sha256": DATA / "{SOURCE_NAME}.attribution.jsonl",
593
+ "stats_sha256": DATA / "{SOURCE_NAME}.stats.json",
594
+ "datasheet_sha256": DATA / "{SOURCE_NAME}.md",
595
+ "legal_evidence_sha256": DATA / "{SOURCE_NAME}.license-evidence.json",
596
+ "source_inventory_sha256": ROOT / "artifacts" / "{SOURCE_NAME}_source_inventory.json",
597
+ "source_profile_sha256": ROOT / "artifacts" / "{SOURCE_NAME}_source_profile.json",
598
+ }}
599
+ assert {{name: sha256_file(path) for name, path in paths.items()}} == checksums
600
+ '''
601
+
602
+
603
+ def build(args: argparse.Namespace) -> dict[str, Any]:
604
+ run_started_at = utc_now()
605
+ for name in ("source_revision", "target_revision", "dataset_payload_commit", "protocol_payload_commit"):
606
+ if not COMMIT_PATTERN.fullmatch(getattr(args, name)):
607
+ raise BuildError(f"{name} must be a 40-character commit")
608
+ for path in (args.target_registry, args.target_findings, args.source_profile):
609
+ if not path.is_file():
610
+ raise BuildError(f"required input is missing: {path}")
611
+
612
+ import pyarrow as pa
613
+ import pyarrow.parquet as pq
614
+ import tiktoken
615
+
616
+ source_shards = sorted((args.source_dir / "data").glob("*.parquet"))
617
+ if not source_shards:
618
+ raise BuildError("no source Parquet shards found")
619
+ output = args.output
620
+ data_dir = output / "data" / SOURCE_NAME
621
+ artifact_dir = output / "artifacts"
622
+ src_dir = output / "src"
623
+ for directory in (data_dir, artifact_dir, src_dir):
624
+ directory.mkdir(parents=True, exist_ok=True)
625
+
626
+ source_inventory = {
627
+ "repository": SOURCE_REPOSITORY,
628
+ "revision": args.source_revision,
629
+ "files": [
630
+ {"path": f"data/{path.name}", "size": path.stat().st_size, "sha256": sha256_file(path)}
631
+ for path in source_shards
632
+ ],
633
+ }
634
+ source_inventory["aggregate_digest"] = f"sha256:{canonical_sha256(source_inventory)}"
635
+ inventory_path = artifact_dir / f"{SOURCE_NAME}_source_inventory.json"
636
+ profile_path = artifact_dir / f"{SOURCE_NAME}_source_profile.json"
637
+ write_json(inventory_path, source_inventory)
638
+ source_profile = json.loads(args.source_profile.read_text(encoding="utf-8"))
639
+ source_profile.pop("samples", None)
640
+ write_json(profile_path, source_profile)
641
+
642
+ schema = output_schema(pa)
643
+ parquet_path = data_dir / f"{SOURCE_NAME}.parquet"
644
+ sidecar_path = data_dir / f"{SOURCE_NAME}.attribution.jsonl"
645
+ parts_dir = output / "_parts"
646
+ parts_dir.mkdir(parents=True, exist_ok=True)
647
+ worker_count = min(max(1, args.workers), len(source_shards))
648
+ worker_token_threads = max(1, args.token_threads // worker_count)
649
+ tasks = [
650
+ (
651
+ str(shard),
652
+ str(parts_dir / f"part-{index:05d}"),
653
+ args.added_date,
654
+ args.source_revision,
655
+ args.batch_size,
656
+ worker_token_threads,
657
+ )
658
+ for index, shard in enumerate(source_shards)
659
+ ]
660
+ if worker_count == 1:
661
+ parts = [process_source_shard(task) for task in tasks]
662
+ else:
663
+ with concurrent.futures.ProcessPoolExecutor(max_workers=worker_count) as pool:
664
+ parts = list(pool.map(process_source_shard, tasks))
665
+
666
+ counts: collections.Counter[str] = collections.Counter()
667
+ normalization: collections.Counter[str] = collections.Counter()
668
+ court_types: collections.Counter[str] = collections.Counter()
669
+ judgment_types: collections.Counter[str] = collections.Counter()
670
+ seen_ids: set[str] = set()
671
+ seen_texts: set[bytes] = set()
672
+ dates: list[str] = []
673
+ writer = pq.ParquetWriter(parquet_path, schema, compression="zstd")
674
+ try:
675
+ with sidecar_path.open("wb") as sidecar:
676
+ for part in parts:
677
+ metadata_parquet = pq.ParquetFile(part["parquet"])
678
+ try:
679
+ part_rows = metadata_parquet.metadata.num_rows
680
+ finally:
681
+ metadata_parquet.close()
682
+ identity_rows = 0
683
+ with pathlib.Path(part["identities"]).open(encoding="ascii") as identities:
684
+ for line in identities:
685
+ source_id, text_digest_hex = line.rstrip("\n").split("\t", 1)
686
+ text_digest = bytes.fromhex(text_digest_hex)
687
+ if source_id in seen_ids:
688
+ raise BuildError(f"cross-shard duplicate source id: {source_id}")
689
+ if text_digest in seen_texts:
690
+ raise BuildError(f"cross-shard duplicate normalized text in {part['shard']}")
691
+ seen_ids.add(source_id)
692
+ seen_texts.add(text_digest)
693
+ identity_rows += 1
694
+ if identity_rows != part_rows:
695
+ raise BuildError(f"identity count mismatch in {part['shard']}")
696
+ with pathlib.Path(part["sidecar"]).open("rb") as source_sidecar:
697
+ shutil.copyfileobj(source_sidecar, sidecar, length=1024 * 1024)
698
+ part_parquet = pq.ParquetFile(part["parquet"])
699
+ try:
700
+ for row_group in range(part_parquet.metadata.num_row_groups):
701
+ writer.write_table(part_parquet.read_row_group(row_group))
702
+ finally:
703
+ part_parquet.close()
704
+ counts.update(part["counts"])
705
+ normalization.update(part["normalization"])
706
+ court_types.update(part["court_types"])
707
+ judgment_types.update(part["judgment_types"])
708
+ if part["created_min"]:
709
+ dates.append(part["created_min"])
710
+ if part["created_max"]:
711
+ dates.append(part["created_max"])
712
+ finally:
713
+ writer.close()
714
+ shutil.rmtree(parts_dir)
715
+
716
+ if not counts["kept"]:
717
+ raise BuildError("no records survived the build")
718
+ stats: dict[str, Any] = {
719
+ **counts,
720
+ "source_rows": counts["source_rows"],
721
+ "kept": counts["kept"],
722
+ "drop_short": counts["drop_short"],
723
+ "drop_lang": counts["drop_lang"],
724
+ "drop_dup": counts["drop_dup"],
725
+ "invalid_dates": counts["invalid_dates"],
726
+ "authors_with_value": counts["authors_with_value"],
727
+ "chars": counts["chars"],
728
+ "tokens": counts["tokens"],
729
+ "created_min": min(dates) if dates else "",
730
+ "created_max": max(dates) if dates else "",
731
+ "by_court_type": dict(sorted(court_types.items())),
732
+ "by_judgment_type": dict(sorted(judgment_types.items())),
733
+ "normalization": dict(sorted(normalization.items())),
734
+ "license": SOURCE_LICENSE,
735
+ "licenses": {SOURCE_LICENSE: counts["kept"]},
736
+ "added": args.added_date,
737
+ "source_revision": args.source_revision,
738
+ "target_base_revision": args.target_revision,
739
+ "official_total_results": args.official_total_results,
740
+ "official_count_observed_at": args.official_count_observed_at,
741
+ "snapshot_live_count_ratio": counts["source_rows"] / args.official_total_results,
742
+ "stats_recomputed_from_parquet": True,
743
+ }
744
+ stats_path = data_dir / f"{SOURCE_NAME}.stats.json"
745
+ legal_path = data_dir / f"{SOURCE_NAME}.license-evidence.json"
746
+ datasheet_path = data_dir / f"{SOURCE_NAME}.md"
747
+ write_json(stats_path, stats)
748
+ write_json(legal_path, legal_evidence(args))
749
+ datasheet_path.write_text(datasheet(stats, args), encoding="utf-8")
750
+ (data_dir / "NOTICE.md").write_text(
751
+ "# Source attribution\n\nOfficial source: System Analizy Orzeczen Sadowych "
752
+ "(SAOS), https://www.saos.org.pl/. Per-record canonical SAOS URLs are "
753
+ "preserved in saos.attribution.jsonl. Snapshot preparation and contribution: "
754
+ "Piotr Sty\u0142a (PiotrSty / PiotrStyla).\n",
755
+ encoding="utf-8",
756
+ )
757
+
758
+ artifact_digests = {
759
+ "parquet_sha256": sha256_file(parquet_path),
760
+ "attribution_sha256": sha256_file(sidecar_path),
761
+ "stats_sha256": sha256_file(stats_path),
762
+ "datasheet_sha256": sha256_file(datasheet_path),
763
+ "legal_evidence_sha256": sha256_file(legal_path),
764
+ "source_inventory_sha256": sha256_file(inventory_path),
765
+ "source_profile_sha256": sha256_file(profile_path),
766
+ }
767
+ version_digest = canonical_sha256({
768
+ "source_revision": args.source_revision,
769
+ "target_revision": args.target_revision,
770
+ "artifacts": artifact_digests,
771
+ })
772
+ object_id = f"slayer://object/dataset-source/{SOURCE_NAME}"
773
+ version_id = f"slayer://version/dataset-source/{SOURCE_NAME}@sha256:{version_digest}"
774
+ protocol_object_id = f"slayer://object/protocol/{SOURCE_NAME}-filter"
775
+ protocol_config = {
776
+ "source_revision": args.source_revision,
777
+ "minimum_characters": 200,
778
+ "minimum_polish_diacritic_ratio": 0.005,
779
+ "deduplication": {"algorithm": "sha1", "field": "normalized_text", "scope": "within_source"},
780
+ "tokenizer": "cl100k_base",
781
+ "date_valid_year_range": [1900, dt.date.today().year + 1],
782
+ "normalization": ["NFKC", "space_quote_dash", "paragraph_preserving_whitespace", "pattern_PII_scrub"],
783
+ "execution": {
784
+ "record_batch_size": args.batch_size,
785
+ "source_workers": args.workers,
786
+ "token_threads": args.token_threads,
787
+ "token_threads_per_worker": max(1, args.token_threads // min(max(1, args.workers), len(source_shards))),
788
+ "parquet_compression": "zstd",
789
+ },
790
+ }
791
+ protocol_spec = {
792
+ "entrypoint": "python src/fetch_saos.py",
793
+ "source_path": "src/fetch_saos.py",
794
+ "summary": "Deterministic normalization and projection of a pinned SAOS judgment snapshot.",
795
+ "configuration": protocol_config,
796
+ "required_inputs": ["14 pinned source Parquet shards", "source profile", "target registry", "target findings log"],
797
+ "outputs": ["DynaWord Parquet", "attribution sidecar", "datasheet", "stats", "legal evidence", "ontology manifest"],
798
+ }
799
+ protocol_code_digest = sha256_file(pathlib.Path(__file__).resolve())
800
+ protocol_digest = canonical_sha256({
801
+ "object_id": protocol_object_id,
802
+ "code_sha256": protocol_code_digest,
803
+ "specification": protocol_spec,
804
+ })
805
+ protocol_version_id = f"slayer://version/protocol/{SOURCE_NAME}-filter@sha256:{protocol_digest}"
806
+ source_version_id = f"hf://datasets/{SOURCE_REPOSITORY}@{args.source_revision}"
807
+ target_version_id = f"hf://datasets/{TARGET_REPOSITORY}@{args.target_revision}"
808
+ run_finished_at = utc_now()
809
+
810
+ def evidence(kind: str, payload: Any) -> dict[str, Any]:
811
+ digest = canonical_sha256({"run": args.run_id, "subject": version_id, "kind": kind, "payload": payload})
812
+ return {
813
+ "id": f"slayer://evidence/{SOURCE_NAME}/{kind}@sha256:{digest}",
814
+ "run_id": args.run_id,
815
+ "subject_version": version_id,
816
+ "observation_type": kind,
817
+ "payload": payload,
818
+ "observed_at": run_finished_at,
819
+ }
820
+
821
+ evidence_items = [
822
+ evidence("dataset_record_counts", stats),
823
+ evidence("artifact_checksums", artifact_digests),
824
+ evidence("pinned_source_inventory", source_inventory),
825
+ evidence("source_completeness_observation", {
826
+ "snapshot_rows": stats["source_rows"],
827
+ "official_total_results": args.official_total_results,
828
+ "observed_at": args.official_count_observed_at,
829
+ "ratio": stats["snapshot_live_count_ratio"],
830
+ "complete": False,
831
+ }),
832
+ evidence("normalization_and_pii_metrics", stats["normalization"]),
833
+ evidence("schema_validation", {"schema": list(EXPECTED_FIELDS), "records": stats["kept"], "valid": True}),
834
+ evidence("legal_provenance_review", {
835
+ "status": "documented-statutory-basis-review-needed",
836
+ "formal_legal_review": "not_performed",
837
+ "artifact": f"data/{SOURCE_NAME}/{SOURCE_NAME}.license-evidence.json",
838
+ "sha256": artifact_digests["legal_evidence_sha256"],
839
+ }),
840
+ ]
841
+ evidence_by_type = {item["observation_type"]: item["id"] for item in evidence_items}
842
+
843
+ def claim(statement: str, falsification: str, support: list[str]) -> dict[str, Any]:
844
+ digest = canonical_sha256({"scope": version_id, "statement": statement, "falsification": falsification})
845
+ return {
846
+ "id": f"slayer://claim/{SOURCE_NAME}@sha256:{digest}",
847
+ "scope": version_id,
848
+ "statement": statement,
849
+ "asserted_by": args.actor,
850
+ "supported_by": support,
851
+ "falsification_condition": falsification,
852
+ }
853
+
854
+ claims = [
855
+ claim(
856
+ "The contribution is derived from the 14 files of the pinned PiotrSty SAOS snapshot.",
857
+ "A source file is missing or its recorded size or SHA-256 differs.",
858
+ [evidence_by_type["pinned_source_inventory"]],
859
+ ),
860
+ claim(
861
+ "The contributed dataset is a partial historical SAOS snapshot and not a complete current copy.",
862
+ "The pinned snapshot row count equals the official live count observed for this run.",
863
+ [evidence_by_type["source_completeness_observation"]],
864
+ ),
865
+ claim(
866
+ "All retained rows conform to the DynaWord source schema and recorded artifact checksums.",
867
+ "A retained row violates the schema or an artifact checksum differs.",
868
+ [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]],
869
+ ),
870
+ claim(
871
+ "Pattern-based PII scrubbing and documented text normalization were applied, without asserting perfect de-identification.",
872
+ "The committed protocol omits a documented transformation or a retained match contradicts its recorded metric.",
873
+ [evidence_by_type["normalization_and_pii_metrics"]],
874
+ ),
875
+ claim(
876
+ "The records are court materials with a documented statutory reuse argument, pending formal legal review and subject to stated limitations.",
877
+ "The records are not official materials or legal review rejects the documented statutory basis.",
878
+ [evidence_by_type["legal_provenance_review"]],
879
+ ),
880
+ ]
881
+ claim_evidence = [
882
+ {"claim_id": item["id"], "evidence_id": evidence_id, "relation": "SUPPORTS", "introduced_by_run": args.run_id}
883
+ for item in claims for evidence_id in item["supported_by"]
884
+ ]
885
+
886
+ def attestation(kind: str, value: Any, support: list[str]) -> dict[str, Any]:
887
+ digest = canonical_sha256({"type": kind, "value": value, "actor": args.actor, "subject": version_id, "support": support})
888
+ return {
889
+ "id": f"slayer://attestation/{SOURCE_NAME}/{kind}@sha256:{digest}",
890
+ "type": kind,
891
+ "value": value,
892
+ "actor_id": args.actor,
893
+ "subject_version": version_id,
894
+ "supported_by": support,
895
+ "created_at": run_finished_at,
896
+ }
897
+
898
+ manifest = {
899
+ "schema_version": "slayer.ai/dataset-source-contribution/v1",
900
+ "ontology_version": "slayer.ai/research-ontology/v0.1",
901
+ "object": {
902
+ "id": object_id, "kind": "dataset_source", "name": SOURCE_NAME,
903
+ "metadata": {"language": "pl", "domain": "legal/judicial", "provider": "SAOS"},
904
+ },
905
+ "version": {
906
+ "id": version_id,
907
+ "object_id": object_id,
908
+ "digest": f"sha256:{version_digest}",
909
+ "schema_version": "slayer.ai/dataset-source/v1",
910
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.dataset_payload_commit}/data/{SOURCE_NAME}/{SOURCE_NAME}.parquet",
911
+ "created_at": run_finished_at,
912
+ "created_by": args.actor,
913
+ },
914
+ "protocol": {
915
+ "id": protocol_object_id,
916
+ "kind": "dataset_filtering",
917
+ "name": f"{SOURCE_NAME}-filter",
918
+ "version": {
919
+ "id": protocol_version_id,
920
+ "object_id": protocol_object_id,
921
+ "digest": f"sha256:{protocol_digest}",
922
+ "code_sha256": protocol_code_digest,
923
+ "schema_version": "slayer.ai/protocol/v1",
924
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.protocol_payload_commit}/src/fetch_saos.py",
925
+ "created_at": run_finished_at,
926
+ "created_by": args.actor,
927
+ },
928
+ "specification": protocol_spec,
929
+ },
930
+ "run": {
931
+ "id": args.run_id,
932
+ "protocol_version_id": protocol_version_id,
933
+ "actor_id": args.actor,
934
+ "git_commit": args.protocol_payload_commit,
935
+ "started_at": run_started_at,
936
+ "finished_at": run_finished_at,
937
+ "config": protocol_config,
938
+ "environment": {
939
+ "python": sys.version,
940
+ "python_executable": sys.executable,
941
+ "platform": platform.platform(),
942
+ "machine": platform.machine(),
943
+ "packages": {"pyarrow": pa.__version__, "tiktoken": importlib.metadata.version("tiktoken")},
944
+ "container_image": None,
945
+ "environment_limitation": "No container image was used; material runtime and package versions are recorded.",
946
+ "determinism": {"sampling": "none", "seed": None, "input_order": [path.name for path in source_shards]},
947
+ },
948
+ "inputs": [
949
+ {"role": "source", "version_id": source_version_id},
950
+ {"role": "target_base", "version_id": target_version_id},
951
+ ],
952
+ "outputs": [{"role": "dataset_source", "version_id": version_id}],
953
+ },
954
+ "relations": [
955
+ {"source_version_id": version_id, "predicate": "DERIVED_FROM", "target_version_id": source_version_id, "introduced_by_run": args.run_id},
956
+ {"source_version_id": version_id, "predicate": "COMPATIBLE_WITH", "target_version_id": target_version_id, "introduced_by_run": args.run_id},
957
+ {"source_version_id": version_id, "predicate": "FILTERED_BY", "target_version_id": protocol_version_id, "introduced_by_run": args.run_id},
958
+ ],
959
+ "evidence": evidence_items,
960
+ "claims": claims,
961
+ "claim_evidence": claim_evidence,
962
+ "actors": [{
963
+ "id": args.actor, "kind": "human", "identity": "Piotr Sty\u0142a",
964
+ "identifiers": {"hugging_face": "PiotrSty", "github": "PiotrStyla"},
965
+ }],
966
+ "attestations": [
967
+ attestation("schema_valid", True, [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]]),
968
+ attestation("source_completeness", "partial_snapshot", [evidence_by_type["source_completeness_observation"]]),
969
+ attestation("provenance", "pinned_and_hashed", [evidence_by_type["pinned_source_inventory"]]),
970
+ attestation("pii_scrubbing", "pattern_scrub_applied_not_guaranteed", [evidence_by_type["normalization_and_pii_metrics"]]),
971
+ attestation("legal_status", "review_needed_documented_official_materials", [evidence_by_type["legal_provenance_review"]]),
972
+ ],
973
+ }
974
+ write_json(artifact_dir / f"{SOURCE_NAME}_ontology_manifest.json", manifest)
975
+ (src_dir / "sources.py").write_text(
976
+ update_registry(args.target_registry.read_text(encoding="utf-8"), stats, args.source_revision),
977
+ encoding="utf-8",
978
+ )
979
+ (artifact_dir / "source_findings.md").write_text(
980
+ update_findings(args.target_findings.read_text(encoding="utf-8"), stats, args),
981
+ encoding="utf-8",
982
+ )
983
+ shutil.copy2(pathlib.Path(__file__).resolve(), src_dir / "fetch_saos.py")
984
+ (src_dir / "test_saos_contract.py").write_text(contract_test(), encoding="utf-8")
985
+ print(json.dumps(stats, ensure_ascii=False, indent=2, sort_keys=True))
986
+ return stats
987
+
988
+
989
+ def main() -> int:
990
+ parser = argparse.ArgumentParser(description=__doc__)
991
+ parser.add_argument("--source-dir", type=pathlib.Path, required=True)
992
+ parser.add_argument("--source-profile", type=pathlib.Path, required=True)
993
+ parser.add_argument("--target-registry", type=pathlib.Path, required=True)
994
+ parser.add_argument("--target-findings", type=pathlib.Path, required=True)
995
+ parser.add_argument("--output", type=pathlib.Path, required=True)
996
+ parser.add_argument("--source-revision", required=True)
997
+ parser.add_argument("--target-revision", required=True)
998
+ parser.add_argument("--dataset-payload-commit", required=True)
999
+ parser.add_argument("--protocol-payload-commit", required=True)
1000
+ parser.add_argument("--official-total-results", type=int, required=True)
1001
+ parser.add_argument("--official-count-observed-at", required=True)
1002
+ parser.add_argument("--added-date", required=True)
1003
+ parser.add_argument("--actor", default="hf:PiotrSty")
1004
+ parser.add_argument("--run-id", required=True)
1005
+ parser.add_argument("--batch-size", type=int, default=32)
1006
+ parser.add_argument("--workers", type=int, default=1)
1007
+ parser.add_argument("--token-threads", type=int, default=4)
1008
+ args = parser.parse_args()
1009
+ build(args)
1010
+ return 0
1011
+
1012
+
1013
+ if __name__ == "__main__":
1014
+ raise SystemExit(main())
src/sources.py CHANGED
@@ -204,6 +204,27 @@ SOURCES = {
204
  "created": "2004-03-22, 2026-10-01",
205
  "is_ocr": False,
206
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  "eurlex": {
208
  "added": "2026-06-15",
209
  "release": "0.2.0",
 
204
  "created": "2004-03-22, 2026-10-01",
205
  "is_ocr": False,
206
  },
207
+ "saos": {
208
+ "added": "2026-09-04",
209
+ "release": None,
210
+ "file_key": "saos",
211
+ "pretty": "SAOS - Polish court judgments (pinned partial snapshot)",
212
+ "license": "public-domain (official documents)",
213
+ "license_spdx": "LicenseRef-Polish-Official-Documents",
214
+ "traceable": "Court judgments are documented as official materials outside "
215
+ "copyright under Polish Copyright Act art. 4(2); formal legal "
216
+ "review has not been performed and statutory limitations remain - "
217
+ "the review scope and responsible party are recorded in the datasheet.",
218
+ "upstream": "https://www.saos.org.pl/api/dump/judgments",
219
+ "provenance": "Converted from the immutable "
220
+ "PiotrSty/saos-polish-court-judgments@736cba4f92999e29d3e49409b0713c88fc683714 snapshot; per-record "
221
+ "SAOS URLs and source identifiers are preserved in a sidecar. Pattern PII scrubbing only - "
222
+ "re-run through SlayerLab/NERGAL before release.",
223
+ "domain": "legal/judicial",
224
+ "created": "1986-05-28, 2017-05-11",
225
+ "is_ocr": False,
226
+ "custom_datasheet": True,
227
+ },
228
  "eurlex": {
229
  "added": "2026-06-15",
230
  "release": "0.2.0",
src/test_saos_contract.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract and ontology checks for the saos contribution."""
2
+
3
+ import hashlib
4
+ import json
5
+ import pathlib
6
+ import re
7
+
8
+ import pyarrow.parquet as pq
9
+
10
+
11
+ ROOT = pathlib.Path(__file__).resolve().parents[1]
12
+ DATA = ROOT / "data" / "saos"
13
+ MANIFEST = ROOT / "artifacts" / "saos_ontology_manifest.json"
14
+ FIELDS = ['id', 'text', 'source', 'added', 'created', 'token_count', 'license', 'author']
15
+
16
+
17
+ def sha256_file(path):
18
+ digest = hashlib.sha256()
19
+ with path.open("rb") as stream:
20
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
21
+ digest.update(chunk)
22
+ return digest.hexdigest()
23
+
24
+
25
+ def test_data_schema_and_stats():
26
+ parquet = DATA / "saos.parquet"
27
+ stats = json.loads((DATA / "saos.stats.json").read_text(encoding="utf-8"))
28
+ source_values, license_values, ids = set(), set(), set()
29
+ rows = chars = tokens = authors = 0
30
+ for batch in pq.ParquetFile(parquet).iter_batches(batch_size=256):
31
+ assert batch.schema.names == FIELDS
32
+ for row in batch.to_pylist():
33
+ rows += 1
34
+ assert row["id"] not in ids
35
+ ids.add(row["id"])
36
+ assert len(row["text"]) >= 200
37
+ assert row["token_count"] > 0
38
+ assert not re.search(
39
+ r"</?(?:p|div|span|br|h[1-6]|table|tbody|thead|tr|td|th|ul|ol|li|strong|em|b|i|a|section)\s*/?>",
40
+ row["text"],
41
+ re.I,
42
+ )
43
+ assert not row["created"] or re.fullmatch(r"20\d{2}-\d{2}-\d{2}|19\d{2}-\d{2}-\d{2}", row["created"])
44
+ source_values.add(row["source"])
45
+ license_values.add(row["license"])
46
+ chars += len(row["text"])
47
+ tokens += row["token_count"]
48
+ authors += bool(row["author"])
49
+ assert rows == stats["kept"]
50
+ assert chars == stats["chars"]
51
+ assert tokens == stats["tokens"]
52
+ assert authors == stats["authors_with_value"]
53
+ assert source_values == {"saos"}
54
+ assert license_values == {"public-domain (official documents)"}
55
+
56
+
57
+ def test_sidecar_legal_and_snapshot_honesty():
58
+ stats = json.loads((DATA / "saos.stats.json").read_text(encoding="utf-8"))
59
+ sidecar = DATA / "saos.attribution.jsonl"
60
+ assert sum(1 for _ in sidecar.open(encoding="utf-8")) == stats["kept"]
61
+ legal = json.loads((DATA / "saos.license-evidence.json").read_text(encoding="utf-8"))
62
+ assert legal["formal_legal_review"] == "not_performed"
63
+ assert legal["hf_source_card_license"] == "unknown"
64
+ assert legal["pinned_source"].endswith(stats["source_revision"])
65
+ assert stats["official_total_results"] > stats["source_rows"]
66
+
67
+
68
+ def test_ontology_kernel_and_references():
69
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
70
+ required = {"object", "version", "protocol", "run", "relations", "evidence",
71
+ "claims", "claim_evidence", "actors", "attestations"}
72
+ assert required <= set(manifest)
73
+ assert manifest["ontology_version"] == "slayer.ai/research-ontology/v0.1"
74
+ actor_ids = {item["id"] for item in manifest["actors"]}
75
+ version = manifest["version"]
76
+ assert version["object_id"] == manifest["object"]["id"]
77
+ assert version["created_by"] in actor_ids
78
+ assert re.fullmatch(r"sha256:[0-9a-f]{64}", version["digest"])
79
+ assert re.search(r"@[0-9a-f]{40}/", version["payload_uri"])
80
+ protocol = manifest["protocol"]
81
+ protocol_version = protocol["version"]
82
+ assert protocol_version["object_id"] == protocol["id"]
83
+ assert manifest["run"]["protocol_version_id"] == protocol_version["id"]
84
+ assert re.search(r"@[0-9a-f]{40}/", protocol_version["payload_uri"])
85
+ assert sha256_file(ROOT / protocol["specification"]["source_path"]) == protocol_version["code_sha256"]
86
+ run = manifest["run"]
87
+ assert run["actor_id"] in actor_ids
88
+ assert run["started_at"] <= run["finished_at"]
89
+ assert {"python", "platform", "machine", "packages", "determinism"} <= set(run["environment"])
90
+
91
+ evidence_ids = {item["id"] for item in manifest["evidence"]}
92
+ claim_ids = {item["id"] for item in manifest["claims"]}
93
+ assert len(evidence_ids) == len(manifest["evidence"])
94
+ assert len(claim_ids) == len(manifest["claims"])
95
+ for item in manifest["evidence"]:
96
+ assert item["run_id"] == run["id"]
97
+ assert item["subject_version"] == version["id"]
98
+ for item in manifest["claims"]:
99
+ assert item["scope"] == version["id"]
100
+ assert item["asserted_by"] in actor_ids
101
+ assert item["falsification_condition"]
102
+ assert set(item["supported_by"]) <= evidence_ids
103
+ for link in manifest["claim_evidence"]:
104
+ assert link["claim_id"] in claim_ids
105
+ assert link["evidence_id"] in evidence_ids
106
+ assert link["relation"] in {"SUPPORTS", "REFUTES", "QUALIFIES"}
107
+ for attestation in manifest["attestations"]:
108
+ assert attestation["actor_id"] in actor_ids
109
+ assert attestation["subject_version"] == version["id"]
110
+ assert set(attestation["supported_by"]) <= evidence_ids
111
+ assert any(item["type"] == "source_completeness" and item["value"] == "partial_snapshot" for item in manifest["attestations"])
112
+
113
+ edges = {}
114
+ for relation in manifest["relations"]:
115
+ source = relation["source_version_id"]
116
+ target = relation["target_version_id"]
117
+ assert source != target
118
+ assert relation["introduced_by_run"] == run["id"]
119
+ if target.startswith("slayer://version/"):
120
+ edges.setdefault(source, set()).add(target)
121
+ visiting, visited = set(), set()
122
+ def visit(node):
123
+ assert node not in visiting, "version lineage must be acyclic"
124
+ if node in visited:
125
+ return
126
+ visiting.add(node)
127
+ for target in edges.get(node, ()):
128
+ visit(target)
129
+ visiting.remove(node)
130
+ visited.add(node)
131
+ for node in edges:
132
+ visit(node)
133
+
134
+
135
+ def test_manifest_artifact_checksums():
136
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
137
+ checksums = next(item["payload"] for item in manifest["evidence"] if item["observation_type"] == "artifact_checksums")
138
+ paths = {
139
+ "parquet_sha256": DATA / "saos.parquet",
140
+ "attribution_sha256": DATA / "saos.attribution.jsonl",
141
+ "stats_sha256": DATA / "saos.stats.json",
142
+ "datasheet_sha256": DATA / "saos.md",
143
+ "legal_evidence_sha256": DATA / "saos.license-evidence.json",
144
+ "source_inventory_sha256": ROOT / "artifacts" / "saos_source_inventory.json",
145
+ "source_profile_sha256": ROOT / "artifacts" / "saos_source_profile.json",
146
+ }
147
+ assert {name: sha256_file(path) for name, path in paths.items()} == checksums