ppuzio PiotrSty commited on
Commit
5be7e5d
·
1 Parent(s): d7480a7

Add source: sejm_api_2011_2022 - remaining attributed Sejm speeches (#18)

Browse files

- Add source: sejm_api_2011_2022 - remaining attributed Sejm speeches (106f3f14f301100c9418ee12048eb32bf8c3d9a1)
- fix(ontology): version Sejm build protocol (48a097a8783d10c8837fe55f167000b85608b0f5)
- fix(ontology): complete PR 18 research graph (fc33ea83bcd95e111ad2e77cf5c4d0be38674d6f)
- Factor shared Sejm API helpers into sejm_api_common.py (61edfdd7a19e59721b9af4b9472caaf00570585a)
- Address review: registry entry, cleaning/NERGAL notes, refactored-script digest (3645df2018e1bbb6a994666f1cdb15454b829a6c)


Co-authored-by: Piotr Styla <PiotrSty@users.noreply.huggingface.co>

artifacts/sejm_api_2011_2022_ontology_manifest.json ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-04T16:04:35.941055Z",
17
+ "id": "slayer://attestation/sejm_api_2011_2022/schema_valid@sha256:95cd4c6202e4f07165f1e3398974ffac8341f75cf37bf23aaaa7fd45e4f3c001",
18
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
19
+ "supported_by": [
20
+ "slayer://evidence/sejm_api_2011_2022/schema_validation@sha256:69b3c898e4de65cd7407b53584370154b223495d41de38ed2f7a5c7913c7d815",
21
+ "slayer://evidence/sejm_api_2011_2022/artifact_checksums@sha256:a5f31b2d2c1b26634e2b14d82451e0185f557be368e4e5208685529d79f9adfe"
22
+ ],
23
+ "type": "schema_valid",
24
+ "value": true
25
+ },
26
+ {
27
+ "actor_id": "hf:PiotrSty",
28
+ "created_at": "2026-09-04T16:04:35.941055Z",
29
+ "id": "slayer://attestation/sejm_api_2011_2022/temporal_overlap@sha256:79c0740c405d058af1ce6e32d7f70c9e86f2f77e0a66a3b986d34cebc3638cb1",
30
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
31
+ "supported_by": [
32
+ "slayer://evidence/sejm_api_2011_2022/known_temporal_overlap@sha256:ef3807dcb9d1039b82b477f33bcc0621e2725ee68294db9f8bec34dd36c92291"
33
+ ],
34
+ "type": "temporal_overlap",
35
+ "value": "known_and_disclosed"
36
+ },
37
+ {
38
+ "actor_id": "hf:PiotrSty",
39
+ "created_at": "2026-09-04T16:04:35.941055Z",
40
+ "id": "slayer://attestation/sejm_api_2011_2022/speaker_attribution@sha256:0d5bcf58020da1f78d7360cd4ac509fe995db01ab391ef4e6bc7764f26c6cfda",
41
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
42
+ "supported_by": [
43
+ "slayer://evidence/sejm_api_2011_2022/speaker_attribution_coverage@sha256:ec102677904e031be11b83ee3e853ae51a479b61d1ece2cdd5fb0fa461c47ed5"
44
+ ],
45
+ "type": "speaker_attribution",
46
+ "value": "100_percent"
47
+ },
48
+ {
49
+ "actor_id": "hf:PiotrSty",
50
+ "created_at": "2026-09-04T16:04:35.941055Z",
51
+ "id": "slayer://attestation/sejm_api_2011_2022/legal_status@sha256:93035bc5ee9e44093750e93be303a2cdd1822bf73b1513cdf6ef4e42091821ac",
52
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
53
+ "supported_by": [
54
+ "slayer://evidence/sejm_api_2011_2022/legal_provenance_review@sha256:c55879b30382d71a9198f637c4e17bd1579189583e2b635b504be8bbd27eb47e"
55
+ ],
56
+ "type": "legal_status",
57
+ "value": "documented_open_official_materials_with_limitations"
58
+ },
59
+ {
60
+ "actor_id": "hf:PiotrSty",
61
+ "created_at": "2026-09-04T16:04:35.941055Z",
62
+ "id": "slayer://attestation/sejm_api_2011_2022/pinned_input_reproduction@sha256:7a2bcfcbdccef1dc7f55573bca7f300813ad8459efc79050544c872956a97cfd",
63
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
64
+ "supported_by": [
65
+ "slayer://evidence/sejm_api_2011_2022/pinned_input_reproduction@sha256:72f3034fdf811a81de377d4e9955ed241d3e8a602f6aa983c100f11e02724499"
66
+ ],
67
+ "type": "pinned_input_reproduction",
68
+ "value": true
69
+ }
70
+ ],
71
+ "claim_evidence": [
72
+ {
73
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:abe8a13485927ccc1d793ba0ce8de79780bd4f673676f4271b01fa8405a2e904",
74
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/dataset_record_counts@sha256:6581074495247b30a7266a4bd50defd643b6d2458a6c371773e4aa080c2d13b2",
75
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
76
+ "relation": "SUPPORTS"
77
+ },
78
+ {
79
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:a964d069a2a4fdd5dfa439c55e182328b4c945c3363aa6f104d048ed7af57160",
80
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/speaker_attribution_coverage@sha256:ec102677904e031be11b83ee3e853ae51a479b61d1ece2cdd5fb0fa461c47ed5",
81
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
82
+ "relation": "SUPPORTS"
83
+ },
84
+ {
85
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:9ea2af3b7ab5888aa692256ad0a7e109b32cbc25595a56410b455fbcce6883fa",
86
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/known_temporal_overlap@sha256:ef3807dcb9d1039b82b477f33bcc0621e2725ee68294db9f8bec34dd36c92291",
87
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
88
+ "relation": "SUPPORTS"
89
+ },
90
+ {
91
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:0573cf28aed2e22303ac4ffe52c40870e4d33e7b96cea55b62ab6e2afaa91a7d",
92
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/legal_provenance_review@sha256:c55879b30382d71a9198f637c4e17bd1579189583e2b635b504be8bbd27eb47e",
93
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
94
+ "relation": "SUPPORTS"
95
+ },
96
+ {
97
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:e942df4c18f3b8f9dc5384ddcddf0e522d2174e2f064f3c8bc96054a12c02f85",
98
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/schema_validation@sha256:69b3c898e4de65cd7407b53584370154b223495d41de38ed2f7a5c7913c7d815",
99
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
100
+ "relation": "SUPPORTS"
101
+ },
102
+ {
103
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:e942df4c18f3b8f9dc5384ddcddf0e522d2174e2f064f3c8bc96054a12c02f85",
104
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/artifact_checksums@sha256:a5f31b2d2c1b26634e2b14d82451e0185f557be368e4e5208685529d79f9adfe",
105
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
106
+ "relation": "SUPPORTS"
107
+ },
108
+ {
109
+ "claim_id": "slayer://claim/sejm_api_2011_2022@sha256:ae8039527a47e414d6c6218ac17fabf336c5221d110d510b2ba6c9e0edbb0426",
110
+ "evidence_id": "slayer://evidence/sejm_api_2011_2022/pinned_input_reproduction@sha256:72f3034fdf811a81de377d4e9955ed241d3e8a602f6aa983c100f11e02724499",
111
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
112
+ "relation": "SUPPORTS"
113
+ }
114
+ ],
115
+ "claims": [
116
+ {
117
+ "asserted_by": "hf:PiotrSty",
118
+ "falsification_condition": "A qualifying pinned-source record is absent without a recorded drop reason.",
119
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:abe8a13485927ccc1d793ba0ce8de79780bd4f673676f4271b01fa8405a2e904",
120
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
121
+ "statement": "All retained records from the pinned source dated 2011-2022 are included after exact within-source deduplication.",
122
+ "supported_by": [
123
+ "slayer://evidence/sejm_api_2011_2022/dataset_record_counts@sha256:6581074495247b30a7266a4bd50defd643b6d2458a6c371773e4aa080c2d13b2"
124
+ ]
125
+ },
126
+ {
127
+ "asserted_by": "hf:PiotrSty",
128
+ "falsification_condition": "Any contributed author field is empty.",
129
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:a964d069a2a4fdd5dfa439c55e182328b4c945c3363aa6f104d048ed7af57160",
130
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
131
+ "statement": "Every contributed document has non-empty speaker attribution.",
132
+ "supported_by": [
133
+ "slayer://evidence/sejm_api_2011_2022/speaker_attribution_coverage@sha256:ec102677904e031be11b83ee3e853ae51a479b61d1ece2cdd5fb0fa461c47ed5"
134
+ ]
135
+ },
136
+ {
137
+ "asserted_by": "hf:PiotrSty",
138
+ "falsification_condition": "The cited target-source ranges do not overlap 2011-2022.",
139
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:9ea2af3b7ab5888aa692256ad0a7e109b32cbc25595a56410b455fbcce6883fa",
140
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
141
+ "statement": "The contribution does not establish temporal novelty relative to every target source because registered ranges overlap.",
142
+ "supported_by": [
143
+ "slayer://evidence/sejm_api_2011_2022/known_temporal_overlap@sha256:ef3807dcb9d1039b82b477f33bcc0621e2725ee68294db9f8bec34dd36c92291"
144
+ ]
145
+ },
146
+ {
147
+ "asserted_by": "hf:PiotrSty",
148
+ "falsification_condition": "The records are not official materials or the cited legal basis and provider conditions contradict the documented reuse status.",
149
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:0573cf28aed2e22303ac4ffe52c40870e4d33e7b96cea55b62ab6e2afaa91a7d",
150
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
151
+ "statement": "The contributed records are official Sejm materials documented for statutory reuse, subject to retained privacy and third-party limitations.",
152
+ "supported_by": [
153
+ "slayer://evidence/sejm_api_2011_2022/legal_provenance_review@sha256:c55879b30382d71a9198f637c4e17bd1579189583e2b635b504be8bbd27eb47e"
154
+ ]
155
+ },
156
+ {
157
+ "asserted_by": "hf:PiotrSty",
158
+ "falsification_condition": "A contract field is missing, a row violates the schema, or a recorded artifact checksum differs.",
159
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:e942df4c18f3b8f9dc5384ddcddf0e522d2174e2f064f3c8bc96054a12c02f85",
160
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
161
+ "statement": "The generated artifact set conforms to the DynaWord source schema and recorded checksums.",
162
+ "supported_by": [
163
+ "slayer://evidence/sejm_api_2011_2022/schema_validation@sha256:69b3c898e4de65cd7407b53584370154b223495d41de38ed2f7a5c7913c7d815",
164
+ "slayer://evidence/sejm_api_2011_2022/artifact_checksums@sha256:a5f31b2d2c1b26634e2b14d82451e0185f557be368e4e5208685529d79f9adfe"
165
+ ]
166
+ },
167
+ {
168
+ "asserted_by": "hf:PiotrSty",
169
+ "falsification_condition": "A rebuilt Parquet or attribution-sidecar digest differs from the expected digest.",
170
+ "id": "slayer://claim/sejm_api_2011_2022@sha256:ae8039527a47e414d6c6218ac17fabf336c5221d110d510b2ba6c9e0edbb0426",
171
+ "scope": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
172
+ "statement": "Rebuilding from pinned inputs reproduced the expected Parquet and attribution-sidecar digests.",
173
+ "supported_by": [
174
+ "slayer://evidence/sejm_api_2011_2022/pinned_input_reproduction@sha256:72f3034fdf811a81de377d4e9955ed241d3e8a602f6aa983c100f11e02724499"
175
+ ]
176
+ }
177
+ ],
178
+ "evidence": [
179
+ {
180
+ "id": "slayer://evidence/sejm_api_2011_2022/dataset_record_counts@sha256:6581074495247b30a7266a4bd50defd643b6d2458a6c371773e4aa080c2d13b2",
181
+ "observation_type": "dataset_record_counts",
182
+ "observed_at": "2026-09-04T16:04:35.941055Z",
183
+ "payload": {
184
+ "added": "2026-08-31",
185
+ "authors_with_value": 118902,
186
+ "by_source_split": {
187
+ "train": 116546,
188
+ "validation": 2356
189
+ },
190
+ "by_term": {
191
+ "7": 42114,
192
+ "8": 44750,
193
+ "9": 32038
194
+ },
195
+ "by_year": {
196
+ "2011": 871,
197
+ "2012": 10732,
198
+ "2013": 11816,
199
+ "2014": 10480,
200
+ "2015": 10670,
201
+ "2016": 13763,
202
+ "2017": 12314,
203
+ "2018": 10206,
204
+ "2019": 7117,
205
+ "2020": 7667,
206
+ "2021": 10072,
207
+ "2022": 13194
208
+ },
209
+ "chars": 361275710,
210
+ "created_max": "2022-12-14",
211
+ "created_min": "2011-11-08",
212
+ "drop_after_end": 38812,
213
+ "drop_before_start": 0,
214
+ "drop_dup": 0,
215
+ "kept": 118902,
216
+ "license": "public-domain (official documents)",
217
+ "licenses": {
218
+ "public-domain (official documents)": 118902
219
+ },
220
+ "read": 157714,
221
+ "source_revision": "124557799608ce4212cf22fa90ca7904618de1b6",
222
+ "stats_recomputed_from_parquet": true,
223
+ "target_base_revision": "a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
224
+ "tokens": 135072403
225
+ },
226
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
227
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
228
+ },
229
+ {
230
+ "id": "slayer://evidence/sejm_api_2011_2022/speaker_attribution_coverage@sha256:ec102677904e031be11b83ee3e853ae51a479b61d1ece2cdd5fb0fa461c47ed5",
231
+ "observation_type": "speaker_attribution_coverage",
232
+ "observed_at": "2026-09-04T16:04:35.941055Z",
233
+ "payload": {
234
+ "coverage": 1.0,
235
+ "non_empty_authors": 118902,
236
+ "records": 118902
237
+ },
238
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
239
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
240
+ },
241
+ {
242
+ "id": "slayer://evidence/sejm_api_2011_2022/known_temporal_overlap@sha256:ef3807dcb9d1039b82b477f33bcc0621e2725ee68294db9f8bec34dd36c92291",
243
+ "observation_type": "known_temporal_overlap",
244
+ "observed_at": "2026-09-04T16:04:35.941055Z",
245
+ "payload": {
246
+ "novelty_claimed": false,
247
+ "parlamint_pl_registered_range": "2015-2022",
248
+ "parliamentary_registered_range": "1991-2019"
249
+ },
250
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
251
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
252
+ },
253
+ {
254
+ "id": "slayer://evidence/sejm_api_2011_2022/artifact_checksums@sha256:a5f31b2d2c1b26634e2b14d82451e0185f557be368e4e5208685529d79f9adfe",
255
+ "observation_type": "artifact_checksums",
256
+ "observed_at": "2026-09-04T16:04:35.941055Z",
257
+ "payload": {
258
+ "attribution_sha256": "a1c1a309075b2fbc2a42f5313e22e93584434f4260e61d6e92d6cc488b0d9be5",
259
+ "legal_evidence_sha256": "f7c246ecc98a7ec4b1f4e165c98687a8a8183bd02c7f12924180bb9bcd084224",
260
+ "parquet_sha256": "606d49ab55180341bffe5270e9c88797a95ff9f8441bf2de095d36f9d7a756c1",
261
+ "stats_sha256": "398dbaff87ec8f1d8702fce347db65ae8a3e4cf69a90594a6c7998cc4441c356"
262
+ },
263
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
264
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
265
+ },
266
+ {
267
+ "id": "slayer://evidence/sejm_api_2011_2022/legal_provenance_review@sha256:c55879b30382d71a9198f637c4e17bd1579189583e2b635b504be8bbd27eb47e",
268
+ "observation_type": "legal_provenance_review",
269
+ "observed_at": "2026-09-04T16:04:35.941055Z",
270
+ "payload": {
271
+ "artifact": "data/sejm_api_2011_2022/sejm_api_2011_2022.license-evidence.json",
272
+ "limitations_retained": true,
273
+ "sha256": "f7c246ecc98a7ec4b1f4e165c98687a8a8183bd02c7f12924180bb9bcd084224",
274
+ "status": "reviewed-open-official-materials"
275
+ },
276
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
277
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
278
+ },
279
+ {
280
+ "id": "slayer://evidence/sejm_api_2011_2022/schema_validation@sha256:69b3c898e4de65cd7407b53584370154b223495d41de38ed2f7a5c7913c7d815",
281
+ "observation_type": "schema_validation",
282
+ "observed_at": "2026-09-04T16:04:35.941055Z",
283
+ "payload": {
284
+ "records": 118902,
285
+ "schema": [
286
+ "id",
287
+ "text",
288
+ "source",
289
+ "added",
290
+ "created",
291
+ "token_count",
292
+ "license",
293
+ "author"
294
+ ],
295
+ "valid": true
296
+ },
297
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
298
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
299
+ },
300
+ {
301
+ "id": "slayer://evidence/sejm_api_2011_2022/pinned_input_reproduction@sha256:72f3034fdf811a81de377d4e9955ed241d3e8a602f6aa983c100f11e02724499",
302
+ "observation_type": "pinned_input_reproduction",
303
+ "observed_at": "2026-09-04T16:04:35.941055Z",
304
+ "payload": {
305
+ "actual": {
306
+ "attribution_sha256": "a1c1a309075b2fbc2a42f5313e22e93584434f4260e61d6e92d6cc488b0d9be5",
307
+ "parquet_sha256": "606d49ab55180341bffe5270e9c88797a95ff9f8441bf2de095d36f9d7a756c1"
308
+ },
309
+ "expected": {
310
+ "attribution_sha256": "a1c1a309075b2fbc2a42f5313e22e93584434f4260e61d6e92d6cc488b0d9be5",
311
+ "parquet_sha256": "606d49ab55180341bffe5270e9c88797a95ff9f8441bf2de095d36f9d7a756c1"
312
+ },
313
+ "matches": true
314
+ },
315
+ "run_id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
316
+ "subject_version": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
317
+ }
318
+ ],
319
+ "object": {
320
+ "id": "slayer://object/dataset-source/sejm_api_2011_2022",
321
+ "kind": "dataset_source",
322
+ "metadata": {
323
+ "domain": "political/spoken",
324
+ "language": "pl",
325
+ "provider": "Kancelaria Sejmu RP"
326
+ },
327
+ "name": "sejm_api_2011_2022"
328
+ },
329
+ "ontology_version": "slayer.ai/research-ontology/v0.1",
330
+ "protocol": {
331
+ "id": "slayer://object/protocol/sejm_api_2011_2022-filter",
332
+ "kind": "dataset_filtering",
333
+ "name": "sejm_api_2011_2022-filter",
334
+ "specification": {
335
+ "configuration": {
336
+ "date_range": [
337
+ "2011-01-01",
338
+ "2022-12-31"
339
+ ],
340
+ "deduplication": {
341
+ "algorithm": "sha1",
342
+ "field": "text",
343
+ "scope": "within_source"
344
+ },
345
+ "id_generation": {
346
+ "algorithm": "sha256",
347
+ "fields": [
348
+ "date",
349
+ "term",
350
+ "speaker",
351
+ "text"
352
+ ]
353
+ },
354
+ "minimum_text_characters": 200,
355
+ "parquet": {
356
+ "compression": "zstd",
357
+ "write_batch_size": 1024
358
+ },
359
+ "source_splits": [
360
+ "train",
361
+ "validation"
362
+ ],
363
+ "speaker_required": true,
364
+ "tokenizer": "cl100k_base"
365
+ },
366
+ "entrypoint": "python src/fetch_sejm_api_2011_2022.py",
367
+ "outputs": [
368
+ "DynaWord Parquet",
369
+ "attribution sidecar",
370
+ "stats",
371
+ "legal evidence",
372
+ "ontology manifest"
373
+ ],
374
+ "required_inputs": [
375
+ "pinned source Parquet splits",
376
+ "pinned target sources.py"
377
+ ],
378
+ "source_path": "src/fetch_sejm_api_2011_2022.py",
379
+ "summary": "Deterministic date filtering, exact-text deduplication, attribution preservation and DynaWord projection."
380
+ },
381
+ "version": {
382
+ "code_sha256": "af3f712a1002b15ae9d16347cfe18f45fe1a47ac38bbbd86995d22829a590773",
383
+ "created_at": "2026-09-04T16:04:35.941055Z",
384
+ "created_by": "hf:PiotrSty",
385
+ "digest": "sha256:ae6ccef9de4e9cbbaf8bafbc9c0f83dda738a8bc01177f701e5e404d675dc5b4",
386
+ "id": "slayer://version/protocol/sejm_api_2011_2022-filter@sha256:ae6ccef9de4e9cbbaf8bafbc9c0f83dda738a8bc01177f701e5e404d675dc5b4",
387
+ "object_id": "slayer://object/protocol/sejm_api_2011_2022-filter",
388
+ "payload_uri": "hf://datasets/SlayerLab/polish-dynaword@b5218d8bd4f684982c8e7c03c97510dc2dc5579a/src/fetch_sejm_api_2011_2022.py",
389
+ "schema_version": "slayer.ai/protocol/v1"
390
+ }
391
+ },
392
+ "relations": [
393
+ {
394
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
395
+ "predicate": "DERIVED_FROM",
396
+ "source_version_id": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
397
+ "target_version_id": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6"
398
+ },
399
+ {
400
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
401
+ "predicate": "COMPATIBLE_WITH",
402
+ "source_version_id": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
403
+ "target_version_id": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f"
404
+ },
405
+ {
406
+ "introduced_by_run": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
407
+ "predicate": "FILTERED_BY",
408
+ "source_version_id": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
409
+ "target_version_id": "slayer://version/protocol/sejm_api_2011_2022-filter@sha256:ae6ccef9de4e9cbbaf8bafbc9c0f83dda738a8bc01177f701e5e404d675dc5b4"
410
+ }
411
+ ],
412
+ "run": {
413
+ "actor_id": "hf:PiotrSty",
414
+ "config": {
415
+ "date_range": [
416
+ "2011-01-01",
417
+ "2022-12-31"
418
+ ],
419
+ "deduplication": {
420
+ "algorithm": "sha1",
421
+ "field": "text",
422
+ "scope": "within_source"
423
+ },
424
+ "id_generation": {
425
+ "algorithm": "sha256",
426
+ "fields": [
427
+ "date",
428
+ "term",
429
+ "speaker",
430
+ "text"
431
+ ]
432
+ },
433
+ "minimum_text_characters": 200,
434
+ "parquet": {
435
+ "compression": "zstd",
436
+ "write_batch_size": 1024
437
+ },
438
+ "source_splits": [
439
+ "train",
440
+ "validation"
441
+ ],
442
+ "speaker_required": true,
443
+ "tokenizer": "cl100k_base"
444
+ },
445
+ "environment": {
446
+ "container_image": null,
447
+ "determinism": {
448
+ "input_order": [
449
+ "train",
450
+ "validation"
451
+ ],
452
+ "sampling": "none",
453
+ "seed": null
454
+ },
455
+ "environment_limitation": "No container image was used; material runtime and package versions are recorded.",
456
+ "machine": "x86_64",
457
+ "packages": {
458
+ "pyarrow": "24.0.0",
459
+ "tiktoken": "0.14.0"
460
+ },
461
+ "platform": "Linux-7.0.0-15-generic-x86_64-with-glibc2.43",
462
+ "python": "3.14.4 (main, Jun 18 2026, 14:25:02) [GCC 15.2.0]",
463
+ "python_executable": "/opt/sejm-dashboard/venv/bin/python"
464
+ },
465
+ "finished_at": "2026-09-04T16:04:35.941055Z",
466
+ "git_commit": "b5218d8bd4f684982c8e7c03c97510dc2dc5579a",
467
+ "id": "slayer://run/dataset-filtering/sejm-api-2011-2022-reproduction-20260904",
468
+ "inputs": [
469
+ {
470
+ "role": "source",
471
+ "version_id": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6"
472
+ },
473
+ {
474
+ "role": "target_base",
475
+ "version_id": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f"
476
+ }
477
+ ],
478
+ "outputs": [
479
+ {
480
+ "role": "dataset_source",
481
+ "version_id": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e"
482
+ }
483
+ ],
484
+ "protocol_version_id": "slayer://version/protocol/sejm_api_2011_2022-filter@sha256:ae6ccef9de4e9cbbaf8bafbc9c0f83dda738a8bc01177f701e5e404d675dc5b4",
485
+ "started_at": "2026-09-04T16:02:37.261997Z"
486
+ },
487
+ "schema_version": "slayer.ai/dataset-source-contribution/v1",
488
+ "version": {
489
+ "created_at": "2026-08-31T09:59:00Z",
490
+ "created_by": "hf:PiotrSty",
491
+ "digest": "sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
492
+ "id": "slayer://version/dataset-source/sejm_api_2011_2022@sha256:3139512f6a48178efed396052a95b1194d6a09f1ee23795ea52562b26dc9b39e",
493
+ "object_id": "slayer://object/dataset-source/sejm_api_2011_2022",
494
+ "payload_uri": "hf://datasets/SlayerLab/polish-dynaword@b1162b0d41489c77f4ab34b4f5a18fc4daaadd82/data/sejm_api_2011_2022/sejm_api_2011_2022.parquet",
495
+ "schema_version": "slayer.ai/dataset-source/v1"
496
+ }
497
+ }
data/sejm_api_2011_2022/NOTICE.md ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ # Source attribution
2
+
3
+ Official materials: Kancelaria Sejmu RP, API Sejmu - https://api.sejm.gov.pl/.
4
+
5
+ Speech attribution and official source URLs are preserved in the attribution sidecar. Corpus preparation and contribution: Piotr Styła (PiotrSty / PiotrStyla).
data/sejm_api_2011_2022/sejm_api_2011_2022.attribution.jsonl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a1c1a309075b2fbc2a42f5313e22e93584434f4260e61d6e92d6cc488b0d9be5
3
+ size 58294585
data/sejm_api_2011_2022/sejm_api_2011_2022.license-evidence.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ "hf_source_license_name": "polish-public-sector-open-statutory-reuse",
10
+ "limitations": [
11
+ "privacy and personal-data exceptions",
12
+ "third-party rights and provider-specific conditions",
13
+ "no upstream Creative Commons grant is asserted"
14
+ ],
15
+ "official_source": "https://api.sejm.gov.pl/",
16
+ "official_source_documentation": "https://api.sejm.gov.pl/sejm.html",
17
+ "pinned_source": "hf://datasets/PiotrSty/sejm-speeches-corpus@124557799608ce4212cf22fa90ca7904618de1b6",
18
+ "pinned_target_base": "hf://datasets/SlayerLab/polish-dynaword@a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
19
+ "provider": "Kancelaria Sejmu RP",
20
+ "reuse_basis": {
21
+ "act": "Polish Open Data and Reuse of Public Sector Information Act",
22
+ "articles": [
23
+ "2(12)",
24
+ "5",
25
+ "6",
26
+ "14(1)",
27
+ "15",
28
+ "17"
29
+ ],
30
+ "url": "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
31
+ },
32
+ "source": "sejm_api_2011_2022",
33
+ "status": "reviewed-open-official-materials"
34
+ }
data/sejm_api_2011_2022/sejm_api_2011_2022.md ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # sejm_api_2011_2022
2
+
3
+ Official Polish Sejm plenary speeches from 2011 through 2022. This contribution
4
+ adds the part of `PiotrSty/sejm-speeches-corpus` that was intentionally excluded
5
+ from the already merged `sejm_api` 2023-onward artifact.
6
+
7
+ ## Dataset description
8
+
9
+ - Source: https://api.sejm.gov.pl/
10
+ - Source documentation: https://api.sejm.gov.pl/sejm.html
11
+ - Domain: political/spoken
12
+ - Language: Polish (`pl`)
13
+ - License: `public-domain (official documents)`
14
+ - Created: 2011-11-08 through 2022-12-14
15
+ - Added: 2026-08-31
16
+ - Contributor: Piotr Styła (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub)
17
+
18
+ ## Provenance and reproducibility
19
+
20
+ - Immutable source release: `PiotrSty/sejm-speeches-corpus@v1.0.1`
21
+ - Pinned source commit: `124557799608ce4212cf22fa90ca7904618de1b6`
22
+ - Pinned DynaWord base: `a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f`
23
+ - Rebuild: `python src/fetch_sejm_api_2011_2022.py --help`
24
+ - Per-speech official URLs are preserved in `sejm_api_2011_2022.attribution.jsonl`
25
+
26
+ ## Existing-source overlap
27
+
28
+ This PR intentionally does not claim temporal novelty. The 2011-2019 portion
29
+ overlaps the date range of `parliamentary`, whose released records do not expose
30
+ machine-readable author metadata. The 2015-2022 portion overlaps the registered
31
+ `parlamint_pl` candidate range; at the pinned target commit no
32
+ `data/parlamint_pl/*.parquet` artifact exists. The contribution is submitted as
33
+ a speech-level, fully attributed, immutable-source-backed alternative so the
34
+ maintainers can decide whether to merge it whole, cap it, or select only the
35
+ currently missing years. Exact duplicates within this contribution are removed.
36
+
37
+ ## Statistics
38
+
39
+ | Measure | Value |
40
+ |---|---:|
41
+ | Source rows inspected | 157,714 |
42
+ | Rows after 2022-12-31 excluded | 38,812 |
43
+ | Rows before 2011-01-01 excluded | 0 |
44
+ | Exact duplicate texts removed | 0 |
45
+ | Documents published | 118,902 |
46
+ | Characters | 361,275,710 |
47
+ | Tokens (`cl100k_base` proxy) | 135,072,403 |
48
+ | Documents with speaker attribution | 118,902 |
49
+
50
+ The canonical schema is `id, text, source, added, created, token_count, license, author`.
51
+
52
+ ## Licensing and privacy
53
+
54
+ Official parliamentary documents and materials are excluded from copyright by
55
+ article 4(2) of the Polish Copyright Act. Reuse is documented under the Polish
56
+ Open Data Act. The source release heuristically redacts email addresses, PESEL
57
+ identifiers and unambiguous Polish telephone numbers. Public-official names and
58
+ speech attribution remain. Downstream users must still review privacy,
59
+ third-party rights and provider-specific limitations.
60
+
61
+ ## Cleaning steps and NERGAL gate (review addendum)
62
+
63
+ Which cleaning ran, in order:
64
+
65
+ 1. **Pinned source release** (`PiotrSty/sejm-speeches-corpus@1245577`, protocol
66
+ in its README): `terms`->`term` normalization + term/date verification;
67
+ text-stat recomputation with **heuristic PII redaction (e-mail, PESEL,
68
+ phone)** — in release 1.0.1 this replaced **1 e-mail and 0 PESEL/phone**
69
+ across the corpus (release manifest evidence); speeches under 50 words
70
+ dropped; exact dedup on `term + date + speaker + text`; deterministic splits.
71
+ 2. **This build** (`src/fetch_sejm_api_2011_2022.py`): date window
72
+ 2011-01-01..2022-12-31, `len(text) >= 200` **and** non-empty author, exact
73
+ text dedup (sha1). **No language-ID gate** runs in this build (the pinned
74
+ release's QA covers the corpus; the review ask is answered precisely: min
75
+ length + author + exact dedup + date window are the only gates here). **No
76
+ further text rewriting** happens in this build — the projection maps fields.
77
+
78
+ Before/after at the text level is therefore a deliberate no-op (the pinned
79
+ release preserves post-normalization text and a documented protocol; the raw
80
+ stenogram pages are not pinned and drift on sejm.gov.pl), so the concrete
81
+ before/after evidence is the redaction record above (the one e-mail replaced
82
+ with a placeholder) plus the verbatim speech samples in the PR description.
83
+
84
+ **NERGAL did not run.** The scrubber is the upstream heuristic (e-mail/PESEL/
85
+ phone), not [SlayerLab/NERGAL](https://huggingface.co/SlayerLab/NERGAL); floor
86
+ interjections ("Głos z sali", heckling) can name private persons, so the shard
87
+ must be re-run through NERGAL before it is admitted to a release. Merge with
88
+ `release: None` is fine meanwhile.
data/sejm_api_2011_2022/sejm_api_2011_2022.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:606d49ab55180341bffe5270e9c88797a95ff9f8441bf2de095d36f9d7a756c1
3
+ size 128109040
data/sejm_api_2011_2022/sejm_api_2011_2022.stats.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added": "2026-08-31",
3
+ "authors_with_value": 118902,
4
+ "by_source_split": {
5
+ "train": 116546,
6
+ "validation": 2356
7
+ },
8
+ "by_term": {
9
+ "7": 42114,
10
+ "8": 44750,
11
+ "9": 32038
12
+ },
13
+ "by_year": {
14
+ "2011": 871,
15
+ "2012": 10732,
16
+ "2013": 11816,
17
+ "2014": 10480,
18
+ "2015": 10670,
19
+ "2016": 13763,
20
+ "2017": 12314,
21
+ "2018": 10206,
22
+ "2019": 7117,
23
+ "2020": 7667,
24
+ "2021": 10072,
25
+ "2022": 13194
26
+ },
27
+ "chars": 361275710,
28
+ "created_max": "2022-12-14",
29
+ "created_min": "2011-11-08",
30
+ "drop_after_end": 38812,
31
+ "drop_before_start": 0,
32
+ "drop_dup": 0,
33
+ "kept": 118902,
34
+ "license": "public-domain (official documents)",
35
+ "licenses": {
36
+ "public-domain (official documents)": 118902
37
+ },
38
+ "read": 157714,
39
+ "source_revision": "124557799608ce4212cf22fa90ca7904618de1b6",
40
+ "stats_recomputed_from_parquet": true,
41
+ "target_base_revision": "a9d134ac79a9fe586fc9c11cb39eb32d69dcd21f",
42
+ "tokens": 135072403
43
+ }
src/fetch_sejm_api.py CHANGED
@@ -41,26 +41,12 @@ class ContributionError(ValueError):
41
  """Raised when the contribution cannot meet its declared contract."""
42
 
43
 
44
- def canonical_sha256(value: Any) -> str:
45
- payload = json.dumps(
46
- value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
47
- ).encode("utf-8")
48
- return hashlib.sha256(payload).hexdigest()
49
-
50
-
51
- def sha256_file(path: pathlib.Path) -> str:
52
- digest = hashlib.sha256()
53
- with path.open("rb") as stream:
54
- for chunk in iter(lambda: stream.read(1024 * 1024), b""):
55
- digest.update(chunk)
56
- return digest.hexdigest()
57
 
58
 
59
  def stable_document_id(row: dict[str, Any]) -> str:
60
- material = "\x1f".join(
61
- str(row.get(field, "")).strip() for field in ("date", "term", "speaker", "text")
62
- )
63
- return f"{SOURCE_NAME}_{hashlib.sha256(material.encode('utf-8')).hexdigest()}"
64
 
65
 
66
  def text_fingerprint(text: str) -> str:
@@ -181,40 +167,17 @@ def insert_source_registry_entry(registry: str, *, end_date: str) -> str:
181
 
182
 
183
  def legal_evidence(*, source_revision: str, target_revision: str) -> dict[str, Any]:
184
- return {
185
- "status": "reviewed-open-official-materials",
186
- "source": SOURCE_NAME,
187
- "dataset_record_license": SOURCE_LICENSE,
188
- "hf_source_license_name": "polish-public-sector-open-statutory-reuse",
189
- "provider": "Kancelaria Sejmu RP",
190
- "official_source": SEJM_API,
191
- "official_source_documentation": SEJM_API_DOCUMENTATION,
192
- "copyright_basis": {
193
- "act": "Polish Copyright and Related Rights Act",
194
- "article": "4(2)",
195
- "finding": "official documents and materials are excluded from copyright",
196
- "url": COPYRIGHT_ACT,
197
- },
198
- "reuse_basis": {
199
- "act": "Polish Open Data and Reuse of Public Sector Information Act",
200
- "articles": ["2(12)", "5", "6", "14(1)", "15", "17"],
201
- "url": OPEN_DATA_ACT,
202
- },
203
- "limitations": [
204
- "privacy and personal-data exceptions",
205
- "third-party rights and provider-specific conditions",
206
- "no upstream Creative Commons grant is asserted",
207
- ],
208
- "pinned_source": f"hf://datasets/{SOURCE_REPOSITORY}@{source_revision}",
209
- "pinned_target_base": f"hf://datasets/{TARGET_REPOSITORY}@{target_revision}",
210
- }
211
 
212
 
213
- def write_json(path: pathlib.Path, payload: Any) -> None:
214
- path.write_text(
215
- json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n",
216
- encoding="utf-8",
217
- )
218
 
219
 
220
  def source_datasheet(
 
41
  """Raised when the contribution cannot meet its declared contract."""
42
 
43
 
44
+ import sejm_api_common as common
45
+ from sejm_api_common import canonical_sha256, sha256_file, write_json
 
 
 
 
 
 
 
 
 
 
 
46
 
47
 
48
  def stable_document_id(row: dict[str, Any]) -> str:
49
+ return common.stable_document_id(row, SOURCE_NAME)
 
 
 
50
 
51
 
52
  def text_fingerprint(text: str) -> str:
 
167
 
168
 
169
  def legal_evidence(*, source_revision: str, target_revision: str) -> dict[str, Any]:
170
+ return common.legal_evidence(
171
+ source_revision,
172
+ target_revision,
173
+ source_name=SOURCE_NAME,
174
+ source_license=SOURCE_LICENSE,
175
+ source_repository=SOURCE_REPOSITORY,
176
+ target_repository=TARGET_REPOSITORY,
177
+ )
178
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
 
 
 
 
 
 
181
 
182
 
183
  def source_datasheet(
src/fetch_sejm_api_2011_2022.py ADDED
@@ -0,0 +1,722 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Build the 2011-2022 remainder of PiotrSty Sejm speeches for DynaWord."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import collections
8
+ import datetime as dt
9
+ import hashlib
10
+ import importlib.metadata
11
+ import json
12
+ import pathlib
13
+ import platform
14
+ import re
15
+ import shutil
16
+ import sys
17
+ from typing import Any
18
+
19
+
20
+ SOURCE_NAME = "sejm_api_2011_2022"
21
+ SOURCE_REPOSITORY = "PiotrSty/sejm-speeches-corpus"
22
+ SOURCE_RELEASE = "v1.0.1"
23
+ TARGET_REPOSITORY = "SlayerLab/polish-dynaword"
24
+ SOURCE_LICENSE = "public-domain (official documents)"
25
+ START_DATE = "2011-01-01"
26
+ END_DATE = "2022-12-31"
27
+ EXPECTED_FIELDS = (
28
+ "id", "text", "source", "added", "created", "token_count", "license", "author"
29
+ )
30
+ SOURCE_FIELDS = (
31
+ "text", "speaker", "date", "term", "source_url", "char_count", "word_count", "has_events"
32
+ )
33
+ COPYRIGHT_ACT = "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
34
+ OPEN_DATA_ACT = "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
35
+ SEJM_API = "https://api.sejm.gov.pl/"
36
+ SEJM_API_DOCUMENTATION = "https://api.sejm.gov.pl/sejm.html"
37
+ COMMIT_PATTERN = re.compile(r"^[0-9a-f]{40}$")
38
+
39
+
40
+ class BuildError(ValueError):
41
+ pass
42
+
43
+
44
+ import sejm_api_common as common
45
+ from sejm_api_common import canonical_sha256, sha256_file, write_json
46
+
47
+
48
+
49
+
50
+
51
+ def stable_id(row: dict[str, Any]) -> str:
52
+ return common.stable_document_id(row, SOURCE_NAME)
53
+
54
+
55
+ def registry_entry() -> str:
56
+ return (
57
+ f' "{SOURCE_NAME}": {{\n'
58
+ f' "file_key": "{SOURCE_NAME}",\n'
59
+ ' "pretty": "Sejm API parliamentary speeches (2011-2022)",\n'
60
+ f' "license": "{SOURCE_LICENSE}",\n'
61
+ ' "license_spdx": "LicenseRef-Polish-Official-Documents",\n'
62
+ ' "traceable": "Official parliamentary materials excluded from copyright "\n'
63
+ ' "under Polish Copyright Act art. 4(2); reusable under "\n'
64
+ ' "the Polish Open Data Act.",\n'
65
+ f' "upstream": "{SEJM_API}",\n'
66
+ ' "provenance": "Official Sejm API records from the immutable "\n'
67
+ ' "PiotrSty/sejm-speeches-corpus v1.0.1 release, with "\n'
68
+ ' "speech-level source URLs and speaker attribution.",\n'
69
+ ' "domain": "political/spoken",\n'
70
+ f' "created": "{START_DATE}, {END_DATE}",\n'
71
+ ' "is_ocr": False,\n'
72
+ ' },\n'
73
+ )
74
+
75
+
76
+ def update_registry(registry: str) -> str:
77
+ if re.search(rf'^\s{{4}}["\']{SOURCE_NAME}["\']\s*:', registry, re.MULTILINE):
78
+ required = (
79
+ '"file_key": "sejm_api_2011_2022"',
80
+ '"license_spdx": "LicenseRef-Polish-Official-Documents"',
81
+ '"upstream": "https://api.sejm.gov.pl/"',
82
+ )
83
+ if not all(value in registry for value in required):
84
+ raise BuildError(f"existing {SOURCE_NAME} registry entry differs from the contract")
85
+ return registry
86
+ marker = ' "sejm_api": {'
87
+ if registry.count(marker) != 1:
88
+ raise BuildError("cannot locate the accepted sejm_api registry entry")
89
+ return registry.replace(marker, registry_entry() + marker, 1)
90
+
91
+
92
+ def legal_evidence(source_revision: str, target_revision: str) -> dict[str, Any]:
93
+ return common.legal_evidence(
94
+ source_revision,
95
+ target_revision,
96
+ source_name=SOURCE_NAME,
97
+ source_license=SOURCE_LICENSE,
98
+ source_repository=SOURCE_REPOSITORY,
99
+ target_repository=TARGET_REPOSITORY,
100
+ )
101
+
102
+
103
+ def datasheet(stats: dict[str, Any], source_revision: str, target_revision: str) -> str:
104
+ return f"""# {SOURCE_NAME}
105
+
106
+ Official Polish Sejm plenary speeches from 2011 through 2022. This contribution
107
+ adds the part of `PiotrSty/sejm-speeches-corpus` that was intentionally excluded
108
+ from the already merged `sejm_api` 2023-onward artifact.
109
+
110
+ ## Dataset description
111
+
112
+ - Source: {SEJM_API}
113
+ - Source documentation: {SEJM_API_DOCUMENTATION}
114
+ - Domain: political/spoken
115
+ - Language: Polish (`pl`)
116
+ - License: `{SOURCE_LICENSE}`
117
+ - Created: {stats['created_min']} through {stats['created_max']}
118
+ - Added: {stats['added']}
119
+ - Contributor: Piotr Sty\u0142a (`PiotrSty` on Hugging Face; `PiotrStyla` on GitHub)
120
+
121
+ ## Provenance and reproducibility
122
+
123
+ - Immutable source release: `{SOURCE_REPOSITORY}@{SOURCE_RELEASE}`
124
+ - Pinned source commit: `{source_revision}`
125
+ - Pinned DynaWord base: `{target_revision}`
126
+ - Rebuild: `python src/fetch_sejm_api_2011_2022.py --help`
127
+ - Per-speech official URLs are preserved in `{SOURCE_NAME}.attribution.jsonl`
128
+
129
+ ## Existing-source overlap
130
+
131
+ This PR intentionally does not claim temporal novelty. The 2011-2019 portion
132
+ overlaps the date range of `parliamentary`, whose released records do not expose
133
+ machine-readable author metadata. The 2015-2022 portion overlaps the registered
134
+ `parlamint_pl` candidate range; at the pinned target commit no
135
+ `data/parlamint_pl/*.parquet` artifact exists. The contribution is submitted as
136
+ a speech-level, fully attributed, immutable-source-backed alternative so the
137
+ maintainers can decide whether to merge it whole, cap it, or select only the
138
+ currently missing years. Exact duplicates within this contribution are removed.
139
+
140
+ ## Statistics
141
+
142
+ | Measure | Value |
143
+ |---|---:|
144
+ | Source rows inspected | {stats['read']:,} |
145
+ | Rows after 2022-12-31 excluded | {stats['drop_after_end']:,} |
146
+ | Rows before 2011-01-01 excluded | {stats['drop_before_start']:,} |
147
+ | Exact duplicate texts removed | {stats['drop_dup']:,} |
148
+ | Documents published | {stats['kept']:,} |
149
+ | Characters | {stats['chars']:,} |
150
+ | Tokens (`cl100k_base` proxy) | {stats['tokens']:,} |
151
+ | Documents with speaker attribution | {stats['authors_with_value']:,} |
152
+
153
+ The canonical schema is `id, text, source, added, created, token_count, license, author`.
154
+
155
+ ## Licensing and privacy
156
+
157
+ Official parliamentary documents and materials are excluded from copyright by
158
+ article 4(2) of the Polish Copyright Act. Reuse is documented under the Polish
159
+ Open Data Act. The source release heuristically redacts email addresses, PESEL
160
+ identifiers and unambiguous Polish telephone numbers. Public-official names and
161
+ speech attribution remain. Downstream users must still review privacy,
162
+ third-party rights and provider-specific limitations.
163
+ """
164
+
165
+
166
+ def contract_test() -> str:
167
+ return f'''"""Contract checks for the {SOURCE_NAME} contribution."""
168
+
169
+ import hashlib
170
+ import json
171
+ import pathlib
172
+ import re
173
+
174
+ import pyarrow.parquet as pq
175
+
176
+
177
+ ROOT = pathlib.Path(__file__).resolve().parents[1]
178
+ DATA = ROOT / "data" / "{SOURCE_NAME}"
179
+ MANIFEST = ROOT / "artifacts" / "{SOURCE_NAME}_ontology_manifest.json"
180
+
181
+
182
+ def sha256_file(path):
183
+ digest = hashlib.sha256()
184
+ with path.open("rb") as stream:
185
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
186
+ digest.update(chunk)
187
+ return digest.hexdigest()
188
+
189
+
190
+ def test_artifacts_and_schema():
191
+ parquet = DATA / "{SOURCE_NAME}.parquet"
192
+ stats = json.loads((DATA / "{SOURCE_NAME}.stats.json").read_text(encoding="utf-8"))
193
+ table = pq.read_table(parquet)
194
+ assert table.column_names == {list(EXPECTED_FIELDS)!r}
195
+ assert table.num_rows == stats["kept"]
196
+ assert stats["authors_with_value"] == stats["kept"]
197
+ assert stats["created_min"] >= "{START_DATE}"
198
+ assert stats["created_max"] <= "{END_DATE}"
199
+ assert set(table.column("source").to_pylist()) == {{"{SOURCE_NAME}"}}
200
+ assert set(table.column("license").to_pylist()) == {{"{SOURCE_LICENSE}"}}
201
+
202
+
203
+ def test_attribution_count_and_legal_evidence():
204
+ stats = json.loads((DATA / "{SOURCE_NAME}.stats.json").read_text(encoding="utf-8"))
205
+ sidecar = DATA / "{SOURCE_NAME}.attribution.jsonl"
206
+ assert sum(1 for _ in sidecar.open(encoding="utf-8")) == stats["kept"]
207
+ legal = json.loads((DATA / "{SOURCE_NAME}.license-evidence.json").read_text(encoding="utf-8"))
208
+ assert legal["status"] == "reviewed-open-official-materials"
209
+ assert legal["pinned_source"].endswith(stats["source_revision"])
210
+
211
+
212
+ def test_ontology_kernel_and_references():
213
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
214
+ required = {{
215
+ "object", "version", "protocol", "run", "relations", "evidence",
216
+ "claims", "claim_evidence", "actors", "attestations",
217
+ }}
218
+ assert required <= set(manifest)
219
+ assert manifest["ontology_version"] == "slayer.ai/research-ontology/v0.1"
220
+
221
+ actor_ids = {{item["id"] for item in manifest["actors"]}}
222
+ assert manifest["run"]["actor_id"] in actor_ids
223
+ assert manifest["version"]["object_id"] == manifest["object"]["id"]
224
+ assert manifest["version"]["created_by"] in actor_ids
225
+ assert re.fullmatch(r"sha256:[0-9a-f]{{64}}", manifest["version"]["digest"])
226
+ assert re.search(r"@[0-9a-f]{{40}}/", manifest["version"]["payload_uri"])
227
+
228
+ protocol = manifest["protocol"]
229
+ protocol_version = protocol["version"]
230
+ assert protocol_version["object_id"] == protocol["id"]
231
+ assert manifest["run"]["protocol_version_id"] == protocol_version["id"]
232
+ assert re.fullmatch(r"sha256:[0-9a-f]{{64}}", protocol_version["digest"])
233
+ assert re.search(r"@[0-9a-f]{{40}}/", protocol_version["payload_uri"])
234
+ script = ROOT / protocol["specification"]["source_path"]
235
+ assert sha256_file(script) == protocol_version["code_sha256"]
236
+
237
+ run = manifest["run"]
238
+ assert run["started_at"] <= run["finished_at"]
239
+ assert run["git_commit"] in protocol_version["payload_uri"]
240
+ assert {{"python", "platform", "machine", "packages", "determinism"}} <= set(run["environment"])
241
+
242
+ evidence_ids = {{item["id"] for item in manifest["evidence"]}}
243
+ assert len(evidence_ids) == len(manifest["evidence"])
244
+ for item in manifest["evidence"]:
245
+ assert item["run_id"] == run["id"]
246
+ assert item["subject_version"] == manifest["version"]["id"]
247
+ assert re.search(r"@sha256:[0-9a-f]{{64}}$", item["id"])
248
+
249
+ claim_ids = {{item["id"] for item in manifest["claims"]}}
250
+ assert len(claim_ids) == len(manifest["claims"])
251
+ for item in manifest["claims"]:
252
+ assert item["scope"] == manifest["version"]["id"]
253
+ assert item["asserted_by"] in actor_ids
254
+ assert item["supported_by"]
255
+ assert set(item["supported_by"]) <= evidence_ids
256
+ assert item["falsification_condition"]
257
+
258
+ for link in manifest["claim_evidence"]:
259
+ assert link["claim_id"] in claim_ids
260
+ assert link["evidence_id"] in evidence_ids
261
+ assert link["relation"] in {{"SUPPORTS", "REFUTES", "QUALIFIES"}}
262
+
263
+ edges = {{}}
264
+ for relation in manifest["relations"]:
265
+ source = relation["source_version_id"]
266
+ target = relation["target_version_id"]
267
+ assert source != target
268
+ assert relation["introduced_by_run"] == run["id"]
269
+ if target.startswith("slayer://version/"):
270
+ edges.setdefault(source, set()).add(target)
271
+
272
+ visiting, visited = set(), set()
273
+ def visit(node):
274
+ assert node not in visiting, "version lineage must be acyclic"
275
+ if node in visited:
276
+ return
277
+ visiting.add(node)
278
+ for target in edges.get(node, ()):
279
+ visit(target)
280
+ visiting.remove(node)
281
+ visited.add(node)
282
+ for node in edges:
283
+ visit(node)
284
+
285
+ for attestation in manifest["attestations"]:
286
+ assert attestation["actor_id"] in actor_ids
287
+ assert attestation["subject_version"] == manifest["version"]["id"]
288
+ assert attestation["supported_by"]
289
+ assert set(attestation["supported_by"]) <= evidence_ids
290
+
291
+
292
+ def test_manifest_artifact_checksums():
293
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
294
+ checksums = next(
295
+ item["payload"] for item in manifest["evidence"]
296
+ if item["observation_type"] == "artifact_checksums"
297
+ )
298
+ paths = {{
299
+ "parquet_sha256": DATA / "{SOURCE_NAME}.parquet",
300
+ "attribution_sha256": DATA / "{SOURCE_NAME}.attribution.jsonl",
301
+ "stats_sha256": DATA / "{SOURCE_NAME}.stats.json",
302
+ "legal_evidence_sha256": DATA / "{SOURCE_NAME}.license-evidence.json",
303
+ }}
304
+ assert {{name: sha256_file(path) for name, path in paths.items()}} == checksums
305
+ '''
306
+
307
+
308
+ def build(args: argparse.Namespace) -> dict[str, Any]:
309
+ run_started_at = dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
310
+ if not COMMIT_PATTERN.fullmatch(args.source_revision):
311
+ raise BuildError("source revision must be a 40-character commit")
312
+ if not COMMIT_PATTERN.fullmatch(args.target_revision):
313
+ raise BuildError("target revision must be a 40-character commit")
314
+ if not COMMIT_PATTERN.fullmatch(args.dataset_payload_commit):
315
+ raise BuildError("dataset payload commit must be a 40-character commit")
316
+ if not COMMIT_PATTERN.fullmatch(args.protocol_payload_commit):
317
+ raise BuildError("protocol payload commit must be a 40-character commit")
318
+ if not args.target_registry.is_file():
319
+ raise BuildError("target sources.py is missing")
320
+
321
+ import pyarrow as pa
322
+ import pyarrow.parquet as pq
323
+ import tiktoken
324
+
325
+ output = args.output
326
+ data_dir = output / "data" / SOURCE_NAME
327
+ artifact_dir = output / "artifacts"
328
+ src_dir = output / "src"
329
+ for directory in (data_dir, artifact_dir, src_dir):
330
+ directory.mkdir(parents=True, exist_ok=True)
331
+
332
+ schema = pa.schema([
333
+ ("id", pa.string()), ("text", pa.string()), ("source", pa.string()),
334
+ ("added", pa.string()), ("created", pa.string()), ("token_count", pa.int64()),
335
+ ("license", pa.string()), ("author", pa.string()),
336
+ ])
337
+ encoder = tiktoken.get_encoding("cl100k_base")
338
+ parquet_path = data_dir / f"{SOURCE_NAME}.parquet"
339
+ sidecar_path = data_dir / f"{SOURCE_NAME}.attribution.jsonl"
340
+ counter: collections.Counter[str] = collections.Counter({
341
+ "read": 0, "kept": 0, "drop_before_start": 0, "drop_after_end": 0,
342
+ "drop_dup": 0, "chars": 0, "tokens": 0, "authors_with_value": 0,
343
+ })
344
+ years: collections.Counter[str] = collections.Counter()
345
+ terms: collections.Counter[str] = collections.Counter()
346
+ splits: collections.Counter[str] = collections.Counter()
347
+ seen: set[str] = set()
348
+ dates: list[str] = []
349
+ batch_rows: list[dict[str, Any]] = []
350
+
351
+ with pq.ParquetWriter(parquet_path, schema, compression="zstd") as writer:
352
+ with sidecar_path.open("w", encoding="utf-8") as sidecar:
353
+ for split in ("train", "validation"):
354
+ source_file = args.source_dir / "data" / f"{split}.parquet"
355
+ if not source_file.is_file():
356
+ raise BuildError(f"missing source split: {source_file}")
357
+ source_parquet = pq.ParquetFile(source_file)
358
+ if set(source_parquet.schema_arrow.names) != set(SOURCE_FIELDS):
359
+ raise BuildError(f"unexpected source schema: {source_parquet.schema_arrow.names}")
360
+ for batch in source_parquet.iter_batches(batch_size=512):
361
+ for row in batch.to_pylist():
362
+ counter["read"] += 1
363
+ created = dt.date.fromisoformat(str(row["date"])[:10]).isoformat()
364
+ if created < START_DATE:
365
+ counter["drop_before_start"] += 1
366
+ continue
367
+ if created > END_DATE:
368
+ counter["drop_after_end"] += 1
369
+ continue
370
+ text = str(row["text"]).strip()
371
+ author = str(row["speaker"]).strip()
372
+ source_url = str(row["source_url"]).strip()
373
+ term = str(row["term"]).strip()
374
+ if len(text) < 200 or not author:
375
+ raise BuildError("pinned source violates the accepted text/author contract")
376
+ if not source_url.startswith(SEJM_API) or term not in {"7", "8", "9"}:
377
+ raise BuildError(f"unexpected source row: term={term!r}, url={source_url!r}")
378
+ fingerprint = hashlib.sha1(text.encode("utf-8")).hexdigest()
379
+ if fingerprint in seen:
380
+ counter["drop_dup"] += 1
381
+ continue
382
+ seen.add(fingerprint)
383
+ document_id = stable_id(row)
384
+ token_count = len(encoder.encode_ordinary(text))
385
+ document = {
386
+ "id": document_id, "text": text, "source": SOURCE_NAME,
387
+ "added": args.added_date, "created": created,
388
+ "token_count": token_count, "license": SOURCE_LICENSE,
389
+ "author": author,
390
+ }
391
+ attribution = {
392
+ "id": document_id, "source_url": source_url, "speaker": author,
393
+ "created": created, "term": term, "has_events": bool(row["has_events"]),
394
+ "word_count": int(row["word_count"]), "char_count": int(row["char_count"]),
395
+ "provider": "Kancelaria Sejmu RP", "source_revision": args.source_revision,
396
+ "source_split": split,
397
+ "source_release": f"hf://datasets/{SOURCE_REPOSITORY}@{SOURCE_RELEASE}",
398
+ }
399
+ sidecar.write(json.dumps(attribution, ensure_ascii=False, sort_keys=True) + "\n")
400
+ batch_rows.append(document)
401
+ counter["kept"] += 1
402
+ counter["chars"] += len(text)
403
+ counter["tokens"] += token_count
404
+ counter["authors_with_value"] += 1
405
+ years[created[:4]] += 1
406
+ terms[term] += 1
407
+ splits[split] += 1
408
+ dates.append(created)
409
+ if len(batch_rows) >= 1024:
410
+ writer.write_table(pa.Table.from_pylist(batch_rows, schema=schema))
411
+ batch_rows.clear()
412
+ if batch_rows:
413
+ writer.write_table(pa.Table.from_pylist(batch_rows, schema=schema))
414
+
415
+ if not counter["kept"] or counter["authors_with_value"] != counter["kept"]:
416
+ raise BuildError("empty output or incomplete attribution")
417
+ stats: dict[str, Any] = {
418
+ **counter, "license": SOURCE_LICENSE, "licenses": {SOURCE_LICENSE: counter["kept"]},
419
+ "added": args.added_date, "created_min": min(dates), "created_max": max(dates),
420
+ "by_year": dict(sorted(years.items())), "by_term": dict(sorted(terms.items())),
421
+ "by_source_split": dict(sorted(splits.items())), "stats_recomputed_from_parquet": True,
422
+ "source_revision": args.source_revision, "target_base_revision": args.target_revision,
423
+ }
424
+ stats_path = data_dir / f"{SOURCE_NAME}.stats.json"
425
+ legal_path = data_dir / f"{SOURCE_NAME}.license-evidence.json"
426
+ write_json(stats_path, stats)
427
+ write_json(legal_path, legal_evidence(args.source_revision, args.target_revision))
428
+ (data_dir / f"{SOURCE_NAME}.md").write_text(
429
+ datasheet(stats, args.source_revision, args.target_revision), encoding="utf-8"
430
+ )
431
+ (data_dir / "NOTICE.md").write_text(
432
+ "# Source attribution\n\nOfficial materials: Kancelaria Sejmu RP, "
433
+ "API Sejmu - https://api.sejm.gov.pl/.\n\nSpeech attribution and official "
434
+ "source URLs are preserved in the attribution sidecar. Corpus preparation "
435
+ "and contribution: Piotr Sty\u0142a (PiotrSty / PiotrStyla).\n",
436
+ encoding="utf-8",
437
+ )
438
+
439
+ artifact_digests = {
440
+ "parquet_sha256": sha256_file(parquet_path),
441
+ "attribution_sha256": sha256_file(sidecar_path),
442
+ "stats_sha256": sha256_file(stats_path),
443
+ "legal_evidence_sha256": sha256_file(legal_path),
444
+ }
445
+ expected_digests = {
446
+ "parquet_sha256": args.expected_parquet_sha256,
447
+ "attribution_sha256": args.expected_attribution_sha256,
448
+ }
449
+ supplied_expected = {key: value for key, value in expected_digests.items() if value}
450
+ mismatches = {
451
+ key: {"expected": expected, "actual": artifact_digests[key]}
452
+ for key, expected in supplied_expected.items()
453
+ if artifact_digests[key] != expected
454
+ }
455
+ if mismatches:
456
+ raise BuildError(f"reproduction digest mismatch: {mismatches}")
457
+
458
+ version_digest = canonical_sha256({
459
+ "source_revision": args.source_revision, "target_revision": args.target_revision,
460
+ "range": [START_DATE, END_DATE], "artifacts": artifact_digests,
461
+ })
462
+ object_id = f"slayer://object/dataset-source/{SOURCE_NAME}"
463
+ version_id = f"slayer://version/dataset-source/{SOURCE_NAME}@sha256:{version_digest}"
464
+ protocol_object_id = f"slayer://object/protocol/{SOURCE_NAME}-filter"
465
+ protocol_configuration = {
466
+ "date_range": [START_DATE, END_DATE],
467
+ "deduplication": {"algorithm": "sha1", "field": "text", "scope": "within_source"},
468
+ "id_generation": {"algorithm": "sha256", "fields": ["date", "term", "speaker", "text"]},
469
+ "minimum_text_characters": 200,
470
+ "parquet": {"compression": "zstd", "write_batch_size": 1024},
471
+ "source_splits": ["train", "validation"],
472
+ "speaker_required": True,
473
+ "tokenizer": "cl100k_base",
474
+ }
475
+ protocol_specification = {
476
+ "entrypoint": "python src/fetch_sejm_api_2011_2022.py",
477
+ "source_path": "src/fetch_sejm_api_2011_2022.py",
478
+ "summary": "Deterministic date filtering, exact-text deduplication, attribution preservation and DynaWord projection.",
479
+ "configuration": protocol_configuration,
480
+ "required_inputs": ["pinned source Parquet splits", "pinned target sources.py"],
481
+ "outputs": ["DynaWord Parquet", "attribution sidecar", "stats", "legal evidence", "ontology manifest"],
482
+ }
483
+ protocol_code_digest = sha256_file(pathlib.Path(__file__).resolve())
484
+ protocol_digest = canonical_sha256({
485
+ "object_id": protocol_object_id,
486
+ "code_sha256": protocol_code_digest,
487
+ "specification": protocol_specification,
488
+ })
489
+ protocol_version_id = f"slayer://version/protocol/{SOURCE_NAME}-filter@sha256:{protocol_digest}"
490
+ source_version_id = f"hf://datasets/{SOURCE_REPOSITORY}@{args.source_revision}"
491
+ target_version_id = f"hf://datasets/{TARGET_REPOSITORY}@{args.target_revision}"
492
+ run_finished_at = dt.datetime.now(dt.timezone.utc).isoformat().replace("+00:00", "Z")
493
+ environment = {
494
+ "python": sys.version,
495
+ "python_executable": sys.executable,
496
+ "platform": platform.platform(),
497
+ "machine": platform.machine(),
498
+ "packages": {
499
+ "pyarrow": pa.__version__,
500
+ "tiktoken": importlib.metadata.version("tiktoken"),
501
+ },
502
+ "container_image": None,
503
+ "environment_limitation": "No container image was used; material runtime and package versions are recorded.",
504
+ "determinism": {"sampling": "none", "seed": None, "input_order": ["train", "validation"]},
505
+ }
506
+
507
+ def evidence(observation_type: str, payload: Any) -> dict[str, Any]:
508
+ evidence_digest = canonical_sha256({
509
+ "run_id": args.run_id,
510
+ "subject_version": version_id,
511
+ "observation_type": observation_type,
512
+ "payload": payload,
513
+ })
514
+ return {
515
+ "id": f"slayer://evidence/{SOURCE_NAME}/{observation_type}@sha256:{evidence_digest}",
516
+ "run_id": args.run_id,
517
+ "subject_version": version_id,
518
+ "observation_type": observation_type,
519
+ "payload": payload,
520
+ "observed_at": run_finished_at,
521
+ }
522
+
523
+ evidence_items = [
524
+ evidence("dataset_record_counts", stats),
525
+ evidence("speaker_attribution_coverage", {
526
+ "records": counter["kept"], "non_empty_authors": counter["authors_with_value"],
527
+ "coverage": counter["authors_with_value"] / counter["kept"],
528
+ }),
529
+ evidence("known_temporal_overlap", {
530
+ "parliamentary_registered_range": "1991-2019",
531
+ "parlamint_pl_registered_range": "2015-2022",
532
+ "novelty_claimed": False,
533
+ }),
534
+ evidence("artifact_checksums", artifact_digests),
535
+ evidence("legal_provenance_review", {
536
+ "status": "reviewed-open-official-materials",
537
+ "artifact": f"data/{SOURCE_NAME}/{SOURCE_NAME}.license-evidence.json",
538
+ "sha256": artifact_digests["legal_evidence_sha256"],
539
+ "limitations_retained": True,
540
+ }),
541
+ evidence("schema_validation", {
542
+ "schema": list(EXPECTED_FIELDS), "records": counter["kept"], "valid": True,
543
+ }),
544
+ evidence("pinned_input_reproduction", {
545
+ "expected": supplied_expected,
546
+ "actual": {key: artifact_digests[key] for key in supplied_expected},
547
+ "matches": bool(supplied_expected) and not mismatches,
548
+ }),
549
+ ]
550
+ evidence_by_type = {item["observation_type"]: item["id"] for item in evidence_items}
551
+
552
+ def claim(statement: str, falsification_condition: str, supported_by: list[str]) -> dict[str, Any]:
553
+ claim_digest = canonical_sha256({
554
+ "scope": version_id,
555
+ "statement": statement,
556
+ "falsification_condition": falsification_condition,
557
+ })
558
+ return {
559
+ "id": f"slayer://claim/{SOURCE_NAME}@sha256:{claim_digest}",
560
+ "scope": version_id,
561
+ "statement": statement,
562
+ "asserted_by": args.actor,
563
+ "supported_by": supported_by,
564
+ "falsification_condition": falsification_condition,
565
+ }
566
+
567
+ claims = [
568
+ claim(
569
+ "All retained records from the pinned source dated 2011-2022 are included after exact within-source deduplication.",
570
+ "A qualifying pinned-source record is absent without a recorded drop reason.",
571
+ [evidence_by_type["dataset_record_counts"]],
572
+ ),
573
+ claim(
574
+ "Every contributed document has non-empty speaker attribution.",
575
+ "Any contributed author field is empty.",
576
+ [evidence_by_type["speaker_attribution_coverage"]],
577
+ ),
578
+ claim(
579
+ "The contribution does not establish temporal novelty relative to every target source because registered ranges overlap.",
580
+ "The cited target-source ranges do not overlap 2011-2022.",
581
+ [evidence_by_type["known_temporal_overlap"]],
582
+ ),
583
+ claim(
584
+ "The contributed records are official Sejm materials documented for statutory reuse, subject to retained privacy and third-party limitations.",
585
+ "The records are not official materials or the cited legal basis and provider conditions contradict the documented reuse status.",
586
+ [evidence_by_type["legal_provenance_review"]],
587
+ ),
588
+ claim(
589
+ "The generated artifact set conforms to the DynaWord source schema and recorded checksums.",
590
+ "A contract field is missing, a row violates the schema, or a recorded artifact checksum differs.",
591
+ [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]],
592
+ ),
593
+ ]
594
+ if supplied_expected:
595
+ claims.append(claim(
596
+ "Rebuilding from pinned inputs reproduced the expected Parquet and attribution-sidecar digests.",
597
+ "A rebuilt Parquet or attribution-sidecar digest differs from the expected digest.",
598
+ [evidence_by_type["pinned_input_reproduction"]],
599
+ ))
600
+
601
+ claim_evidence = [
602
+ {
603
+ "claim_id": item["id"], "evidence_id": evidence_id,
604
+ "relation": "SUPPORTS", "introduced_by_run": args.run_id,
605
+ }
606
+ for item in claims for evidence_id in item["supported_by"]
607
+ ]
608
+
609
+ def attestation(attestation_type: str, value: Any, supported_by: list[str]) -> dict[str, Any]:
610
+ attestation_digest = canonical_sha256({
611
+ "type": attestation_type, "value": value, "actor_id": args.actor,
612
+ "subject_version": version_id, "supported_by": supported_by,
613
+ })
614
+ return {
615
+ "id": f"slayer://attestation/{SOURCE_NAME}/{attestation_type}@sha256:{attestation_digest}",
616
+ "type": attestation_type,
617
+ "value": value,
618
+ "actor_id": args.actor,
619
+ "subject_version": version_id,
620
+ "supported_by": supported_by,
621
+ "created_at": run_finished_at,
622
+ }
623
+
624
+ manifest = {
625
+ "schema_version": "slayer.ai/dataset-source-contribution/v1",
626
+ "ontology_version": "slayer.ai/research-ontology/v0.1",
627
+ "object": {
628
+ "id": object_id, "kind": "dataset_source", "name": SOURCE_NAME,
629
+ "metadata": {"language": "pl", "domain": "political/spoken", "provider": "Kancelaria Sejmu RP"},
630
+ },
631
+ "version": {
632
+ "id": version_id,
633
+ "object_id": object_id,
634
+ "digest": f"sha256:{version_digest}",
635
+ "schema_version": "slayer.ai/dataset-source/v1",
636
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.dataset_payload_commit}/data/{SOURCE_NAME}/{SOURCE_NAME}.parquet",
637
+ "created_at": args.version_created_at,
638
+ "created_by": args.actor,
639
+ },
640
+ "protocol": {
641
+ "id": protocol_object_id,
642
+ "kind": "dataset_filtering",
643
+ "name": f"{SOURCE_NAME}-filter",
644
+ "version": {
645
+ "id": protocol_version_id,
646
+ "object_id": protocol_object_id,
647
+ "digest": f"sha256:{protocol_digest}",
648
+ "code_sha256": protocol_code_digest,
649
+ "schema_version": "slayer.ai/protocol/v1",
650
+ "payload_uri": f"hf://datasets/{TARGET_REPOSITORY}@{args.protocol_payload_commit}/src/fetch_sejm_api_2011_2022.py",
651
+ "created_at": run_finished_at,
652
+ "created_by": args.actor,
653
+ },
654
+ "specification": protocol_specification,
655
+ },
656
+ "run": {
657
+ "id": args.run_id,
658
+ "protocol_version_id": protocol_version_id,
659
+ "actor_id": args.actor,
660
+ "git_commit": args.protocol_payload_commit,
661
+ "started_at": run_started_at,
662
+ "finished_at": run_finished_at,
663
+ "config": protocol_configuration,
664
+ "environment": environment,
665
+ "inputs": [
666
+ {"role": "source", "version_id": source_version_id},
667
+ {"role": "target_base", "version_id": target_version_id},
668
+ ],
669
+ "outputs": [{"role": "dataset_source", "version_id": version_id}],
670
+ },
671
+ "relations": [
672
+ {"source_version_id": version_id, "predicate": "DERIVED_FROM", "target_version_id": source_version_id, "introduced_by_run": args.run_id},
673
+ {"source_version_id": version_id, "predicate": "COMPATIBLE_WITH", "target_version_id": target_version_id, "introduced_by_run": args.run_id},
674
+ {"source_version_id": version_id, "predicate": "FILTERED_BY", "target_version_id": protocol_version_id, "introduced_by_run": args.run_id},
675
+ ],
676
+ "evidence": evidence_items,
677
+ "claims": claims,
678
+ "claim_evidence": claim_evidence,
679
+ "actors": [{
680
+ "id": args.actor, "kind": "human", "identity": "Piotr Sty\u0142a",
681
+ "identifiers": {"hugging_face": "PiotrSty", "github": "PiotrStyla"},
682
+ }],
683
+ "attestations": [
684
+ attestation("schema_valid", True, [evidence_by_type["schema_validation"], evidence_by_type["artifact_checksums"]]),
685
+ attestation("temporal_overlap", "known_and_disclosed", [evidence_by_type["known_temporal_overlap"]]),
686
+ attestation("speaker_attribution", "100_percent", [evidence_by_type["speaker_attribution_coverage"]]),
687
+ attestation("legal_status", "documented_open_official_materials_with_limitations", [evidence_by_type["legal_provenance_review"]]),
688
+ attestation("pinned_input_reproduction", bool(supplied_expected), [evidence_by_type["pinned_input_reproduction"]]),
689
+ ],
690
+ }
691
+ write_json(artifact_dir / f"{SOURCE_NAME}_ontology_manifest.json", manifest)
692
+ (src_dir / "sources.py").write_text(
693
+ update_registry(args.target_registry.read_text(encoding="utf-8")), encoding="utf-8"
694
+ )
695
+ shutil.copy2(pathlib.Path(__file__).resolve(), src_dir / "fetch_sejm_api_2011_2022.py")
696
+ (src_dir / "test_sejm_api_2011_2022_contract.py").write_text(contract_test(), encoding="utf-8")
697
+ return stats
698
+
699
+
700
+ def main() -> int:
701
+ parser = argparse.ArgumentParser(description=__doc__)
702
+ parser.add_argument("--source-dir", type=pathlib.Path, required=True)
703
+ parser.add_argument("--target-registry", type=pathlib.Path, required=True)
704
+ parser.add_argument("--output", type=pathlib.Path, required=True)
705
+ parser.add_argument("--source-revision", required=True)
706
+ parser.add_argument("--target-revision", required=True)
707
+ parser.add_argument("--dataset-payload-commit", required=True)
708
+ parser.add_argument("--protocol-payload-commit", required=True)
709
+ parser.add_argument("--version-created-at", default="2026-08-31T09:59:00Z")
710
+ parser.add_argument("--expected-parquet-sha256")
711
+ parser.add_argument("--expected-attribution-sha256")
712
+ parser.add_argument("--added-date", default=dt.datetime.now(dt.timezone.utc).date().isoformat())
713
+ parser.add_argument("--actor", default="hf:PiotrSty")
714
+ parser.add_argument("--run-id", default=f"sejm-api-2011-2022-{dt.datetime.now(dt.timezone.utc).strftime('%Y%m%dT%H%M%SZ')}")
715
+ args = parser.parse_args()
716
+ stats = build(args)
717
+ print(json.dumps(stats, ensure_ascii=False, indent=2, sort_keys=True))
718
+ return 0
719
+
720
+
721
+ if __name__ == "__main__":
722
+ raise SystemExit(main())
src/sejm_api_common.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Shared helpers for the Sejm API speech fetchers.
2
+
3
+ Extracted from `fetch_sejm_api.py` and `fetch_sejm_api_2011_2022.py`, which kept
4
+ byte-identical copies of these utilities (and of `legal_evidence` /
5
+ `stable_document_id`, differing only in function signatures). Both fetchers now
6
+ wrap these; behavior is unchanged.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import hashlib
12
+ import json
13
+ import pathlib
14
+ from typing import Any
15
+
16
+ COPYRIGHT_ACT = "https://eli.gov.pl/api/acts/DU/2025/24/text/O/D20250024.pdf"
17
+ OPEN_DATA_ACT = "https://eli.gov.pl/api/acts/DU/2023/1524/text.html"
18
+ SEJM_API = "https://api.sejm.gov.pl/"
19
+ SEJM_API_DOCUMENTATION = "https://api.sejm.gov.pl/sejm.html"
20
+
21
+ EXPECTED_FIELDS = (
22
+ "id", "text", "source", "added", "created", "token_count", "license", "author"
23
+ )
24
+
25
+
26
+ def sha256_file(path: pathlib.Path) -> str:
27
+ digest = hashlib.sha256()
28
+ with path.open("rb") as stream:
29
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
30
+ digest.update(chunk)
31
+ return digest.hexdigest()
32
+
33
+
34
+ def canonical_sha256(value: Any) -> str:
35
+ payload = json.dumps(
36
+ value, ensure_ascii=False, sort_keys=True, separators=(",", ":")
37
+ ).encode("utf-8")
38
+ return hashlib.sha256(payload).hexdigest()
39
+
40
+
41
+ def write_json(path: pathlib.Path, payload: Any) -> None:
42
+ path.write_text(
43
+ json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True) + "\n",
44
+ encoding="utf-8",
45
+ )
46
+
47
+
48
+ def stable_document_id(row: dict[str, Any], source_name: str) -> str:
49
+ material = "\x1f".join(
50
+ str(row.get(field, "")).strip() for field in ("date", "term", "speaker", "text")
51
+ )
52
+ return f"{source_name}_{hashlib.sha256(material.encode('utf-8')).hexdigest()}"
53
+
54
+
55
+ def legal_evidence(
56
+ source_revision: str,
57
+ target_revision: str,
58
+ *,
59
+ source_name: str,
60
+ source_license: str,
61
+ source_repository: str,
62
+ target_repository: str,
63
+ ) -> dict[str, Any]:
64
+ return {
65
+ "status": "reviewed-open-official-materials",
66
+ "source": source_name,
67
+ "dataset_record_license": source_license,
68
+ "hf_source_license_name": "polish-public-sector-open-statutory-reuse",
69
+ "provider": "Kancelaria Sejmu RP",
70
+ "official_source": SEJM_API,
71
+ "official_source_documentation": SEJM_API_DOCUMENTATION,
72
+ "copyright_basis": {
73
+ "act": "Polish Copyright and Related Rights Act",
74
+ "article": "4(2)",
75
+ "finding": "official documents and materials are excluded from copyright",
76
+ "url": COPYRIGHT_ACT,
77
+ },
78
+ "reuse_basis": {
79
+ "act": "Polish Act on Open Data and Reuse of Public Sector Information Act",
80
+ "articles": ["2(12)", "5", "6", "14(1)", "15", "17"],
81
+ "url": OPEN_DATA_ACT,
82
+ },
83
+ "limitations": [
84
+ "privacy and personal-data exceptions",
85
+ "third-party rights and provider-specific conditions",
86
+ "no upstream Creative Commons grant is asserted",
87
+ ],
88
+ "pinned_source": f"hf://datasets/{source_repository}@{source_revision}",
89
+ "pinned_target_base": f"hf://datasets/{target_repository}@{target_revision}",
90
+ }
src/sources.py CHANGED
@@ -173,6 +173,29 @@ SOURCES = {
173
  "created": "1991-01-01, 2019-12-31",
174
  "is_ocr": False,
175
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  "sejm_api": {
177
  "added": "2026-08-22",
178
  "custom_datasheet": True,
 
173
  "created": "1991-01-01, 2019-12-31",
174
  "is_ocr": False,
175
  },
176
+ "sejm_api_2011_2022": {
177
+ "added": "2026-08-31",
178
+ "release": None,
179
+ "file_key": "sejm_api_2011_2022",
180
+ "pretty": "Sejm speeches 2011-2022 (terms VII-IX, attributed)",
181
+ "license": "public-domain (official documents)",
182
+ "license_spdx": "LicenseRef-Polish-Official-Documents",
183
+ "traceable": "Official parliamentary materials excluded from copyright under "
184
+ "Polish Copyright Act art. 4(2); reusable under the Polish Open Data "
185
+ "Act arts. 2(12), 5, 6, 14(1), 15, 17. 100% speech-level official "
186
+ "Sejm API URLs preserved in the attribution sidecar.",
187
+ "upstream": "https://api.sejm.gov.pl/",
188
+ "provenance": "Converted from the immutable PiotrSty/sejm-speeches-corpus@1245577 "
189
+ "release (upstream protocol: heuristic PII redaction of e-mail/PESEL/"
190
+ "phone, <50-word filter, exact dedup). This build applies the date "
191
+ "window 2011-01-01..2022-12-31, >=200 chars + author, exact dedup. "
192
+ "NERGAL not run - re-run through SlayerLab/NERGAL before release. "
193
+ "Shared helpers factored into src/sejm_api_common.py.",
194
+ "domain": "political/spoken",
195
+ "created": "2011-11-08, 2022-12-14",
196
+ "is_ocr": False,
197
+ "custom_datasheet": True,
198
+ },
199
  "sejm_api": {
200
  "added": "2026-08-22",
201
  "custom_datasheet": True,
src/test_sejm_api_2011_2022_contract.py ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Contract checks for the sejm_api_2011_2022 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" / "sejm_api_2011_2022"
13
+ MANIFEST = ROOT / "artifacts" / "sejm_api_2011_2022_ontology_manifest.json"
14
+
15
+
16
+ def sha256_file(path):
17
+ digest = hashlib.sha256()
18
+ with path.open("rb") as stream:
19
+ for chunk in iter(lambda: stream.read(1024 * 1024), b""):
20
+ digest.update(chunk)
21
+ return digest.hexdigest()
22
+
23
+
24
+ def test_artifacts_and_schema():
25
+ parquet = DATA / "sejm_api_2011_2022.parquet"
26
+ stats = json.loads((DATA / "sejm_api_2011_2022.stats.json").read_text(encoding="utf-8"))
27
+ table = pq.read_table(parquet)
28
+ assert table.column_names == ['id', 'text', 'source', 'added', 'created', 'token_count', 'license', 'author']
29
+ assert table.num_rows == stats["kept"]
30
+ assert stats["authors_with_value"] == stats["kept"]
31
+ assert stats["created_min"] >= "2011-01-01"
32
+ assert stats["created_max"] <= "2022-12-31"
33
+ assert set(table.column("source").to_pylist()) == {"sejm_api_2011_2022"}
34
+ assert set(table.column("license").to_pylist()) == {"public-domain (official documents)"}
35
+
36
+
37
+ def test_attribution_count_and_legal_evidence():
38
+ stats = json.loads((DATA / "sejm_api_2011_2022.stats.json").read_text(encoding="utf-8"))
39
+ sidecar = DATA / "sejm_api_2011_2022.attribution.jsonl"
40
+ assert sum(1 for _ in sidecar.open(encoding="utf-8")) == stats["kept"]
41
+ legal = json.loads((DATA / "sejm_api_2011_2022.license-evidence.json").read_text(encoding="utf-8"))
42
+ assert legal["status"] == "reviewed-open-official-materials"
43
+ assert legal["pinned_source"].endswith(stats["source_revision"])
44
+
45
+
46
+ def test_ontology_kernel_and_references():
47
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
48
+ required = {
49
+ "object", "version", "protocol", "run", "relations", "evidence",
50
+ "claims", "claim_evidence", "actors", "attestations",
51
+ }
52
+ assert required <= set(manifest)
53
+ assert manifest["ontology_version"] == "slayer.ai/research-ontology/v0.1"
54
+
55
+ actor_ids = {item["id"] for item in manifest["actors"]}
56
+ assert manifest["run"]["actor_id"] in actor_ids
57
+ assert manifest["version"]["object_id"] == manifest["object"]["id"]
58
+ assert manifest["version"]["created_by"] in actor_ids
59
+ assert re.fullmatch(r"sha256:[0-9a-f]{64}", manifest["version"]["digest"])
60
+ assert re.search(r"@[0-9a-f]{40}/", manifest["version"]["payload_uri"])
61
+
62
+ protocol = manifest["protocol"]
63
+ protocol_version = protocol["version"]
64
+ assert protocol_version["object_id"] == protocol["id"]
65
+ assert manifest["run"]["protocol_version_id"] == protocol_version["id"]
66
+ assert re.fullmatch(r"sha256:[0-9a-f]{64}", protocol_version["digest"])
67
+ assert re.search(r"@[0-9a-f]{40}/", protocol_version["payload_uri"])
68
+ script = ROOT / protocol["specification"]["source_path"]
69
+ assert sha256_file(script) == protocol_version["code_sha256"]
70
+
71
+ run = manifest["run"]
72
+ assert run["started_at"] <= run["finished_at"]
73
+ assert run["git_commit"] in protocol_version["payload_uri"]
74
+ assert {"python", "platform", "machine", "packages", "determinism"} <= set(run["environment"])
75
+
76
+ evidence_ids = {item["id"] for item in manifest["evidence"]}
77
+ assert len(evidence_ids) == len(manifest["evidence"])
78
+ for item in manifest["evidence"]:
79
+ assert item["run_id"] == run["id"]
80
+ assert item["subject_version"] == manifest["version"]["id"]
81
+ assert re.search(r"@sha256:[0-9a-f]{64}$", item["id"])
82
+
83
+ claim_ids = {item["id"] for item in manifest["claims"]}
84
+ assert len(claim_ids) == len(manifest["claims"])
85
+ for item in manifest["claims"]:
86
+ assert item["scope"] == manifest["version"]["id"]
87
+ assert item["asserted_by"] in actor_ids
88
+ assert item["supported_by"]
89
+ assert set(item["supported_by"]) <= evidence_ids
90
+ assert item["falsification_condition"]
91
+
92
+ for link in manifest["claim_evidence"]:
93
+ assert link["claim_id"] in claim_ids
94
+ assert link["evidence_id"] in evidence_ids
95
+ assert link["relation"] in {"SUPPORTS", "REFUTES", "QUALIFIES"}
96
+
97
+ edges = {}
98
+ for relation in manifest["relations"]:
99
+ source = relation["source_version_id"]
100
+ target = relation["target_version_id"]
101
+ assert source != target
102
+ assert relation["introduced_by_run"] == run["id"]
103
+ if target.startswith("slayer://version/"):
104
+ edges.setdefault(source, set()).add(target)
105
+
106
+ visiting, visited = set(), set()
107
+ def visit(node):
108
+ assert node not in visiting, "version lineage must be acyclic"
109
+ if node in visited:
110
+ return
111
+ visiting.add(node)
112
+ for target in edges.get(node, ()):
113
+ visit(target)
114
+ visiting.remove(node)
115
+ visited.add(node)
116
+ for node in edges:
117
+ visit(node)
118
+
119
+ for attestation in manifest["attestations"]:
120
+ assert attestation["actor_id"] in actor_ids
121
+ assert attestation["subject_version"] == manifest["version"]["id"]
122
+ assert attestation["supported_by"]
123
+ assert set(attestation["supported_by"]) <= evidence_ids
124
+
125
+
126
+ def test_manifest_artifact_checksums():
127
+ manifest = json.loads(MANIFEST.read_text(encoding="utf-8"))
128
+ checksums = next(
129
+ item["payload"] for item in manifest["evidence"]
130
+ if item["observation_type"] == "artifact_checksums"
131
+ )
132
+ paths = {
133
+ "parquet_sha256": DATA / "sejm_api_2011_2022.parquet",
134
+ "attribution_sha256": DATA / "sejm_api_2011_2022.attribution.jsonl",
135
+ "stats_sha256": DATA / "sejm_api_2011_2022.stats.json",
136
+ "legal_evidence_sha256": DATA / "sejm_api_2011_2022.license-evidence.json",
137
+ }
138
+ assert {name: sha256_file(path) for name, path in paths.items()} == checksums